More @DirtiesContext for tests in core module

Additional code style cleanups in the affected classes

**Auto-cherry-pick to `6.3.x` & `6.2.x`**
This commit is contained in:
Artem Bilan
2024-11-15 13:40:29 -05:00
parent 09750f2012
commit 8f4c2be0cb
67 changed files with 415 additions and 422 deletions

View File

@@ -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.
@@ -19,8 +19,7 @@ package org.springframework.integration.aggregator.integration;
import java.util.HashMap;
import java.util.Map;
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.beans.factory.annotation.Qualifier;
@@ -28,8 +27,8 @@ import org.springframework.integration.IntegrationMessageHeaderAccessor;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.support.GenericMessage;
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;
@@ -39,8 +38,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Oleg Zhurakousky
* @author Artem Bilan
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@SpringJUnitConfig
@DirtiesContext
public class AggregatorExpressionIntegrationTests {
@Autowired
@@ -51,7 +50,7 @@ public class AggregatorExpressionIntegrationTests {
@Qualifier("output")
private PollableChannel output;
@Test//(timeout=5000)
@Test
public void testVanillaAggregation() {
for (int i = 0; i < 5; i++) {
Map<String, Object> headers = stubHeaders(i, 5, 1);

View File

@@ -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.
@@ -38,6 +38,7 @@ import org.springframework.integration.config.EnableIntegration;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.PollableChannel;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
@@ -47,6 +48,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Artem Bilan
*/
@SpringJUnitConfig(classes = AnnotationAggregatorTests.TestConfiguration.class)
@DirtiesContext
public class AnnotationAggregatorTests {
@Autowired

View File

@@ -19,16 +19,15 @@ package org.springframework.integration.aggregator.integration;
import java.util.Collections;
import java.util.List;
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.DirectChannel;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.PollableChannel;
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;
@@ -36,8 +35,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Mark Fisher
* @author Artem Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class MethodInvokingAggregatorReturningMessageTests {
@Autowired
@@ -52,7 +51,7 @@ public class MethodInvokingAggregatorReturningMessageTests {
@Autowired
PollableChannel defaultOutput;
@Test // INT-1107
@Test
public void messageReturningPojoAggregatorResultIsNotWrappedInAnotherMessage() {
List<String> payload = Collections.singletonList("test");
this.pojoInput.send(MessageBuilder.withPayload(payload).build());

View File

@@ -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,7 @@
package org.springframework.integration.aggregator.integration;
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.context.ApplicationContext;
@@ -31,8 +30,7 @@ import org.springframework.integration.test.util.TestUtils;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
@@ -41,8 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author David Liu
* @author Artem Bilan
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@SpringJUnitConfig
@DirtiesContext
public class ResequencerIntegrationTests {

View File

@@ -16,32 +16,37 @@
package org.springframework.integration.dispatcher;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.aop.framework.Advised;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
/**
* This test was influenced by INT-1483 where via registering TX Advisor
* in the BeanFactory while having <aop:config> resent resulted in
* TX Advisor being applied on all beans in AC
*
* @author Oleg Zhurakousky
* @author Gunnar Hillert
* @author Gary Russell
*
* This test was influenced by INT-1483 where by registering TX Advisor
* in the BeanFactory while having <aop:config> resent resulted in
* TX Advisor being applied on all beans in AC
* @author Artem Bilan
*/
@SpringJUnitConfig
@DirtiesContext
public class TransactionalPollerWithMixedAopConfigTests {
@Autowired
ApplicationContext applicationContext;
@Test
public void validateTransactionalProxyIsolationToThePollerOnly() {
ClassPathXmlApplicationContext context =
new ClassPathXmlApplicationContext("TransactionalPollerWithMixedAopConfig-context.xml", this.getClass());
assertThat(!(context.getBean("foo") instanceof Advised)).isTrue();
assertThat(!(context.getBean("inputChannel") instanceof Advised)).isTrue();
context.close();
assertThat(this.applicationContext.getBean("foo")).isNotInstanceOf(Advised.class);
assertThat(applicationContext.getBean("inputChannel")).isNotInstanceOf(Advised.class);
}
public static class SampleService {
@@ -58,9 +63,4 @@ public class TransactionalPollerWithMixedAopConfigTests {
}
// public static class SampleAdvice implements MethodInterceptor{
// public Object invoke(MethodInvocation invocation) throws Throwable {
// return invocation.proceed();
// }
// }
}

View File

@@ -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,10 @@
package org.springframework.integration.dispatcher;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.integration.gateway.RequestReplyExchanger;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
@@ -26,6 +27,8 @@ import org.springframework.messaging.MessageDeliveryException;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.SubscribableChannel;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,26 +36,28 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Oleg Zhurakousky
* @author Gunnar Hillert
* @author Gary Russell
*
* @author Artem Bilan
*/
@SpringJUnitConfig
@DirtiesContext
public class UnicastingDispatcherTests {
@SuppressWarnings("unchecked")
@Autowired
ApplicationContext applicationContext;
@Test
public void withInboundGatewayAsyncRequestChannelAndExplicitErrorChannel() throws Exception {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("unicasting-with-async.xml", this.getClass());
SubscribableChannel errorChannel = context.getBean("errorChannel", SubscribableChannel.class);
public void withInboundGatewayAsyncRequestChannelAndExplicitErrorChannel() {
SubscribableChannel errorChannel = this.applicationContext.getBean("errorChannel", SubscribableChannel.class);
MessageHandler errorHandler = message -> {
MessageChannel replyChannel = (MessageChannel) message.getHeaders().getReplyChannel();
assertThat(message.getPayload() instanceof MessageDeliveryException).isTrue();
replyChannel.send(new GenericMessage<String>("reply"));
replyChannel.send(new GenericMessage<>("reply"));
};
errorChannel.subscribe(errorHandler);
RequestReplyExchanger exchanger = context.getBean(RequestReplyExchanger.class);
Message<String> reply = (Message<String>) exchanger.exchange(new GenericMessage<String>("Hello"));
RequestReplyExchanger exchanger = this.applicationContext.getBean(RequestReplyExchanger.class);
Message<?> reply = exchanger.exchange(new GenericMessage<>("Hello"));
assertThat(reply.getPayload()).isEqualTo("reply");
context.close();
}
}

View File

@@ -35,6 +35,7 @@ import org.springframework.integration.core.GenericTransformer;
import org.springframework.integration.handler.LambdaMessageProcessor;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
@@ -47,6 +48,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @since 5.0
*/
@SpringJUnitConfig
@DirtiesContext
public class LambdaMessageProcessorTests {
@Autowired

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2018-2022 the original author or authors.
* Copyright 2018-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,7 @@
package org.springframework.integration.dsl.lifecycle;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanClassLoaderAware;
@@ -42,7 +41,7 @@ import org.springframework.core.io.ResourceLoader;
import org.springframework.integration.config.EnableIntegration;
import org.springframework.integration.dsl.IntegrationComponentSpec;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.util.StringValueResolver;
import static org.assertj.core.api.Assertions.assertThat;
@@ -52,7 +51,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @since 5.0.7
*/
@RunWith(SpringRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class IntegrationComponentSpecLifecycleTests {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2022 the original author or authors.
* Copyright 2017-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,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.function.Consumer;
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.beans.factory.annotation.Qualifier;
@@ -34,7 +33,8 @@ import org.springframework.integration.dsl.context.IntegrationFlowContext.Integr
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
@@ -44,7 +44,8 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @since 5.0
*/
@RunWith(SpringRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class PublishSubscribeTests {
@Autowired

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 the original author or authors.
* Copyright 2019-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.
@@ -27,6 +27,7 @@ import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.config.EnableIntegration;
import org.springframework.integration.dsl.IntegrationFlow;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
@@ -39,6 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
*/
@SpringJUnitConfig
@DirtiesContext
public class NoFallbackAllowedTests {
@Test

View File

@@ -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.
@@ -19,8 +19,8 @@ package org.springframework.integration.endpoint;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.After;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.channel.PublishSubscribeChannel;
@@ -33,6 +33,7 @@ import org.springframework.messaging.support.ErrorMessage;
import org.springframework.messaging.support.GenericMessage;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
* @author Oleg Zhurakousky
@@ -45,14 +46,14 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
public class MessageProducerSupportTests {
private TestApplicationContext context = TestUtils.createTestApplicationContext();
private final TestApplicationContext context = TestUtils.createTestApplicationContext();
@After
@AfterEach
public void tearDown() {
this.context.close();
}
@Test(expected = MessageDeliveryException.class)
@Test
public void validateExceptionIfNoErrorChannel() {
DirectChannel outChannel = new DirectChannel();
@@ -66,10 +67,11 @@ public class MessageProducerSupportTests {
mps.setBeanFactory(this.context);
mps.afterPropertiesSet();
mps.start();
mps.sendMessage(new GenericMessage<>("hello"));
assertThatExceptionOfType(MessageDeliveryException.class)
.isThrownBy(() -> mps.sendMessage(new GenericMessage<>("hello")));
}
@Test(expected = MessageDeliveryException.class)
@Test
public void validateExceptionIfSendToErrorChannelFails() {
DirectChannel outChannel = new DirectChannel();
outChannel.subscribe(message -> {
@@ -87,7 +89,8 @@ public class MessageProducerSupportTests {
mps.setBeanFactory(this.context);
mps.afterPropertiesSet();
mps.start();
mps.sendMessage(new GenericMessage<>("hello"));
assertThatExceptionOfType(MessageDeliveryException.class)
.isThrownBy(() -> mps.sendMessage(new GenericMessage<>("hello")));
}
@Test

View File

@@ -23,13 +23,12 @@ import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
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.context.support.AbstractApplicationContext;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
@@ -40,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @since 2.0
*/
@RunWith(SpringRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class ProducerAndConsumerAutoStartupTests {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 the original author or authors.
* Copyright 2014-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,7 @@
package org.springframework.integration.expression;
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.messaging.Message;
@@ -25,8 +24,7 @@ import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
@@ -35,8 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 3.0.2
*
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class ForeignClassloaderTests {
@@ -54,7 +51,7 @@ public class ForeignClassloaderTests {
public void testThreadHasWrongClassLoader() {
Thread t = new Thread(() -> {
try {
foo.send(new GenericMessage<String>("foo"));
foo.send(new GenericMessage<>("foo"));
}
catch (Exception e) {
e.printStackTrace();

View File

@@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
@@ -31,6 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Artem Bilan
*/
@SpringJUnitConfig
@DirtiesContext
public class DynamicExpressionFilterIntegrationTests {
@Autowired

View File

@@ -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,7 @@
package org.springframework.integration.filter;
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.endpoint.AbstractEndpoint;
@@ -25,8 +24,8 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.support.GenericMessage;
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 +33,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Mark Fisher
* @author Artem Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class FilterContextTests {
@Autowired
@@ -52,7 +51,7 @@ public class FilterContextTests {
@Test
public void methodInvokingFilterRejects() {
this.input.send(new GenericMessage<String>("foo"));
this.input.send(new GenericMessage<>("foo"));
Message<?> reply = this.output.receive(0);
assertThat(reply).isNull();
@@ -65,7 +64,7 @@ public class FilterContextTests {
@Test
public void methodInvokingFilterAccepts() {
this.input.send(new GenericMessage<String>("foobar"));
this.input.send(new GenericMessage<>("foobar"));
Message<?> reply = this.output.receive(0);
assertThat(reply.getPayload()).isEqualTo("foobar");
}

View File

@@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
@@ -31,6 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Artem Bilan
*/
@SpringJUnitConfig
@DirtiesContext
public class SpelFilterIntegrationTests {
@Autowired

View File

@@ -16,8 +16,7 @@
package org.springframework.integration.gateway;
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.beans.factory.annotation.Qualifier;
@@ -28,19 +27,19 @@ import org.springframework.messaging.SubscribableChannel;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
* @author Oleg Zhurakousky
* @author Gunnar Hillert
* @author Artem Bilan
*
* @since 2.0
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
public class GatewayInvokingMessageHandlerTests {
@@ -95,21 +94,14 @@ public class GatewayInvokingMessageHandlerTests {
assertThat(result).isNotNull();
assertThat(result).isEqualTo("Error happened in message: echoWithRuntimeExceptionChannel");
try {
gatewayWithError.process("echoWithRuntimeExceptionChannel");
fail("SampleRuntimeException expected");
}
catch (SampleRuntimeException e) {
assertThat(e.getMessage()).isEqualTo("echoWithRuntimeExceptionChannel");
}
assertThatExceptionOfType(SampleRuntimeException.class)
.isThrownBy(() -> gatewayWithError.process("echoWithRuntimeExceptionChannel"))
.withMessage("echoWithRuntimeExceptionChannel");
try {
gatewayWithError.process("echoWithMessagingExceptionChannel");
fail("MessageHandlingException expected");
}
catch (MessageHandlingException e) {
assertThat(e.getFailedMessage().getPayload()).isEqualTo("echoWithMessagingExceptionChannel");
}
assertThatExceptionOfType(MessageHandlingException.class)
.isThrownBy(() -> gatewayWithError.process("echoWithMessagingExceptionChannel"))
.extracting("failedMessage.payload")
.isEqualTo("echoWithMessagingExceptionChannel");
result = gatewayWithErrorChannelAndTransformer.process("echoWithMessagingExceptionChannel");
assertThat(result).isNotNull();
@@ -118,13 +110,8 @@ public class GatewayInvokingMessageHandlerTests {
@Test
public void validateGatewayWithErrorAsync() {
try {
gatewayWithErrorAsync.process("echoWithErrorAsyncChannel");
fail("SampleRuntimeException expected");
}
catch (Exception e) {
assertThat(e.getClass()).isEqualTo(SampleRuntimeException.class);
}
assertThatExceptionOfType(SampleRuntimeException.class)
.isThrownBy(() -> gatewayWithErrorAsync.process("echoWithErrorAsyncChannel"));
}
@Test

View File

@@ -16,16 +16,16 @@
package org.springframework.integration.gateway;
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.context.ApplicationContext;
import org.springframework.integration.handler.ReplyRequiredException;
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;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
* @author Mark Fisher
@@ -34,8 +34,8 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @since 2.0
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class GatewayRequiresReplyTests {
@Autowired
@@ -48,10 +48,11 @@ public class GatewayRequiresReplyTests {
assertThat(result).isEqualTo("bar");
}
@Test(expected = ReplyRequiredException.class)
@Test
public void noReplyReceived() {
TestService gateway = this.applicationContext.getBean("gateway", TestService.class);
gateway.test("bad");
assertThatExceptionOfType(ReplyRequiredException.class)
.isThrownBy(() -> gateway.test("bad"));
}
@Test

View File

@@ -9,7 +9,7 @@
<gateway id="gateway"
default-request-channel="requestChannel"
service-interface="org.springframework.integration.gateway.GatewayWithHeaderAnnotations$TestService" />
service-interface="org.springframework.integration.gateway.GatewayWithHeaderAnnotationsTests$TestService" />
<service-activator input-channel="requestChannel"
expression="payload + headers.priority + headers.$custom + headers.baz"/>

View File

@@ -16,31 +16,32 @@
package org.springframework.integration.gateway;
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.context.ApplicationContext;
import org.springframework.integration.IntegrationMessageHeaderAccessor;
import org.springframework.messaging.handler.annotation.Header;
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;
/**
* @author Mark Fisher
* @author Gary Russell
* @author Artem Bilan
*
* @since 2.0
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
public class GatewayWithHeaderAnnotations {
@SpringJUnitConfig
@DirtiesContext
public class GatewayWithHeaderAnnotationsTests {
@Autowired
private ApplicationContext applicationContext;
@Test // INT-1205
@Test
public void priorityAsArgument() {
TestService gateway = (TestService) applicationContext.getBean("gateway");
String result = gateway.test("foo", 99, "bar", "qux");

View File

@@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
@@ -34,6 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 2.0
*/
@SpringJUnitConfig
@DirtiesContext
public class GatewayWithPayloadExpressionTests {
@Autowired

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 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.
@@ -26,6 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.expression.Expression;
import org.springframework.integration.annotation.Gateway;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
@@ -38,6 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
*/
@SpringJUnitConfig
@DirtiesContext
public class GatewayXmlAndAnnotationTests {
@Autowired

View File

@@ -16,15 +16,14 @@
package org.springframework.integration.gateway;
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.messaging.Message;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.handler.annotation.Header;
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;
@@ -32,10 +31,12 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Oleg Zhurakousky
* @author Mark Fisher
* @author Gunnar Hillert
* @author Artem Bilan
*
* @since 2.0
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@SpringJUnitConfig
@DirtiesContext
public class HeaderEnrichedGatewayTests {
@Autowired
@@ -50,7 +51,7 @@ public class HeaderEnrichedGatewayTests {
private Object testPayload;
@Test
public void validateHeaderValueMappings() throws Exception {
public void validateHeaderValueMappings() {
testPayload = "hello";
gatewayWithHeaderValues.sendString((String) testPayload);
Message<?> message1 = channel.receive(0);
@@ -77,7 +78,7 @@ public class HeaderEnrichedGatewayTests {
}
@Test
public void validateHeaderExpressionMappings() throws Exception {
public void validateHeaderExpressionMappings() {
testPayload = "hello";
gatewayWithHeaderExpressions.sendString((String) testPayload);
Message<?> message1 = channel.receive(0);

View File

@@ -19,16 +19,16 @@ package org.springframework.integration.gateway;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
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.endpoint.SourcePollingChannelAdapter;
import org.springframework.messaging.SubscribableChannel;
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;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
* @author Oleg Zhurakousky
@@ -36,8 +36,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Artem Bilan
*
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class InnerGatewayWithChainTests {
@Autowired
@@ -79,10 +79,11 @@ public class InnerGatewayWithChainTests {
assertThat(reply).isEqualTo("ERROR from errorChannelB");
}
// if no error channels explicitly defined exception is rethrown
@Test(expected = ArithmeticException.class)
// If no error channels explicitly defined exception is rethrown
@Test
public void testGatewaysNoErrorChannel() {
testGatewayWithNoErrorChannelAAA.echo(0);
assertThatExceptionOfType(ArithmeticException.class)
.isThrownBy(() -> testGatewayWithNoErrorChannelAAA.echo(0));
}
@Test

View File

@@ -16,13 +16,12 @@
package org.springframework.integration.gateway;
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.context.ApplicationContext;
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;
@@ -33,8 +32,8 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @since 2.0
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class MultiMethodGatewayConfigTests {
@Autowired

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 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,22 +16,22 @@
package org.springframework.integration.gateway;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.support.MessageBuilder;
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;
/**
* @author Oleg Zhurakousky
* @author Artem Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class MultipleEndpointGatewayTests {
@Autowired
@@ -44,20 +44,17 @@ public class MultipleEndpointGatewayTests {
@Test
public void gatewayNoDefaultReplyChannel() {
gatewayA.echo("echoAsMessageChannel");
// there is nothing to assert. Successful execution of the above is all we care in this test
Assertions.assertThatNoException().isThrownBy(() -> gatewayA.echo("echoAsMessageChannel"));
}
@Test
public void gatewayWithDefaultReplyChannel() {
gatewayB.echo("echoAsMessageChannelIgnoreDefOutChannel");
// there is nothing to assert. Successful execution of the above is all we care in this test
Assertions.assertThatNoException().isThrownBy(() -> gatewayB.echo("echoAsMessageChannelIgnoreDefOutChannel"));
}
@Test
public void gatewayWithReplySentBackToDefaultReplyChannel() {
gatewayB.echo("echoAsMessageChannelDefaultOutputChannel");
// there is nothing to assert. Successful execution of the above is all we care in this test
Assertions.assertThatNoException().isThrownBy(() -> gatewayB.echo("echoAsMessageChannelDefaultOutputChannel"));
}
public interface SampleGateway {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2022 the original author or authors.
* Copyright 2017-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,7 @@
package org.springframework.integration.handler;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.aop.framework.ProxyFactoryBean;
import org.springframework.aop.support.AopUtils;
@@ -30,16 +29,20 @@ import org.springframework.integration.history.MessageHistory;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Gary Russell
* @author Artem Bilan
*
* @since 4.3.10
*
*/
@RunWith(SpringRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class CGLibProxyHandlerTests {
@Autowired

View File

@@ -16,8 +16,7 @@
package org.springframework.integration.handler;
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.beans.factory.annotation.Qualifier;
@@ -27,18 +26,19 @@ import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
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;
/**
* @author Mark Fisher
* @author Artem Bilan
*
* @since 2.0
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class CustomConverterMessageProcessingTests {
@Autowired

View File

@@ -7,6 +7,6 @@
http://www.springframework.org/schema/integration
https://www.springframework.org/schema/integration/spring-integration.xsd">
<logging-channel-adapter id="input" expression="payload.name + ':' + payload.age"/>
<logging-channel-adapter id="input" logger-name="test.logging.handler" expression="payload.name + ':' + payload.age"/>
</beans:beans>

View File

@@ -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.
@@ -25,6 +25,7 @@ import org.mockito.ArgumentMatchers;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.core.log.LogAccessor;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.Expression;
@@ -35,10 +36,10 @@ import org.springframework.integration.test.util.TestUtils;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -55,39 +56,45 @@ import static org.mockito.Mockito.when;
* @since 2.0
*/
@SpringJUnitConfig
@DirtiesContext
@LogLevels(categories = "test.logging.handler")
public class LoggingHandlerTests {
@Autowired
@Qualifier("input.handler")
LoggingHandler loggingHandler;
@Autowired
MessageChannel input;
@Test
public void logWithExpression() {
DirectFieldAccessor accessor = new DirectFieldAccessor(loggingHandler);
LogAccessor log = (LogAccessor) accessor.getPropertyValue("messageLogger");
log = spy(log);
accessor.setPropertyValue("messageLogger", log);
TestBean bean = new TestBean("test", 55);
input.send(MessageBuilder.withPayload(bean).setHeader("foo", "bar").build());
verify(log)
.info(ArgumentMatchers.<Supplier<? extends CharSequence>>argThat(logMessage ->
logMessage.get().equals("test:55")));
}
@Test
public void assertMutuallyExclusive() {
LoggingHandler loggingHandler = new LoggingHandler("INFO");
loggingHandler.setLogExpressionString("'foo'");
try {
loggingHandler.setShouldLogFullMessage(true);
fail("Expected IllegalArgumentException");
}
catch (IllegalArgumentException e) {
assertThat(e.getMessage()).isEqualTo("Cannot set both 'expression' AND 'shouldLogFullMessage' properties");
}
loggingHandler.setLogExpressionString("'test'");
assertThatIllegalArgumentException()
.isThrownBy(() -> loggingHandler.setShouldLogFullMessage(true))
.withMessage("Cannot set both 'expression' AND 'shouldLogFullMessage' properties");
loggingHandler = new LoggingHandler("INFO");
loggingHandler.setShouldLogFullMessage(true);
try {
loggingHandler.setLogExpressionString("'foo'");
fail("Expected IllegalArgumentException");
}
catch (IllegalArgumentException e) {
assertThat(e.getMessage()).isEqualTo("Cannot set both 'expression' AND 'shouldLogFullMessage' properties");
}
LoggingHandler loggingHandler2 = new LoggingHandler("INFO");
loggingHandler2.setShouldLogFullMessage(true);
assertThatIllegalArgumentException()
.isThrownBy(() -> loggingHandler2.setLogExpressionString("'test'"))
.withMessage("Cannot set both 'expression' AND 'shouldLogFullMessage' properties");
}
@Test
@@ -149,24 +156,7 @@ public class LoggingHandlerTests {
logMessage.get().equals(testPayload)));
}
public static class TestBean {
private final String name;
private final int age;
public TestBean(String name, int age) {
this.name = name;
this.age = age;
}
public String getName() {
return this.name;
}
public int getAge() {
return this.age;
}
public record TestBean(String name, int age) {
}

View File

@@ -16,8 +16,7 @@
package org.springframework.integration.handler;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
@@ -26,8 +25,8 @@ import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
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;
@@ -36,8 +35,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Mark Fisher
* @author Artem Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class MockHandlerTests {
@Autowired

View File

@@ -16,22 +16,22 @@
package org.springframework.integration.handler;
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.context.ApplicationContext;
import org.springframework.integration.test.util.TestUtils;
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;
/**
* @author Mark Fisher
* @author Artem Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class SendTimeoutConfigurationTests {
@Autowired
@@ -39,31 +39,31 @@ public class SendTimeoutConfigurationTests {
@Test
public void serviceActivator() {
assertThat(this.getTimeout("serviceActivator")).isEqualTo(123);
assertThat(getTimeout("serviceActivator")).isEqualTo(123);
}
@Test
public void filter() {
assertThat(this.getTimeout("filter")).isEqualTo(123);
assertThat(getTimeout("filter")).isEqualTo(123);
}
@Test
public void transformer() {
assertThat(this.getTimeout("transformer")).isEqualTo(123);
assertThat(getTimeout("transformer")).isEqualTo(123);
}
@Test
public void splitter() {
assertThat(this.getTimeout("splitter")).isEqualTo(123);
assertThat(getTimeout("splitter")).isEqualTo(123);
}
@Test
public void router() {
assertThat(this.getTimeout("router")).isEqualTo(123);
assertThat(getTimeout("router")).isEqualTo(123);
}
private long getTimeout(String endpointName) {
return TestUtils.getPropertyValue(context.getBean(endpointName),
return TestUtils.getPropertyValue(this.context.getBean(endpointName),
"handler.messagingTemplate.sendTimeout", Long.class);
}

View File

@@ -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.
@@ -40,6 +40,7 @@ import org.springframework.messaging.MessageHandlingException;
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.support.ErrorMessage;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
@@ -55,6 +56,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @since 2.0.1
*/
@SpringJUnitConfig
@DirtiesContext
public class ServiceActivatorDefaultFrameworkMethodTests {
@Autowired

View File

@@ -16,8 +16,7 @@
package org.springframework.integration.handler;
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.beans.factory.annotation.Qualifier;
@@ -26,8 +25,8 @@ import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.handler.annotation.Header;
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.mockito.Mockito.verify;
@@ -36,8 +35,8 @@ import static org.mockito.Mockito.verify;
* @author Gunnar Hillert
* @author Artem Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class ServiceActivatorOnMockitoMockTests {
@Autowired
@@ -83,14 +82,6 @@ public class ServiceActivatorOnMockitoMockTests {
verify(singleMethodOnClass).move("SingleMethodOnClass");
}
public static class SingleMethodAcceptingHeaderOnClass {
public String move(@Header("s") String s) {
return s;
}
}
@Autowired
SingleMethodAcceptingHeaderOnClass singleMethodAcceptingHeaderOnClass;
@@ -102,4 +93,12 @@ public class ServiceActivatorOnMockitoMockTests {
verify(singleMethodAcceptingHeaderOnClass).move("SingleMethodAcceptingHeaderOnClass");
}
public static class SingleMethodAcceptingHeaderOnClass {
public String move(@Header("s") String s) {
return s;
}
}
}

View File

@@ -33,6 +33,7 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.ErrorMessage;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
@@ -45,6 +46,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
*/
@SpringJUnitConfig
@DirtiesContext
public class ExpressionEvaluatingRequestHandlerAdviceTests {
@Autowired

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 the original author or authors.
* Copyright 2014-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.
@@ -19,8 +19,7 @@ package org.springframework.integration.handler.advice;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.aop.framework.ProxyFactory;
@@ -41,18 +40,17 @@ import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
/**
* @author Artem Bilan
*
* @since 4.1
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class IdempotentReceiverTests {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 the original author or authors.
* Copyright 2019-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.
@@ -35,6 +35,7 @@ import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
@@ -46,6 +47,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @since 5.2
*/
@SpringJUnitConfig
@DirtiesContext
public class RateLimiterRequestHandlerAdviceTests {
private static final Duration REFRESH_PERIOD = Duration.ofMillis(500);

View File

@@ -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,16 +16,15 @@
package org.springframework.integration.handler.advice;
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.classify.ClassifierSupport;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.retry.RetryState;
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;
@@ -36,8 +35,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 2.2
*
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class SpelExpressionRetryStateGeneratorTests {
@Autowired

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2023 the original author or authors.
* Copyright 2017-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.
@@ -39,6 +39,7 @@ import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.messaging.support.ChannelInterceptor;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
@@ -49,6 +50,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 5.0
*/
@SpringJUnitConfig
@DirtiesContext
public class ContentTypeConversionTests {
@Autowired

View File

@@ -45,6 +45,7 @@ import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
@@ -57,6 +58,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @since 3.0
*/
@SpringJUnitConfig(classes = JsonPathTests.JsonPathTestsContextConfiguration.class)
@DirtiesContext
public class JsonPathTests {
private static File JSON_FILE;
@@ -72,7 +74,7 @@ public class JsonPathTests {
Scanner scanner = new Scanner(JSON_FILE);
JSON = scanner.useDelimiter("\\Z").next();
scanner.close();
testMessage = new GenericMessage<String>(JSON);
testMessage = new GenericMessage<>(JSON);
}
@Autowired

View File

@@ -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.
@@ -34,6 +34,7 @@ import org.springframework.integration.test.util.TestUtils;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandler;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
@@ -48,6 +49,7 @@ import static org.mockito.Mockito.verify;
* @since 2.0
*/
@SpringJUnitConfig
@DirtiesContext
public class JsonToObjectTransformerParserTests {
@Autowired

View File

@@ -37,6 +37,7 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
@@ -50,6 +51,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 2.0
*/
@SpringJUnitConfig
@DirtiesContext
public class ObjectToJsonTransformerParserTests {
@Autowired

View File

@@ -16,16 +16,15 @@
package org.springframework.integration.router.config;
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.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
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;
@@ -33,8 +32,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Mark Fisher
* @author Artem Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class DynamicExpressionRouterIntegrationTests {
@Autowired
@@ -68,17 +67,7 @@ public class DynamicExpressionRouterIntegrationTests {
assertThat(even.receive(0)).isNull();
}
static class TestBean {
private final int number;
TestBean(int number) {
this.number = number;
}
public int getNumber() {
return this.number;
}
record TestBean(int number) {
}

View File

@@ -16,16 +16,15 @@
package org.springframework.integration.router.config;
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.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
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;
@@ -33,8 +32,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Mark Fisher
* @author Artem Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class HeaderValueRouterConvertibleTypeTests {
@Autowired

View File

@@ -16,16 +16,15 @@
package org.springframework.integration.router.config;
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.context.ConfigurableApplicationContext;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.PollableChannel;
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;
@@ -33,8 +32,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Oleg Zhurakousky
* @author Artem Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class HeaderValueRouterParserTests {
@Autowired

View File

@@ -18,8 +18,7 @@ package org.springframework.integration.router.config;
import java.io.ByteArrayInputStream;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.annotation.Autowired;
@@ -30,16 +29,18 @@ import org.springframework.core.io.InputStreamResource;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.PollableChannel;
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;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
* @author Oleg Zhurakousky
* @author Artem Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class PayloadTypeRouterParserTests {
@Autowired
@@ -63,47 +64,37 @@ public class PayloadTypeRouterParserTests {
PollableChannel chanel2 = (PollableChannel) context.getBean("channel2");
PollableChannel chanel3 = (PollableChannel) context.getBean("channel3");
PollableChannel chanel4 = (PollableChannel) context.getBean("channel4");
assertThat(chanel1.receive(100).getPayload() instanceof String).isTrue();
assertThat(chanel2.receive(100).getPayload() instanceof Integer).isTrue();
assertThat(chanel1.receive(100).getPayload()).isInstanceOf(String.class);
assertThat(chanel2.receive(100).getPayload()).isInstanceOf(Integer.class);
assertThat(chanel3.receive(100).getPayload().getClass().isArray()).isTrue();
assertThat(chanel4.receive(100).getPayload().getClass().isArray()).isTrue();
}
@Test(expected = BeanDefinitionStoreException.class)
@Test
public void testNoMappingElement() {
ByteArrayInputStream stream = new ByteArrayInputStream(routerConfigNoMaping.getBytes());
ByteArrayInputStream stream = new ByteArrayInputStream(routerConfigNoMapping.getBytes());
GenericApplicationContext ac = new GenericApplicationContext();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(ac);
reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD);
reader.loadBeanDefinitions(new InputStreamResource(stream));
assertThatExceptionOfType(BeanDefinitionStoreException.class)
.isThrownBy(() -> reader.loadBeanDefinitions(new InputStreamResource(stream)));
}
@SuppressWarnings("unused")
private final String routerConfigFakeType =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<beans:beans xmlns=\"http://www.springframework.org/schema/integration\"" +
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:beans=\"http://www.springframework.org/schema/beans\"" +
" xsi:schemaLocation=\"http://www.springframework.org/schema/beans" +
" https://www.springframework.org/schema/beans/spring-beans.xsd" +
" http://www.springframework.org/schema/integration" +
" https://www.springframework.org/schema/integration/spring-integration.xsd\">" +
" <channel id=\"routingChannel\" />" +
" <payload-type-router input-channel=\"routingChannel\">" +
" <mapping type=\"FAKE_TYPE\" channel=\"channel1\" />" +
" </payload-type-router>" +
"</beans:beans>";
private static final String routerConfigNoMapping =
"""
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration
https://www.springframework.org/schema/integration/spring-integration.xsd">
private final String routerConfigNoMaping =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<beans:beans xmlns=\"http://www.springframework.org/schema/integration\"" +
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:beans=\"http://www.springframework.org/schema/beans\"" +
" xsi:schemaLocation=\"http://www.springframework.org/schema/beans" +
" https://www.springframework.org/schema/beans/spring-beans.xsd" +
" http://www.springframework.org/schema/integration" +
" https://www.springframework.org/schema/integration/spring-integration.xsd\">" +
" <channel id=\"routingChannel\" />" +
" <payload-type-router input-channel=\"routingChannel\"/>" +
"</beans:beans>";
<channel id="routingChannel" />
<payload-type-router input-channel="routingChannel"/>
</beans:beans>
""";
public interface TestService {

View File

@@ -40,6 +40,7 @@ import org.springframework.messaging.SubscribableChannel;
import org.springframework.messaging.core.DestinationResolutionException;
import org.springframework.messaging.core.DestinationResolver;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
@@ -55,6 +56,7 @@ import static org.mockito.Mockito.verify;
* @author Artem Bilan
*/
@SpringJUnitConfig
@DirtiesContext
public class RouterParserTests {
@Autowired

View File

@@ -16,8 +16,7 @@
package org.springframework.integration.router.config;
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.beans.factory.annotation.Qualifier;
@@ -28,17 +27,18 @@ import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
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;
/**
* @author Mark Fisher
* @author Gary Russell
* @author Artem Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class RouterWithMappingTests {
@Autowired
@@ -125,17 +125,7 @@ public class RouterWithMappingTests {
assertThat(this.testBean.isRunning()).isTrue();
}
private static class TestBean {
private final String name;
TestBean(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
private record TestBean(String name) {
}
@@ -145,7 +135,7 @@ public class RouterWithMappingTests {
@SuppressWarnings("unused")
public String route(TestBean bean) {
return bean.getName();
return bean.name();
}
@Override

View File

@@ -16,8 +16,7 @@
package org.springframework.integration.router.config;
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;
@@ -25,8 +24,8 @@ import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
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 +33,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Mark Fisher
* @author Artme Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class SpelRouterIntegrationTests {
@Autowired

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 the original author or authors.
* Copyright 2014-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.
@@ -18,8 +18,7 @@ package org.springframework.integration.scattergather.config;
import java.util.Collection;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -31,8 +30,8 @@ import org.springframework.integration.router.RecipientListRouter;
import org.springframework.integration.scattergather.ScatterGatherHandler;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.messaging.MessageHandler;
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;
@@ -42,8 +41,8 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @since 4.1
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class ScatterGatherParserTests {
@Autowired

View File

@@ -19,16 +19,15 @@ package org.springframework.integration.splitter;
import java.util.ArrayList;
import java.util.List;
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.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
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;
@@ -36,8 +35,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Mark Fisher
* @author Artem Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class DynamicExpressionSplitterIntegrationTests {
@Autowired

View File

@@ -30,6 +30,7 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
@@ -40,6 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Gary Russell
*/
@SpringJUnitConfig
@DirtiesContext
public class SpelSplitterIntegrationTests {
@Autowired

View File

@@ -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.
@@ -26,11 +26,17 @@ import org.springframework.integration.test.support.PayloadValidator;
import org.springframework.integration.test.support.RequestResponseScenario;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Gary Russell
* @author Artem Bilan
*/
@ContextConfiguration
@DirtiesContext
public class MessageScenariosTests extends AbstractRequestResponseScenarioTests {
@Override

View File

@@ -19,16 +19,23 @@ package org.springframework.integration.support;
import org.springframework.integration.test.support.PayloadValidator;
import org.springframework.integration.test.support.RequestResponseScenario;
import org.springframework.integration.test.support.SingleRequestResponseScenarioTests;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author David Turanski
* @author Mark Fisher
* @author Artem Bilan
*/
@ContextConfiguration("MessageScenariosTests-context.xml")
@DirtiesContext
public class SingleScenarioTests extends SingleRequestResponseScenarioTests {
@Override
protected RequestResponseScenario defineRequestResponseScenario() {
RequestResponseScenario scenario = new RequestResponseScenario(
return new RequestResponseScenario(
"inputChannel", "outputChannel")
.setPayload("hello")
.setResponseValidator(new PayloadValidator<String>() {
@@ -38,7 +45,6 @@ public class SingleScenarioTests extends SingleRequestResponseScenarioTests {
assertThat(response).isEqualTo("HELLO");
}
});
return scenario;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2018-2022 the original author or authors.
* Copyright 2018-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.
@@ -30,6 +30,7 @@ import org.springframework.integration.config.EnableIntegration;
import org.springframework.integration.config.EnableIntegrationManagement;
import org.springframework.integration.support.management.metrics.MetricsCaptor;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
@@ -46,6 +47,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
*/
@SpringJUnitConfig
@TestExecutionListeners(DependencyInjectionTestExecutionListener.class)
@DirtiesContext
public class MicrometerCustomMetricsTests {
@Autowired

View File

@@ -19,8 +19,7 @@ package org.springframework.integration.support.mutable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
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.context.annotation.Bean;
@@ -36,17 +35,19 @@ import org.springframework.integration.config.EnableIntegration;
import org.springframework.integration.support.MutableMessageBuilderFactory;
import org.springframework.messaging.MessageHeaders;
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;
/**
* @author Stuart Williams
* @author Artem Bilan
*
* @since 4.2
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@SpringJUnitConfig
@DirtiesContext
public class MutableMessageBuilderFactoryTests {
@Autowired

View File

@@ -16,13 +16,13 @@
package org.springframework.integration.transaction;
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.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionManager;
import org.springframework.transaction.annotation.Isolation;
@@ -38,7 +38,8 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @since 5.0
*/
@RunWith(SpringRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class TransactionInterceptorBuilderTests {
@Autowired

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 the original author or authors.
* Copyright 2019-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.
@@ -34,6 +34,7 @@ import org.springframework.integration.transformer.support.AvroHeaders;
import org.springframework.messaging.Message;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
@@ -47,6 +48,7 @@ import static org.mockito.Mockito.verify;
*
*/
@SpringJUnitConfig
@DirtiesContext
@LogLevels(categories = "foo", level = "DEBUG")
public class AvroTests {

View File

@@ -16,16 +16,15 @@
package org.springframework.integration.transformer;
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.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
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;
@@ -33,8 +32,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Mark Fisher
* @author Artem Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class DynamicExpressionHeaderEnricherIntegrationTests {
@Autowired

View File

@@ -16,16 +16,15 @@
package org.springframework.integration.transformer;
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.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
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;
@@ -33,8 +32,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Mark Fisher
* @author Artem Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class DynamicExpressionTransformerIntegrationTests {
@Autowired

View File

@@ -16,8 +16,7 @@
package org.springframework.integration.transformer;
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.Transformer;
@@ -29,18 +28,20 @@ import org.springframework.messaging.handler.annotation.Header;
import org.springframework.messaging.handler.annotation.Headers;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.messaging.support.GenericMessage;
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;
/**
* @author Gary Russell
* @author Artem Bilan
*
* @since 2.2
*
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class MessageHistoryParameterTests {
@Autowired
@@ -51,7 +52,7 @@ public class MessageHistoryParameterTests {
@Test
public void test() {
input.send(new GenericMessage<String>("foo"));
input.send(new GenericMessage<>("foo"));
assertThat(output.receive(10000)).isNotNull();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2023 the original author or authors.
* Copyright 2023-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.
@@ -34,6 +34,7 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
@@ -41,10 +42,12 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
*
* @author Christian Tzolov
* @author Artem Bilan
*
* @since 6.1
*/
@SpringJUnitConfig
@DirtiesContext
public class ProtoTests {
@Test

View File

@@ -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,7 @@
package org.springframework.integration.transformer;
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.beans.factory.annotation.Qualifier;
@@ -25,8 +24,8 @@ import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
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;
@@ -35,8 +34,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author David Turanski
* @author Artem Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class SpelHeaderEnricherIntegrationTests {
@Autowired

View File

@@ -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.
@@ -27,6 +27,7 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
@@ -39,6 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Artem Bilan
*/
@SpringJUnitConfig
@DirtiesContext
public class TransformerContextTests {
private static volatile int adviceCalled;

View File

@@ -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.
@@ -28,6 +28,7 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.SubscribableChannel;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static org.assertj.core.api.Assertions.assertThat;
@@ -48,6 +49,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Artem Bilan
*/
@RunWith(SpringJUnit4ClassRunner.class)
@DirtiesContext
public abstract class AbstractRequestResponseScenarioTests {
private List<RequestResponseScenario> scenarios = null;