More @DirtiesContext in test of core module

The another attempt to mitigate out of memory error on GitHub Actions
This commit is contained in:
Artem Bilan
2024-11-12 15:52:52 -05:00
parent a171ffd12d
commit 4ccec0bae3
16 changed files with 117 additions and 128 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.
@@ -18,8 +18,7 @@ package org.springframework.integration.config;
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.beans.factory.annotation.Qualifier;
@@ -31,8 +30,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;
@@ -42,8 +41,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Gunnar Hillert
* @author Artem Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class AggregatorWithCorrelationStrategyTests {
@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.
@@ -18,8 +18,7 @@ package org.springframework.integration.config;
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.beans.factory.annotation.Qualifier;
@@ -33,7 +32,7 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
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;
@@ -41,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Dave Syer
* @author Artem Bilan
*/
@RunWith(SpringRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class ChannelWithMessageStoreParserTests {
@@ -71,7 +70,6 @@ public class ChannelWithMessageStoreParserTests {
private MessageGroupStore priorityMessageStore;
@Test
@DirtiesContext
public void testActivatorSendsToPersistentQueue() throws Exception {
input.send(createMessage("123", "id1", 3, 1, null));
@@ -87,7 +85,6 @@ public class ChannelWithMessageStoreParserTests {
}
@Test
@DirtiesContext
public void testPriorityMessageStore() {
assertThat(TestUtils.getPropertyValue(this.priorityChannel, "queue.messageGroupStore"))
.isSameAs(this.priorityMessageStore);
@@ -96,6 +93,7 @@ public class ChannelWithMessageStoreParserTests {
private static <T> Message<T> createMessage(T payload, Object correlationId, int sequenceSize, int sequenceNumber,
MessageChannel outputChannel) {
return MessageBuilder.withPayload(payload).setCorrelationId(correlationId).setSequenceSize(sequenceSize)
.setSequenceNumber(sequenceNumber).setReplyChannel(outputChannel).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.
@@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
public class CorrelationStrategyInvalidConfigurationTests {
@Test
public void testCorrelationStrategyWithVoidReturningMethods() throws Exception {
public void testCorrelationStrategyWithVoidReturningMethods() {
assertThatExceptionOfType(BeanCreationException.class)
.isThrownBy(() -> new ClassPathXmlApplicationContext("correlationStrategyWithVoidMethods.xml",
getClass()))

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.
@@ -18,7 +18,7 @@ package org.springframework.integration.config;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.messaging.MessageChannel;
@@ -35,16 +35,15 @@ public class EndpointParserTests {
@Test
public void testSimpleEndpoint() throws InterruptedException {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"simpleEndpointTests.xml", this.getClass());
context.start();
MessageChannel channel = (MessageChannel) context.getBean("endpointParserTestInput");
TestHandler handler = (TestHandler) context.getBean("testHandler");
assertThat(handler.getMessageString()).isNull();
channel.send(new GenericMessage<>("test"));
assertThat(handler.getLatch().await(10000, TimeUnit.MILLISECONDS)).isTrue();
assertThat(handler.getMessageString()).isEqualTo("test");
context.close();
try (var context = new ClassPathXmlApplicationContext("simpleEndpointTests.xml", getClass())) {
context.start();
MessageChannel channel = (MessageChannel) context.getBean("endpointParserTestInput");
TestHandler handler = (TestHandler) context.getBean("testHandler");
assertThat(handler.getMessageString()).isNull();
channel.send(new GenericMessage<>("test"));
assertThat(handler.getLatch().await(10000, TimeUnit.MILLISECONDS)).isTrue();
assertThat(handler.getMessageString()).isEqualTo("test");
}
}
}

View File

@@ -16,8 +16,7 @@
package org.springframework.integration.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;
@@ -30,19 +29,20 @@ 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 org.springframework.util.StringUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
* @author Mark Fisher
* @author Gary Russell
* @author Artem Bilan
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@SpringJUnitConfig
@DirtiesContext
public class FilterParserTests {
@Autowired
@@ -136,9 +136,10 @@ public class FilterParserTests {
assertThat(reply).isNotNull();
}
@Test(expected = MessageRejectedException.class)
@Test
public void exceptionThrowingFilterRejects() {
exceptionInput.send(new GenericMessage<>(""));
assertThatExceptionOfType(MessageRejectedException.class)
.isThrownBy(() -> exceptionInput.send(new GenericMessage<>("")));
}
@Test
@@ -150,20 +151,14 @@ public class FilterParserTests {
assertThat(adapterOutput.receive(0)).isNull();
}
@Test(expected = MessageRejectedException.class)
public void filterWithDiscardChannelAndException() throws Exception {
Exception exception = null;
try {
discardAndExceptionInput.send(new GenericMessage<>(""));
}
catch (Exception e) {
exception = e;
}
@Test
public void filterWithDiscardChannelAndException() {
assertThatExceptionOfType(MessageRejectedException.class)
.isThrownBy(() -> discardAndExceptionInput.send(new GenericMessage<>("")));
Message<?> discard = discardAndExceptionOutput.receive(0);
assertThat(discard).isNotNull();
assertThat(discard.getPayload()).isEqualTo("");
assertThat(adapterOutput.receive(0)).isNull();
throw exception;
}
public static class TestSelectorBean {

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,9 +20,8 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.integration.channel.interceptor.GlobalChannelInterceptorWrapper;
@@ -30,6 +29,7 @@ import org.springframework.messaging.support.ChannelInterceptor;
import org.springframework.messaging.support.InterceptableChannel;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -44,7 +44,7 @@ public class GlobalChannelInterceptorProcessorTests {
private ListableBeanFactory beanFactory;
@Before
@BeforeEach
public void setup() {
this.globalChannelInterceptorProcessor = new GlobalChannelInterceptorProcessor();
this.beanFactory = mock(ListableBeanFactory.class);
@@ -58,7 +58,7 @@ public class GlobalChannelInterceptorProcessorTests {
this.globalChannelInterceptorProcessor.afterSingletonsInstantiated();
verify(this.beanFactory)
.getBeansOfType(GlobalChannelInterceptorWrapper.class);
verify(this.beanFactory, Mockito.never())
verify(this.beanFactory, never())
.getBeansOfType(InterceptableChannel.class);
}
@@ -66,11 +66,11 @@ public class GlobalChannelInterceptorProcessorTests {
public void testProcessorWithInterceptorDefaultPattern() {
Map<String, GlobalChannelInterceptorWrapper> interceptors = new HashMap<>();
Map<String, InterceptableChannel> channels = new HashMap<>();
ChannelInterceptor channelInterceptor = Mockito.mock(ChannelInterceptor.class);
ChannelInterceptor channelInterceptor = mock();
GlobalChannelInterceptorWrapper globalChannelInterceptorWrapper =
new GlobalChannelInterceptorWrapper(channelInterceptor);
InterceptableChannel channel = Mockito.mock(InterceptableChannel.class);
InterceptableChannel channel = mock();
interceptors.put("Test-1", globalChannelInterceptorWrapper);
channels.put("Test-1", channel);
@@ -89,11 +89,11 @@ public class GlobalChannelInterceptorProcessorTests {
public void testProcessorWithInterceptorMatchingPattern() {
Map<String, GlobalChannelInterceptorWrapper> interceptors = new HashMap<>();
Map<String, InterceptableChannel> channels = new HashMap<>();
ChannelInterceptor channelInterceptor = Mockito.mock(ChannelInterceptor.class);
ChannelInterceptor channelInterceptor = mock();
GlobalChannelInterceptorWrapper globalChannelInterceptorWrapper =
new GlobalChannelInterceptorWrapper(channelInterceptor);
InterceptableChannel channel = Mockito.mock(InterceptableChannel.class);
InterceptableChannel channel = mock();
globalChannelInterceptorWrapper.setPatterns(new String[] {"Te*"});
interceptors.put("Test-1", globalChannelInterceptorWrapper);
@@ -112,11 +112,11 @@ public class GlobalChannelInterceptorProcessorTests {
public void testProcessorWithInterceptorNotMatchingPattern() {
Map<String, GlobalChannelInterceptorWrapper> interceptors = new HashMap<>();
Map<String, InterceptableChannel> channels = new HashMap<>();
ChannelInterceptor channelInterceptor = Mockito.mock(ChannelInterceptor.class);
ChannelInterceptor channelInterceptor = mock();
GlobalChannelInterceptorWrapper globalChannelInterceptorWrapper =
new GlobalChannelInterceptorWrapper(channelInterceptor);
InterceptableChannel channel = Mockito.mock(InterceptableChannel.class);
InterceptableChannel channel = mock();
globalChannelInterceptorWrapper.setPatterns(new String[] {"te*"});
interceptors.put("Test-1", globalChannelInterceptorWrapper);
@@ -128,7 +128,7 @@ public class GlobalChannelInterceptorProcessorTests {
this.globalChannelInterceptorProcessor.afterSingletonsInstantiated();
verify(channel, Mockito.never())
verify(channel, never())
.addInterceptor(channelInterceptor);
}
@@ -136,11 +136,11 @@ public class GlobalChannelInterceptorProcessorTests {
public void testProcessorWithInterceptorMatchingNegativePattern() {
Map<String, GlobalChannelInterceptorWrapper> interceptors = new HashMap<>();
Map<String, InterceptableChannel> channels = new HashMap<>();
ChannelInterceptor channelInterceptor = Mockito.mock(ChannelInterceptor.class);
ChannelInterceptor channelInterceptor = mock();
GlobalChannelInterceptorWrapper globalChannelInterceptorWrapper =
new GlobalChannelInterceptorWrapper(channelInterceptor);
InterceptableChannel channel = Mockito.mock(InterceptableChannel.class);
InterceptableChannel channel = mock();
globalChannelInterceptorWrapper.setPatterns(new String[] {"!te*", "!Te*"});
interceptors.put("Test-1", globalChannelInterceptorWrapper);
@@ -151,7 +151,7 @@ public class GlobalChannelInterceptorProcessorTests {
.thenReturn(channels);
this.globalChannelInterceptorProcessor.afterSingletonsInstantiated();
verify(channel, Mockito.never())
verify(channel, never())
.addInterceptor(channelInterceptor);
}

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.
@@ -18,8 +18,7 @@ package org.springframework.integration.config;
import java.util.concurrent.Executor;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
@@ -29,7 +28,8 @@ import org.springframework.integration.dispatcher.BroadcastingDispatcher;
import org.springframework.integration.support.utils.IntegrationUtils;
import org.springframework.integration.util.ErrorHandlingTaskExecutor;
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 org.springframework.util.ErrorHandler;
import static org.assertj.core.api.Assertions.assertThat;
@@ -39,7 +39,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Gary Russell
* @author Artem Bilan
*/
@RunWith(SpringRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class PublishSubscribeChannelParserTests {
@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.
@@ -33,6 +33,7 @@ import org.springframework.integration.store.SimpleMessageGroup;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.messaging.Message;
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.springframework.integration.test.util.TestUtils.getPropertyVal
* @author Gary Russell
*/
@SpringJUnitConfig
@DirtiesContext
public class ResequencerParserTests {
@Autowired

View File

@@ -16,8 +16,7 @@
package org.springframework.integration.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;
@@ -27,8 +26,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;
@@ -36,8 +35,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Dave Syer
* @author Artem Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class ResequencerWithMessageStoreParserTests {
@Autowired
@@ -75,6 +74,7 @@ public class ResequencerWithMessageStoreParserTests {
private static <T> Message<T> createMessage(T payload, Object correlationId, int sequenceSize, int sequenceNumber,
MessageChannel outputChannel) {
return MessageBuilder.withPayload(payload)
.setCorrelationId(correlationId)
.setSequenceSize(sequenceSize)

View File

@@ -16,18 +16,17 @@
package org.springframework.integration.config;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.router.AbstractMappingMessageRouter;
import org.springframework.integration.test.util.TestUtils;
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;
@@ -35,8 +34,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Mark Fisher
* @author Artem Bilan
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@SpringJUnitConfig
@DirtiesContext
public class RouterFactoryBeanDelegationTests {
@Autowired
@@ -57,8 +56,7 @@ public class RouterFactoryBeanDelegationTests {
@Test
public void checkResolutionRequiredConfiguredOnTargetRouter() {
@SuppressWarnings("unchecked")
boolean resolutionRequired = (Boolean) new DirectFieldAccessor(router).getPropertyValue("resolutionRequired");
boolean resolutionRequired = TestUtils.getPropertyValue(router, "resolutionRequired", Boolean.class);
assertThat(resolutionRequired).as("The 'resolutionRequired' property should be 'true'").isTrue();
}

View File

@@ -18,19 +18,18 @@ package org.springframework.integration.config;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.integration.core.MessageSelector;
import org.springframework.integration.selector.MessageSelectorChain;
import org.springframework.integration.selector.MessageSelectorChain.VotingStrategy;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.messaging.Message;
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 Iwein Fuld
* @author Artem Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class SelectorChainParserTests {
@Autowired
@@ -96,12 +95,11 @@ public class SelectorChainParserTests {
@SuppressWarnings("unchecked")
private List<MessageSelector> getSelectors(MessageSelectorChain chain) {
DirectFieldAccessor accessor = new DirectFieldAccessor(chain);
return (List<MessageSelector>) accessor.getPropertyValue("selectors");
return (List<MessageSelector>) TestUtils.getPropertyValue(chain, "selectors", List.class);
}
private VotingStrategy getStrategy(MessageSelectorChain chain) {
return (VotingStrategy) new DirectFieldAccessor(chain).getPropertyValue("votingStrategy");
return TestUtils.getPropertyValue(chain, "votingStrategy", VotingStrategy.class);
}
public static class StubPojoSelector {

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,23 +16,23 @@
package org.springframework.integration.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.ApplicationContext;
import org.springframework.integration.core.MessageSelector;
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 Mark Fisher
* @author Artem Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class TopLevelSelectorParserTests {
@Autowired
@@ -40,8 +40,8 @@ public class TopLevelSelectorParserTests {
@Test
public void topLevelSelector() {
MessageSelector selector = (MessageSelector) context.getBean("selector");
assertThat(selector.accept(new GenericMessage<String>("test"))).isTrue();
MessageSelector selector = context.getBean("selector", MessageSelector.class);
assertThat(selector.accept(new GenericMessage<>("test"))).isTrue();
}
}

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.
@@ -18,10 +18,8 @@ package org.springframework.integration.config;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.channel.interceptor.WireTap;
@@ -31,17 +29,18 @@ 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;
/**
* @author Mark Fisher
* @author Gary Russell
* @author Artem Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class WireTapParserTests {
@Autowired
@@ -68,7 +67,7 @@ public class WireTapParserTests {
@Test
public void simpleWireTap() {
assertThat(wireTapChannel.receive(0)).isNull();
Message<?> original = new GenericMessage<String>("test");
Message<?> original = new GenericMessage<>("test");
noSelectors.send(original);
Message<?> intercepted = wireTapChannel.receive(0);
assertThat(intercepted).isNotNull();
@@ -78,7 +77,7 @@ public class WireTapParserTests {
@Test
public void simpleWireTapWithIdAndSelectorExpression() {
assertThat(TestUtils.getPropertyValue(wireTap, "selector")).isInstanceOf(ExpressionEvaluatingSelector.class);
Message<?> original = new GenericMessage<String>("test");
Message<?> original = new GenericMessage<>("test");
withId.send(original);
Message<?> intercepted = wireTapChannel.receive(0);
assertThat(intercepted).isNotNull();
@@ -88,7 +87,7 @@ public class WireTapParserTests {
@Test
public void wireTapWithAcceptingSelector() {
assertThat(wireTapChannel.receive(0)).isNull();
Message<?> original = new GenericMessage<String>("test");
Message<?> original = new GenericMessage<>("test");
accepting.send(original);
Message<?> intercepted = wireTapChannel.receive(0);
assertThat(intercepted).isNotNull();
@@ -98,7 +97,7 @@ public class WireTapParserTests {
@Test
public void wireTapWithRejectingSelector() {
assertThat(wireTapChannel.receive(0)).isNull();
Message<?> original = new GenericMessage<String>("test");
Message<?> original = new GenericMessage<>("test");
rejecting.send(original);
Message<?> intercepted = wireTapChannel.receive(0);
assertThat(intercepted).isNull();
@@ -110,7 +109,7 @@ public class WireTapParserTests {
int expectedTimeoutCount = 0;
int otherTimeoutCount = 0;
for (WireTap wireTap : wireTaps) {
long timeout = ((Long) new DirectFieldAccessor(wireTap).getPropertyValue("timeout")).longValue();
long timeout = TestUtils.getPropertyValue(wireTap, "timeout", Long.class);
if (timeout == 0) {
defaultTimeoutCount++;
}

View File

@@ -16,8 +16,7 @@
package org.springframework.integration.config.annotation;
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;
@@ -32,8 +31,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.SpringRunner;
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 5.0.8
*/
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = BridgeFromIntegrationTests.RootTestConfiguration.class)
@SpringJUnitConfig(classes = BridgeFromIntegrationTests.RootTestConfiguration.class)
@DirtiesContext
public class BridgeFromIntegrationTests {
@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.
@@ -50,6 +50,7 @@ import org.springframework.integration.util.MessagingAnnotationUtils;
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;
@@ -63,6 +64,7 @@ import static org.mockito.Mockito.verify;
* @since 4.3.8
*/
@SpringJUnitConfig
@DirtiesContext
public class CustomMessagingAnnotationTests {
@Autowired(required = false)

View File

@@ -20,8 +20,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
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;
@@ -31,8 +30,8 @@ import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.PollableChannel;
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;
@@ -41,8 +40,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Mark Fisher
* @author Artem Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class MessagingAnnotationPostProcessorAopIntegrationTests {
@Qualifier("input")