diff --git a/spring-boot-extension-autoconfigure/src/test/java/com/livk/autoconfigure/fastexcel/FastExcelAutoConfigurationTest.java b/spring-boot-extension-autoconfigure/src/test/java/com/livk/autoconfigure/fastexcel/FastExcelAutoConfigurationTest.java index f97b8d2bb..fd070ad1c 100644 --- a/spring-boot-extension-autoconfigure/src/test/java/com/livk/autoconfigure/fastexcel/FastExcelAutoConfigurationTest.java +++ b/spring-boot-extension-autoconfigure/src/test/java/com/livk/autoconfigure/fastexcel/FastExcelAutoConfigurationTest.java @@ -20,10 +20,8 @@ import com.livk.context.fastexcel.resolver.ReactiveExcelMethodReturnValueHandler; import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration; import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration; -import org.springframework.boot.test.context.TestConfiguration; import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner; import org.springframework.boot.test.context.runner.WebApplicationContextRunner; import org.springframework.web.reactive.result.method.HandlerMethodArgumentResolver; @@ -44,9 +42,9 @@ class FastExcelAutoConfigurationTest { @Test void testServlet() { WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(FastExcelAutoConfiguration.class)); + .withConfiguration(AutoConfigurations.of(WebMvcAutoConfiguration.class, FastExcelAutoConfiguration.class)); - contextRunner.withUserConfiguration(WebMvcConfig.class).run(context -> { + contextRunner.run(context -> { RequestMappingHandlerAdapter adapter = context.getBean(RequestMappingHandlerAdapter.class); assertThat(adapter.getArgumentResolvers()).isNotNull() .hasAtLeastOneElementOfType(ExcelMethodArgumentResolver.class); @@ -59,9 +57,9 @@ void testServlet() { @SuppressWarnings("unchecked") void testReactive() { ReactiveWebApplicationContextRunner contextRunner = new ReactiveWebApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(FastExcelAutoConfiguration.class)); + .withConfiguration(AutoConfigurations.of(WebFluxAutoConfiguration.class, FastExcelAutoConfiguration.class)); - contextRunner.withUserConfiguration(WebFluxConfig.class).run(context -> { + contextRunner.run(context -> { org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter adapter = context .getBean(org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter.class); @@ -76,16 +74,4 @@ void testReactive() { }); } - @TestConfiguration - @ImportAutoConfiguration(WebMvcAutoConfiguration.class) - static class WebMvcConfig { - - } - - @TestConfiguration - @ImportAutoConfiguration(WebFluxAutoConfiguration.class) - static class WebFluxConfig { - - } - } diff --git a/spring-boot-extension-autoconfigure/src/test/java/com/livk/autoconfigure/mybatis/inject/SqlDataInjectionAutoConfigurationTest.java b/spring-boot-extension-autoconfigure/src/test/java/com/livk/autoconfigure/mybatis/inject/SqlDataInjectionAutoConfigurationTest.java index b742368ab..c76867224 100644 --- a/spring-boot-extension-autoconfigure/src/test/java/com/livk/autoconfigure/mybatis/inject/SqlDataInjectionAutoConfigurationTest.java +++ b/spring-boot-extension-autoconfigure/src/test/java/com/livk/autoconfigure/mybatis/inject/SqlDataInjectionAutoConfigurationTest.java @@ -20,7 +20,6 @@ import org.junit.jupiter.api.Test; import org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.boot.test.context.runner.ApplicationContextRunner; @@ -36,7 +35,8 @@ class SqlDataInjectionAutoConfigurationTest { final ApplicationContextRunner contextRunner = new ApplicationContextRunner().withUserConfiguration(Config.class) .withBean(DataSource.class, HikariDataSource::new) - .withConfiguration(AutoConfigurations.of(SqlDataInjectionAutoConfiguration.class)); + .withConfiguration( + AutoConfigurations.of(MybatisAutoConfiguration.class, SqlDataInjectionAutoConfiguration.class)); @Test void sqlDataInjectionConfigurationCustomizer() { @@ -49,7 +49,6 @@ void sqlDataInjectionConfigurationCustomizer() { @TestConfiguration @EnableSqlPlugin - @ImportAutoConfiguration(MybatisAutoConfiguration.class) static class Config { } diff --git a/spring-boot-extension-autoconfigure/src/test/java/com/livk/autoconfigure/mybatis/monitor/MybatisLogMonitorAutoConfigurationTest.java b/spring-boot-extension-autoconfigure/src/test/java/com/livk/autoconfigure/mybatis/monitor/MybatisLogMonitorAutoConfigurationTest.java index 026fafc85..60251a94a 100644 --- a/spring-boot-extension-autoconfigure/src/test/java/com/livk/autoconfigure/mybatis/monitor/MybatisLogMonitorAutoConfigurationTest.java +++ b/spring-boot-extension-autoconfigure/src/test/java/com/livk/autoconfigure/mybatis/monitor/MybatisLogMonitorAutoConfigurationTest.java @@ -38,7 +38,8 @@ class MybatisLogMonitorAutoConfigurationTest { final ApplicationContextRunner contextRunner = new ApplicationContextRunner().withUserConfiguration(Config.class) .withBean(DataSource.class, HikariDataSource::new) - .withConfiguration(AutoConfigurations.of(MybatisLogMonitorAutoConfiguration.class)); + .withConfiguration( + AutoConfigurations.of(MybatisAutoConfiguration.class, MybatisLogMonitorAutoConfiguration.class)); @Test void mybatisLogMonitorConfigurationCustomizer() { @@ -51,7 +52,6 @@ void mybatisLogMonitorConfigurationCustomizer() { @TestConfiguration @EnableSqlMonitor - @ImportAutoConfiguration(MybatisAutoConfiguration.class) @EnableConfigurationProperties(MybatisLogMonitorProperties.class) static class Config { diff --git a/spring-boot-extension-autoconfigure/src/test/java/com/livk/autoconfigure/mybatis/type/MybatisTypeHandlerAutoConfigurationTest.java b/spring-boot-extension-autoconfigure/src/test/java/com/livk/autoconfigure/mybatis/type/MybatisTypeHandlerAutoConfigurationTest.java index 6f3fde7f8..1629e9005 100644 --- a/spring-boot-extension-autoconfigure/src/test/java/com/livk/autoconfigure/mybatis/type/MybatisTypeHandlerAutoConfigurationTest.java +++ b/spring-boot-extension-autoconfigure/src/test/java/com/livk/autoconfigure/mybatis/type/MybatisTypeHandlerAutoConfigurationTest.java @@ -20,8 +20,6 @@ import org.junit.jupiter.api.Test; import org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.test.context.TestConfiguration; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import javax.sql.DataSource; @@ -34,9 +32,10 @@ */ class MybatisTypeHandlerAutoConfigurationTest { - final ApplicationContextRunner contextRunner = new ApplicationContextRunner().withUserConfiguration(Config.class) + final ApplicationContextRunner contextRunner = new ApplicationContextRunner() .withBean(DataSource.class, HikariDataSource::new) - .withConfiguration(AutoConfigurations.of(MybatisTypeHandlerAutoConfiguration.class)); + .withConfiguration( + AutoConfigurations.of(MybatisAutoConfiguration.class, MybatisTypeHandlerAutoConfiguration.class)); @Test void testMysql() { @@ -51,7 +50,7 @@ void testMysql() { @Test void testPgsql() { - this.contextRunner.withUserConfiguration(Config.class).run((context) -> { + this.contextRunner.run((context) -> { SqlSessionFactory factory = context.getBean(SqlSessionFactory.class); Collection> typeHandlers = factory.getConfiguration() .getTypeHandlerRegistry() @@ -60,10 +59,4 @@ void testPgsql() { }); } - @TestConfiguration - @ImportAutoConfiguration(MybatisAutoConfiguration.class) - static class Config { - - } - } diff --git a/spring-boot-extension-autoconfigure/src/test/java/com/livk/autoconfigure/qrcode/QRCodeAutoConfigurationTest.java b/spring-boot-extension-autoconfigure/src/test/java/com/livk/autoconfigure/qrcode/QRCodeAutoConfigurationTest.java index 7b3b0bdaf..ae137883c 100644 --- a/spring-boot-extension-autoconfigure/src/test/java/com/livk/autoconfigure/qrcode/QRCodeAutoConfigurationTest.java +++ b/spring-boot-extension-autoconfigure/src/test/java/com/livk/autoconfigure/qrcode/QRCodeAutoConfigurationTest.java @@ -18,10 +18,8 @@ import com.livk.context.qrcode.support.GoogleQRCodeGenerator; import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration; import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration; -import org.springframework.boot.test.context.TestConfiguration; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner; import org.springframework.boot.test.context.runner.WebApplicationContextRunner; @@ -50,9 +48,9 @@ void googleQRCodeGenerator() { void testServlet() { WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() .withBean(Jackson2ObjectMapperBuilder.class, Jackson2ObjectMapperBuilder::new) - .withConfiguration(AutoConfigurations.of(QRCodeAutoConfiguration.class)); + .withConfiguration(AutoConfigurations.of(WebMvcAutoConfiguration.class, QRCodeAutoConfiguration.class)); - contextRunner.withUserConfiguration(WebMvcConfig.class).run(context -> { + contextRunner.run(context -> { RequestMappingHandlerAdapter adapter = context.getBean(RequestMappingHandlerAdapter.class); assertThat(adapter.getReturnValueHandlers()).isNotNull() .hasAtLeastOneElementOfType(QRCodeMethodReturnValueHandler.class); @@ -63,23 +61,11 @@ void testServlet() { void testReactive() { ReactiveWebApplicationContextRunner contextRunner = new ReactiveWebApplicationContextRunner() .withBean(Jackson2ObjectMapperBuilder.class, Jackson2ObjectMapperBuilder::new) - .withConfiguration(AutoConfigurations.of(QRCodeAutoConfiguration.class)); + .withConfiguration(AutoConfigurations.of(WebFluxAutoConfiguration.class, QRCodeAutoConfiguration.class)); - contextRunner.withUserConfiguration(WebFluxConfig.class).run(context -> { + contextRunner.run(context -> { assertThat(context).hasSingleBean(ReactiveQRCodeMethodReturnValueHandler.class); }); } - @TestConfiguration - @ImportAutoConfiguration(WebMvcAutoConfiguration.class) - static class WebMvcConfig { - - } - - @TestConfiguration - @ImportAutoConfiguration(WebFluxAutoConfiguration.class) - static class WebFluxConfig { - - } - } diff --git a/spring-boot-extension-autoconfigure/src/test/java/com/livk/autoconfigure/redisson/RedissonAutoConfigurationTest.java b/spring-boot-extension-autoconfigure/src/test/java/com/livk/autoconfigure/redisson/RedissonAutoConfigurationTest.java index dc828599e..a40b7236b 100644 --- a/spring-boot-extension-autoconfigure/src/test/java/com/livk/autoconfigure/redisson/RedissonAutoConfigurationTest.java +++ b/spring-boot-extension-autoconfigure/src/test/java/com/livk/autoconfigure/redisson/RedissonAutoConfigurationTest.java @@ -25,7 +25,6 @@ import org.springframework.boot.context.properties.bind.PropertySourcesPlaceholdersResolver; import org.springframework.boot.context.properties.source.ConfigurationPropertySource; import org.springframework.boot.context.properties.source.ConfigurationPropertySources; -import org.springframework.boot.test.context.TestConfiguration; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.boot.testcontainers.properties.TestcontainersPropertySourceAutoConfiguration; import org.springframework.boot.testcontainers.service.connection.ServiceConnection; @@ -71,14 +70,14 @@ static void redisProperties(DynamicPropertyRegistry registry) { @Test void redissonClient() { - this.contextRunner.withUserConfiguration(Config.class).run((context) -> { + this.contextRunner.run((context) -> { assertThat(context).hasSingleBean(RedissonClient.class); }); } @Test void redissonConnectionFactory() { - this.contextRunner.withUserConfiguration(Config.class).run((context) -> { + this.contextRunner.run((context) -> { assertThat(context).hasSingleBean(RedissonConnectionFactory.class); }); } @@ -93,9 +92,4 @@ ConfigProperties properties() { return binder.bind(ConfigProperties.PREFIX, ConfigProperties.class).get(); } - @TestConfiguration(proxyBeanMethods = false) - static class Config { - - } - } diff --git a/spring-boot-extension-autoconfigure/src/test/java/com/livk/autoconfigure/useragent/UserAgentAutoConfigurationTest.java b/spring-boot-extension-autoconfigure/src/test/java/com/livk/autoconfigure/useragent/UserAgentAutoConfigurationTest.java index cdcb621dc..78cd70efc 100644 --- a/spring-boot-extension-autoconfigure/src/test/java/com/livk/autoconfigure/useragent/UserAgentAutoConfigurationTest.java +++ b/spring-boot-extension-autoconfigure/src/test/java/com/livk/autoconfigure/useragent/UserAgentAutoConfigurationTest.java @@ -25,10 +25,8 @@ import nl.basjes.parse.useragent.UserAgentAnalyzer; import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration; import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration; -import org.springframework.boot.test.context.TestConfiguration; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner; import org.springframework.boot.test.context.runner.WebApplicationContextRunner; @@ -78,9 +76,9 @@ void testYauaa() { @Test void testServlet() { WebApplicationContextRunner runner = new WebApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(UserAgentAutoConfiguration.class)); + .withConfiguration(AutoConfigurations.of(WebMvcAutoConfiguration.class, UserAgentAutoConfiguration.class)); - runner.withUserConfiguration(WebMvcConfig.class).run(context -> { + runner.run(context -> { RequestMappingHandlerAdapter adapter = context.getBean(RequestMappingHandlerAdapter.class); assertThat(adapter.getArgumentResolvers()).isNotNull().hasAtLeastOneElementOfType(UserAgentResolver.class); @@ -98,9 +96,9 @@ void testServlet() { @SuppressWarnings("unchecked") void testReactive() { ReactiveWebApplicationContextRunner runner = new ReactiveWebApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(UserAgentAutoConfiguration.class)); + .withConfiguration(AutoConfigurations.of(WebFluxAutoConfiguration.class, UserAgentAutoConfiguration.class)); - runner.withUserConfiguration(WebFluxConfig.class).run(context -> { + runner.run(context -> { org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter adapter = context .getBean(org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter.class); @@ -114,16 +112,4 @@ void testReactive() { }); } - @TestConfiguration - @ImportAutoConfiguration(WebMvcAutoConfiguration.class) - static class WebMvcConfig { - - } - - @TestConfiguration - @ImportAutoConfiguration(WebFluxAutoConfiguration.class) - static class WebFluxConfig { - - } - }