From 587693fc0151122ac66850b6cc707e068d36a42e Mon Sep 17 00:00:00 2001 From: Jiandong Date: Wed, 7 May 2025 23:04:26 +0800 Subject: [PATCH] Migrate `spring-integration-core` tests from Junit 4 to Junit Jupiter * Remove redundant assert from lambda in test Signed-off-by: Jiandong Ma Signed-off-by: Artem Bilan Co-authored-by: Artem Bilan --- ...atingMessageGroupProcessorHeaderTests.java | 8 +- .../CorrelatingMessageBarrierTests.java | 24 +++-- ...elatingMessageHandlerIntegrationTests.java | 8 +- .../CorrelationStrategyAdapterTests.java | 8 +- ...ionEvaluatingCorrelationStrategyTests.java | 19 ++-- ...nEvaluatingMessageGroupProcessorTests.java | 15 ++-- ...ressionEvaluatingReleaseStrategyTests.java | 8 +- ...aderAttributeCorrelationStrategyTests.java | 4 +- .../MessageSequenceComparatorTests.java | 4 +- ...hodInvokingMessageGroupProcessorTests.java | 32 +++---- ...esequencingMessageGroupProcessorTests.java | 4 +- .../SequenceSizeReleaseStrategyTests.java | 4 +- ...CountSequenceSizeReleaseStrategyTests.java | 4 +- .../AggregatorSupportedUseCasesTests.java | 4 +- .../scenarios/AggregationResendTests.java | 17 ++-- .../AggregatorReplyChannelTests.java | 15 ++-- .../scenarios/NestedAggregationTests.java | 11 +-- .../PartialSequencesWithGapsTests.java | 15 ++-- .../channel/ChannelPurgerTests.java | 15 ++-- .../channel/DatatypeChannelTests.java | 20 +++-- .../channel/DirectChannelParserTests.java | 4 +- .../config/RendezvousChannelParserTests.java | 4 +- .../interceptor/ChannelInterceptorTests.java | 4 +- ...obalChannelInterceptorSubElementTests.java | 11 +-- .../GlobalChannelInterceptorTests.java | 11 +-- .../interceptor/GlobalWireTapTests.java | 11 +-- .../ImplicitConsumerChannelTests.java | 11 +-- .../MessageSelectingInterceptorTests.java | 10 ++- .../channel/interceptor/WireTapTests.java | 10 ++- .../codec/kryo/CompositeCodecTests.java | 8 +- .../codec/kryo/FileKryoRegistrarTests.java | 4 +- .../codec/kryo/KryoCodecTests.java | 4 +- .../InvalidPriorityChannelParserTests.java | 4 +- .../InvalidQueueChannelParserTests.java | 4 +- .../config/MessageBusParserTests.java | 4 +- .../ReleaseStrategyFactoryBeanTests.java | 4 +- .../config/xml/ContextHierarchyTests.java | 4 +- ...xSubscribersDefaultConfigurationTests.java | 11 +-- ...axSubscribersDontOverrideDefaultTests.java | 11 +-- ...herMaxSubscribersOverrideDefaultTests.java | 11 +-- .../config/xml/EnricherParser3Tests.java | 4 +- .../config/xml/HeaderFilterParserTests.java | 11 +-- .../MapToObjectTransformerParserTests.java | 19 ++-- .../MethodInvokingSelectorParserTests.java | 11 +-- .../config/xml/NestedChainParserTests.java | 15 ++-- .../ObjectToStringTransformerParserTests.java | 11 +-- ...loadSerializingTransformerParserTests.java | 17 ++-- .../xml/PollerWithErrorChannelTests.java | 4 +- .../xml/PublishingInterceptorParserTests.java | 11 +-- .../xml/StreamTransformerParserTests.java | 11 +-- .../xml/SyslogTransformerParserTests.java | 11 +-- ...tionSynchronizationFactoryParserTests.java | 4 +- .../PropertyPlaceholderTests.java | 11 +-- ...ggregateMessageDeliveryExceptionTests.java | 8 +- .../dispatcher/PollingTransactionTests.java | 4 +- .../RoundRobinDispatcherConcurrentTests.java | 32 +++---- .../dispatcher/RoundRobinDispatcherTests.java | 22 ++--- .../endpoint/CorrelationIdTests.java | 4 +- ...xpressionEvaluatingMessageSourceTests.java | 10 ++- .../MessageSourcePollingTemplateTests.java | 4 +- .../PollingConsumerEndpointTests.java | 27 +++--- .../PollingEndpointErrorHandlingTests.java | 4 +- .../ServiceActivatorEndpointTests.java | 15 ++-- ...ServiceActivatorMethodResolutionTests.java | 15 ++-- .../expression/DynamicExpressionTests.java | 8 +- ...FilterAnnotationMethodResolutionTests.java | 4 +- .../filter/MessageFilterTests.java | 23 +++-- .../filter/MethodInvokingSelectorTests.java | 17 ++-- .../gateway/NestedGatewayTests.java | 4 +- .../handler/CollectionAndArrayTests.java | 4 +- ...essionEvaluatingMessageProcessorTests.java | 4 +- .../HeaderAnnotationTransformerTests.java | 4 +- .../MethodInvokingHeaderEnricherTests.java | 4 +- .../integration/history/AnnotatedTests.java | 4 +- ...AbstractJsonInboundMessageMapperTests.java | 4 +- ...actJsonSymmetricalMessageMappingTests.java | 4 +- .../JsonTransformersSymmetricalTests.java | 4 +- .../json/ObjectToJsonTransformerTests.java | 10 ++- .../mapping/HeaderMapperTests.java | 4 +- ...pressionEvaluatingMessageHandlerTests.java | 31 +++---- .../message/GenericMessageTests.java | 4 +- .../message/MessageBuilderAtConfigTests.java | 12 +-- .../MethodInvokingMessageSourceTests.java | 20 +++-- .../selector/PayloadTypeSelectorTests.java | 4 +- .../UnexpiredMessageSelectorTests.java | 4 +- ...ourceInboundChannelAdapterParserTests.java | 22 ++--- .../ErrorMessageExceptionTypeRouterTests.java | 12 +-- .../router/HeaderValueRouterTests.java | 4 +- .../router/MethodInvokingRouterTests.java | 10 ++- .../router/MultiChannelRouterTests.java | 14 +-- .../router/PayloadTypeRouterTests.java | 20 +++-- .../router/RecipientListRouterTests.java | 90 +++++++++---------- .../integration/router/RouterTests.java | 51 ++++++----- .../router/config/RouterFactoryBeanTests.java | 4 +- .../config/SplitterAggregatorTests.java | 4 +- .../router/config/SplitterParserTests.java | 10 ++- .../selector/MessageSelectorChainTests.java | 4 +- .../splitter/StreamingSplitterTests.java | 8 +- .../store/MessageStoreReaperTests.java | 11 +-- .../support/MutableMessageTests.java | 4 +- .../SmartLifecycleRoleControllerTests.java | 4 +- .../converter/MapMessageConverterTests.java | 4 +- .../ClaimCheckTransformerTests.java | 10 ++- .../transformer/CodecTransformerTests.java | 4 +- .../transformer/HeaderFilterTests.java | 4 +- .../ObjectToStringTransformerTests.java | 4 +- .../PayloadSerializingTransformerTests.java | 10 ++- .../transformer/PayloadTransformerTests.java | 15 ++-- ...PayloadTypeConvertingTransformerTests.java | 4 +- .../transformer/SysLogTransformerTests.java | 4 +- .../util/BeanFactoryTypeConverterTests.java | 8 +- .../integration/util/UUIDConverterTests.java | 10 ++- 112 files changed, 583 insertions(+), 612 deletions(-) diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/AggregatingMessageGroupProcessorHeaderTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/AggregatingMessageGroupProcessorHeaderTests.java index 37cc914ac5..5be6200b94 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/AggregatingMessageGroupProcessorHeaderTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/AggregatingMessageGroupProcessorHeaderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,8 +22,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.beans.factory.BeanFactory; @@ -52,7 +52,7 @@ public class AggregatingMessageGroupProcessorHeaderTests { private final MethodInvokingMessageGroupProcessor methodInvokingProcessor = new MethodInvokingMessageGroupProcessor(new TestAggregatorBean(), "aggregate"); - @Before + @BeforeEach public void setup() { this.defaultProcessor.setBeanFactory(mock(BeanFactory.class)); this.methodInvokingProcessor.setBeanFactory(mock(BeanFactory.class)); diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/CorrelatingMessageBarrierTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/CorrelatingMessageBarrierTests.java index 65cfe971fd..a9220951eb 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/CorrelatingMessageBarrierTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/CorrelatingMessageBarrierTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,12 +22,11 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Semaphore; +import java.util.concurrent.TimeUnit; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; import org.springframework.integration.store.MessageGroup; import org.springframework.integration.support.MessageBuilder; @@ -36,6 +35,7 @@ import org.springframework.messaging.MessageHandler; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.isA; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -43,18 +43,15 @@ import static org.mockito.Mockito.when; * @author Iwein Fuld * @author Gary Russell */ -@RunWith(MockitoJUnitRunner.class) public class CorrelatingMessageBarrierTests { private CorrelatingMessageBarrier barrier; - @Mock - private CorrelationStrategy correlationStrategy; + private final CorrelationStrategy correlationStrategy = mock(); - @Mock - private ReleaseStrategy releaseStrategy; + private final ReleaseStrategy releaseStrategy = mock(); - @Before + @BeforeEach public void initializeBarrier() { barrier = new CorrelatingMessageBarrier(); barrier.setCorrelationStrategy(correlationStrategy); @@ -83,7 +80,8 @@ public class CorrelatingMessageBarrierTests { assertThat(barrier.receive()).isNull(); } - @Test(timeout = 10000) + @Test + @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS) public void shouldNotDropMessageOrBlockSendingThread() { OneMessagePerKeyReleaseStrategy trackingReleaseStrategy = new OneMessagePerKeyReleaseStrategy(); barrier.setReleaseStrategy(trackingReleaseStrategy); diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/CorrelatingMessageHandlerIntegrationTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/CorrelatingMessageHandlerIntegrationTests.java index f510978f76..320ab46cb6 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/CorrelatingMessageHandlerIntegrationTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/CorrelatingMessageHandlerIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,8 +16,8 @@ package org.springframework.integration.aggregator; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.integration.store.MessageGroupStore; @@ -49,7 +49,7 @@ public class CorrelatingMessageHandlerIntegrationTests { private final AggregatingMessageHandler defaultHandler = new AggregatingMessageHandler(processor, store); - @Before + @BeforeEach public void setupHandler() { when(outputChannel.send(isA(Message.class))).thenReturn(true); defaultHandler.setOutputChannel(outputChannel); diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/CorrelationStrategyAdapterTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/CorrelationStrategyAdapterTests.java index bfe8b71cdb..a0d11b25d1 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/CorrelationStrategyAdapterTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/CorrelationStrategyAdapterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,8 +16,8 @@ package org.springframework.integration.aggregator; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.integration.support.MessageBuilder; @@ -37,7 +37,7 @@ public class CorrelationStrategyAdapterTests { private Message message; - @Before + @BeforeEach public void init() { message = MessageBuilder.withPayload("foo").setHeader("a", "b").setHeader("c", "d").build(); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/ExpressionEvaluatingCorrelationStrategyTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/ExpressionEvaluatingCorrelationStrategyTests.java index fa8ea3dbc6..e5c2d5b2c1 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/ExpressionEvaluatingCorrelationStrategyTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/ExpressionEvaluatingCorrelationStrategyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,7 +16,7 @@ package org.springframework.integration.aggregator; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -31,6 +31,7 @@ import org.springframework.messaging.MessageChannel; import org.springframework.messaging.support.GenericMessage; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.Mockito.mock; /** @@ -43,15 +44,17 @@ public class ExpressionEvaluatingCorrelationStrategyTests { private ExpressionEvaluatingCorrelationStrategy strategy; - @Test(expected = IllegalArgumentException.class) - public void testCreateInstanceWithEmptyExpressionFails() throws Exception { - strategy = new ExpressionEvaluatingCorrelationStrategy(""); + @Test + public void testCreateInstanceWithEmptyExpressionFails() { + assertThatThrownBy(() -> strategy = new ExpressionEvaluatingCorrelationStrategy("")) + .isInstanceOf(IllegalArgumentException.class); } - @Test(expected = IllegalArgumentException.class) - public void testCreateInstanceWithNullExpressionFails() throws Exception { + @Test + public void testCreateInstanceWithNullExpressionFails() { Expression nullExpression = null; - strategy = new ExpressionEvaluatingCorrelationStrategy(nullExpression); + assertThatThrownBy(() -> strategy = new ExpressionEvaluatingCorrelationStrategy(nullExpression)) + .isInstanceOf(IllegalArgumentException.class); } @Test diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/ExpressionEvaluatingMessageGroupProcessorTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/ExpressionEvaluatingMessageGroupProcessorTests.java index 0c35d4ea81..f93210335e 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/ExpressionEvaluatingMessageGroupProcessorTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/ExpressionEvaluatingMessageGroupProcessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,11 +20,8 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.integration.store.MessageGroup; @@ -42,17 +39,15 @@ import static org.mockito.Mockito.when; * @author Gary Russell * @author Artem Bilan */ -@RunWith(MockitoJUnitRunner.class) public class ExpressionEvaluatingMessageGroupProcessorTests { private ExpressionEvaluatingMessageGroupProcessor processor; - @Mock - private MessageGroup group; + private final MessageGroup group = mock(); private final List> messages = new ArrayList<>(); - @Before + @BeforeEach public void setup() { messages.clear(); for (int i = 0; i < 5; i++) { diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/ExpressionEvaluatingReleaseStrategyTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/ExpressionEvaluatingReleaseStrategyTests.java index 03e650a732..ffa7ea7304 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/ExpressionEvaluatingReleaseStrategyTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/ExpressionEvaluatingReleaseStrategyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,8 +16,8 @@ package org.springframework.integration.aggregator; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.integration.store.SimpleMessageGroup; @@ -39,7 +39,7 @@ public class ExpressionEvaluatingReleaseStrategyTests { private final SimpleMessageGroup messages = new SimpleMessageGroup("foo"); - @Before + @BeforeEach @SuppressWarnings({"unchecked", "rawtypes"}) public void setup() { for (int i = 0; i < 5; i++) { diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/HeaderAttributeCorrelationStrategyTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/HeaderAttributeCorrelationStrategyTests.java index 6e8e0535db..3ddd844d4d 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/HeaderAttributeCorrelationStrategyTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/HeaderAttributeCorrelationStrategyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,7 +16,7 @@ package org.springframework.integration.aggregator; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.integration.support.MessageBuilder; import org.springframework.messaging.Message; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/MessageSequenceComparatorTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/MessageSequenceComparatorTests.java index ddec02461c..4cd9345e82 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/MessageSequenceComparatorTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/MessageSequenceComparatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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.aggregator; import java.util.Comparator; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.integration.support.MessageBuilder; import org.springframework.messaging.Message; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/MethodInvokingMessageGroupProcessorTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/MethodInvokingMessageGroupProcessorTests.java index 10a81b8df6..b184eeaa37 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/MethodInvokingMessageGroupProcessorTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/MethodInvokingMessageGroupProcessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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. @@ -23,11 +23,8 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.factory.BeanFactory; @@ -49,6 +46,8 @@ import org.springframework.messaging.handler.annotation.Headers; import org.springframework.messaging.support.GenericMessage; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.assertj.core.api.Assertions.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -62,15 +61,13 @@ import static org.mockito.Mockito.when; * @author Gary Russell * @author Artem Bilan */ -@RunWith(MockitoJUnitRunner.class) public class MethodInvokingMessageGroupProcessorTests { private final List> messagesUpForProcessing = new ArrayList<>(3); - @Mock - private MessageGroup messageGroupMock; + private final MessageGroup messageGroupMock = mock(); - @Before + @BeforeEach public void initializeMessagesUpForProcessing() { this.messagesUpForProcessing.add(MessageBuilder.withPayload(1).build()); this.messagesUpForProcessing.add(MessageBuilder.withPayload(2).build()); @@ -488,7 +485,7 @@ public class MethodInvokingMessageGroupProcessorTests { assertThat(aggregator.aggregatePayloads(group, aggregator.aggregateHeaders(group))).isEqualTo("foobar"); } - @Test(expected = IllegalArgumentException.class) + @Test public void multipleAnnotations() { class MultipleAnnotationTestBean { @@ -506,7 +503,8 @@ public class MethodInvokingMessageGroupProcessorTests { } MultipleAnnotationTestBean bean = new MultipleAnnotationTestBean(); - new MethodInvokingMessageGroupProcessor(bean); + assertThatIllegalArgumentException() + .isThrownBy(() -> new MethodInvokingMessageGroupProcessor(bean)); } @Test @@ -534,7 +532,7 @@ public class MethodInvokingMessageGroupProcessorTests { assertThat(aggregator.aggregatePayloads(group, null)).isEqualTo("foo"); } - @Test(expected = IllegalArgumentException.class) + @Test public void multiplePublicMethods() { @SuppressWarnings("unused") @@ -551,10 +549,11 @@ public class MethodInvokingMessageGroupProcessorTests { } MultiplePublicMethodTestBean bean = new MultiplePublicMethodTestBean(); - new MethodInvokingMessageGroupProcessor(bean); + assertThatIllegalArgumentException() + .isThrownBy(() -> new MethodInvokingMessageGroupProcessor(bean)); } - @Test(expected = IllegalStateException.class) + @Test public void noPublicMethods() { @SuppressWarnings("unused") @@ -567,7 +566,8 @@ public class MethodInvokingMessageGroupProcessorTests { } NoPublicMethodTestBean bean = new NoPublicMethodTestBean(); - new MethodInvokingMessageGroupProcessor(bean); + assertThatIllegalStateException() + .isThrownBy(() -> new MethodInvokingMessageGroupProcessor(bean)); } @Test diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/ResequencingMessageGroupProcessorTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/ResequencingMessageGroupProcessorTests.java index fbad31db32..ce38422163 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/ResequencingMessageGroupProcessorTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/ResequencingMessageGroupProcessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,7 +19,7 @@ package org.springframework.integration.aggregator; import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.integration.store.SimpleMessageGroup; import org.springframework.integration.support.MessageBuilder; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/SequenceSizeReleaseStrategyTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/SequenceSizeReleaseStrategyTests.java index bb1858f7c2..0792471a44 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/SequenceSizeReleaseStrategyTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/SequenceSizeReleaseStrategyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,7 +16,7 @@ package org.springframework.integration.aggregator; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.integration.store.MessageGroup; import org.springframework.integration.store.SimpleMessageGroup; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/TimeoutCountSequenceSizeReleaseStrategyTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/TimeoutCountSequenceSizeReleaseStrategyTests.java index affc619a69..9d3ac2c42b 100755 --- a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/TimeoutCountSequenceSizeReleaseStrategyTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/TimeoutCountSequenceSizeReleaseStrategyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,7 +16,7 @@ package org.springframework.integration.aggregator; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.integration.store.SimpleMessageGroup; import org.springframework.integration.support.MessageBuilder; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/integration/AggregatorSupportedUseCasesTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/integration/AggregatorSupportedUseCasesTests.java index 34570b07dc..4d22f70253 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/integration/AggregatorSupportedUseCasesTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/integration/AggregatorSupportedUseCasesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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.aggregator.integration; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.integration.aggregator.AggregatingMessageHandler; import org.springframework.integration.aggregator.DefaultAggregatingMessageGroupProcessor; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/scenarios/AggregationResendTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/scenarios/AggregationResendTests.java index 6dbefdeca3..49b2da0b21 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/scenarios/AggregationResendTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/scenarios/AggregationResendTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,17 +19,15 @@ package org.springframework.integration.aggregator.scenarios; import java.util.ArrayList; import java.util.List; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.integration.channel.DirectChannel; import org.springframework.integration.channel.QueueChannel; 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.context.junit.jupiter.SpringJUnitConfig; import static org.assertj.core.api.Assertions.assertThat; @@ -40,8 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Gunnar Hillert * @author Artem Bilan */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig public class AggregationResendTests { @Autowired @@ -61,7 +58,7 @@ public class AggregationResendTests { *

We should not get another 3 after the 1 second. */ @Test - @Ignore // timeout is no longer supported + @Disabled // timeout is no longer supported public void testAggregatorWithoutExplicitTimeoutReturnsOnlyOneMessage() { sendMessage(this.input_for_aggregator_with_explicit_timeout, 2000); } @@ -75,7 +72,7 @@ public class AggregationResendTests { *

We should not get another 3 after the 60 seconds. */ @Test - @Ignore // disabling from normal testing, should be the same behavior whether explicit or default + @Disabled // disabling from normal testing, should be the same behavior whether explicit or default public void testAggregatorWithTimeoutReturnsOnlyOneMessage() { sendMessage(this.input_for_aggregator_without_explicit_timeout, 62000); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/scenarios/AggregatorReplyChannelTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/scenarios/AggregatorReplyChannelTests.java index 34b2a9d4e3..5fed06f521 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/scenarios/AggregatorReplyChannelTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/scenarios/AggregatorReplyChannelTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,17 +19,15 @@ package org.springframework.integration.aggregator.scenarios; import java.util.ArrayList; import java.util.List; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +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.context.junit.jupiter.SpringJUnitConfig; import static org.assertj.core.api.Assertions.assertThat; @@ -39,8 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat; * * @since 2.0 */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig public class AggregatorReplyChannelTests { @Autowired @@ -51,7 +48,7 @@ public class AggregatorReplyChannelTests { private final List list = new ArrayList<>(); - @Before + @BeforeEach public void setupList() { this.list.add("foo"); this.list.add("bar"); diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/scenarios/NestedAggregationTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/scenarios/NestedAggregationTests.java index a0f33bcd8f..3150de0ee8 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/scenarios/NestedAggregationTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/scenarios/NestedAggregationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,16 +19,14 @@ package org.springframework.integration.aggregator.scenarios; import java.util.Arrays; 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.core.MessagingTemplate; 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.context.junit.jupiter.SpringJUnitConfig; import static org.assertj.core.api.Assertions.assertThat; @@ -37,8 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Dave Syer * @author Artem Bilan */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig public class NestedAggregationTests { @Autowired diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/scenarios/PartialSequencesWithGapsTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/scenarios/PartialSequencesWithGapsTests.java index a345d3ecc5..a8dc5c8a7f 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/scenarios/PartialSequencesWithGapsTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/scenarios/PartialSequencesWithGapsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,9 +19,8 @@ package org.springframework.integration.aggregator.scenarios; import java.util.Queue; import java.util.concurrent.ArrayBlockingQueue; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.integration.IntegrationMessageHeaderAccessor; @@ -29,8 +28,7 @@ import org.springframework.integration.support.MessageBuilder; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; import org.springframework.messaging.SubscribableChannel; -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; @@ -38,8 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Iwein Fuld * @author Gary Russell */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig public class PartialSequencesWithGapsTests { @Autowired @@ -51,7 +48,7 @@ public class PartialSequencesWithGapsTests { @SuppressWarnings("rawtypes") Queue received = new ArrayBlockingQueue(10); - @Before + @BeforeEach public void collectOutput() { out.subscribe(message -> received.add(message)); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/channel/ChannelPurgerTests.java b/spring-integration-core/src/test/java/org/springframework/integration/channel/ChannelPurgerTests.java index 87e61f4f1c..4c14e50785 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/channel/ChannelPurgerTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/channel/ChannelPurgerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,12 +18,13 @@ package org.springframework.integration.channel; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.messaging.Message; import org.springframework.messaging.support.GenericMessage; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; /** * @author Mark Fisher @@ -138,16 +139,18 @@ public class ChannelPurgerTests { assertThat(channel2.receive(0)).isNotNull(); } - @Test(expected = IllegalArgumentException.class) + @Test public void testNullChannel() { QueueChannel channel = null; - new ChannelPurger(channel); + assertThatIllegalArgumentException() + .isThrownBy(() -> new ChannelPurger(channel)); } - @Test(expected = IllegalArgumentException.class) + @Test public void testEmptyChannelArray() { QueueChannel[] channels = new QueueChannel[0]; - new ChannelPurger(channels); + assertThatIllegalArgumentException() + .isThrownBy(() -> new ChannelPurger(channels)); } } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/channel/DatatypeChannelTests.java b/spring-integration-core/src/test/java/org/springframework/integration/channel/DatatypeChannelTests.java index 416fe247dc..af6afb37f6 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/channel/DatatypeChannelTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/channel/DatatypeChannelTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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. @@ -21,7 +21,7 @@ import java.util.Date; import java.util.HashSet; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; @@ -45,6 +45,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 Mark Fisher @@ -61,10 +62,11 @@ public class DatatypeChannelTests { assertThat(channel.send(new GenericMessage("test"))).isTrue(); } - @Test(expected = MessageDeliveryException.class) + @Test public void unsupportedTypeAndNoConversionService() { MessageChannel channel = createChannel(Integer.class); - channel.send(new GenericMessage("123")); + assertThatExceptionOfType(MessageDeliveryException.class) + .isThrownBy(() -> channel.send(new GenericMessage("123"))); } @Test @@ -77,14 +79,15 @@ public class DatatypeChannelTests { assertThat(channel.send(new GenericMessage("123"))).isTrue(); } - @Test(expected = MessageDeliveryException.class) + @Test public void unsupportedTypeAndConversionServiceDoesNotSupport() { QueueChannel channel = createChannel(Integer.class); ConversionService conversionService = new DefaultConversionService(); DefaultDatatypeChannelMessageConverter converter = new DefaultDatatypeChannelMessageConverter(); converter.setConversionService(conversionService); channel.setMessageConverter(converter); - assertThat(channel.send(new GenericMessage(Boolean.TRUE))).isTrue(); + assertThatExceptionOfType(MessageDeliveryException.class) + .isThrownBy(() -> channel.send(new GenericMessage(Boolean.TRUE))); } @Test @@ -199,10 +202,11 @@ public class DatatypeChannelTests { assertThat(channel.send(new ErrorMessage(new MessagingException("test")))).isTrue(); } - @Test(expected = MessageDeliveryException.class) + @Test public void superclassOfAcceptedTypeNotAccepted() { MessageChannel channel = createChannel(RuntimeException.class); - channel.send(new ErrorMessage(new Exception("test"))); + assertThatExceptionOfType(MessageDeliveryException.class) + .isThrownBy(() -> channel.send(new ErrorMessage(new Exception("test")))); } @Test diff --git a/spring-integration-core/src/test/java/org/springframework/integration/channel/DirectChannelParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/channel/DirectChannelParserTests.java index 9ad9dad433..5ef2e8e4a0 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/channel/DirectChannelParserTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/channel/DirectChannelParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,7 +16,7 @@ package org.springframework.integration.channel; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.context.support.ClassPathXmlApplicationContext; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/channel/config/RendezvousChannelParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/channel/config/RendezvousChannelParserTests.java index ca77514e5e..9f84352b9a 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/channel/config/RendezvousChannelParserTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/channel/config/RendezvousChannelParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,7 +16,7 @@ package org.springframework.integration.channel.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.integration.channel.RendezvousChannel; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/ChannelInterceptorTests.java b/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/ChannelInterceptorTests.java index 35e1343022..a78fda7e63 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/ChannelInterceptorTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/ChannelInterceptorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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. @@ -23,7 +23,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/GlobalChannelInterceptorSubElementTests.java b/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/GlobalChannelInterceptorSubElementTests.java index 3f6c10155e..d837ce9d5e 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/GlobalChannelInterceptorSubElementTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/GlobalChannelInterceptorSubElementTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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.channel.interceptor; -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,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; @@ -36,8 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Artem Bilan * @since 2.0 */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration +@SpringJUnitConfig @DirtiesContext public class GlobalChannelInterceptorSubElementTests { diff --git a/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/GlobalChannelInterceptorTests.java b/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/GlobalChannelInterceptorTests.java index 45f7c71140..64c6aa2173 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/GlobalChannelInterceptorTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/GlobalChannelInterceptorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,8 +22,7 @@ import java.util.Map; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; -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; @@ -35,8 +34,7 @@ import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; import org.springframework.messaging.support.ChannelInterceptor; import org.springframework.messaging.support.InterceptableChannel; -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; @@ -48,8 +46,7 @@ import static org.assertj.core.api.Assertions.assertThat; * * @since 2.0 */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration +@SpringJUnitConfig public class GlobalChannelInterceptorTests { @Autowired diff --git a/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/GlobalWireTapTests.java b/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/GlobalWireTapTests.java index 44174c27b1..5612f1ae74 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/GlobalWireTapTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/GlobalWireTapTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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.channel.interceptor; -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,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; @@ -38,8 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Gary Russell * @author Artem Bilan */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig @DirtiesContext public class GlobalWireTapTests { diff --git a/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/ImplicitConsumerChannelTests.java b/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/ImplicitConsumerChannelTests.java index e8a8529349..cc29d77133 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/ImplicitConsumerChannelTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/ImplicitConsumerChannelTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2022 the original author or authors. + * Copyright 2014-2025 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.channel.interceptor; 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.AbstractMessageChannel; @@ -27,8 +26,7 @@ import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; import org.springframework.messaging.support.ChannelInterceptor; import org.springframework.messaging.support.InterceptableChannel; -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; @@ -37,8 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @since 4.0 * */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig public class ImplicitConsumerChannelTests { @Autowired diff --git a/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/MessageSelectingInterceptorTests.java b/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/MessageSelectingInterceptorTests.java index 9304abf944..77b6067482 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/MessageSelectingInterceptorTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/MessageSelectingInterceptorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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.channel.interceptor; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.core.MessageSelector; @@ -27,6 +27,7 @@ import org.springframework.messaging.MessageDeliveryException; import org.springframework.messaging.support.GenericMessage; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; /** * @author Mark Fisher @@ -44,14 +45,15 @@ public class MessageSelectingInterceptorTests { assertThat(channel.send(new GenericMessage<>("test1"))).isTrue(); } - @Test(expected = MessageDeliveryException.class) + @Test public void testSingleSelectorRejects() { final AtomicInteger counter = new AtomicInteger(); MessageSelector selector = new TestMessageSelector(false, counter); MessageSelectingInterceptor interceptor = new MessageSelectingInterceptor(selector); QueueChannel channel = new QueueChannel(); channel.addInterceptor(interceptor); - channel.send(new GenericMessage<>("test1")); + assertThatExceptionOfType(MessageDeliveryException.class) + .isThrownBy(() -> channel.send(new GenericMessage<>("test1"))); } @Test diff --git a/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/WireTapTests.java b/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/WireTapTests.java index b6e541917d..c2c54e8779 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/WireTapTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/WireTapTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,7 +16,7 @@ package org.springframework.integration.channel.interceptor; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.core.MessageSelector; @@ -26,6 +26,7 @@ import org.springframework.messaging.MessageChannel; import org.springframework.messaging.support.GenericMessage; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; /** * @author Mark Fisher @@ -71,9 +72,10 @@ public class WireTapTests { assertThat(intercepted).isEqualTo(original); } - @Test(expected = IllegalArgumentException.class) + @Test public void wireTapTargetMustNotBeNull() { - new WireTap((MessageChannel) null); + assertThatThrownBy(() -> new WireTap((MessageChannel) null)) + .isInstanceOf(IllegalArgumentException.class); } @Test diff --git a/spring-integration-core/src/test/java/org/springframework/integration/codec/kryo/CompositeCodecTests.java b/spring-integration-core/src/test/java/org/springframework/integration/codec/kryo/CompositeCodecTests.java index b9475fa0f3..ff1b9d48aa 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/codec/kryo/CompositeCodecTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/codec/kryo/CompositeCodecTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +20,8 @@ import java.io.IOException; import java.util.HashMap; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.integration.codec.Codec; import org.springframework.integration.codec.CompositeCodec; @@ -36,7 +36,7 @@ public class CompositeCodecTests { private Codec codec; - @Before + @BeforeEach public void setup() { Map, Codec> codecs = new HashMap<>(); this.codec = new CompositeCodec(codecs, new PojoCodec( diff --git a/spring-integration-core/src/test/java/org/springframework/integration/codec/kryo/FileKryoRegistrarTests.java b/spring-integration-core/src/test/java/org/springframework/integration/codec/kryo/FileKryoRegistrarTests.java index 4ee5832b51..1ece78efcf 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/codec/kryo/FileKryoRegistrarTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/codec/kryo/FileKryoRegistrarTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 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,7 +19,7 @@ package org.springframework.integration.codec.kryo; import java.io.File; import java.io.IOException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/codec/kryo/KryoCodecTests.java b/spring-integration-core/src/test/java/org/springframework/integration/codec/kryo/KryoCodecTests.java index 34b107b2d4..d8be224695 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/codec/kryo/KryoCodecTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/codec/kryo/KryoCodecTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2022 the original author or authors. + * Copyright 2015-2025 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,7 +25,7 @@ import java.util.HashMap; import java.util.Map; import org.assertj.core.data.Offset; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/InvalidPriorityChannelParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/InvalidPriorityChannelParserTests.java index 9d5056265e..1d14d34063 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/InvalidPriorityChannelParserTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/InvalidPriorityChannelParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,7 +16,7 @@ package org.springframework.integration.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; import org.springframework.context.support.ClassPathXmlApplicationContext; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/InvalidQueueChannelParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/InvalidQueueChannelParserTests.java index b07e8b1ab0..c57bea915d 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/InvalidQueueChannelParserTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/InvalidQueueChannelParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,7 +16,7 @@ package org.springframework.integration.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; import org.springframework.context.support.ClassPathXmlApplicationContext; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/MessageBusParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/MessageBusParserTests.java index e09767af54..60dd45ef8a 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/MessageBusParserTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/MessageBusParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,7 +16,7 @@ package org.springframework.integration.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.context.ConfigurableApplicationContext; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/ReleaseStrategyFactoryBeanTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/ReleaseStrategyFactoryBeanTests.java index c5145f0d9f..c3e149b01c 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/ReleaseStrategyFactoryBeanTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/ReleaseStrategyFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2022 the original author or authors. + * Copyright 2014-2025 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.Collection; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.integration.aggregator.MethodInvokingReleaseStrategy; import org.springframework.integration.aggregator.ReleaseStrategy; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/ContextHierarchyTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/ContextHierarchyTests.java index cabd8fd543..73595e5c10 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/ContextHierarchyTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/ContextHierarchyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,7 +16,7 @@ package org.springframework.integration.config.xml; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.context.ConfigurableApplicationContext; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DispatcherMaxSubscribersDefaultConfigurationTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DispatcherMaxSubscribersDefaultConfigurationTests.java index 42de443b62..3af90230fe 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DispatcherMaxSubscribersDefaultConfigurationTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DispatcherMaxSubscribersDefaultConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,11 +16,9 @@ package org.springframework.integration.config.xml; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; /** * @author Gary Russell @@ -29,8 +27,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * @since 2.2 * */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig public class DispatcherMaxSubscribersDefaultConfigurationTests extends DispatcherMaxSubscribersTests { @Test diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DispatcherMaxSubscribersDontOverrideDefaultTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DispatcherMaxSubscribersDontOverrideDefaultTests.java index 486cc6d6bc..2485a42faf 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DispatcherMaxSubscribersDontOverrideDefaultTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DispatcherMaxSubscribersDontOverrideDefaultTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,11 +16,9 @@ package org.springframework.integration.config.xml; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; /** * @author Gary Russell @@ -29,8 +27,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * @since 2.2 * */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig public class DispatcherMaxSubscribersDontOverrideDefaultTests extends DispatcherMaxSubscribersTests { @Test diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DispatcherMaxSubscribersOverrideDefaultTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DispatcherMaxSubscribersOverrideDefaultTests.java index 277dfda4fc..24e850cb95 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DispatcherMaxSubscribersOverrideDefaultTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DispatcherMaxSubscribersOverrideDefaultTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,13 +16,11 @@ package org.springframework.integration.config.xml; -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.SubscribableChannel; -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; @@ -32,8 +30,7 @@ import static org.assertj.core.api.Assertions.fail; * @since 2.2 * */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig public class DispatcherMaxSubscribersOverrideDefaultTests extends DispatcherMaxSubscribersTests { @Autowired diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/EnricherParser3Tests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/EnricherParser3Tests.java index 0e7bde2a54..9961cda9eb 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/EnricherParser3Tests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/EnricherParser3Tests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,7 +16,7 @@ package org.springframework.integration.config.xml; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.expression.spel.SpelEvaluationException; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/HeaderFilterParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/HeaderFilterParserTests.java index 236a8acee3..7c76662f15 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/HeaderFilterParserTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/HeaderFilterParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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.config.xml; -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,7 @@ import org.springframework.integration.support.MessageBuilder; 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; @@ -35,8 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Gary Russell * @since 2.0 */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig @DirtiesContext public class HeaderFilterParserTests { diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/MapToObjectTransformerParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/MapToObjectTransformerParserTests.java index 0ad28fa615..1f54e70a26 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/MapToObjectTransformerParserTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/MapToObjectTransformerParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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.config.xml; 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.BeanCreationException; import org.springframework.beans.factory.annotation.Autowired; @@ -31,17 +30,16 @@ 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.context.junit.jupiter.SpringJUnitConfig; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; /** * @author Oleg Zhurakousky * @since 2.0 */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig public class MapToObjectTransformerParserTests { @Autowired @@ -126,10 +124,11 @@ public class MapToObjectTransformerParserTests { assertThat(person.getAddress().getStreet()).isEqualTo("1123 Main st"); } - @Test(expected = BeanCreationException.class) + @Test public void testNonPrototypeFailure() { - new ClassPathXmlApplicationContext("MapToObjectTransformerParserTests-context-fail.xml", - MapToObjectTransformerParserTests.class).close(); + assertThatExceptionOfType(BeanCreationException.class) + .isThrownBy(() -> new ClassPathXmlApplicationContext("MapToObjectTransformerParserTests-context-fail.xml", + MapToObjectTransformerParserTests.class)); } public static class Person { diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/MethodInvokingSelectorParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/MethodInvokingSelectorParserTests.java index 3f3c68bd83..f18263ebda 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/MethodInvokingSelectorParserTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/MethodInvokingSelectorParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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.xml; 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; @@ -27,8 +26,7 @@ import org.springframework.integration.core.MessageSelector; import org.springframework.integration.filter.MethodInvokingSelector; import org.springframework.integration.selector.MessageSelectorChain; import org.springframework.messaging.Message; -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; @@ -37,8 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Gunnar Hillert * @author Artem Bilan */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig public class MethodInvokingSelectorParserTests { @Autowired diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/NestedChainParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/NestedChainParserTests.java index 7e5a7c1fa1..3cba0a5529 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/NestedChainParserTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/NestedChainParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,17 +18,15 @@ package org.springframework.integration.config.xml; import java.util.List; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Disabled; +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.handler.MessageHandlerChain; import org.springframework.messaging.MessageHandler; -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; @@ -36,9 +34,8 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Mark Fisher * @author Artem Bilan */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) -@Ignore +@SpringJUnitConfig +@Disabled public class NestedChainParserTests { @Autowired diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/ObjectToStringTransformerParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/ObjectToStringTransformerParserTests.java index 130138a492..45724d795f 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/ObjectToStringTransformerParserTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/ObjectToStringTransformerParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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.config.xml; -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,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; @@ -37,8 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Mark Fisher * @author Gary Russell */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig @DirtiesContext public class ObjectToStringTransformerParserTests { diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/PayloadSerializingTransformerParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/PayloadSerializingTransformerParserTests.java index 340c4aaecc..fff414c2fb 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/PayloadSerializingTransformerParserTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/PayloadSerializingTransformerParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,8 +22,7 @@ import java.io.ObjectInputStream; import java.io.OutputStream; import java.io.Serializable; -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.core.serializer.Serializer; @@ -33,17 +32,16 @@ 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; +import static org.assertj.core.api.Assertions.assertThatThrownBy; /** * @author Mark Fisher * @author Artem Bilan */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig @DirtiesContext public class PayloadSerializingTransformerParserTests { @@ -98,9 +96,10 @@ public class PayloadSerializingTransformerParserTests { assertThat(((TestBean) deserialized).name).isEqualTo("test"); } - @Test(expected = MessageTransformationException.class) + @Test public void invalidPayload() { - directInput.send(new GenericMessage(new Object())); + assertThatThrownBy(() -> directInput.send(new GenericMessage(new Object()))) + .isInstanceOf(MessageTransformationException.class); } @Test diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/PollerWithErrorChannelTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/PollerWithErrorChannelTests.java index c54409027b..924bb2b89a 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/PollerWithErrorChannelTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/PollerWithErrorChannelTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,7 +19,7 @@ package org.springframework.integration.config.xml; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.integration.channel.QueueChannel; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/PublishingInterceptorParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/PublishingInterceptorParserTests.java index 4b0c361426..5b5952ae6e 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/PublishingInterceptorParserTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/PublishingInterceptorParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,14 @@ package org.springframework.integration.config.xml; -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; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHandler; import org.springframework.messaging.SubscribableChannel; -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.mockito.ArgumentMatchers.any; @@ -39,8 +37,7 @@ import static org.mockito.Mockito.verify; * @author Artem Bilan * @since 2.0 */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig public class PublishingInterceptorParserTests { @Autowired diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/StreamTransformerParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/StreamTransformerParserTests.java index 0870fc1f22..228c764e17 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/StreamTransformerParserTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/StreamTransformerParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2022 the original author or authors. + * Copyright 2016-2025 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.config.xml; import java.io.ByteArrayInputStream; import java.io.InputStream; -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; @@ -29,8 +28,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; @@ -39,8 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Gary Russell * @author Artem Bilan */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig @DirtiesContext public class StreamTransformerParserTests { diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/SyslogTransformerParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/SyslogTransformerParserTests.java index a7fa40b13a..20f7407db3 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/SyslogTransformerParserTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/SyslogTransformerParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 the original author or authors. + * Copyright 2012-2025 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,16 +19,14 @@ package org.springframework.integration.config.xml; import java.util.Date; 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.integration.transformer.SyslogToMapTransformer; 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.context.junit.jupiter.SpringJUnitConfig; import static org.assertj.core.api.Assertions.assertThat; @@ -40,8 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @since 2.2 * */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig public class SyslogTransformerParserTests { @Autowired diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/TransactionSynchronizationFactoryParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/TransactionSynchronizationFactoryParserTests.java index 352fa82547..63f545ffa4 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/TransactionSynchronizationFactoryParserTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/TransactionSynchronizationFactoryParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,7 +16,7 @@ package org.springframework.integration.config.xml; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.expression.Expression; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/propertyplaceholder/PropertyPlaceholderTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/propertyplaceholder/PropertyPlaceholderTests.java index 53662cf33f..d0e30d6eca 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/propertyplaceholder/PropertyPlaceholderTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/propertyplaceholder/PropertyPlaceholderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2025 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,19 +16,16 @@ package org.springframework.integration.config.xml.propertyplaceholder; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; /** * * @author Iwein Fuld * @author Artem Bilan */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig public class PropertyPlaceholderTests { @Test diff --git a/spring-integration-core/src/test/java/org/springframework/integration/dispatcher/AggregateMessageDeliveryExceptionTests.java b/spring-integration-core/src/test/java/org/springframework/integration/dispatcher/AggregateMessageDeliveryExceptionTests.java index c9f68ec896..ab62a831a2 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/dispatcher/AggregateMessageDeliveryExceptionTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/dispatcher/AggregateMessageDeliveryExceptionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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.dispatcher; import java.util.Arrays; import java.util.List; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.springframework.messaging.Message; import org.springframework.messaging.MessageDeliveryException; @@ -50,7 +50,7 @@ public class AggregateMessageDeliveryExceptionTests { } @Test - @Ignore + @Disabled // turn this on if you want to read the message and stacktrace in the // console public void shouldThrow() { diff --git a/spring-integration-core/src/test/java/org/springframework/integration/dispatcher/PollingTransactionTests.java b/spring-integration-core/src/test/java/org/springframework/integration/dispatcher/PollingTransactionTests.java index f444c0df14..c8d7d0749c 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/dispatcher/PollingTransactionTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/dispatcher/PollingTransactionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import java.util.concurrent.Callable; import org.aopalliance.aop.Advice; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.Advisor; import org.springframework.aop.ProxyMethodInvocation; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/dispatcher/RoundRobinDispatcherConcurrentTests.java b/spring-integration-core/src/test/java/org/springframework/integration/dispatcher/RoundRobinDispatcherConcurrentTests.java index ce178e44d9..0378f0c5fd 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/dispatcher/RoundRobinDispatcherConcurrentTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/dispatcher/RoundRobinDispatcherConcurrentTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,12 +20,9 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.integration.MessageRejectedException; import org.springframework.messaging.Message; @@ -36,6 +33,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -43,7 +41,6 @@ import static org.mockito.Mockito.verify; * @author Iwein Fuld * @author Artem Bilan */ -@RunWith(MockitoJUnitRunner.class) public class RoundRobinDispatcherConcurrentTests { private static final int TOTAL_EXECUTIONS = 40; @@ -52,22 +49,17 @@ public class RoundRobinDispatcherConcurrentTests { private final ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - @Mock - private MessageHandler handler1; + private final MessageHandler handler1 = mock(); - @Mock - private MessageHandler handler2; + private final MessageHandler handler2 = mock(); - @Mock - private MessageHandler handler3; + private final MessageHandler handler3 = mock(); - @Mock - private MessageHandler handler4; + private final MessageHandler handler4 = mock(); - @Mock - private Message message; + private final Message message = mock(); - @Before + @BeforeEach public void initialize() { dispatcher.setLoadBalancingStrategy(new RoundRobinLoadBalancingStrategy()); executor.setCorePoolSize(10); @@ -75,7 +67,7 @@ public class RoundRobinDispatcherConcurrentTests { executor.initialize(); } - @After + @AfterEach public void tearDown() { this.executor.shutdown(); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/dispatcher/RoundRobinDispatcherTests.java b/spring-integration-core/src/test/java/org/springframework/integration/dispatcher/RoundRobinDispatcherTests.java index 8ad78e5938..8a65f12ce9 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/dispatcher/RoundRobinDispatcherTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/dispatcher/RoundRobinDispatcherTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,11 +19,8 @@ package org.springframework.integration.dispatcher; import java.util.concurrent.atomic.AtomicInteger; import org.apache.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.integration.support.MessageBuilder; @@ -39,6 +36,7 @@ import static org.mockito.ArgumentMatchers.startsWith; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -49,21 +47,17 @@ import static org.mockito.Mockito.verify; * @author Gary Russell * @author Artem Bilan */ -@RunWith(MockitoJUnitRunner.class) public class RoundRobinDispatcherTests { private final UnicastingDispatcher dispatcher = new UnicastingDispatcher(); - @Mock - private MessageHandler handler; + private final MessageHandler handler = mock(); - @Mock - private Message message; + private final Message message = mock(); - @Mock - private MessageHandler differentHandler; + private final MessageHandler differentHandler = mock(); - @Before + @BeforeEach public void setupDispatcher() { this.dispatcher.setLoadBalancingStrategy(new RoundRobinLoadBalancingStrategy()); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/endpoint/CorrelationIdTests.java b/spring-integration-core/src/test/java/org/springframework/integration/endpoint/CorrelationIdTests.java index ff6d779246..49b0ef1089 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/endpoint/CorrelationIdTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/endpoint/CorrelationIdTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,7 +16,7 @@ package org.springframework.integration.endpoint; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.integration.IntegrationMessageHeaderAccessor; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/endpoint/ExpressionEvaluatingMessageSourceTests.java b/spring-integration-core/src/test/java/org/springframework/integration/endpoint/ExpressionEvaluatingMessageSourceTests.java index 86128f074a..8170bb7dd0 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/endpoint/ExpressionEvaluatingMessageSourceTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/endpoint/ExpressionEvaluatingMessageSourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,7 +16,7 @@ package org.springframework.integration.endpoint; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.core.convert.ConversionFailedException; @@ -25,6 +25,7 @@ import org.springframework.expression.common.LiteralExpression; import org.springframework.messaging.Message; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.Mockito.mock; /** @@ -45,13 +46,14 @@ public class ExpressionEvaluatingMessageSourceTests { assertThat(message.getPayload()).isEqualTo("foo"); } - @Test(expected = ConversionFailedException.class) + @Test public void unexpectedType() { Expression expression = new LiteralExpression("foo"); ExpressionEvaluatingMessageSource source = new ExpressionEvaluatingMessageSource(expression, Integer.class); source.setBeanFactory(mock(BeanFactory.class)); - source.receive(); + assertThatThrownBy(() -> source.receive()) + .isInstanceOf(ConversionFailedException.class); } } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/endpoint/MessageSourcePollingTemplateTests.java b/spring-integration-core/src/test/java/org/springframework/integration/endpoint/MessageSourcePollingTemplateTests.java index 7a5d0a5fcf..80d493b775 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/endpoint/MessageSourcePollingTemplateTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/endpoint/MessageSourcePollingTemplateTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2018-2022 the original author or authors. + * Copyright 2018-2025 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.endpoint; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.integration.IntegrationMessageHeaderAccessor; import org.springframework.integration.acks.AcknowledgmentCallback; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollingConsumerEndpointTests.java b/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollingConsumerEndpointTests.java index 3a8b17c09b..c4873648b5 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollingConsumerEndpointTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollingConsumerEndpointTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,9 +18,9 @@ package org.springframework.integration.endpoint; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.beans.factory.BeanFactory; @@ -35,6 +35,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; import org.springframework.util.ErrorHandler; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.Mockito.mock; /** @@ -62,7 +63,7 @@ public class PollingConsumerEndpointTests { private PollableChannel channelMock; - @Before + @BeforeEach public void init() { this.channelMock = mock(PollableChannel.class); this.endpoint = new PollingConsumer(this.channelMock, this.consumer); @@ -76,7 +77,7 @@ public class PollingConsumerEndpointTests { this.taskScheduler.afterPropertiesSet(); } - @After + @AfterEach public void stop() { taskScheduler.destroy(); } @@ -124,25 +125,27 @@ public class PollingConsumerEndpointTests { } } - @Test(expected = MessageRejectedException.class) - public void rejectedMessage() throws Throwable { + @Test + public void rejectedMessage() { Mockito.when(this.channelMock.receive()).thenReturn(this.badMessage); this.endpoint.start(); this.trigger.await(); this.endpoint.stop(); assertThat(this.consumer.counter.get()).isEqualTo(1); - this.errorHandler.throwLastErrorIfAvailable(); + assertThatThrownBy(this.errorHandler::throwLastErrorIfAvailable) + .isInstanceOf(MessageRejectedException.class); } - @Test(expected = MessageRejectedException.class) - public void droppedMessage_onePerPoll() throws Throwable { + @Test + public void droppedMessage_onePerPoll() { Mockito.when(this.channelMock.receive()).thenReturn(this.badMessage); this.endpoint.setMaxMessagesPerPoll(10); this.endpoint.start(); this.trigger.await(); this.endpoint.stop(); assertThat(this.consumer.counter.get()).isEqualTo(1); - this.errorHandler.throwLastErrorIfAvailable(); + assertThatThrownBy(this.errorHandler::throwLastErrorIfAvailable) + .isInstanceOf(MessageRejectedException.class); } @Test diff --git a/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollingEndpointErrorHandlingTests.java b/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollingEndpointErrorHandlingTests.java index 4b01834ade..69a4437495 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollingEndpointErrorHandlingTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollingEndpointErrorHandlingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,7 +16,7 @@ package org.springframework.integration.endpoint; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.messaging.Message; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/endpoint/ServiceActivatorEndpointTests.java b/spring-integration-core/src/test/java/org/springframework/integration/endpoint/ServiceActivatorEndpointTests.java index 99375d2be2..1d9d31bbba 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/endpoint/ServiceActivatorEndpointTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/endpoint/ServiceActivatorEndpointTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,7 +16,7 @@ package org.springframework.integration.endpoint; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.integration.IntegrationMessageHeaderAccessor; @@ -31,6 +31,7 @@ import org.springframework.messaging.MessagingException; import org.springframework.messaging.support.GenericMessage; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.Mockito.mock; /** @@ -149,11 +150,12 @@ public class ServiceActivatorEndpointTests { assertThat(reply.getPayload()).isEqualTo("FOO"); } - @Test(expected = MessagingException.class) + @Test public void noReplyTarget() { ServiceActivatingHandler endpoint = this.createEndpoint(); Message message = MessageBuilder.withPayload("foo").build(); - endpoint.handleMessage(message); + assertThatThrownBy(() -> endpoint.handleMessage(message)) + .isInstanceOf(MessagingException.class); } @Test @@ -168,7 +170,7 @@ public class ServiceActivatorEndpointTests { assertThat(channel.receive(0)).isNull(); } - @Test(expected = ReplyRequiredException.class) + @Test public void noReplyMessageWithRequiresReply() { QueueChannel channel = new QueueChannel(1); ServiceActivatingHandler endpoint = new ServiceActivatingHandler(new TestNullReplyBean(), "handle"); @@ -177,7 +179,8 @@ public class ServiceActivatorEndpointTests { endpoint.setBeanFactory(mock(BeanFactory.class)); endpoint.afterPropertiesSet(); Message message = MessageBuilder.withPayload("foo").build(); - endpoint.handleMessage(message); + assertThatThrownBy(() -> endpoint.handleMessage(message)) + .isInstanceOf(ReplyRequiredException.class); } @Test diff --git a/spring-integration-core/src/test/java/org/springframework/integration/endpoint/ServiceActivatorMethodResolutionTests.java b/spring-integration-core/src/test/java/org/springframework/integration/endpoint/ServiceActivatorMethodResolutionTests.java index b28ebf5908..70dd159b0b 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/endpoint/ServiceActivatorMethodResolutionTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/endpoint/ServiceActivatorMethodResolutionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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.endpoint; import java.util.Date; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.integration.annotation.ServiceActivator; @@ -31,6 +31,7 @@ import org.springframework.messaging.handler.annotation.Payload; import org.springframework.messaging.support.GenericMessage; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.Mockito.mock; /** @@ -54,10 +55,11 @@ public class ServiceActivatorMethodResolutionTests { assertThat(result.getPayload()).isEqualTo("FOO"); } - @Test(expected = IllegalArgumentException.class) + @Test public void multipleAnnotationFails() { MultipleAnnotationTestBean testBean = new MultipleAnnotationTestBean(); - new ServiceActivatingHandler(testBean); + assertThatThrownBy(() -> new ServiceActivatingHandler(testBean)) + .isInstanceOf(IllegalArgumentException.class); } @Test @@ -74,10 +76,11 @@ public class ServiceActivatorMethodResolutionTests { assertThat(result.getPayload()).isEqualTo("FOO"); } - @Test(expected = IllegalArgumentException.class) + @Test public void multiplePublicMethodFails() { MultiplePublicMethodTestBean testBean = new MultiplePublicMethodTestBean(); - new ServiceActivatingHandler(testBean); + assertThatThrownBy(() -> new ServiceActivatingHandler(testBean)) + .isInstanceOf(IllegalArgumentException.class); } @Test diff --git a/spring-integration-core/src/test/java/org/springframework/integration/expression/DynamicExpressionTests.java b/spring-integration-core/src/test/java/org/springframework/integration/expression/DynamicExpressionTests.java index aa8f5ff6c8..539c5bfff2 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/expression/DynamicExpressionTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/expression/DynamicExpressionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,8 @@ package org.springframework.integration.expression; import java.io.FileOutputStream; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; @@ -37,7 +37,7 @@ public class DynamicExpressionTests { private static final String filepath = basename + ".properties"; - @After + @AfterEach public void resetFile() { writeExpressionStringToFile("'Hello World!'"); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/filter/FilterAnnotationMethodResolutionTests.java b/spring-integration-core/src/test/java/org/springframework/integration/filter/FilterAnnotationMethodResolutionTests.java index c5aedbb00b..5f890c242f 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/filter/FilterAnnotationMethodResolutionTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/filter/FilterAnnotationMethodResolutionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,7 +16,7 @@ package org.springframework.integration.filter; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.integration.annotation.Filter; import org.springframework.integration.channel.QueueChannel; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/filter/MessageFilterTests.java b/spring-integration-core/src/test/java/org/springframework/integration/filter/MessageFilterTests.java index c7cc1c6775..8501f8ef7b 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/filter/MessageFilterTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/filter/MessageFilterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,7 +16,7 @@ package org.springframework.integration.filter; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.integration.MessageRejectedException; import org.springframework.integration.channel.DirectChannel; @@ -26,6 +26,7 @@ import org.springframework.messaging.Message; import org.springframework.messaging.support.GenericMessage; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; /** * @author Mark Fisher @@ -53,13 +54,14 @@ public class MessageFilterTests { assertThat(output.receive(0)).isNull(); } - @Test(expected = MessageRejectedException.class) + @Test public void filterThrowsException() { MessageFilter filter = new MessageFilter(message -> false); filter.setThrowExceptionOnRejection(true); QueueChannel output = new QueueChannel(); filter.setOutputChannel(output); - filter.handleMessage(new GenericMessage("test")); + assertThatExceptionOfType(MessageRejectedException.class) + .isThrownBy(() -> filter.handleMessage(new GenericMessage("test"))); } @Test @@ -90,7 +92,7 @@ public class MessageFilterTests { assertThat(outputChannel.receive(0)).isNull(); } - @Test(expected = MessageRejectedException.class) + @Test public void filterThrowsExceptionWithChannels() { DirectChannel inputChannel = new DirectChannel(); QueueChannel outputChannel = new QueueChannel(); @@ -100,7 +102,8 @@ public class MessageFilterTests { EventDrivenConsumer endpoint = new EventDrivenConsumer(inputChannel, filter); endpoint.start(); Message message = new GenericMessage("test"); - assertThat(inputChannel.send(message)).isTrue(); + assertThatExceptionOfType(MessageRejectedException.class) + .isThrownBy(() -> assertThat(inputChannel.send(message)).isTrue()); } @Test @@ -121,8 +124,8 @@ public class MessageFilterTests { assertThat(outputChannel.receive(0)).isNull(); } - @Test(expected = MessageRejectedException.class) - public void filterDiscardsMessageAndThrowsException() throws Exception { + @Test + public void filterDiscardsMessageAndThrowsException() { DirectChannel inputChannel = new DirectChannel(); QueueChannel outputChannel = new QueueChannel(); QueueChannel discardChannel = new QueueChannel(); @@ -133,11 +136,12 @@ public class MessageFilterTests { EventDrivenConsumer endpoint = new EventDrivenConsumer(inputChannel, filter); endpoint.start(); Message message = new GenericMessage("test"); + Exception caughtException = null; try { assertThat(inputChannel.send(message)).isTrue(); } catch (Exception e) { - throw e; + caughtException = e; } finally { Message reply = discardChannel.receive(0); @@ -145,6 +149,7 @@ public class MessageFilterTests { assertThat(reply).isEqualTo(message); assertThat(outputChannel.receive(0)).isNull(); } + assertThat(caughtException).isInstanceOf(MessageRejectedException.class); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/filter/MethodInvokingSelectorTests.java b/spring-integration-core/src/test/java/org/springframework/integration/filter/MethodInvokingSelectorTests.java index 65a1a28207..53b86b5d5c 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/filter/MethodInvokingSelectorTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/filter/MethodInvokingSelectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,13 +18,14 @@ package org.springframework.integration.filter; import java.lang.reflect.Method; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.messaging.Message; import org.springframework.messaging.support.GenericMessage; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.Mockito.mock; /** @@ -83,20 +84,20 @@ public class MethodInvokingSelectorTests { assertThat(selector.accept(new GenericMessage<>("test"))).isTrue(); } - @Test(expected = IllegalArgumentException.class) + @Test public void voidReturningMethodWithMethodName() { MethodInvokingSelector selector = new MethodInvokingSelector(new TestBean(), "returnVoid"); selector.setBeanFactory(mock(BeanFactory.class)); - selector.accept(new GenericMessage<>("test")); + assertThatIllegalArgumentException() + .isThrownBy(() -> selector.accept(new GenericMessage<>("test"))); } - @Test(expected = IllegalArgumentException.class) + @Test public void voidReturningMethodWithMethodReference() throws Exception { TestBean testBean = new TestBean(); Method method = testBean.getClass().getMethod("returnVoid", Message.class); - MethodInvokingSelector selector = new MethodInvokingSelector(testBean, method); - selector.setBeanFactory(mock(BeanFactory.class)); - selector.accept(new GenericMessage<>("test")); + assertThatIllegalArgumentException() + .isThrownBy(() -> new MethodInvokingSelector(testBean, method)); } @SuppressWarnings("unused") diff --git a/spring-integration-core/src/test/java/org/springframework/integration/gateway/NestedGatewayTests.java b/spring-integration-core/src/test/java/org/springframework/integration/gateway/NestedGatewayTests.java index 01e8666cd3..87b21f7f2a 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/gateway/NestedGatewayTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/gateway/NestedGatewayTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,7 +16,7 @@ package org.springframework.integration.gateway; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.integration.channel.DirectChannel; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/handler/CollectionAndArrayTests.java b/spring-integration-core/src/test/java/org/springframework/integration/handler/CollectionAndArrayTests.java index fc0d7393ac..5360d1e999 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/handler/CollectionAndArrayTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/handler/CollectionAndArrayTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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. @@ -21,7 +21,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.splitter.AbstractMessageSplitter; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/handler/ExpressionEvaluatingMessageProcessorTests.java b/spring-integration-core/src/test/java/org/springframework/integration/handler/ExpressionEvaluatingMessageProcessorTests.java index 0050dfab88..f492ed4b02 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/handler/ExpressionEvaluatingMessageProcessorTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/handler/ExpressionEvaluatingMessageProcessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,7 +19,7 @@ package org.springframework.integration.handler; import java.util.Arrays; import java.util.UUID; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.config.BeanDefinition; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/handler/HeaderAnnotationTransformerTests.java b/spring-integration-core/src/test/java/org/springframework/integration/handler/HeaderAnnotationTransformerTests.java index 354f27f171..09afbe56fd 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/handler/HeaderAnnotationTransformerTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/handler/HeaderAnnotationTransformerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,7 +16,7 @@ package org.springframework.integration.handler; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.integration.IntegrationMessageHeaderAccessor; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/handler/MethodInvokingHeaderEnricherTests.java b/spring-integration-core/src/test/java/org/springframework/integration/handler/MethodInvokingHeaderEnricherTests.java index 33e8d537ab..5756a37efa 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/handler/MethodInvokingHeaderEnricherTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/handler/MethodInvokingHeaderEnricherTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,7 +20,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanInitializationException; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/history/AnnotatedTests.java b/spring-integration-core/src/test/java/org/springframework/integration/history/AnnotatedTests.java index 36e2c9c31f..74e1a00117 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/history/AnnotatedTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/history/AnnotatedTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,7 +19,7 @@ package org.springframework.integration.history; import java.lang.reflect.Field; import java.util.Properties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.context.ApplicationEvent; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/json/AbstractJsonInboundMessageMapperTests.java b/spring-integration-core/src/test/java/org/springframework/integration/json/AbstractJsonInboundMessageMapperTests.java index a3ab776018..7d0ca5e952 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/json/AbstractJsonInboundMessageMapperTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/json/AbstractJsonInboundMessageMapperTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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. @@ -23,7 +23,7 @@ import java.util.List; import java.util.Map; import java.util.UUID; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.ParameterizedTypeReference; import org.springframework.integration.support.MessageBuilder; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/json/AbstractJsonSymmetricalMessageMappingTests.java b/spring-integration-core/src/test/java/org/springframework/integration/json/AbstractJsonSymmetricalMessageMappingTests.java index e39ef9a410..e20ee4b712 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/json/AbstractJsonSymmetricalMessageMappingTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/json/AbstractJsonSymmetricalMessageMappingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,7 +16,7 @@ package org.springframework.integration.json; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.integration.history.MessageHistory; import org.springframework.integration.support.MessageBuilder; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/json/JsonTransformersSymmetricalTests.java b/spring-integration-core/src/test/java/org/springframework/integration/json/JsonTransformersSymmetricalTests.java index 8d154f4de5..2fb546b78c 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/json/JsonTransformersSymmetricalTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/json/JsonTransformersSymmetricalTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2022 the original author or authors. + * Copyright 2013-2025 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,7 +19,7 @@ package org.springframework.integration.json; import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.messaging.Message; import org.springframework.messaging.support.GenericMessage; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/json/ObjectToJsonTransformerTests.java b/spring-integration-core/src/test/java/org/springframework/integration/json/ObjectToJsonTransformerTests.java index 56f22358bf..f22c23ddb9 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/json/ObjectToJsonTransformerTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/json/ObjectToJsonTransformerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,7 +27,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.json.JsonMapper; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.integration.mapping.support.JsonHeaders; import org.springframework.integration.support.MessageBuilder; @@ -37,6 +37,7 @@ import org.springframework.messaging.MessageHeaders; import org.springframework.messaging.support.GenericMessage; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; /** * @author Mark Fisher @@ -105,10 +106,11 @@ public class ObjectToJsonTransformerTests { assertThat(result.getHeaders().get(MessageHeaders.CONTENT_TYPE)).isEqualTo("text/xml"); } - @Test(expected = IllegalArgumentException.class) + @Test public void withProvidedContentTypeAsNull() { ObjectToJsonTransformer transformer = new ObjectToJsonTransformer(); - transformer.setContentType(null); + assertThatThrownBy(() -> transformer.setContentType(null)) + .isInstanceOf(IllegalArgumentException.class); } @Test diff --git a/spring-integration-core/src/test/java/org/springframework/integration/mapping/HeaderMapperTests.java b/spring-integration-core/src/test/java/org/springframework/integration/mapping/HeaderMapperTests.java index 55d3f54574..d41d4c59d0 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/mapping/HeaderMapperTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/mapping/HeaderMapperTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.integration.mapping.AbstractHeaderMapper.CompositeHeaderMatcher; import org.springframework.integration.mapping.AbstractHeaderMapper.ContentBasedHeaderMatcher; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/message/ExpressionEvaluatingMessageHandlerTests.java b/spring-integration-core/src/test/java/org/springframework/integration/message/ExpressionEvaluatingMessageHandlerTests.java index 587ee68062..f69de0543a 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/message/ExpressionEvaluatingMessageHandlerTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/message/ExpressionEvaluatingMessageHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,8 @@ package org.springframework.integration.message; import java.util.HashMap; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.expression.Expression; @@ -30,7 +30,7 @@ import org.springframework.messaging.Message; import org.springframework.messaging.MessagingException; import org.springframework.messaging.support.GenericMessage; -import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.mockito.Mockito.mock; /** @@ -42,7 +42,7 @@ public class ExpressionEvaluatingMessageHandlerTests { private ExpressionParser parser; - @Before + @BeforeEach public void setup() { parser = new SpelExpressionParser(); } @@ -76,20 +76,17 @@ public class ExpressionEvaluatingMessageHandlerTests { handler.handleMessage(new GenericMessage("testtest", headers)); } - @Test(expected = MessagingException.class) + @Test public void expressionWithReturnValue() { Message message = new GenericMessage(.1f); - try { - Expression expression = parser.parseExpression("T(System).out.printf('$%4.2f', payload)"); - ExpressionEvaluatingMessageHandler handler = new ExpressionEvaluatingMessageHandler(expression); - handler.setBeanFactory(mock(BeanFactory.class)); - handler.afterPropertiesSet(); - handler.handleMessage(message); - } - catch (MessagingException e) { - assertThat(message).isEqualTo(e.getFailedMessage()); - throw e; - } + Expression expression = parser.parseExpression("T(System).out.printf('$%4.2f', payload)"); + ExpressionEvaluatingMessageHandler handler = new ExpressionEvaluatingMessageHandler(expression); + handler.setBeanFactory(mock(BeanFactory.class)); + handler.afterPropertiesSet(); + assertThatExceptionOfType(MessagingException.class) + .isThrownBy(() -> handler.handleMessage(message)) + .extracting(MessagingException::getFailedMessage) + .isEqualTo(message); } } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/message/GenericMessageTests.java b/spring-integration-core/src/test/java/org/springframework/integration/message/GenericMessageTests.java index 8156eca776..59c945fd9e 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/message/GenericMessageTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/message/GenericMessageTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,7 +19,7 @@ package org.springframework.integration.message; import java.util.HashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.integration.IntegrationMessageHeaderAccessor; import org.springframework.messaging.support.GenericMessage; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/message/MessageBuilderAtConfigTests.java b/spring-integration-core/src/test/java/org/springframework/integration/message/MessageBuilderAtConfigTests.java index 637eaebebb..e73caf530a 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/message/MessageBuilderAtConfigTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/message/MessageBuilderAtConfigTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2022 the original author or authors. + * Copyright 2014-2025 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.message; -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; @@ -28,15 +27,13 @@ import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.config.ConsumerEndpointFactoryBean; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.handler.AbstractReplyProducingMessageHandler; -import org.springframework.integration.message.MessageBuilderAtConfigTests.MBConfig; import org.springframework.integration.support.MessageBuilderFactory; import org.springframework.integration.support.MutableMessageBuilderFactory; 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.context.junit.jupiter.SpringJUnitConfig; import static org.assertj.core.api.Assertions.assertThat; @@ -44,8 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Gary Russell * @author Marius Bogoevici */ -@ContextConfiguration(classes = MBConfig.class) -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig public class MessageBuilderAtConfigTests { @Autowired diff --git a/spring-integration-core/src/test/java/org/springframework/integration/message/MethodInvokingMessageSourceTests.java b/spring-integration-core/src/test/java/org/springframework/integration/message/MethodInvokingMessageSourceTests.java index 5eb5d40019..ce9d84e4cb 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/message/MethodInvokingMessageSourceTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/message/MethodInvokingMessageSourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,7 +19,7 @@ package org.springframework.integration.message; import java.util.HashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.expression.Expression; @@ -30,6 +30,7 @@ import org.springframework.messaging.Message; import org.springframework.messaging.MessagingException; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.Mockito.mock; /** @@ -68,31 +69,34 @@ public class MethodInvokingMessageSourceTests { assertThat(result.getHeaders().get("bar")).isEqualTo(123); } - @Test(expected = MessagingException.class) + @Test public void testNoMatchingMethodName() { MethodInvokingMessageSource source = new MethodInvokingMessageSource(); source.setBeanFactory(mock(BeanFactory.class)); source.setObject(new TestBean()); source.setMethodName("noMatchingMethod"); - source.receive(); + assertThatThrownBy(() -> source.receive()) + .isInstanceOf(MessagingException.class); } - @Test(expected = MessagingException.class) + @Test public void testInvalidMethodWithArg() { MethodInvokingMessageSource source = new MethodInvokingMessageSource(); source.setBeanFactory(mock(BeanFactory.class)); source.setObject(new TestBean()); source.setMethodName("invalidMethodWithArg"); - source.receive(); + assertThatThrownBy(() -> source.receive()) + .isInstanceOf(MessagingException.class); } - @Test(expected = MessagingException.class) + @Test public void testInvalidMethodWithNoReturnValue() { MethodInvokingMessageSource source = new MethodInvokingMessageSource(); source.setBeanFactory(mock(BeanFactory.class)); source.setObject(new TestBean()); source.setMethodName("invalidMethodWithNoReturnValue"); - source.receive(); + assertThatThrownBy(() -> source.receive()) + .isInstanceOf(MessagingException.class); } @Test diff --git a/spring-integration-core/src/test/java/org/springframework/integration/message/selector/PayloadTypeSelectorTests.java b/spring-integration-core/src/test/java/org/springframework/integration/message/selector/PayloadTypeSelectorTests.java index 9fc35c1b14..d68be2eb08 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/message/selector/PayloadTypeSelectorTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/message/selector/PayloadTypeSelectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,7 +16,7 @@ package org.springframework.integration.message.selector; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.integration.selector.PayloadTypeSelector; import org.springframework.messaging.MessagingException; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/message/selector/UnexpiredMessageSelectorTests.java b/spring-integration-core/src/test/java/org/springframework/integration/message/selector/UnexpiredMessageSelectorTests.java index 1498bb42b8..d1b7bd27a1 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/message/selector/UnexpiredMessageSelectorTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/message/selector/UnexpiredMessageSelectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,7 +16,7 @@ package org.springframework.integration.message.selector; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.integration.selector.UnexpiredMessageSelector; import org.springframework.integration.support.MessageBuilder; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/resource/ResourceInboundChannelAdapterParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/resource/ResourceInboundChannelAdapterParserTests.java index 408d11e137..fc1052dce9 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/resource/ResourceInboundChannelAdapterParserTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/resource/ResourceInboundChannelAdapterParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,10 +19,10 @@ package org.springframework.integration.resource; import java.io.File; import java.util.Collection; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanCreationException; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -34,6 +34,7 @@ import org.springframework.integration.util.CollectionFilter; import org.springframework.messaging.Message; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; /** * @author Oleg Zhurakousky @@ -45,14 +46,14 @@ public class ResourceInboundChannelAdapterParserTests { private static File workDir; - @BeforeClass + @BeforeAll public static void setupClass() { workDir = new File(System.getProperty("java.io.tmpdir"), "ResourceInboundChannelAdapterParserTests"); workDir.mkdir(); workDir.deleteOnExit(); } - @After + @AfterEach public void cleanUpWorkDir() throws Exception { File[] listFiles = workDir.listFiles(); for (File file : listFiles) { @@ -60,7 +61,7 @@ public class ResourceInboundChannelAdapterParserTests { } } - @AfterClass + @AfterAll public static void cleanUp() { workDir.delete(); } @@ -82,9 +83,10 @@ public class ResourceInboundChannelAdapterParserTests { context.close(); } - @Test(expected = BeanCreationException.class) + @Test public void testDefaultConfigNoLocationPattern() { - new ClassPathXmlApplicationContext("ResourcePatternResolver-config-fail.xml", getClass()).close(); + assertThatExceptionOfType(BeanCreationException.class) + .isThrownBy(() -> new ClassPathXmlApplicationContext("ResourcePatternResolver-config-fail.xml", getClass())); } @Test diff --git a/spring-integration-core/src/test/java/org/springframework/integration/router/ErrorMessageExceptionTypeRouterTests.java b/spring-integration-core/src/test/java/org/springframework/integration/router/ErrorMessageExceptionTypeRouterTests.java index 36e537d546..98814b52ea 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/router/ErrorMessageExceptionTypeRouterTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/router/ErrorMessageExceptionTypeRouterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,9 +16,9 @@ package org.springframework.integration.router; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; @@ -54,7 +54,7 @@ public class ErrorMessageExceptionTypeRouterTests { private final QueueChannel defaultChannel = new QueueChannel(); - @Before + @BeforeEach public void prepare() { this.context.registerBean("illegalArgumentChannel", this.illegalArgumentChannel); this.context.registerBean("runtimeExceptionChannel", this.runtimeExceptionChannel); @@ -64,7 +64,7 @@ public class ErrorMessageExceptionTypeRouterTests { this.context.refresh(); } - @After + @AfterEach public void terDown() { this.context.close(); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/router/HeaderValueRouterTests.java b/spring-integration-core/src/test/java/org/springframework/integration/router/HeaderValueRouterTests.java index bc25ccd3f2..81e91e8e9f 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/router/HeaderValueRouterTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/router/HeaderValueRouterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,7 +16,7 @@ package org.springframework.integration.router; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.ManagedMap; import org.springframework.beans.factory.support.RootBeanDefinition; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/router/MethodInvokingRouterTests.java b/spring-integration-core/src/test/java/org/springframework/integration/router/MethodInvokingRouterTests.java index 0ac4580ad9..34cb5a9cce 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/router/MethodInvokingRouterTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/router/MethodInvokingRouterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,7 +20,7 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.integration.channel.QueueChannel; @@ -35,6 +35,7 @@ import org.springframework.messaging.handler.annotation.Header; import org.springframework.messaging.support.GenericMessage; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.fail; import static org.mockito.Mockito.mock; @@ -102,12 +103,13 @@ public class MethodInvokingRouterTests { assertThat(fooReply).isEqualTo(message); } - @Test(expected = MessagingException.class) + @Test public void failsWhenRequiredHeaderIsNotProvided() throws Exception { SingleChannelNameRoutingTestBean testBean = new SingleChannelNameRoutingTestBean(); Method routingMethod = testBean.getClass().getMethod("routeByHeader", String.class); MethodInvokingRouter router = new MethodInvokingRouter(testBean, routingMethod); - router.handleMessage(new GenericMessage("testing")); + assertThatThrownBy(() -> router.handleMessage(new GenericMessage("testing"))) + .isInstanceOf(MessagingException.class); } @Test diff --git a/spring-integration-core/src/test/java/org/springframework/integration/router/MultiChannelRouterTests.java b/spring-integration-core/src/test/java/org/springframework/integration/router/MultiChannelRouterTests.java index e6dc9aac36..12ad6954cc 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/router/MultiChannelRouterTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/router/MultiChannelRouterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,7 +20,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.integration.channel.QueueChannel; @@ -30,6 +30,7 @@ import org.springframework.messaging.MessagingException; import org.springframework.messaging.support.GenericMessage; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.Mockito.mock; /** @@ -63,7 +64,7 @@ public class MultiChannelRouterTests { assertThat(result2.getPayload()).isEqualTo("test"); } - @Test(expected = MessagingException.class) + @Test public void channelNameLookupFailure() { AbstractMappingMessageRouter router = new AbstractMappingMessageRouter() { @@ -74,10 +75,10 @@ public class MultiChannelRouterTests { TestChannelResolver channelResolver = new TestChannelResolver(); router.setChannelResolver(channelResolver); Message message = new GenericMessage<>("test"); - router.handleMessage(message); + assertThatThrownBy(() -> router.handleMessage(message)).isInstanceOf(MessagingException.class); } - @Test(expected = MessagingException.class) + @Test public void channelMappingNotAvailable() { AbstractMappingMessageRouter router = new AbstractMappingMessageRouter() { @@ -88,7 +89,8 @@ public class MultiChannelRouterTests { }; router.setBeanFactory(mock(BeanFactory.class)); Message message = new GenericMessage<>("test"); - router.handleMessage(message); + assertThatThrownBy(() -> router.handleMessage(message)) + .isInstanceOf(MessagingException.class); } } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/router/PayloadTypeRouterTests.java b/spring-integration-core/src/test/java/org/springframework/integration/router/PayloadTypeRouterTests.java index e5aaf18243..dcc93a0e11 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/router/PayloadTypeRouterTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/router/PayloadTypeRouterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,7 +20,7 @@ import java.io.Serializable; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.integration.channel.QueueChannel; @@ -29,6 +29,7 @@ import org.springframework.messaging.MessageHandlingException; import org.springframework.messaging.support.GenericMessage; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.fail; /** @@ -346,7 +347,7 @@ public class PayloadTypeRouterTests { assertThat(result).isNotNull(); } - @Test(expected = MessageHandlingException.class) + @Test public void ambiguityFailure() { QueueChannel defaultChannel = new QueueChannel(); defaultChannel.setBeanName("defaultChannel"); @@ -370,7 +371,8 @@ public class PayloadTypeRouterTests { router.setDefaultOutputChannel(defaultChannel); Message message = new GenericMessage<>("test"); - router.handleMessage(message); + assertThatThrownBy(() -> router.handleMessage(message)) + .isInstanceOf(MessageHandlingException.class); } @Test @@ -499,7 +501,7 @@ public class PayloadTypeRouterTests { assertThat(c2Channel.receive(100)).isNotNull(); } - @Test(expected = MessageHandlingException.class) + @Test public void classLosesOverLessDistantAmbiguousInterfaces() { QueueChannel defaultChannel = new QueueChannel(); defaultChannel.setBeanName("defaultChannel"); @@ -529,10 +531,11 @@ public class PayloadTypeRouterTests { router.setDefaultOutputChannel(defaultChannel); Message message = new GenericMessage<>(new C1()); - router.handleMessage(message); + assertThatThrownBy(() -> router.handleMessage(message)) + .isInstanceOf(MessageHandlingException.class); } - @Test(expected = MessageHandlingException.class) + @Test public void classLosesOverAmbiguousInterfacesAtSameLevel() { QueueChannel defaultChannel = new QueueChannel(); defaultChannel.setBeanName("defaultChannel"); @@ -562,7 +565,8 @@ public class PayloadTypeRouterTests { router.setDefaultOutputChannel(defaultChannel); Message message = new GenericMessage<>(new C1()); - router.handleMessage(message); + assertThatThrownBy(() -> router.handleMessage(message)) + .isInstanceOf(MessageHandlingException.class); } @SuppressWarnings("serial") diff --git a/spring-integration-core/src/test/java/org/springframework/integration/router/RecipientListRouterTests.java b/spring-integration-core/src/test/java/org/springframework/integration/router/RecipientListRouterTests.java index adad56591e..09c8e7828a 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/router/RecipientListRouterTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/router/RecipientListRouterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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. @@ -21,7 +21,7 @@ import java.util.Collections; import java.util.List; import java.util.concurrent.ConcurrentLinkedQueue; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.beans.DirectFieldAccessor; @@ -38,6 +38,8 @@ import org.springframework.messaging.MessageDeliveryException; import org.springframework.messaging.support.GenericMessage; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -103,7 +105,7 @@ public class RecipientListRouterTests { assertThat(result2).isNull(); } - @Test(expected = MessageDeliveryException.class) + @Test public void sendFailureOnFirstRecipientTriggersExceptionByDefault() { QueueChannel channelA = new QueueChannel(1); QueueChannel channelB = new QueueChannel(1); @@ -120,20 +122,16 @@ public class RecipientListRouterTests { router.setChannels(channels); channelA.send(new GenericMessage("blocker")); Message message = new GenericMessage("test"); - try { - router.handleMessage(message); - } - catch (RuntimeException e) { - Message result1a = channelA.receive(0); - assertThat(result1a).isNotNull(); - assertThat(result1a.getPayload()).isEqualTo("blocker"); - assertThat(channelB.receive(0)).isNull(); - assertThat(channelC.receive(0)).isNull(); - throw e; - } + assertThatExceptionOfType(MessageDeliveryException.class) + .isThrownBy(() -> router.handleMessage(message)); + Message result1a = channelA.receive(0); + assertThat(result1a).isNotNull(); + assertThat(result1a.getPayload()).isEqualTo("blocker"); + assertThat(channelB.receive(0)).isNull(); + assertThat(channelC.receive(0)).isNull(); } - @Test(expected = MessageDeliveryException.class) + @Test public void sendFailureOnMiddleRecipientTriggersExceptionByDefault() { QueueChannel channelA = new QueueChannel(1); QueueChannel channelB = new QueueChannel(1); @@ -150,22 +148,18 @@ public class RecipientListRouterTests { router.setChannels(channels); channelB.send(new GenericMessage("blocker")); Message message = new GenericMessage("test"); - try { - router.handleMessage(message); - } - catch (RuntimeException e) { - Message result1a = channelA.receive(0); - assertThat(result1a).isNotNull(); - assertThat(result1a.getPayload()).isEqualTo("test"); - Message result1b = channelB.receive(0); - assertThat(result1b).isNotNull(); - assertThat(result1b.getPayload()).isEqualTo("blocker"); - assertThat(channelC.receive(0)).isNull(); - throw e; - } + assertThatExceptionOfType(MessageDeliveryException.class) + .isThrownBy(() -> router.handleMessage(message)); + Message result1a = channelA.receive(0); + assertThat(result1a).isNotNull(); + assertThat(result1a.getPayload()).isEqualTo("test"); + Message result1b = channelB.receive(0); + assertThat(result1b).isNotNull(); + assertThat(result1b.getPayload()).isEqualTo("blocker"); + assertThat(channelC.receive(0)).isNull(); } - @Test(expected = MessageDeliveryException.class) + @Test public void sendFailureOnLastRecipientTriggersExceptionByDefault() { QueueChannel channelA = new QueueChannel(1); QueueChannel channelB = new QueueChannel(1); @@ -182,21 +176,17 @@ public class RecipientListRouterTests { router.setChannels(channels); channelC.send(new GenericMessage("blocker")); Message message = new GenericMessage("test"); - try { - router.handleMessage(message); - } - catch (RuntimeException e) { - Message result1a = channelA.receive(0); - assertThat(result1a).isNotNull(); - assertThat(result1a.getPayload()).isEqualTo("test"); - Message result1b = channelB.receive(0); - assertThat(result1b).isNotNull(); - assertThat(result1b.getPayload()).isEqualTo("test"); - Message result1c = channelC.receive(0); - assertThat(result1c).isNotNull(); - assertThat(result1c.getPayload()).isEqualTo("blocker"); - throw e; - } + assertThatExceptionOfType(MessageDeliveryException.class) + .isThrownBy(() -> router.handleMessage(message)); + Message result1a = channelA.receive(0); + assertThat(result1a).isNotNull(); + assertThat(result1a.getPayload()).isEqualTo("test"); + Message result1b = channelB.receive(0); + assertThat(result1b).isNotNull(); + assertThat(result1b.getPayload()).isEqualTo("test"); + Message result1c = channelC.receive(0); + assertThat(result1c).isNotNull(); + assertThat(result1c.getPayload()).isEqualTo("blocker"); } @Test @@ -346,17 +336,19 @@ public class RecipientListRouterTests { .isEqualTo(message.getHeaders().getId()); } - @Test(expected = IllegalArgumentException.class) + @Test public void nullChannelListRejected() { RecipientListRouter router = new RecipientListRouter(); - router.setChannels(null); + assertThatIllegalArgumentException() + .isThrownBy(() -> router.setChannels(null)); } - @Test(expected = IllegalArgumentException.class) + @Test public void emptyChannelListRejected() { RecipientListRouter router = new RecipientListRouter(); - List channels = new ArrayList(); - router.setChannels(channels); + List channels = new ArrayList<>(); + assertThatIllegalArgumentException() + .isThrownBy(() -> router.setChannels(channels)); } @Test diff --git a/spring-integration-core/src/test/java/org/springframework/integration/router/RouterTests.java b/spring-integration-core/src/test/java/org/springframework/integration/router/RouterTests.java index 2ed7c9a47b..d67ae5a933 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/router/RouterTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/router/RouterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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. @@ -21,7 +21,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.context.support.GenericApplicationContext; @@ -34,6 +34,7 @@ import org.springframework.messaging.MessagingException; import org.springframework.messaging.support.GenericMessage; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.Mockito.mock; /** @@ -44,7 +45,7 @@ import static org.mockito.Mockito.mock; */ public class RouterTests { - @Test(expected = MessageDeliveryException.class) + @Test public void nullChannelRaisesMessageDeliveryExceptionByDefault() { AbstractMappingMessageRouter router = new AbstractMappingMessageRouter() { @@ -55,10 +56,11 @@ public class RouterTests { } }; Message message = new GenericMessage<>("test"); - router.handleMessage(message); + assertThatThrownBy(() -> router.handleMessage(message)) + .isInstanceOf(MessageDeliveryException.class); } - @Test(expected = MessageDeliveryException.class) + @Test public void nullChannelIdentifierUsingChannelResolverRaisesMessageDeliveryExceptionByDefault() { AbstractMappingMessageRouter router = new AbstractMappingMessageRouter() { @@ -71,10 +73,11 @@ public class RouterTests { TestChannelResolver channelResolver = new TestChannelResolver(); router.setChannelResolver(channelResolver); Message message = new GenericMessage<>("test"); - router.handleMessage(message); + assertThatThrownBy(() -> router.handleMessage(message)) + .isInstanceOf(MessageDeliveryException.class); } - @Test(expected = MessageDeliveryException.class) + @Test public void nullChannelIdentifierInListRaisesMessageDeliveryExceptionByDefault() { AbstractMappingMessageRouter router = new AbstractMappingMessageRouter() { @@ -87,10 +90,11 @@ public class RouterTests { TestChannelResolver channelResolver = new TestChannelResolver(); router.setChannelResolver(channelResolver); Message message = new GenericMessage<>("test"); - router.handleMessage(message); + assertThatThrownBy(() -> router.handleMessage(message)) + .isInstanceOf(MessageDeliveryException.class); } - @Test(expected = MessageDeliveryException.class) + @Test public void emptyChannelNameArrayRaisesMessageDeliveryExceptionByDefault() { AbstractMappingMessageRouter router = new AbstractMappingMessageRouter() { @@ -102,10 +106,11 @@ public class RouterTests { TestChannelResolver channelResolver = new TestChannelResolver(); router.setChannelResolver(channelResolver); Message message = new GenericMessage<>("test"); - router.handleMessage(message); + assertThatThrownBy(() -> router.handleMessage(message)) + .isInstanceOf(MessageDeliveryException.class); } - @Test(expected = MessagingException.class) + @Test public void channelMappingIsRequiredWhenResolvingChannelNames() { AbstractMappingMessageRouter router = new AbstractMappingMessageRouter() { @@ -115,7 +120,8 @@ public class RouterTests { } }; router.setBeanFactory(mock(BeanFactory.class)); - router.handleMessage(new GenericMessage<>("this should fail")); + assertThatThrownBy(() -> router.handleMessage(new GenericMessage<>("this should fail"))) + .isInstanceOf(MessageDeliveryException.class); } @Test @@ -172,7 +178,7 @@ public class RouterTests { context.close(); } - @Test(expected = MessagingException.class) + @Test public void channelResolutionIsRequiredByDefault() { AbstractMappingMessageRouter router = new AbstractMappingMessageRouter() { @@ -188,8 +194,9 @@ public class RouterTests { context.refresh(); router.setBeanFactory(context); - router.handleMessage(new GenericMessage<>("test")); + assertThatThrownBy(() -> router.handleMessage(new GenericMessage<>("test"))) + .isInstanceOf(MessagingException.class); } @Test @@ -242,7 +249,7 @@ public class RouterTests { context.close(); } - @Test(expected = MessagingException.class) + @Test public void beanFactoryWithRouterAndChannelPrefixFailing() { AbstractMappingMessageRouter router = new AbstractMappingMessageRouter() { @@ -260,7 +267,8 @@ public class RouterTests { context.refresh(); router.setBeanFactory(context); - router.handleMessage(new GenericMessage<>("test")); + assertThatThrownBy(() -> router.handleMessage(new GenericMessage<>("test"))) + .isInstanceOf(MessagingException.class); context.close(); } @@ -290,7 +298,7 @@ public class RouterTests { context.close(); } - @Test(expected = MessagingException.class) + @Test public void beanFactoryWithRouterAndChannelSuffixFailing() { AbstractMappingMessageRouter router = new AbstractMappingMessageRouter() { @@ -308,7 +316,8 @@ public class RouterTests { context.refresh(); router.setBeanFactory(context); - router.handleMessage(new GenericMessage<>("test")); + assertThatThrownBy(() -> router.handleMessage(new GenericMessage<>("test"))) + .isInstanceOf(MessagingException.class); context.close(); } @@ -439,7 +448,7 @@ public class RouterTests { } - @Test(expected = MessagingException.class) + @Test public void beanFactoryWithRouterAndRetrieveChannelIdentifierUsingDefaultConversionServiceFailing() { final QueueChannel testChannel1 = new QueueChannel(); @@ -458,7 +467,9 @@ public class RouterTests { context.refresh(); router.setBeanFactory(context); - router.handleMessage(new GenericMessage<>("test")); + + assertThatThrownBy(() -> router.handleMessage(new GenericMessage<>("test"))) + .isInstanceOf(MessagingException.class); } } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/router/config/RouterFactoryBeanTests.java b/spring-integration-core/src/test/java/org/springframework/integration/router/config/RouterFactoryBeanTests.java index 469d4e5142..9cddcf077c 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/router/config/RouterFactoryBeanTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/router/config/RouterFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2022 the original author or authors. + * Copyright 2016-2025 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,7 +16,7 @@ package org.springframework.integration.router.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.config.RouterFactoryBean; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/router/config/SplitterAggregatorTests.java b/spring-integration-core/src/test/java/org/springframework/integration/router/config/SplitterAggregatorTests.java index da358c5747..fe09277774 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/router/config/SplitterAggregatorTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/router/config/SplitterAggregatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,7 +20,7 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.messaging.Message; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/router/config/SplitterParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/router/config/SplitterParserTests.java index cb521c5e7d..462357b500 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/router/config/SplitterParserTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/router/config/SplitterParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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.router.config; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.integration.IntegrationMessageHeaderAccessor; @@ -31,6 +31,7 @@ import org.springframework.messaging.PollableChannel; import org.springframework.messaging.support.GenericMessage; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; /** * @author Mark Fisher @@ -99,13 +100,14 @@ public class SplitterParserTests { context.close(); } - @Test(expected = ReplyRequiredException.class) + @Test public void splitterParserTestWithRequiresReply() { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "splitterParserTests.xml", this.getClass()); context.start(); DirectChannel inputChannel = context.getBean("requiresReplyInput", DirectChannel.class); - inputChannel.send(MessageBuilder.withPayload(Collections.emptyList()).build()); + assertThatThrownBy(() -> inputChannel.send(MessageBuilder.withPayload(Collections.emptyList()).build())) + .isInstanceOf(ReplyRequiredException.class); context.close(); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/selector/MessageSelectorChainTests.java b/spring-integration-core/src/test/java/org/springframework/integration/selector/MessageSelectorChainTests.java index 21cc5013ed..506a14d0c8 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/selector/MessageSelectorChainTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/selector/MessageSelectorChainTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,7 +16,7 @@ package org.springframework.integration.selector; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.integration.core.MessageSelector; import org.springframework.messaging.Message; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/splitter/StreamingSplitterTests.java b/spring-integration-core/src/test/java/org/springframework/integration/splitter/StreamingSplitterTests.java index 662ee21db0..d3a751ff22 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/splitter/StreamingSplitterTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/splitter/StreamingSplitterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,8 +22,8 @@ import java.util.List; import java.util.UUID; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.integration.IntegrationMessageHeaderAccessor; @@ -50,7 +50,7 @@ public class StreamingSplitterTests { private Message message; - @Before + @BeforeEach public void setUp() { this.message = new GenericMessage<>("foo.bar"); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/store/MessageStoreReaperTests.java b/spring-integration-core/src/test/java/org/springframework/integration/store/MessageStoreReaperTests.java index 1e6aa6548d..ad0984bc4c 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/store/MessageStoreReaperTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/store/MessageStoreReaperTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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.store; 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.beans.factory.annotation.Qualifier; @@ -31,8 +30,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; @@ -42,8 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Artem Bilan * @author Gary Russell */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig @DirtiesContext public class MessageStoreReaperTests { diff --git a/spring-integration-core/src/test/java/org/springframework/integration/support/MutableMessageTests.java b/spring-integration-core/src/test/java/org/springframework/integration/support/MutableMessageTests.java index 9b1eb07ee4..e3a6b4ab7d 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/support/MutableMessageTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/support/MutableMessageTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 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,7 +26,7 @@ import java.util.HashMap; import java.util.Map; import java.util.UUID; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.messaging.MessageHeaders; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/support/SmartLifecycleRoleControllerTests.java b/spring-integration-core/src/test/java/org/springframework/integration/support/SmartLifecycleRoleControllerTests.java index 420db40f54..f97f661857 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/support/SmartLifecycleRoleControllerTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/support/SmartLifecycleRoleControllerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2024 the original author or authors. + * Copyright 2015-2025 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,7 +16,7 @@ package org.springframework.integration.support; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.InOrder; import org.springframework.context.SmartLifecycle; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/support/converter/MapMessageConverterTests.java b/spring-integration-core/src/test/java/org/springframework/integration/support/converter/MapMessageConverterTests.java index cbd9b24487..9032c8d5d6 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/support/converter/MapMessageConverterTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/support/converter/MapMessageConverterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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.support.converter; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.integration.support.MessageBuilder; import org.springframework.messaging.Message; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/transformer/ClaimCheckTransformerTests.java b/spring-integration-core/src/test/java/org/springframework/integration/transformer/ClaimCheckTransformerTests.java index 777c70f6c1..86b0f134e2 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/transformer/ClaimCheckTransformerTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/transformer/ClaimCheckTransformerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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.transformer; import java.util.UUID; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.integration.store.MessageStore; import org.springframework.integration.store.SimpleMessageStore; @@ -26,6 +26,7 @@ import org.springframework.integration.support.MessageBuilder; import org.springframework.messaging.Message; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; /** * @author Mark Fisher @@ -56,11 +57,12 @@ public class ClaimCheckTransformerTests { assertThat(output.getPayload()).isEqualTo("test"); } - @Test(expected = MessageTransformationException.class) + @Test public void unknown() { MessageStore store = new SimpleMessageStore(10); ClaimCheckOutTransformer transformer = new ClaimCheckOutTransformer(store); - transformer.transform(MessageBuilder.withPayload(UUID.randomUUID()).build()); + assertThatThrownBy(() -> transformer.transform(MessageBuilder.withPayload(UUID.randomUUID()).build())) + .isInstanceOf(MessageTransformationException.class); } } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/transformer/CodecTransformerTests.java b/spring-integration-core/src/test/java/org/springframework/integration/transformer/CodecTransformerTests.java index 9e227a0485..7c1f3aaaf9 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/transformer/CodecTransformerTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/transformer/CodecTransformerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2022 the original author or authors. + * Copyright 2015-2025 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. @@ -21,7 +21,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.expression.spel.standard.SpelExpressionParser; import org.springframework.expression.spel.support.StandardEvaluationContext; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/transformer/HeaderFilterTests.java b/spring-integration-core/src/test/java/org/springframework/integration/transformer/HeaderFilterTests.java index 763c4892f1..e9107bb8d2 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/transformer/HeaderFilterTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/transformer/HeaderFilterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,7 +19,7 @@ package org.springframework.integration.transformer; import java.util.Date; import java.util.UUID; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanInitializationException; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/transformer/ObjectToStringTransformerTests.java b/spring-integration-core/src/test/java/org/springframework/integration/transformer/ObjectToStringTransformerTests.java index acb167c7d3..a3c7bdab99 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/transformer/ObjectToStringTransformerTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/transformer/ObjectToStringTransformerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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.transformer; import java.nio.charset.Charset; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.messaging.Message; import org.springframework.messaging.support.GenericMessage; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/transformer/PayloadSerializingTransformerTests.java b/spring-integration-core/src/test/java/org/springframework/integration/transformer/PayloadSerializingTransformerTests.java index 43a20f685f..38f2de7bd9 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/transformer/PayloadSerializingTransformerTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/transformer/PayloadSerializingTransformerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,13 +20,14 @@ import java.io.ByteArrayInputStream; import java.io.ObjectInputStream; import java.io.Serializable; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.integration.support.MessageBuilder; import org.springframework.messaging.Message; import org.springframework.messaging.support.GenericMessage; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; /** * @author Mark Fisher @@ -61,10 +62,11 @@ public class PayloadSerializingTransformerTests { assertThat(((TestBean) deserialized).name).isEqualTo(testBean.name); } - @Test(expected = MessageTransformationException.class) + @Test public void invalidPayload() { PayloadSerializingTransformer transformer = new PayloadSerializingTransformer(); - transformer.transform(new GenericMessage(new Object())); + assertThatThrownBy(() -> transformer.transform(new GenericMessage(new Object()))) + .isInstanceOf(MessageTransformationException.class); } @Test diff --git a/spring-integration-core/src/test/java/org/springframework/integration/transformer/PayloadTransformerTests.java b/spring-integration-core/src/test/java/org/springframework/integration/transformer/PayloadTransformerTests.java index 5c1024cb93..cc0ce4574c 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/transformer/PayloadTransformerTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/transformer/PayloadTransformerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 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,13 +18,14 @@ package org.springframework.integration.transformer; import java.util.Date; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.messaging.Message; import org.springframework.messaging.MessagingException; import org.springframework.messaging.support.GenericMessage; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; /** * @author Mark Fisher @@ -39,18 +40,20 @@ public class PayloadTransformerTests { assertThat(result.getPayload()).isEqualTo(3); } - @Test(expected = MessagingException.class) + @Test public void testExceptionThrownByTransformer() { TestPayloadTransformer transformer = new TestPayloadTransformer(); Message message = new GenericMessage("bad"); - transformer.transform(message); + assertThatThrownBy(() -> transformer.transform(message)) + .isInstanceOf(MessagingException.class); } - @Test(expected = MessagingException.class) + @Test public void testWrongPayloadType() { TestPayloadTransformer transformer = new TestPayloadTransformer(); Message message = new GenericMessage(new Date()); - transformer.transform(message); + assertThatThrownBy(() -> transformer.transform(message)) + .isInstanceOf(MessagingException.class); } private static class TestPayloadTransformer extends AbstractPayloadTransformer { diff --git a/spring-integration-core/src/test/java/org/springframework/integration/transformer/PayloadTypeConvertingTransformerTests.java b/spring-integration-core/src/test/java/org/springframework/integration/transformer/PayloadTypeConvertingTransformerTests.java index 97116bf8c0..aa3f591eac 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/transformer/PayloadTypeConvertingTransformerTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/transformer/PayloadTypeConvertingTransformerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,7 +16,7 @@ package org.springframework.integration.transformer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/transformer/SysLogTransformerTests.java b/spring-integration-core/src/test/java/org/springframework/integration/transformer/SysLogTransformerTests.java index 4a54708b53..113718feca 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/transformer/SysLogTransformerTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/transformer/SysLogTransformerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,7 +20,7 @@ import java.util.Date; import java.util.Map; import java.util.Map.Entry; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-integration-core/src/test/java/org/springframework/integration/util/BeanFactoryTypeConverterTests.java b/spring-integration-core/src/test/java/org/springframework/integration/util/BeanFactoryTypeConverterTests.java index 69c2995339..808de8d757 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/util/BeanFactoryTypeConverterTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/util/BeanFactoryTypeConverterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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. @@ -32,8 +32,8 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.springframework.beans.SimpleTypeConverter; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -295,7 +295,7 @@ public class BeanFactoryTypeConverterTests { } @Test - @Ignore("Too sensitive for the time") + @Disabled("Too sensitive for the time") public void initialConcurrency() throws Exception { ConversionService conversionService = mock(ConversionService.class); // can convert nothing so we drop down to // P.E.s diff --git a/spring-integration-core/src/test/java/org/springframework/integration/util/UUIDConverterTests.java b/spring-integration-core/src/test/java/org/springframework/integration/util/UUIDConverterTests.java index 72b9dbf1c1..52583d17ad 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/util/UUIDConverterTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/util/UUIDConverterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 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,9 +19,10 @@ package org.springframework.integration.util; import java.util.Date; import java.util.UUID; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.fail; /** @@ -81,9 +82,10 @@ public class UUIDConverterTests { assertThat(UUIDConverter.getUUID(new Date())).isNotNull(); } - @Test(expected = IllegalArgumentException.class) + @Test public void testConvertNonSerializable() { - assertThat(UUIDConverter.getUUID(new Object())).isNotNull(); + assertThatThrownBy(() -> assertThat(UUIDConverter.getUUID(new Object())).isNotNull()) + .isInstanceOf(IllegalArgumentException.class); } }