diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/GatewayProxyInstantiationPostProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/config/GatewayProxyInstantiationPostProcessor.java index d5e15aa9f7..4566265a9b 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/GatewayProxyInstantiationPostProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/GatewayProxyInstantiationPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 the original author or authors. + * Copyright 2022-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package org.springframework.integration.config; +import org.springframework.aop.framework.AopInfrastructureBean; import org.springframework.beans.BeansException; import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition; import org.springframework.beans.factory.aot.BeanRegistrationAotContribution; @@ -44,7 +45,7 @@ import org.springframework.integration.gateway.AnnotationGatewayProxyFactoryBean * @see AnnotationGatewayProxyFactoryBean */ class GatewayProxyInstantiationPostProcessor implements - InstantiationAwareBeanPostProcessor, BeanRegistrationAotProcessor, ApplicationContextAware { + InstantiationAwareBeanPostProcessor, BeanRegistrationAotProcessor, ApplicationContextAware, AopInfrastructureBean { private final BeanDefinitionRegistry registry; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/GlobalChannelInterceptorProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/config/GlobalChannelInterceptorProcessor.java index f9cf8f748f..747df83abf 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/GlobalChannelInterceptorProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/GlobalChannelInterceptorProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import java.util.Set; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.aop.framework.AopInfrastructureBean; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; @@ -54,7 +55,7 @@ import org.springframework.util.StringUtils; * @since 2.0 */ public final class GlobalChannelInterceptorProcessor - implements BeanFactoryAware, SmartInitializingSingleton, BeanPostProcessor { + implements BeanFactoryAware, SmartInitializingSingleton, BeanPostProcessor, AopInfrastructureBean { private static final Log LOGGER = LogFactory.getLog(GlobalChannelInterceptorProcessor.class); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/BaseIntegrationFlowDefinition.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/BaseIntegrationFlowDefinition.java index c2b8ea8626..ab976321ce 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/BaseIntegrationFlowDefinition.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/BaseIntegrationFlowDefinition.java @@ -29,6 +29,7 @@ import reactor.core.publisher.Flux; import reactor.util.function.Tuple2; import org.springframework.aop.framework.Advised; +import org.springframework.aop.framework.AopInfrastructureBean; import org.springframework.aop.support.AopUtils; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanCreationException; @@ -3047,7 +3048,7 @@ public abstract class BaseIntegrationFlowDefinition diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aop/MessagePublishingAnnotationUsageTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aop/MessagePublishingAnnotationUsageTests.java index 00152283e3..ec2a517587 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/aop/MessagePublishingAnnotationUsageTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/aop/MessagePublishingAnnotationUsageTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,8 +16,8 @@ package org.springframework.integration.aop; -import org.junit.Test; -import org.junit.runner.RunWith; + +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.integration.annotation.Publisher; @@ -25,8 +25,8 @@ import org.springframework.integration.channel.QueueChannel; import org.springframework.messaging.Message; import org.springframework.messaging.handler.annotation.Header; import org.springframework.messaging.handler.annotation.Payload; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import static org.assertj.core.api.Assertions.assertThat; @@ -37,8 +37,8 @@ import static org.assertj.core.api.Assertions.assertThat; * * @since 2.0 */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig +@DirtiesContext public class MessagePublishingAnnotationUsageTests { @Autowired diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aop/MessagePublishingInterceptorTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aop/MessagePublishingInterceptorTests.java index 732c3c591e..f15efc2077 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/aop/MessagePublishingInterceptorTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/aop/MessagePublishingInterceptorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +20,8 @@ import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory; @@ -49,7 +49,7 @@ public class MessagePublishingInterceptorTests { private DefaultListableBeanFactory beanFactory; - @Before + @BeforeEach public void setup() { beanFactory = new DefaultListableBeanFactory(); channelResolver = new BeanFactoryChannelResolver(beanFactory); diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aop/MessagePublishingInterceptorUsageTests-context.xml b/spring-integration-core/src/test/java/org/springframework/integration/aop/MessagePublishingInterceptorUsageTests-context.xml index 4082c7cfee..2c0029a889 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/aop/MessagePublishingInterceptorUsageTests-context.xml +++ b/spring-integration-core/src/test/java/org/springframework/integration/aop/MessagePublishingInterceptorUsageTests-context.xml @@ -31,7 +31,9 @@ - + + + @@ -42,16 +44,6 @@ - - - - - - - - - diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aop/MessagePublishingInterceptorUsageTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aop/MessagePublishingInterceptorUsageTests.java index 3f3516e6d7..444c58ca6a 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/aop/MessagePublishingInterceptorUsageTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/aop/MessagePublishingInterceptorUsageTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,14 +16,14 @@ package org.springframework.integration.aop; -import org.junit.Test; -import org.junit.runner.RunWith; + +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.integration.channel.QueueChannel; import org.springframework.messaging.Message; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import static org.assertj.core.api.Assertions.assertThat; @@ -34,8 +34,8 @@ import static org.assertj.core.api.Assertions.assertThat; * * @since 2.0 */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig +@DirtiesContext public class MessagePublishingInterceptorUsageTests { @Autowired diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aop/MethodAnnotationPublisherMetadataSourceTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aop/MethodAnnotationPublisherMetadataSourceTests.java index 0e5f7df80a..cc958bb4e3 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/aop/MethodAnnotationPublisherMetadataSourceTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/aop/MethodAnnotationPublisherMetadataSourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import java.lang.reflect.Method; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.annotation.AliasFor; import org.springframework.expression.Expression; @@ -32,6 +32,8 @@ import org.springframework.messaging.handler.annotation.Payload; import org.springframework.test.util.ReflectionTestUtils; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; /** * @author Mark Fisher @@ -104,10 +106,11 @@ public class MethodAnnotationPublisherMetadataSourceTests { assertThat(payloadExpression).isEqualTo("#method"); } - @Test(expected = IllegalArgumentException.class) + @Test public void voidReturnWithInvalidPayloadExpression() { Method method = getMethod("methodWithVoidReturnAndReturnValueAsPayload"); - source.getExpressionForPayload(method); + assertThatIllegalArgumentException() + .isThrownBy(() -> source.getExpressionForPayload(method)); } @Test @@ -117,22 +120,25 @@ public class MethodAnnotationPublisherMetadataSourceTests { assertThat(payloadExpression).isEqualTo("#args[0]"); } - @Test(expected = IllegalStateException.class) + @Test public void voidReturnAndParameterPayloadAnnotationWithExpression() { Method method = getMethod("methodWithVoidReturnAndParameterPayloadAnnotationWithExpression", String.class); - source.getExpressionForPayload(method).getExpressionString(); + assertThatIllegalStateException() + .isThrownBy(() -> source.getExpressionForPayload(method).getExpressionString()); } - @Test(expected = IllegalStateException.class) + @Test public void voidReturnAndParameterPayloadAnnotationWithValue() { Method method = getMethod("methodWithVoidReturnAndParameterPayloadAnnotationWithValue", String.class); - source.getExpressionForPayload(method).getExpressionString(); + assertThatIllegalStateException() + .isThrownBy(() -> source.getExpressionForPayload(method).getExpressionString()); } - @Test(expected = IllegalArgumentException.class) + @Test public void voidReturnAndNoPayloadAnnotation() { Method method = getMethod("methodWithVoidReturnAndNoPayloadAnnotation", String.class); - source.getExpressionForPayload(method); + assertThatIllegalArgumentException() + .isThrownBy(() -> source.getExpressionForPayload(method)); } @Test diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aop/PublisherExpressionTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aop/PublisherExpressionTests.java index e256fe3edf..0b44559c18 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/aop/PublisherExpressionTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/aop/PublisherExpressionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,9 +16,9 @@ package org.springframework.integration.aop; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; import org.springframework.context.support.StaticApplicationContext; @@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Mark Fisher * @author Gary Russell - * @author Artme Bilan + * @author Artem Bilan * * @since 2.0 */ @@ -45,7 +45,7 @@ public class PublisherExpressionTests { private final StaticApplicationContext context = new StaticApplicationContext(); - @Before + @BeforeEach public void setup() throws Exception { this.context.registerSingleton("testChannel", QueueChannel.class); IntegrationEvaluationContextFactoryBean factory = new IntegrationEvaluationContextFactoryBean(); @@ -57,7 +57,7 @@ public class PublisherExpressionTests { this.context.getBeanFactory().registerSingleton("foo", "foo"); } - @After + @AfterEach public void tearDown() { this.context.close(); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/channel/reactive/FluxMessageChannelTests.java b/spring-integration-core/src/test/java/org/springframework/integration/channel/reactive/FluxMessageChannelTests.java index 0072b58f44..bb9b81fe5f 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/channel/reactive/FluxMessageChannelTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/channel/reactive/FluxMessageChannelTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2023 the original author or authors. + * Copyright 2016-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -164,7 +164,7 @@ public class FluxMessageChannelTests { Disposable.Composite upstreamSubscriptions = TestUtils.getPropertyValue(messageChannel, "upstreamSubscriptions", Disposable.Composite.class); - assertThat(upstreamSubscriptions.size()).isEqualTo(0); + await().untilAsserted(() -> assertThat(upstreamSubscriptions.size()).isEqualTo(0)); } @Configuration