File tree Expand file tree Collapse file tree 4 files changed +9
-19
lines changed
framework-docs/src/main/java/org/springframework/docs/core/aot/hints/testing
integration-tests/src/test/java/org/springframework/aot/test
spring-beans/src/test/java/org/springframework/beans/factory/config Expand file tree Collapse file tree 4 files changed +9
-19
lines changed Original file line number Diff line number Diff line change @@ -44,8 +44,7 @@ void shouldRegisterReflectionHints() {
44
44
45
45
// Invoke the relevant piece of code we want to test within a recording lambda
46
46
RuntimeHintsInvocations invocations = org .springframework .aot .test .agent .RuntimeHintsRecorder .record (() -> {
47
- SampleReflection sample = new SampleReflection ();
48
- sample .performReflection ();
47
+ new SampleReflection ().performReflection ();
49
48
});
50
49
// assert that the recorded invocations are covered by the contributed hints
51
50
assertThat (invocations ).match (runtimeHints );
Original file line number Diff line number Diff line change @@ -35,8 +35,7 @@ void sampleTest() {
35
35
hints .reflection ().registerType (String .class );
36
36
37
37
RuntimeHintsInvocations invocations = org .springframework .aot .test .agent .RuntimeHintsRecorder .record (() -> {
38
- SampleReflection sample = new SampleReflection ();
39
- sample .sample (); // does Method[] methods = String.class.getMethods();
38
+ new SampleReflection ().sample (); // does Method[] methods = String.class.getMethods();
40
39
});
41
40
assertThat (invocations ).match (hints );
42
41
}
@@ -47,8 +46,7 @@ void multipleCallsTest() {
47
46
hints .reflection ().registerType (String .class );
48
47
hints .reflection ().registerType (Integer .class );
49
48
RuntimeHintsInvocations invocations = org .springframework .aot .test .agent .RuntimeHintsRecorder .record (() -> {
50
- SampleReflection sample = new SampleReflection ();
51
- sample .multipleCalls (); // does Method[] methods = String.class.getMethods(); methods = Integer.class.getMethods();
49
+ new SampleReflection ().multipleCalls (); // does Method[] methods = String.class.getMethods(); methods = Integer.class.getMethods();
52
50
});
53
51
assertThat (invocations ).match (hints );
54
52
}
Original file line number Diff line number Diff line change @@ -26,15 +26,13 @@ public class SampleReflection {
26
26
27
27
@ SuppressWarnings ("unused" )
28
28
public void sample () {
29
- // -@cs[UnusedLocalVariable]
30
- Method [] methods = String .class .getMethods ();
29
+ String .class .getMethods ();
31
30
}
32
31
33
32
@ SuppressWarnings ("unused" )
34
33
public void multipleCalls () {
35
- Method [] methods = String .class .getMethods ();
36
- // -@cs[UnusedLocalVariable]
37
- methods = Integer .class .getMethods ();
34
+ String .class .getMethods ();
35
+ Integer .class .getMethods ();
38
36
}
39
37
40
38
}
Original file line number Diff line number Diff line change @@ -122,14 +122,9 @@ void testStringArgGetter() throws Exception {
122
122
genericBeanDefinition (ServiceLocatorFactoryBean .class )
123
123
.addPropertyValue ("serviceLocatorInterface" , TestServiceLocator2 .class )
124
124
.getBeanDefinition ());
125
-
126
- // test string-arg getter with null id
127
- TestServiceLocator2 factory = (TestServiceLocator2 ) bf .getBean ("factory" );
128
-
129
- factory .getTestService (null );
130
- // now test with explicit id
131
- factory .getTestService ("testService" );
132
- // now verify failure on bad id
125
+ TestServiceLocator2 factory = (TestServiceLocator2 ) bf .getBean ("factory" ); // test string-arg getter with null id
126
+ factory .getTestService (null ); // now test with explicit id
127
+ factory .getTestService ("testService" ); // now verify failure on bad id
133
128
assertThatExceptionOfType (NoSuchBeanDefinitionException .class ).isThrownBy (() ->
134
129
factory .getTestService ("bogusTestService" ));
135
130
}
You can’t perform that action at this time.
0 commit comments