diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index bfc6e64de..351fab561 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -20,9 +20,9 @@ owasp-dependencycheck = "11.1.0" protobuf = "4.28.3" protobuf-plugin = "0.9.4" spotless = "6.25.0" -spring-boot-plugin = "3.3.5" -spring-cloud = "2023.0.3" # not managed by spring-boot-dependencies -spring-cloud-stream = "4.1.3" # not managed by spring-boot-dependencies +spring-boot-plugin = "3.4.0" +spring-cloud = "2024.0.0" # not managed by spring-boot-dependencies +spring-cloud-stream = "4.1.4" # not managed by spring-boot-dependencies [libraries] activemq-broker = { module = "org.apache.activemq:activemq-broker", version.ref = "activemq" } diff --git a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/DefaultAsyncApiServiceIntegrationTest.java b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/DefaultAsyncApiServiceIntegrationTest.java index e2fc0f2e7..fce2aa43a 100644 --- a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/DefaultAsyncApiServiceIntegrationTest.java +++ b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/DefaultAsyncApiServiceIntegrationTest.java @@ -18,11 +18,11 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.Import; import org.springframework.core.annotation.Order; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.Map; @@ -55,16 +55,16 @@ }) class DefaultAsyncApiServiceIntegrationTest { - @MockBean + @MockitoBean private ChannelsService channelsService; - @MockBean + @MockitoBean private OperationsService operationsService; - @MockBean + @MockitoBean private ComponentsService componentsService; - @MockBean + @MockitoBean private AsyncApiGroupService groupService; @Autowired diff --git a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/beans/DefaultBeanMethodsScannerIntegrationTest.java b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/beans/DefaultBeanMethodsScannerIntegrationTest.java index 472059402..b373c01a1 100644 --- a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/beans/DefaultBeanMethodsScannerIntegrationTest.java +++ b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/beans/DefaultBeanMethodsScannerIntegrationTest.java @@ -5,9 +5,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.Bean; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.lang.reflect.Method; @@ -25,7 +25,7 @@ class DefaultBeanMethodsScannerIntegrationTest { @Autowired private DefaultBeanMethodsScanner beanMethodsScanner; - @MockBean + @MockitoBean private ComponentClassScanner componentClassScanner; @Test diff --git a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/classes/SpringwolfClassScannerIntegrationTest.java b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/classes/SpringwolfClassScannerIntegrationTest.java index 1d483b346..599749628 100644 --- a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/classes/SpringwolfClassScannerIntegrationTest.java +++ b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/classes/SpringwolfClassScannerIntegrationTest.java @@ -12,10 +12,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.core.env.Environment; import org.springframework.core.env.StandardEnvironment; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import java.util.Set; @@ -34,7 +34,7 @@ TestOtherConditionalComponent.class }) class SpringwolfClassScannerIntegrationTest { - @MockBean + @MockitoBean private AsyncApiDocketService asyncApiDocketService; @Autowired diff --git a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/classes/spring/ComponentClassScannerIntegrationTest.java b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/classes/spring/ComponentClassScannerIntegrationTest.java index e8d5cacc7..b63992356 100644 --- a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/classes/spring/ComponentClassScannerIntegrationTest.java +++ b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/classes/spring/ComponentClassScannerIntegrationTest.java @@ -13,10 +13,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.core.env.Environment; import org.springframework.core.env.StandardEnvironment; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import java.util.Set; @@ -32,7 +32,7 @@ TestOtherConditionalComponent.class }) class ComponentClassScannerIntegrationTest { - @MockBean + @MockitoBean private AsyncApiDocketService asyncApiDocketService; @Autowired diff --git a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/classes/spring/ConfigurationClassScannerIntegrationTest.java b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/classes/spring/ConfigurationClassScannerIntegrationTest.java index 37428c7a2..bccc924ef 100644 --- a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/classes/spring/ConfigurationClassScannerIntegrationTest.java +++ b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/classes/spring/ConfigurationClassScannerIntegrationTest.java @@ -8,8 +8,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.Set; @@ -21,7 +21,7 @@ @ContextConfiguration(classes = {ConfigurationClassScanner.class, ComponentClassScanner.class}) class ConfigurationClassScannerIntegrationTest { - @MockBean + @MockitoBean private AsyncApiDocketService asyncApiDocketService; @Autowired diff --git a/springwolf-examples/springwolf-amqp-example/src/test/java/io/github/springwolf/examples/amqp/AmqpProducerSystemTest.java b/springwolf-examples/springwolf-amqp-example/src/test/java/io/github/springwolf/examples/amqp/AmqpProducerSystemTest.java index 38414b58a..883485943 100644 --- a/springwolf-examples/springwolf-amqp-example/src/test/java/io/github/springwolf/examples/amqp/AmqpProducerSystemTest.java +++ b/springwolf-examples/springwolf-amqp-example/src/test/java/io/github/springwolf/examples/amqp/AmqpProducerSystemTest.java @@ -14,11 +14,11 @@ import org.springframework.amqp.rabbit.connection.ConnectionFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.SpyBean; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.DynamicPropertyRegistry; import org.springframework.test.context.DynamicPropertySource; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.bean.override.mockito.MockitoSpyBean; import org.testcontainers.containers.DockerComposeContainer; import org.testcontainers.containers.wait.strategy.Wait; import org.testcontainers.junit.jupiter.Container; @@ -53,7 +53,7 @@ public class AmqpProducerSystemTest { @Autowired SpringwolfAmqpProducer springwolfAmqpProducer; - @SpyBean + @MockitoSpyBean ExampleConsumer exampleConsumer; @Container diff --git a/springwolf-examples/springwolf-jms-example/src/test/java/io/github/springwolf/examples/jms/JmsProducerSystemTest.java b/springwolf-examples/springwolf-jms-example/src/test/java/io/github/springwolf/examples/jms/JmsProducerSystemTest.java index 353ddf310..3897e9ae5 100644 --- a/springwolf-examples/springwolf-jms-example/src/test/java/io/github/springwolf/examples/jms/JmsProducerSystemTest.java +++ b/springwolf-examples/springwolf-jms-example/src/test/java/io/github/springwolf/examples/jms/JmsProducerSystemTest.java @@ -9,9 +9,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.SpyBean; import org.springframework.test.context.DynamicPropertyRegistry; import org.springframework.test.context.DynamicPropertySource; +import org.springframework.test.context.bean.override.mockito.MockitoSpyBean; import org.testcontainers.containers.DockerComposeContainer; import org.testcontainers.containers.wait.strategy.Wait; import org.testcontainers.junit.jupiter.Container; @@ -43,7 +43,7 @@ public class JmsProducerSystemTest { @Autowired SpringwolfJmsProducer springwolfJmsProducer; - @SpyBean + @MockitoSpyBean ExampleConsumer exampleConsumer; @Value("${spring.activemq.broker-url}") diff --git a/springwolf-examples/springwolf-sqs-example/src/test/java/io/github/springwolf/examples/sqs/SqsProducerSystemTest.java b/springwolf-examples/springwolf-sqs-example/src/test/java/io/github/springwolf/examples/sqs/SqsProducerSystemTest.java index 79d624bc3..38a464345 100644 --- a/springwolf-examples/springwolf-sqs-example/src/test/java/io/github/springwolf/examples/sqs/SqsProducerSystemTest.java +++ b/springwolf-examples/springwolf-sqs-example/src/test/java/io/github/springwolf/examples/sqs/SqsProducerSystemTest.java @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.SpyBean; +import org.springframework.test.context.bean.override.mockito.MockitoSpyBean; import org.testcontainers.containers.DockerComposeContainer; import org.testcontainers.containers.wait.strategy.Wait; import org.testcontainers.junit.jupiter.Container; @@ -37,7 +37,7 @@ public class SqsProducerSystemTest { @Autowired SpringwolfSqsProducer springwolfSqsProducer; - @SpyBean + @MockitoSpyBean ExampleConsumer exampleConsumer; @Container diff --git a/springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/springwolf/plugins/amqp/configuration/SpringwolfAmqpProducerConfigurationIntegrationTest.java b/springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/springwolf/plugins/amqp/configuration/SpringwolfAmqpProducerConfigurationIntegrationTest.java index 9b55d0d57..32366f631 100644 --- a/springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/springwolf/plugins/amqp/configuration/SpringwolfAmqpProducerConfigurationIntegrationTest.java +++ b/springwolf-plugins/springwolf-amqp-plugin/src/test/java/io/github/springwolf/plugins/amqp/configuration/SpringwolfAmqpProducerConfigurationIntegrationTest.java @@ -5,9 +5,7 @@ import io.github.springwolf.core.asyncapi.components.ComponentsService; import io.github.springwolf.core.asyncapi.scanners.classes.SpringwolfClassScanner; import io.github.springwolf.core.asyncapi.scanners.common.headers.HeaderClassExtractor; -import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadAsyncOperationService; import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadMethodParameterService; -import io.github.springwolf.core.configuration.docket.AsyncApiDocketService; import io.github.springwolf.core.controller.PublishingPayloadCreator; import io.github.springwolf.plugins.amqp.controller.SpringwolfAmqpController; import io.github.springwolf.plugins.amqp.producer.SpringwolfAmqpProducer; @@ -16,10 +14,9 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.boot.test.mock.mockito.MockBeans; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.util.StringValueResolver; @@ -34,7 +31,7 @@ public class SpringwolfAmqpProducerConfigurationIntegrationTest { classes = { SpringwolfAmqpAutoConfiguration.class, PublishingPayloadCreator.class, - ObjectMapperTestConfiguration.class + ObjectMapperTestConfiguration.class, }) @TestPropertySource( properties = { @@ -46,20 +43,8 @@ public class SpringwolfAmqpProducerConfigurationIntegrationTest { "springwolf.docket.servers.test-protocol.host=some-server:1234", "springwolf.plugin.amqp.publishing.enabled=true" }) - @MockBeans( - value = { - @MockBean(AsyncApiService.class), - @MockBean(RabbitTemplate.class), - @MockBean(SpringwolfClassScanner.class), - @MockBean(ComponentsService.class), - @MockBean(PayloadAsyncOperationService.class), - @MockBean(PayloadMethodParameterService.class), - @MockBean(HeaderClassExtractor.class), - @MockBean(AsyncApiDocketService.class), - @MockBean(StringValueResolver.class), - }) @Nested - class AmqpProducerWillBeCreatedIfEnabledTest { + class AmqpProducerWillBeCreatedIfEnabledTest extends MockBeanConfiguration { @Autowired private Optional springwolfAmqpProducer; @@ -78,7 +63,7 @@ void springwolfAmqpProducerShouldBePresentInSpringContext() { classes = { SpringwolfAmqpAutoConfiguration.class, PublishingPayloadCreator.class, - ObjectMapperTestConfiguration.class + ObjectMapperTestConfiguration.class, }) @TestPropertySource( properties = { @@ -90,19 +75,8 @@ void springwolfAmqpProducerShouldBePresentInSpringContext() { "springwolf.docket.servers.test-protocol.host=some-server:1234", "springwolf.plugin.amqp.publishing.enabled=false" }) - @MockBeans( - value = { - @MockBean(AsyncApiService.class), - @MockBean(RabbitTemplate.class), - @MockBean(SpringwolfClassScanner.class), - @MockBean(ComponentsService.class), - @MockBean(PayloadAsyncOperationService.class), - @MockBean(PayloadMethodParameterService.class), - @MockBean(HeaderClassExtractor.class), - @MockBean(StringValueResolver.class), - }) @Nested - class AmqpProducerWillNotBeCreatedIfDisabledTest { + class AmqpProducerWillNotBeCreatedIfDisabledTest extends MockBeanConfiguration { @Autowired private Optional springwolfAmqpProducer; @@ -115,4 +89,32 @@ void springwolfAmqpProducerShouldNotBePresentInSpringContext() { assertThat(springwolfAmqpController).isNotPresent(); } } + + /** + * Introduced due to migration of spring boot 3.3 -> 3.4 and @MockBean deprecation + * + * feature request: https://github.com/spring-projects/spring-framework/issues/33925 + */ + class MockBeanConfiguration { + @MockitoBean + private SpringwolfClassScanner springwolfClassScanner; + + @MockitoBean + private ComponentsService componentsService; + + @MockitoBean + private HeaderClassExtractor headerClassExtractor; + + @MockitoBean + private PayloadMethodParameterService payloadMethodParameterService; + + @MockitoBean + private StringValueResolver stringValueResolver; + + @MockitoBean + private AsyncApiService asyncApiService; + + @MockitoBean + private RabbitTemplate rabbitTemplate; + } } diff --git a/springwolf-plugins/springwolf-cloud-stream-plugin/src/test/java/io/github/springwolf/plugins/cloudstream/asyncapi/scanners/channels/CloudStreamFunctionChannelsScannerIntegrationTest.java b/springwolf-plugins/springwolf-cloud-stream-plugin/src/test/java/io/github/springwolf/plugins/cloudstream/asyncapi/scanners/channels/CloudStreamFunctionChannelsScannerIntegrationTest.java index 7d86f66ab..cd2de3f5e 100644 --- a/springwolf-plugins/springwolf-cloud-stream-plugin/src/test/java/io/github/springwolf/plugins/cloudstream/asyncapi/scanners/channels/CloudStreamFunctionChannelsScannerIntegrationTest.java +++ b/springwolf-plugins/springwolf-cloud-stream-plugin/src/test/java/io/github/springwolf/plugins/cloudstream/asyncapi/scanners/channels/CloudStreamFunctionChannelsScannerIntegrationTest.java @@ -42,13 +42,13 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.cloud.stream.config.BindingProperties; import org.springframework.cloud.stream.config.BindingServiceProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.util.Collections; @@ -97,7 +97,7 @@ @Import(CloudStreamFunctionChannelsScannerIntegrationTest.Configuration.class) class CloudStreamFunctionChannelsScannerIntegrationTest { - @MockBean + @MockitoBean private BindingServiceProperties bindingServiceProperties; @Autowired diff --git a/springwolf-plugins/springwolf-jms-plugin/src/test/java/io/github/springwolf/plugins/jms/configuration/SpringwolfJmsProducerConfigurationIntegrationTest.java b/springwolf-plugins/springwolf-jms-plugin/src/test/java/io/github/springwolf/plugins/jms/configuration/SpringwolfJmsProducerConfigurationIntegrationTest.java index 3e11ab846..40610bcb1 100644 --- a/springwolf-plugins/springwolf-jms-plugin/src/test/java/io/github/springwolf/plugins/jms/configuration/SpringwolfJmsProducerConfigurationIntegrationTest.java +++ b/springwolf-plugins/springwolf-jms-plugin/src/test/java/io/github/springwolf/plugins/jms/configuration/SpringwolfJmsProducerConfigurationIntegrationTest.java @@ -12,11 +12,10 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.boot.test.mock.mockito.MockBeans; import org.springframework.jms.core.JmsTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.util.StringValueResolver; @@ -31,7 +30,7 @@ public class SpringwolfJmsProducerConfigurationIntegrationTest { classes = { SpringwolfJmsAutoConfiguration.class, PublishingPayloadCreator.class, - ObjectMapperTestConfiguration.class + ObjectMapperTestConfiguration.class, }) @TestPropertySource( properties = { @@ -43,17 +42,8 @@ public class SpringwolfJmsProducerConfigurationIntegrationTest { "springwolf.docket.servers.test-protocol.host=some-server:1234", "springwolf.plugin.jms.publishing.enabled=true" }) - @MockBeans( - value = { - @MockBean(SpringwolfClassScanner.class), - @MockBean(ComponentsService.class), - @MockBean(PayloadMethodParameterService.class), - @MockBean(HeaderClassExtractor.class), - @MockBean(JmsTemplate.class), - @MockBean(StringValueResolver.class), - }) @Nested - class JmsProducerWillBeCreatedIfEnabledTest { + class JmsProducerWillBeCreatedIfEnabledTest extends MockBeanConfiguration { @Autowired private Optional springwolfJmsProducer; @@ -72,7 +62,7 @@ void springwolfJmsProducerShouldBePresentInSpringContext() { classes = { SpringwolfJmsAutoConfiguration.class, PublishingPayloadCreator.class, - ObjectMapperTestConfiguration.class + ObjectMapperTestConfiguration.class, }) @TestPropertySource( properties = { @@ -84,17 +74,8 @@ void springwolfJmsProducerShouldBePresentInSpringContext() { "springwolf.docket.servers.test-protocol.host=some-server:1234", "springwolf.plugin.jms.publishing.enabled=false" }) - @MockBeans( - value = { - @MockBean(SpringwolfClassScanner.class), - @MockBean(ComponentsService.class), - @MockBean(PayloadMethodParameterService.class), - @MockBean(HeaderClassExtractor.class), - @MockBean(JmsTemplate.class), - @MockBean(StringValueResolver.class), - }) @Nested - class JmsProducerWillNotBeCreatedIfDisabledTest { + class JmsProducerWillNotBeCreatedIfDisabledTest extends MockBeanConfiguration { @Autowired private Optional springwolfJmsProducer; @@ -107,4 +88,29 @@ void springwolfJmsProducerShouldNotBePresentInSpringContext() { assertThat(springwolfJmsController).isNotPresent(); } } + + /** + * Introduced due to migration of spring boot 3.3 -> 3.4 and @MockBean deprecation + * + * feature request: https://github.com/spring-projects/spring-framework/issues/33925 + */ + class MockBeanConfiguration { + @MockitoBean + private SpringwolfClassScanner springwolfClassScanner; + + @MockitoBean + private ComponentsService componentsService; + + @MockitoBean + private HeaderClassExtractor headerClassExtractor; + + @MockitoBean + private PayloadMethodParameterService payloadMethodParameterService; + + @MockitoBean + private StringValueResolver stringValueResolver; + + @MockitoBean + private JmsTemplate jmsTemplate; + } } diff --git a/springwolf-plugins/springwolf-jms-plugin/src/test/java/io/github/springwolf/plugins/jms/controller/SpringwolfJmsControllerIntegrationTest.java b/springwolf-plugins/springwolf-jms-plugin/src/test/java/io/github/springwolf/plugins/jms/controller/SpringwolfJmsControllerIntegrationTest.java index d708ed75f..50d299356 100644 --- a/springwolf-plugins/springwolf-jms-plugin/src/test/java/io/github/springwolf/plugins/jms/controller/SpringwolfJmsControllerIntegrationTest.java +++ b/springwolf-plugins/springwolf-jms-plugin/src/test/java/io/github/springwolf/plugins/jms/controller/SpringwolfJmsControllerIntegrationTest.java @@ -27,10 +27,10 @@ import org.mockito.Captor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.web.servlet.MockMvc; import java.util.HashMap; @@ -80,7 +80,7 @@ class SpringwolfJmsControllerIntegrationTest { @Autowired private ComponentsService componentsService; - @MockBean + @MockitoBean private SpringwolfJmsProducer springwolfJmsProducer; @Captor diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/springwolf/plugins/kafka/configuration/SpringwolfKafkaProducerConfigurationIntegrationTest.java b/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/springwolf/plugins/kafka/configuration/SpringwolfKafkaProducerConfigurationIntegrationTest.java index 096726384..e8cf524b3 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/springwolf/plugins/kafka/configuration/SpringwolfKafkaProducerConfigurationIntegrationTest.java +++ b/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/springwolf/plugins/kafka/configuration/SpringwolfKafkaProducerConfigurationIntegrationTest.java @@ -4,7 +4,6 @@ import io.github.springwolf.core.asyncapi.components.ComponentsService; import io.github.springwolf.core.asyncapi.scanners.classes.SpringwolfClassScanner; import io.github.springwolf.core.asyncapi.scanners.common.headers.HeaderClassExtractor; -import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadAsyncOperationService; import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadMethodParameterService; import io.github.springwolf.core.controller.PublishingPayloadCreator; import io.github.springwolf.plugins.kafka.controller.SpringwolfKafkaController; @@ -13,10 +12,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.boot.test.mock.mockito.MockBeans; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.util.StringValueResolver; @@ -32,7 +30,7 @@ public class SpringwolfKafkaProducerConfigurationIntegrationTest { classes = { SpringwolfKafkaAutoConfiguration.class, PublishingPayloadCreator.class, - ObjectMapperTestConfiguration.class + ObjectMapperTestConfiguration.class, }) @TestPropertySource( properties = { @@ -44,16 +42,7 @@ public class SpringwolfKafkaProducerConfigurationIntegrationTest { "springwolf.docket.servers.test-protocol.host=some-server:1234", "springwolf.plugin.kafka.publishing.enabled=true" }) - @MockBeans( - value = { - @MockBean(SpringwolfClassScanner.class), - @MockBean(ComponentsService.class), - @MockBean(PayloadAsyncOperationService.class), - @MockBean(HeaderClassExtractor.class), - @MockBean(PayloadMethodParameterService.class), - @MockBean(StringValueResolver.class), - }) - class KafkaProducerWillBeCreatedIfEnabledTest { + class KafkaProducerWillBeCreatedIfEnabledTest extends MockBeanConfiguration { @Autowired private Optional springwolfKafkaProducer; @@ -73,7 +62,7 @@ void springwolfKafkaTemplateShouldBePresentInSpringContext() { classes = { SpringwolfKafkaAutoConfiguration.class, PublishingPayloadCreator.class, - ObjectMapperTestConfiguration.class + ObjectMapperTestConfiguration.class, }) @TestPropertySource( properties = { @@ -85,16 +74,7 @@ void springwolfKafkaTemplateShouldBePresentInSpringContext() { "springwolf.docket.servers.test-protocol.host=some-server:1234", "springwolf.plugin.kafka.publishing.enabled=false" }) - @MockBeans( - value = { - @MockBean(SpringwolfClassScanner.class), - @MockBean(ComponentsService.class), - @MockBean(PayloadAsyncOperationService.class), - @MockBean(PayloadMethodParameterService.class), - @MockBean(HeaderClassExtractor.class), - @MockBean(StringValueResolver.class), - }) - class KafkaProducerWillNotBeCreatedIfDisabledTest { + class KafkaProducerWillNotBeCreatedIfDisabledTest extends MockBeanConfiguration { @Autowired private Optional springwolfKafkaProducer; @@ -107,4 +87,26 @@ void springwolfKafkaTemplateShouldNotBePresentInSpringContext() { assertThat(springwolfKafkaController).isNotPresent(); } } + + /** + * Introduced due to migration of spring boot 3.3 -> 3.4 and @MockBean deprecation + * + * feature request: https://github.com/spring-projects/spring-framework/issues/33925 + */ + class MockBeanConfiguration { + @MockitoBean + private SpringwolfClassScanner springwolfClassScanner; + + @MockitoBean + private ComponentsService componentsService; + + @MockitoBean + private HeaderClassExtractor headerClassExtractor; + + @MockitoBean + private PayloadMethodParameterService payloadMethodParameterService; + + @MockitoBean + private StringValueResolver stringValueResolver; + } } diff --git a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/springwolf/plugins/kafka/controller/SpringwolfKafkaControllerIntegrationTest.java b/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/springwolf/plugins/kafka/controller/SpringwolfKafkaControllerIntegrationTest.java index 612ce3485..d59e5f4f7 100644 --- a/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/springwolf/plugins/kafka/controller/SpringwolfKafkaControllerIntegrationTest.java +++ b/springwolf-plugins/springwolf-kafka-plugin/src/test/java/io/github/springwolf/plugins/kafka/controller/SpringwolfKafkaControllerIntegrationTest.java @@ -27,10 +27,10 @@ import org.mockito.Captor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.web.servlet.MockMvc; import java.util.HashMap; @@ -80,7 +80,7 @@ class SpringwolfKafkaControllerIntegrationTest { @Autowired private ComponentsService componentsService; - @MockBean + @MockitoBean private SpringwolfKafkaProducer springwolfKafkaProducer; @Captor diff --git a/springwolf-plugins/springwolf-sns-plugin/build.gradle b/springwolf-plugins/springwolf-sns-plugin/build.gradle index d6c3a6ea7..880d6b8d4 100644 --- a/springwolf-plugins/springwolf-sns-plugin/build.gradle +++ b/springwolf-plugins/springwolf-sns-plugin/build.gradle @@ -40,6 +40,7 @@ dependencies { testImplementation libs.spring.boot.test testImplementation libs.spring.beans + testImplementation libs.spring.core testImplementation libs.spring.test testAnnotationProcessor libs.lombok diff --git a/springwolf-plugins/springwolf-sns-plugin/src/test/java/io/github/springwolf/plugins/sns/configuration/SpringwolfSnsProducerConfigurationIntegrationTest.java b/springwolf-plugins/springwolf-sns-plugin/src/test/java/io/github/springwolf/plugins/sns/configuration/SpringwolfSnsProducerConfigurationIntegrationTest.java index 3a252ae53..c92b7c6a2 100644 --- a/springwolf-plugins/springwolf-sns-plugin/src/test/java/io/github/springwolf/plugins/sns/configuration/SpringwolfSnsProducerConfigurationIntegrationTest.java +++ b/springwolf-plugins/springwolf-sns-plugin/src/test/java/io/github/springwolf/plugins/sns/configuration/SpringwolfSnsProducerConfigurationIntegrationTest.java @@ -2,13 +2,10 @@ package io.github.springwolf.plugins.sns.configuration; import io.awspring.cloud.sns.core.SnsTemplate; -import io.github.springwolf.core.asyncapi.AsyncApiService; -import io.github.springwolf.core.asyncapi.channels.ChannelsService; import io.github.springwolf.core.asyncapi.components.ComponentsService; import io.github.springwolf.core.asyncapi.scanners.classes.SpringwolfClassScanner; -import io.github.springwolf.core.asyncapi.scanners.common.payload.internal.PayloadExtractor; -import io.github.springwolf.core.asyncapi.scanners.common.payload.internal.TypeExtractor; -import io.github.springwolf.core.configuration.docket.AsyncApiDocketService; +import io.github.springwolf.core.asyncapi.scanners.common.headers.HeaderClassExtractor; +import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadMethodParameterService; import io.github.springwolf.core.controller.PublishingPayloadCreator; import io.github.springwolf.plugins.sns.controller.SpringwolfSnsController; import io.github.springwolf.plugins.sns.producer.SpringwolfSnsProducer; @@ -16,11 +13,11 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.boot.test.mock.mockito.MockBeans; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.util.StringValueResolver; import java.util.Optional; @@ -33,7 +30,7 @@ public class SpringwolfSnsProducerConfigurationIntegrationTest { classes = { SpringwolfSnsAutoConfiguration.class, PublishingPayloadCreator.class, - ObjectMapperTestConfiguration.class + ObjectMapperTestConfiguration.class, }) @TestPropertySource( properties = { @@ -45,18 +42,8 @@ public class SpringwolfSnsProducerConfigurationIntegrationTest { "springwolf.docket.servers.test-protocol.host=some-server:1234", "springwolf.plugin.sns.publishing.enabled=true" }) - @MockBeans( - value = { - @MockBean(SpringwolfClassScanner.class), - @MockBean(ComponentsService.class), - @MockBean(PayloadExtractor.class), - @MockBean(TypeExtractor.class), - @MockBean(AsyncApiDocketService.class), - @MockBean(AsyncApiService.class), - @MockBean(SnsTemplate.class) - }) @Nested - class SqsProducerWillBeCreatedIfEnabledTest { + class SqsProducerWillBeCreatedIfEnabledTest extends MockBeanConfiguration { @Autowired private Optional springwolfSqsProducer; @@ -75,7 +62,7 @@ void springwolfSqsProducerShouldBePresentInSpringContext() { classes = { SpringwolfSnsAutoConfiguration.class, PublishingPayloadCreator.class, - ObjectMapperTestConfiguration.class + ObjectMapperTestConfiguration.class, }) @TestPropertySource( properties = { @@ -87,17 +74,8 @@ void springwolfSqsProducerShouldBePresentInSpringContext() { "springwolf.docket.servers.test-protocol.host=some-server:1234", "springwolf.plugin.sns.publishing.enabled=false" }) - @MockBeans( - value = { - @MockBean(SpringwolfClassScanner.class), - @MockBean(ComponentsService.class), - @MockBean(PayloadExtractor.class), - @MockBean(TypeExtractor.class), - @MockBean(ChannelsService.class), - @MockBean(SnsTemplate.class) - }) @Nested - class SqsProducerWillNotBeCreatedIfDisabledTest { + class SqsProducerWillNotBeCreatedIfDisabledTest extends MockBeanConfiguration { @Autowired private Optional springwolfSqsProducer; @@ -110,4 +88,29 @@ void springwolfSqsProducerShouldNotBePresentInSpringContext() { assertThat(springwolfSqsController).isNotPresent(); } } + + /** + * Introduced due to migration of spring boot 3.3 -> 3.4 and @MockBean deprecation + * + * feature request: https://github.com/spring-projects/spring-framework/issues/33925 + */ + class MockBeanConfiguration { + @MockitoBean + private SpringwolfClassScanner springwolfClassScanner; + + @MockitoBean + private ComponentsService componentsService; + + @MockitoBean + private HeaderClassExtractor headerClassExtractor; + + @MockitoBean + private PayloadMethodParameterService payloadMethodParameterService; + + @MockitoBean + private StringValueResolver stringValueResolver; + + @MockitoBean + private SnsTemplate snsTemplate; + } } diff --git a/springwolf-plugins/springwolf-sqs-plugin/src/test/java/io/github/springwolf/plugins/sqs/configuration/SpringwolfSqsProducerConfigurationIntegrationTest.java b/springwolf-plugins/springwolf-sqs-plugin/src/test/java/io/github/springwolf/plugins/sqs/configuration/SpringwolfSqsProducerConfigurationIntegrationTest.java index d28c3f6e7..8c91fb8a3 100644 --- a/springwolf-plugins/springwolf-sqs-plugin/src/test/java/io/github/springwolf/plugins/sqs/configuration/SpringwolfSqsProducerConfigurationIntegrationTest.java +++ b/springwolf-plugins/springwolf-sqs-plugin/src/test/java/io/github/springwolf/plugins/sqs/configuration/SpringwolfSqsProducerConfigurationIntegrationTest.java @@ -13,10 +13,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.boot.test.mock.mockito.MockBeans; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.util.StringValueResolver; @@ -30,9 +29,8 @@ public class SpringwolfSqsProducerConfigurationIntegrationTest { @ContextConfiguration( classes = { SpringwolfSqsAutoConfiguration.class, - ComponentsService.class, PublishingPayloadCreator.class, - ObjectMapperTestConfiguration.class + ObjectMapperTestConfiguration.class, }) @TestPropertySource( properties = { @@ -44,17 +42,8 @@ public class SpringwolfSqsProducerConfigurationIntegrationTest { "springwolf.docket.servers.test-protocol.host=some-server:1234", "springwolf.plugin.sqs.publishing.enabled=true" }) - @MockBeans( - value = { - @MockBean(SpringwolfClassScanner.class), - @MockBean(ComponentsService.class), - @MockBean(PayloadMethodParameterService.class), - @MockBean(HeaderClassExtractor.class), - @MockBean(SqsTemplate.class), - @MockBean(StringValueResolver.class), - }) @Nested - class SqsProducerWillBeCreatedIfEnabledTest { + class SqsProducerWillBeCreatedIfEnabledTest extends MockBeanConfiguration { @Autowired private Optional springwolfSqsProducer; @@ -73,7 +62,7 @@ void springwolfSqsProducerShouldBePresentInSpringContext() { classes = { SpringwolfSqsAutoConfiguration.class, PublishingPayloadCreator.class, - ObjectMapperTestConfiguration.class + ObjectMapperTestConfiguration.class, }) @TestPropertySource( properties = { @@ -85,17 +74,8 @@ void springwolfSqsProducerShouldBePresentInSpringContext() { "springwolf.docket.servers.test-protocol.host=some-server:1234", "springwolf.plugin.sqs.publishing.enabled=false" }) - @MockBeans( - value = { - @MockBean(SpringwolfClassScanner.class), - @MockBean(ComponentsService.class), - @MockBean(PayloadMethodParameterService.class), - @MockBean(HeaderClassExtractor.class), - @MockBean(SqsTemplate.class), - @MockBean(StringValueResolver.class), - }) @Nested - class SqsProducerWillNotBeCreatedIfDisabledTest { + class SqsProducerWillNotBeCreatedIfDisabledTest extends MockBeanConfiguration { @Autowired private Optional springwolfSqsProducer; @@ -108,4 +88,29 @@ void springwolfSqsProducerShouldNotBePresentInSpringContext() { assertThat(springwolfSqsController).isNotPresent(); } } + + /** + * Introduced due to migration of spring boot 3.3 -> 3.4 and @MockBean deprecation + * + * feature request: https://github.com/spring-projects/spring-framework/issues/33925 + */ + class MockBeanConfiguration { + @MockitoBean + private SpringwolfClassScanner springwolfClassScanner; + + @MockitoBean + private ComponentsService componentsService; + + @MockitoBean + private HeaderClassExtractor headerClassExtractor; + + @MockitoBean + private PayloadMethodParameterService payloadMethodParameterService; + + @MockitoBean + private StringValueResolver stringValueResolver; + + @MockitoBean + private SqsTemplate sqsTemplate; + } }