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 37cc914ac59..5be6200b946 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.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 65cfe971fd1..a9220951eb7 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.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 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 @@ * @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 void shouldRemoveKeyWithoutLockingOnEmptyQueue() throws InterruptedExcept 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 f510978f76d..320ab46cb69 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 bfe8b71cdbe..a0d11b25d1e 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 fa8ea3dbc6e..e5c2d5b2c10 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.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 0c35d4ea81b..f93210335e7 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.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 @@ * @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 03e650a732f..ffa7ea73042 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 6e8e0535db4..3ddd844d4da 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 ddec02461c9..4cd9345e825 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 @@ 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 10a81b8df69..b184eeaa37b 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.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.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 @@ * @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 String method1(List input, @Headers Map map) { assertThat(aggregator.aggregatePayloads(group, aggregator.aggregateHeaders(group))).isEqualTo("foobar"); } - @Test(expected = IllegalArgumentException.class) + @Test public void multipleAnnotations() { class MultipleAnnotationTestBean { @@ -506,7 +503,8 @@ public String method2(List input) { } MultipleAnnotationTestBean bean = new MultipleAnnotationTestBean(); - new MethodInvokingMessageGroupProcessor(bean); + assertThatIllegalArgumentException() + .isThrownBy(() -> new MethodInvokingMessageGroupProcessor(bean)); } @Test @@ -534,7 +532,7 @@ String method2(List input) { assertThat(aggregator.aggregatePayloads(group, null)).isEqualTo("foo"); } - @Test(expected = IllegalArgumentException.class) + @Test public void multiplePublicMethods() { @SuppressWarnings("unused") @@ -551,10 +549,11 @@ public String lowerCase(String s) { } 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 @@ String lowerCase(String s) { } 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 fbad31db32c..ce384221636 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 @@ 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 bb1858f7c27..0792471a449 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 affc619a699..9d3ac2c42b3 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 34570b07dc7..4d22f702536 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 @@ 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 6dbefdeca37..49b2da0b21d 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 @@ 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 @@ * @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 void testAggregatorWithoutExplicitTimeoutReturnsOnlyOneMessage() { *

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 34b2a9d4e36..5fed06f5216 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 @@ 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 @@ * * @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 a0f33bcd8f6..3150de0ee8b 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 @@ 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 @@ * @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 a345d3ecc5c..a8dc5c8a7f3 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 @@ 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.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 @@ * @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 87e61f4f1c9..4c14e507851 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 @@ 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 void testPurgeNoneWithSelectorAndMultipleChannels() { 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 416fe247dcc..af6afb37f6a 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.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.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 void supportedType() { 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 void unsupportedTypeButConversionServiceSupports() { 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 void subclassOfAcceptedType() { 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 9ad9dad4334..5ef2e8e4a09 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 ca77514e5ed..9f84352b9ab 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 35e13430226..a78fda7e63f 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.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 3f6c10155e4..d837ce9d5ed 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.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 @@ * @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 45f7c711407..64c6aa21730 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 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.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 @@ * * @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 44174c27b19..5612f1ae740 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.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 @@ * @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 e8a8529349f..cc29d77133f 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 @@ 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.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 @@ * @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 9304abf9440..77b60674824 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 @@ 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.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 void testSingleSelectorAccepts() { 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 b6e541917d9..c2c54e87791 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.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 void wireTapWithAcceptingSelector() { 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 b9475fa0f3a..ff1b9d48aaf 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.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 4ee5832b510..1ece78efcf9 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 @@ 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 34b107b2d4c..d8be2246956 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.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 9d5056265e2..1d14d340637 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 b07e8b1ab0b..c57bea915d5 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 e09767af541..60dd45ef8aa 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 c5145f0d9f6..c3e149b01cf 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 @@ 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 cabd8fd5430..73595e5c10f 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 42de443b628..3af90230fe1 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 @@ * @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 486cc6d6bc4..2485a42faff 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 @@ * @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 277dfda4fc5..24e850cb95e 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 @@ * @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 0e7bde2a54b..9961cda9ebf 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 236a8acee32..7c76662f150 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.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 @@ * @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 0ad28fa6155..1f54e70a26d 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 @@ 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.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 void testMapToObjectTransformationWithConversionService() { 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 3f3c68bd83c..f18263ebda1 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 @@ 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.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 @@ * @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 7e5a7c1fa11..3cba0a55292 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 @@ 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 @@ * @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 130138a492c..45724d795fc 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.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 @@ * @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 340c4aaecc0..fff414c2fb1 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.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.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 void queueChannelWithObjectMessage() throws Exception { 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 c54409027ba..924bb2b89aa 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 @@ 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 4b0c3614263..5b5952ae6eb 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 @@ * @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 0870fc1f22d..228c764e17b 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 @@ 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.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 @@ * @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 a7fa40b13ad..20f7407db30 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 @@ 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 @@ * @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 352fa82547d..63f545ffa4b 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 53662cf33f1..d0e30d6ecaf 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 c9f68ec8965..ab62a831a23 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 @@ 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 @@ private List exceptionsList() { } @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 f444c0df147..c8d7d0749cc 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 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 ce178e44d92..0378f0c5fd0 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.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 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 @@ * @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 void initialize() { 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 8ad78e5938d..8a65f12ce96 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 @@ 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.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 @@ * @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 ff6d779246c..49b0ef1089d 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 86128f074af..8170bb7dd03 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.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 void literalExpression() { 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 7a5d0a5fcf6..80d493b7759 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 @@ 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 3a8b17c09b0..c4873648b5b 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 @@ 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.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 void init() { this.taskScheduler.afterPropertiesSet(); } - @After + @AfterEach public void stop() { taskScheduler.destroy(); } @@ -124,25 +125,27 @@ public void heavierLoadTest() { } } - @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 4b01834ade6..69a4437495a 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 99375d2be2c..1d9d31bbba4 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.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 void noOutputChannelFallsBackToReturnAddress() { 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 void noReplyMessage() { 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 void noReplyMessageWithRequiresReply() { 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 b28ebf59082..70dd159b0bf 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 @@ 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.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 void singleAnnotationMatches() { 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 void singlePublicMethodMatches() { 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 aa8f5ff6c83..539c5bfff23 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 @@ 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 c5aedbb00bd..5f890c242f1 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 c7cc1c6775f..8501f8ef7b6 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.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 void filterRejectsMessageSilently() { 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 void filterRejectsSilentlyWithChannels() { 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 void filterThrowsExceptionWithChannels() { 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 void filterDiscardsMessage() { 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 void filterDiscardsMessageAndThrowsException() throws Exception { 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 void filterDiscardsMessageAndThrowsException() throws Exception { 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 65a1a282070..53b86b5d5cc 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 @@ 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 void noArgMethodWithMethodReference() throws Exception { 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 01e8666cd3a..87b21f7f2ad 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 fc0d7393ac8..5360d1e999d 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.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 0050dfab88c..f492ed4b02c 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 @@ 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 354f27f171a..09afbe56fd6 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 33e8d537abc..5756a37efa4 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.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 36e2c9c31fd..74e1a00117a 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 @@ 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 a3ab7760188..7d0ca5e9525 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.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 e39ef9a4100..e20ee4b7129 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 8d154f4de52..2fb546b78c0 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 @@ 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 56f22358bfb..f22c23ddb9b 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.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.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 void withProvidedContentTypeAsEmptyStringDoesNotOverride() { 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 55d3f545745..d41d4c59d01 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.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 587ee68062e..f69de0543aa 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 @@ 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.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 void validExpressionWithSomeArgs() { 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 8156eca7767..59c945fd9e8 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 @@ 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 637eaebebbe..e73caf530ad 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.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 @@ * @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 5eb5d400190..ce9d84e4cbc 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 @@ 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.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 void testHeaderExpressions() { 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 9fc35c1b146..d68be2eb08e 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 1498bb42b8a..d1b7bd27a11 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 408d11e137e..fc1052dce9c 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 @@ 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.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 void cleanUpWorkDir() throws Exception { } } - @AfterClass + @AfterAll public static void cleanUp() { workDir.delete(); } @@ -82,9 +83,10 @@ public void testDefaultConfig() { 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 36e537d5461..98814b52ea8 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 void prepare() { 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 bc25ccd3f2b..81e91e8e9f6 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 0ac4580ad98..34cb5a9cce2 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.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.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 void channelNameResolutionByHeader() throws Exception { 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 e6dc9aac36d..12ad6954ccd 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.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.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 List getChannelKeys(Message message) { assertThat(result2.getPayload()).isEqualTo("test"); } - @Test(expected = MessagingException.class) + @Test public void channelNameLookupFailure() { AbstractMappingMessageRouter router = new AbstractMappingMessageRouter() { @@ -74,10 +75,10 @@ public List getChannelKeys(Message message) { 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 List getChannelKeys(Message message) { }; 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 e5aaf182439..dcc93a0e11a 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.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.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 void directInterfaceFavoredOverSuperclass() { assertThat(result).isNotNull(); } - @Test(expected = MessageHandlingException.class) + @Test public void ambiguityFailure() { QueueChannel defaultChannel = new QueueChannel(); defaultChannel.setBeanName("defaultChannel"); @@ -370,7 +371,8 @@ public void ambiguityFailure() { router.setDefaultOutputChannel(defaultChannel); Message message = new GenericMessage<>("test"); - router.handleMessage(message); + assertThatThrownBy(() -> router.handleMessage(message)) + .isInstanceOf(MessageHandlingException.class); } @Test @@ -499,7 +501,7 @@ public void classWinsOverMoreDistantAmbiguousInterfaces() { 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 void classLosesOverLessDistantAmbiguousInterfaces() { 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 void classLosesOverAmbiguousInterfacesAtSameLevel() { 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 adad56591ef..09c8e7828ac 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.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.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 void routeToSingleChannel() { 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 void sendFailureOnFirstRecipientTriggersExceptionByDefault() { 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 void sendFailureOnMiddleRecipientTriggersExceptionByDefault() { 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 void sendFailureOnLastRecipientTriggersExceptionByDefault() { 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 void applySequenceEnabled() { .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 2ed7c9a47b8..d67ae5a9331 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.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.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 @@ */ public class RouterTests { - @Test(expected = MessageDeliveryException.class) + @Test public void nullChannelRaisesMessageDeliveryExceptionByDefault() { AbstractMappingMessageRouter router = new AbstractMappingMessageRouter() { @@ -55,10 +56,11 @@ protected List getChannelKeys(Message message) { } }; 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 @@ protected List getChannelKeys(Message message) { 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 @@ protected List getChannelKeys(Message message) { 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 @@ protected List getChannelKeys(Message message) { 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 @@ protected List getChannelKeys(Message message) { } }; 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 @@ protected List getChannelKeys(Message message) { context.close(); } - @Test(expected = MessagingException.class) + @Test public void channelResolutionIsRequiredByDefault() { AbstractMappingMessageRouter router = new AbstractMappingMessageRouter() { @@ -188,8 +194,9 @@ protected List getChannelKeys(Message message) { context.refresh(); router.setBeanFactory(context); - router.handleMessage(new GenericMessage<>("test")); + assertThatThrownBy(() -> router.handleMessage(new GenericMessage<>("test"))) + .isInstanceOf(MessagingException.class); } @Test @@ -242,7 +249,7 @@ protected List getChannelKeys(Message message) { context.close(); } - @Test(expected = MessagingException.class) + @Test public void beanFactoryWithRouterAndChannelPrefixFailing() { AbstractMappingMessageRouter router = new AbstractMappingMessageRouter() { @@ -260,7 +267,8 @@ protected List getChannelKeys(Message message) { 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 @@ protected List getChannelKeys(Message message) { context.close(); } - @Test(expected = MessagingException.class) + @Test public void beanFactoryWithRouterAndChannelSuffixFailing() { AbstractMappingMessageRouter router = new AbstractMappingMessageRouter() { @@ -308,7 +316,8 @@ protected List getChannelKeys(Message message) { 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 String getChannel() { } - @Test(expected = MessagingException.class) + @Test public void beanFactoryWithRouterAndRetrieveChannelIdentifierUsingDefaultConversionServiceFailing() { final QueueChannel testChannel1 = new QueueChannel(); @@ -458,7 +467,9 @@ protected List getChannelKeys(Message message) { 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 469d4e51428..9cddcf077cc 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 da358c57471..fe09277774a 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.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 cb521c5e7da..462357b5007 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 @@ 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.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 void splitterImplementation() { 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 21cc5013ed6..506a14d0c86 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 662ee21db01..d3a751ff220 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.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 1e6aa6548dd..ad0984bc4c1 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 @@ 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.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 @@ * @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 9b1eb07ee4f..e3a6b4ab7d1 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.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 420db40f54e..f97f6618578 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 cbd9b24487b..9032c8d5d60 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 @@ 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 777c70f6c14..86b0f134e2d 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 @@ 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.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 void retrieve() { 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 9e227a0485d..7c1f3aaaf9c 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.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 763c4892f11..e9107bb8d2b 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 @@ 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 acb167c7d36..a3c7bdab993 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 @@ 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 43a20f685fc..38f2de7bd9e 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.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 void serializeObject() throws Exception { 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 5c1024cb930..cc0ce4574c3 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 @@ 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 void testSuccessfulTransformation() { 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 97116bf8c01..aa3f591eac3 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 4a54708b531..113718feca2 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.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 69c2995339c..808de8d7576 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.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 void testDelegateWithTargetUUID() { } @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 72b9dbf1c17..52583d17ad4 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 @@ 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 void testConvertSerializable() { 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); } }