Revise contribution
Beginning with Java 16, inner classes may contain static members. We therefore need to search for @DynamicPropertySource methods in the current class after searching enclosing classes so that a local @DynamicPropertySource method can override properties registered in an enclosing class. However, since Spring Framework 5.3.x is built using Java 8, this commit removes DynamicPropertySourceOverridesEnclosingClassTests since it declares a static method in a @Nested (inner) test class, which results in a compiler error on Java 8. See https://bugs.openjdk.org/browse/JDK-8254321 See gh-31085
This commit is contained in:
@@ -39,7 +39,6 @@ import static org.springframework.test.context.NestedTestConfiguration.Enclosing
|
||||
* {@link SpringExtension} in a JUnit Jupiter environment.
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @author Yanming Zhou
|
||||
* @since 5.3.2
|
||||
*/
|
||||
@SpringJUnitConfig
|
||||
@@ -126,22 +125,6 @@ class DynamicPropertySourceNestedTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
class DynamicPropertySourceOverrideEnclosingClassTests {
|
||||
|
||||
@DynamicPropertySource
|
||||
static void overrideDynamicPropertyFromEnclosingClass(DynamicPropertyRegistry registry) {
|
||||
registry.add(TEST_CONTAINER_PORT, () -> -999);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("@Service has values injected from @DynamicPropertySource in enclosing class and nested class")
|
||||
void serviceHasInjectedValues(@Autowired Service service) {
|
||||
assertThat(service.getIp()).isEqualTo("127.0.0.1");
|
||||
assertThat(service.getPort()).isEqualTo(-999);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static abstract class DynamicPropertySourceSuperclass {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user