From b689e22bcf2f6d91764b0fa176bcbaa707c38a22 Mon Sep 17 00:00:00 2001 From: michaelin007 Date: Thu, 21 Dec 2023 09:48:02 +0000 Subject: [PATCH] https://jira.baeldung.com/browse/BAEL-7376 --- .../SpringJUnitConfigIntegrationTest.java | 10 +++++----- .../SpringJUnitConfigurationParameterizedTest.java | 6 ++---- .../SpringJUnitWebConfigIntegrationTest.java | 10 +++++----- .../baeldung/springjunitconfiguration/TestConfig.java | 2 +- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/spring-boot-modules/spring-boot-3/src/test/java/com/baeldung/springjunitconfiguration/SpringJUnitConfigIntegrationTest.java b/spring-boot-modules/spring-boot-3/src/test/java/com/baeldung/springjunitconfiguration/SpringJUnitConfigIntegrationTest.java index 864eba97cc..a163ef893c 100644 --- a/spring-boot-modules/spring-boot-3/src/test/java/com/baeldung/springjunitconfiguration/SpringJUnitConfigIntegrationTest.java +++ b/spring-boot-modules/spring-boot-3/src/test/java/com/baeldung/springjunitconfiguration/SpringJUnitConfigIntegrationTest.java @@ -10,7 +10,7 @@ import static org.junit.Assert.assertNotNull; /** * @SpringJUnitConfig(SpringJUnitConfigTest.Config.class) is equivalent to: - * + * * @ExtendWith(SpringExtension.class) * @ContextConfiguration(classes = SpringJUnitConfigTest.Config.class ) * @@ -18,10 +18,6 @@ import static org.junit.Assert.assertNotNull; @SpringJUnitConfig(SpringJUnitConfigIntegrationTest.Config.class) public class SpringJUnitConfigIntegrationTest { - @Configuration - static class Config { - } - @Autowired private ApplicationContext applicationContext; @@ -30,4 +26,8 @@ public class SpringJUnitConfigIntegrationTest { assertNotNull(applicationContext); } + @Configuration + static class Config { + } + } diff --git a/spring-boot-modules/spring-boot-3/src/test/java/com/baeldung/springjunitconfiguration/SpringJUnitConfigurationParameterizedTest.java b/spring-boot-modules/spring-boot-3/src/test/java/com/baeldung/springjunitconfiguration/SpringJUnitConfigurationParameterizedTest.java index 92874e2d59..642a9c9f64 100644 --- a/spring-boot-modules/spring-boot-3/src/test/java/com/baeldung/springjunitconfiguration/SpringJUnitConfigurationParameterizedTest.java +++ b/spring-boot-modules/spring-boot-3/src/test/java/com/baeldung/springjunitconfiguration/SpringJUnitConfigurationParameterizedTest.java @@ -1,15 +1,13 @@ package com.baeldung.springjunitconfiguration; -import java.util.List; import org.junit.jupiter.params.ParameterizedTest; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.ApplicationContext; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.support.AnnotationConfigContextLoader; +import java.util.List; -@SpringJUnitConfig(classes = TestConfig.class , loader = AnnotationConfigContextLoader.class) +@SpringJUnitConfig(classes = TestConfig.class, loader = AnnotationConfigContextLoader.class) public class SpringJUnitConfigurationParameterizedTest { @ParameterizedTest diff --git a/spring-boot-modules/spring-boot-3/src/test/java/com/baeldung/springjunitconfiguration/SpringJUnitWebConfigIntegrationTest.java b/spring-boot-modules/spring-boot-3/src/test/java/com/baeldung/springjunitconfiguration/SpringJUnitWebConfigIntegrationTest.java index 42422f4537..0ccb988e0a 100644 --- a/spring-boot-modules/spring-boot-3/src/test/java/com/baeldung/springjunitconfiguration/SpringJUnitWebConfigIntegrationTest.java +++ b/spring-boot-modules/spring-boot-3/src/test/java/com/baeldung/springjunitconfiguration/SpringJUnitWebConfigIntegrationTest.java @@ -10,7 +10,7 @@ import static org.junit.Assert.assertNotNull; /** * @SpringJUnitWebConfig(SpringJUnitWebConfigTest.Config.class) is equivalent to: - * + * * @ExtendWith(SpringExtension.class) * @WebAppConfiguration * @ContextConfiguration(classes = SpringJUnitWebConfigTest.Config.class ) @@ -19,10 +19,6 @@ import static org.junit.Assert.assertNotNull; @SpringJUnitWebConfig(SpringJUnitWebConfigIntegrationTest.Config.class) public class SpringJUnitWebConfigIntegrationTest { - @Configuration - static class Config { - } - @Autowired private WebApplicationContext webAppContext; @@ -31,4 +27,8 @@ public class SpringJUnitWebConfigIntegrationTest { assertNotNull(webAppContext); } + @Configuration + static class Config { + } + } diff --git a/spring-boot-modules/spring-boot-3/src/test/java/com/baeldung/springjunitconfiguration/TestConfig.java b/spring-boot-modules/spring-boot-3/src/test/java/com/baeldung/springjunitconfiguration/TestConfig.java index a02c542e8d..859aff9d9b 100644 --- a/spring-boot-modules/spring-boot-3/src/test/java/com/baeldung/springjunitconfiguration/TestConfig.java +++ b/spring-boot-modules/spring-boot-3/src/test/java/com/baeldung/springjunitconfiguration/TestConfig.java @@ -2,7 +2,7 @@ package com.baeldung.springjunitconfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; + @Configuration public class TestConfig {