Skip to content

Commit 0a19bf9

Browse files
author
Vincent Potucek
committed
wip
1 parent bfdf60a commit 0a19bf9

File tree

4 files changed

+9
-19
lines changed

4 files changed

+9
-19
lines changed

framework-docs/src/main/java/org/springframework/docs/core/aot/hints/testing/SampleReflectionRuntimeHintsTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ void shouldRegisterReflectionHints() {
4444

4545
// Invoke the relevant piece of code we want to test within a recording lambda
4646
RuntimeHintsInvocations invocations = org.springframework.aot.test.agent.RuntimeHintsRecorder.record(() -> {
47-
SampleReflection sample = new SampleReflection();
48-
sample.performReflection();
47+
new SampleReflection().performReflection();
4948
});
5049
// assert that the recorded invocations are covered by the contributed hints
5150
assertThat(invocations).match(runtimeHints);

integration-tests/src/test/java/org/springframework/aot/test/ReflectionInvocationsTests.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ void sampleTest() {
3535
hints.reflection().registerType(String.class);
3636

3737
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();
4039
});
4140
assertThat(invocations).match(hints);
4241
}
@@ -47,8 +46,7 @@ void multipleCallsTest() {
4746
hints.reflection().registerType(String.class);
4847
hints.reflection().registerType(Integer.class);
4948
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();
5250
});
5351
assertThat(invocations).match(hints);
5452
}

integration-tests/src/test/java/org/springframework/aot/test/SampleReflection.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,13 @@ public class SampleReflection {
2626

2727
@SuppressWarnings("unused")
2828
public void sample() {
29-
// -@cs[UnusedLocalVariable]
30-
Method[] methods = String.class.getMethods();
29+
String.class.getMethods();
3130
}
3231

3332
@SuppressWarnings("unused")
3433
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();
3836
}
3937

4038
}

spring-beans/src/test/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBeanTests.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,9 @@ void testStringArgGetter() throws Exception {
122122
genericBeanDefinition(ServiceLocatorFactoryBean.class)
123123
.addPropertyValue("serviceLocatorInterface", TestServiceLocator2.class)
124124
.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
133128
assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() ->
134129
factory.getTestService("bogusTestService"));
135130
}

0 commit comments

Comments
 (0)