diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/config/TcpConnectionFactoryFactoryBeanTest.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/config/TcpConnectionFactoryFactoryBeanTest.java index 2bf70c4a16c..2c982e05640 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/config/TcpConnectionFactoryFactoryBeanTest.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/config/TcpConnectionFactoryFactoryBeanTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2024 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,7 +16,7 @@ package org.springframework.integration.ip.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.integration.test.util.TestUtils; diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/AutoStartTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/AutoStartTests.java index f4aa907bd70..be7f3913f01 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/AutoStartTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/AutoStartTests.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.ip.tcp; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.integration.ip.tcp.connection.AbstractServerConnectionFactory; import org.springframework.integration.ip.util.TestingUtilities; 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; @@ -34,8 +32,7 @@ * @since 2.1 * */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig @DirtiesContext public class AutoStartTests { diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/ClientModeControlBusTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/ClientModeControlBusTests.java index 1b060eed082..e0bdb8ddb9c 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/ClientModeControlBusTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/ClientModeControlBusTests.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,9 +18,8 @@ import java.time.Duration; -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.ip.tcp.connection.AbstractClientConnectionFactory; @@ -29,8 +28,7 @@ import org.springframework.integration.test.util.TestUtils; import org.springframework.scheduling.TaskScheduler; 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.awaitility.Awaitility.await; @@ -40,8 +38,7 @@ * @since 2.1 * */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig @DirtiesContext public class ClientModeControlBusTests { @@ -60,7 +57,7 @@ public class ClientModeControlBusTests { @Autowired TaskScheduler taskScheduler; // default - @Before + @BeforeEach public void before() { TestingUtilities.waitListening(this.server, null); this.client.setPort(this.server.getPort()); diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/ConnectionToConnectionTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/ConnectionToConnectionTests.java index 2af062a8f79..5cbc8340717 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/ConnectionToConnectionTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/ConnectionToConnectionTests.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,10 +18,9 @@ import java.util.Properties; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.MethodSorters; +import org.junit.jupiter.api.MethodOrderer.MethodName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestMethodOrder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ConfigurableApplicationContext; @@ -42,8 +41,7 @@ import org.springframework.integration.test.util.TestUtils; import org.springframework.messaging.Message; 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; @@ -53,9 +51,8 @@ * @since 2.0 * */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) +@SpringJUnitConfig +@TestMethodOrder(MethodName.class) @DirtiesContext public class ConnectionToConnectionTests { diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/FactoryStopStartTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/FactoryStopStartTests.java index 209114d7b6c..fbe1a8ba1f8 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/FactoryStopStartTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/FactoryStopStartTests.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.ip.tcp; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.integration.ip.tcp.connection.AbstractServerConnectionFactory; import org.springframework.integration.ip.tcp.connection.TcpNetServerConnectionFactory; diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/SharedConnectionTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/SharedConnectionTests.java index 67e735f7a04..85354c8ac52 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/SharedConnectionTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/SharedConnectionTests.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,8 +18,7 @@ import java.util.Properties; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.support.AbstractApplicationContext; @@ -34,8 +33,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; @@ -43,8 +41,7 @@ * @author Gary Russell * @since 2.0 */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig @DirtiesContext public class SharedConnectionTests { diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/TcpConfigInboundGatewayTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/TcpConfigInboundGatewayTests.java index 04aad4a8273..2dad9b7b895 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/TcpConfigInboundGatewayTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/TcpConfigInboundGatewayTests.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. @@ -23,8 +23,7 @@ import javax.net.SocketFactory; -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; @@ -32,7 +31,7 @@ import org.springframework.integration.ip.tcp.connection.AbstractServerConnectionFactory; import org.springframework.integration.ip.tcp.serializer.ByteArrayStxEtxSerializer; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import static org.assertj.core.api.Assertions.assertThat; @@ -42,7 +41,7 @@ * * @since 2.0 */ -@RunWith(SpringRunner.class) +@SpringJUnitConfig @DirtiesContext public class TcpConfigInboundGatewayTests { diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/TcpConfigOutboundGatewayTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/TcpConfigOutboundGatewayTests.java index 1d7423cb62b..19bec7ae7ed 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/TcpConfigOutboundGatewayTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/TcpConfigOutboundGatewayTests.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,8 @@ import java.util.Map; -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.beans.factory.annotation.Qualifier; @@ -35,8 +34,7 @@ import org.springframework.messaging.PollableChannel; import org.springframework.messaging.SubscribableChannel; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; @@ -46,8 +44,7 @@ * @author Artem Bilan * @since 2.0 */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig @DirtiesContext public class TcpConfigOutboundGatewayTests { @@ -123,7 +120,7 @@ public class TcpConfigOutboundGatewayTests { @Autowired MessageChannel tcpOutboundGatewayInsideChain; - @Before + @BeforeEach public void before() { if (initializedFactories) { return; diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/TcpSendingNoSocketTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/TcpSendingNoSocketTests.java index 8f6fd0a3ef9..127b54de09d 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/TcpSendingNoSocketTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/TcpSendingNoSocketTests.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.ip.tcp; -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.MessageChannel; import org.springframework.messaging.MessageHandlingException; import org.springframework.messaging.support.GenericMessage; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; @@ -35,8 +33,7 @@ * @since 2.2 * */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig @DirtiesContext public class TcpSendingNoSocketTests { diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/ConnectionTimeoutTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/ConnectionTimeoutTests.java index 9b1f4da0421..a071c4d6e8b 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/ConnectionTimeoutTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/ConnectionTimeoutTests.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,14 +21,13 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationEventPublisher; import org.springframework.integration.ip.util.TestingUtilities; import org.springframework.integration.support.MessageBuilder; -import org.springframework.integration.test.support.LongRunningIntegrationTest; +import org.springframework.integration.test.condition.LongRunningTest; import org.springframework.integration.test.util.TestUtils; import org.springframework.messaging.Message; import org.springframework.messaging.support.ErrorMessage; @@ -39,11 +38,9 @@ * @author Gary Russell * @since 2.2 */ +@LongRunningTest public class ConnectionTimeoutTests { - @Rule - public LongRunningIntegrationTest longTests = new LongRunningIntegrationTest(); - @Test public void testDefaultTimeout() throws Exception { TcpNetServerConnectionFactory server = new TcpNetServerConnectionFactory(0); diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/PushbackTcpTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/PushbackTcpTests.java index fd2aa65f333..0fbefa18f85 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/PushbackTcpTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/PushbackTcpTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2022 the original author or authors. + * Copyright 2017-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.time.Duration; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/SOLingerTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/SOLingerTests.java index 9fb8db552a3..d79c5f29dcd 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/SOLingerTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/SOLingerTests.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. @@ -23,14 +23,12 @@ import javax.net.SocketFactory; -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.ip.util.TestingUtilities; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; @@ -40,8 +38,7 @@ * @since 2.0.2 * */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration +@SpringJUnitConfig @DirtiesContext public class SOLingerTests { diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpConnectionEventListenerTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpConnectionEventListenerTests.java index 5830e74f189..8d18b0527e7 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpConnectionEventListenerTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpConnectionEventListenerTests.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.ip.tcp.connection; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.beans.factory.BeanFactory; diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNetConnectionSupportTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNetConnectionSupportTests.java index efc20699c93..b5b39b4445b 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNetConnectionSupportTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNetConnectionSupportTests.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. @@ -24,7 +24,7 @@ import javax.net.SocketFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationEventPublisher; import org.springframework.messaging.Message; diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNetConnectionTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNetConnectionTests.java index 941243f6341..0ca13eed336 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNetConnectionTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNetConnectionTests.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,7 +32,7 @@ import javax.net.SocketFactory; import org.apache.commons.logging.Log; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.beans.DirectFieldAccessor; @@ -162,9 +162,7 @@ public void socketClosedNextRead() throws InterruptedException, IOException { } }; server.setApplicationEventPublisher(publisher); - server.registerListener(message -> { - return false; - }); + server.registerListener(message -> false); server.afterPropertiesSet(); server.start(); assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue(); diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNioConnectionWriteTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNioConnectionWriteTests.java index 7ad7d37bda2..72f37c6540c 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNioConnectionWriteTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNioConnectionWriteTests.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. @@ -26,7 +26,7 @@ import javax.net.ServerSocketFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.integration.ip.tcp.serializer.AbstractByteArraySerializer; import org.springframework.integration.ip.tcp.serializer.ByteArrayCrLfSerializer; diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/ThreadAffinityClientConnectionFactoryTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/ThreadAffinityClientConnectionFactoryTests.java index 57e38385437..6fc117e7947 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/ThreadAffinityClientConnectionFactoryTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/ThreadAffinityClientConnectionFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2022 the original author or authors. + * Copyright 2017-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.time.Duration; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/serializer/LengthHeaderSerializationTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/serializer/LengthHeaderSerializationTests.java index 72afa59481c..3ed2934b377 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/serializer/LengthHeaderSerializationTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/serializer/LengthHeaderSerializationTests.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,8 +21,8 @@ import java.io.IOException; import java.util.Arrays; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; @@ -42,7 +42,7 @@ public class LengthHeaderSerializationTests { private String testFFFF; - @Before + @BeforeEach public void setup() { char[] chars = new char[255]; Arrays.fill(chars, 'x'); diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/serializer/MapJsonSerializerTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/serializer/MapJsonSerializerTests.java index 47815106eb8..335bb72bf81 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/serializer/MapJsonSerializerTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/serializer/MapJsonSerializerTests.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.io.ByteArrayInputStream; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/serializer/PooledDeserializationTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/serializer/PooledDeserializationTests.java index 77abc62e238..3f2624085c4 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/serializer/PooledDeserializationTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/serializer/PooledDeserializationTests.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. @@ -20,7 +20,7 @@ import java.io.IOException; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.integration.test.util.TestUtils; diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/serializer/SerializationTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/serializer/SerializationTests.java index b0d454e4382..d05c2077ec6 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/serializer/SerializationTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/serializer/SerializationTests.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. @@ -28,7 +28,7 @@ import javax.net.ServerSocketFactory; import javax.net.SocketFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.serializer.DefaultSerializer; diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/serializer/TcpCodecsTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/serializer/TcpCodecsTests.java index ce1def1e666..ad72913ddaf 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/serializer/TcpCodecsTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/serializer/TcpCodecsTests.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.ip.tcp.serializer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.integration.test.util.TestUtils; diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/DatagramPacketMulticastSendingHandlerTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/DatagramPacketMulticastSendingHandlerTests.java index 28b29627c52..acba1fbabd9 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/DatagramPacketMulticastSendingHandlerTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/DatagramPacketMulticastSendingHandlerTests.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. @@ -28,8 +28,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.core.task.SimpleAsyncTaskExecutor; @@ -47,13 +46,11 @@ * * @since 2.0 */ +@Multicast public class DatagramPacketMulticastSendingHandlerTests { - @Rule - public MulticastRule multicastRule = new MulticastRule(); - @Test - public void verifySendMulticast() throws Exception { + public void verifySendMulticast(MulticastCondition multicastCondition) throws Exception { MulticastSocket socket; try { socket = new MulticastSocket(); @@ -62,7 +59,7 @@ public void verifySendMulticast() throws Exception { return; } final int testPort = socket.getLocalPort(); - final String multicastAddress = this.multicastRule.getGroup(); + final String multicastAddress = multicastCondition.getGroup(); final String payload = "foo"; final CountDownLatch listening = new CountDownLatch(2); final CountDownLatch received = new CountDownLatch(2); @@ -71,7 +68,7 @@ public void verifySendMulticast() throws Exception { byte[] buffer = new byte[8]; DatagramPacket receivedPacket = new DatagramPacket(buffer, buffer.length); MulticastSocket socket1 = new MulticastSocket(testPort); - socket1.setNetworkInterface(multicastRule.getNic()); + socket1.setNetworkInterface(multicastCondition.getNic()); InetAddress group = InetAddress.getByName(multicastAddress); socket1.joinGroup(new InetSocketAddress(group, 0), null); listening.countDown(); @@ -96,7 +93,7 @@ public void verifySendMulticast() throws Exception { assertThat(listening.await(10000, TimeUnit.MILLISECONDS)).isTrue(); MulticastSendingMessageHandler handler = new MulticastSendingMessageHandler(multicastAddress, testPort); handler.setBeanFactory(mock(BeanFactory.class)); - NetworkInterface nic = this.multicastRule.getNic(); + NetworkInterface nic = multicastCondition.getNic(); if (nic != null) { String hostName = null; Enumeration addressesFromNetworkInterface = nic.getInetAddresses(); @@ -122,7 +119,7 @@ public void verifySendMulticast() throws Exception { } @Test - public void verifySendMulticastWithAcks() throws Exception { + public void verifySendMulticastWithAcks(MulticastCondition multicastCondition) throws Exception { MulticastSocket socket; try { @@ -134,18 +131,18 @@ public void verifySendMulticastWithAcks() throws Exception { final int testPort = socket.getLocalPort(); final AtomicInteger ackPort = new AtomicInteger(); - final String multicastAddress = this.multicastRule.getGroup(); + final String multicastAddress = multicastCondition.getGroup(); final String payload = "foobar"; final CountDownLatch listening = new CountDownLatch(2); final CountDownLatch ackListening = new CountDownLatch(1); final CountDownLatch ackSent = new CountDownLatch(2); - NetworkInterface nic = this.multicastRule.getNic(); + NetworkInterface nic = multicastCondition.getNic(); Runnable catcher = () -> { try { byte[] buffer = new byte[1000]; DatagramPacket receivedPacket = new DatagramPacket(buffer, buffer.length); MulticastSocket socket1 = new MulticastSocket(testPort); - socket1.setNetworkInterface(multicastRule.getNic()); + socket1.setNetworkInterface(multicastCondition.getNic()); socket1.setSoTimeout(8000); InetAddress group = InetAddress.getByName(multicastAddress); socket1.joinGroup(new InetSocketAddress(group, 0), null); diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/DatagramPacketSendingHandlerTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/DatagramPacketSendingHandlerTests.java index 3465afbde74..ae00a0fcf92 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/DatagramPacketSendingHandlerTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/DatagramPacketSendingHandlerTests.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. @@ -24,7 +24,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.core.task.SimpleAsyncTaskExecutor; diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/MultiClientTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/MultiClientTests.java index 20561a764ac..2f1d2f77537 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/MultiClientTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/MultiClientTests.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.concurrent.atomic.AtomicBoolean; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.ip.util.SocketTestUtils; @@ -47,7 +47,7 @@ public class MultiClientTests { @SuppressWarnings("unchecked") @Test - @Ignore + @Disabled public void testNoAck() throws Exception { final String payload = largePayload(1000); final UnicastReceivingChannelAdapter adapter = @@ -93,7 +93,7 @@ public void testNoAck() throws Exception { @SuppressWarnings("unchecked") @Test - @Ignore + @Disabled public void testAck() throws Exception { final String payload = largePayload(1000); final UnicastReceivingChannelAdapter adapter = @@ -141,7 +141,7 @@ public void testAck() throws Exception { @SuppressWarnings("unchecked") @Test - @Ignore + @Disabled public void testAckWithLength() throws Exception { final String payload = largePayload(1000); final UnicastReceivingChannelAdapter adapter = diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/Multicast.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/Multicast.java new file mode 100644 index 00000000000..d386dcd4b54 --- /dev/null +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/Multicast.java @@ -0,0 +1,46 @@ +/* + * Copyright 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.integration.ip.udp; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.junit.jupiter.api.extension.ExtendWith; + +/** + * Test classes annotated with this will check whether the system supports multicast or not. + * If it is not supported, tests will be skipped. + * + * @author Jiandong Ma + * + * @since 6.5.0 + */ +@ExtendWith(MulticastCondition.class) +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface Multicast { + + /** + * The hostname. + * @return the hostname. + */ + String group() default MulticastCondition.DEFAULT_GROUP; +} diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/MulticastCondition.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/MulticastCondition.java new file mode 100644 index 00000000000..321a72c5b77 --- /dev/null +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/MulticastCondition.java @@ -0,0 +1,133 @@ +/* + * Copyright 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.integration.ip.udp; + +import java.lang.reflect.AnnotatedElement; +import java.net.InetSocketAddress; +import java.net.MulticastSocket; +import java.net.NetworkInterface; +import java.util.Optional; + +import org.apache.commons.logging.LogFactory; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.extension.BeforeAllCallback; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.ParameterContext; +import org.junit.jupiter.api.extension.ParameterResolutionException; +import org.junit.jupiter.api.extension.ParameterResolver; + +import org.springframework.core.annotation.MergedAnnotation; +import org.springframework.core.annotation.MergedAnnotations; +import org.springframework.integration.ip.util.SocketTestUtils; +import org.springframework.lang.Nullable; +import org.springframework.util.Assert; + +/** + * A JUnit condition that checks whether the system supports multicast or not. + * If it is not supported, tests will be skipped. + *

+ * The default multicast group is "225.6.7.8", but a custom group can be specified. + * + * @author Jiandong Ma + * + * @since 6.5.0 + */ +public class MulticastCondition implements BeforeAllCallback, ParameterResolver { + + public static final String DEFAULT_GROUP = "225.6.7.8"; + + private String group; + + @Nullable + private NetworkInterface nic; + + private boolean skip; + + public void checkMulticast(String group) { + Assert.hasText(group, "'group' must not be empty"); + this.group = group; + System.setProperty("java.net.preferIPv4Stack", "true"); + System.setProperty("multicast.group", group); + try { + this.nic = doCheckMulticast(group); + } + catch (Exception e) { + throw new IllegalStateException(e); + } + if (this.nic != null) { + System.setProperty("multicast.local.address", this.nic.getInetAddresses().nextElement().getHostName()); + } + } + + @Nullable + private NetworkInterface doCheckMulticast(String group) throws Exception { + NetworkInterface nic = SocketTestUtils.chooseANic(true); + if (nic == null) { // no multicast support + this.skip = true; + return null; + } + try { + MulticastSocket socket = new MulticastSocket(); + socket.joinGroup(new InetSocketAddress(group, 0), nic); + socket.close(); + } + catch (Exception e) { + this.skip = true; + // Ignore. Assume no Multicast - skip the test. + } + return nic; + } + + public String getGroup() { + return group; + } + + @Nullable + public NetworkInterface getNic() { + return nic; + } + + @Override + public void beforeAll(ExtensionContext context) { + Optional element = context.getElement(); + MergedAnnotations annotations = MergedAnnotations.from(element.get(), + MergedAnnotations.SearchStrategy.DIRECT); + MergedAnnotation mergedAnnotation = annotations.get(Multicast.class); + String group = DEFAULT_GROUP; + if (mergedAnnotation.isPresent()) { + Multicast multicast = mergedAnnotation.synthesize(); + group = multicast.group(); + } + checkMulticast(group); + + if (this.skip) { + LogFactory.getLog(getClass()).info("No Multicast support; test skipped"); + } + Assumptions.assumeFalse(this.skip); + } + + @Override + public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException { + return parameterContext.getParameter().getType() == MulticastCondition.class; + } + + @Override + public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException { + return this; + } + +} diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/MulticastRule.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/MulticastRule.java deleted file mode 100644 index b85897b0935..00000000000 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/MulticastRule.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2015-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.integration.ip.udp; - -import java.net.InetSocketAddress; -import java.net.MulticastSocket; -import java.net.NetworkInterface; - -import org.apache.commons.logging.LogFactory; -import org.junit.Assume; -import org.junit.rules.TestWatcher; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; - -import org.springframework.integration.ip.util.SocketTestUtils; -import org.springframework.lang.Nullable; -import org.springframework.util.Assert; - -/** - * @author Artem Bilan - * - * @since 4.3 - */ -public class MulticastRule extends TestWatcher { - - public static String GROUP = "225.6.7.8"; - - private final String group; - - @Nullable - private final NetworkInterface nic; - - private boolean skip; - - public MulticastRule() { - this(GROUP); - } - - public MulticastRule(String group) { - Assert.hasText(group, "'group' must not be empty"); - this.group = group; - System.setProperty("java.net.preferIPv4Stack", "true"); - System.setProperty("multicast.group", this.group); - try { - this.nic = checkMulticast(); - } - catch (Exception e) { - throw new IllegalStateException(e); - } - if (this.nic != null) { - System.setProperty("multicast.local.address", this.nic.getInetAddresses().nextElement().getHostName()); - } - } - - @Nullable - private NetworkInterface checkMulticast() throws Exception { - NetworkInterface nic = SocketTestUtils.chooseANic(true); - if (nic == null) { // no multicast support - this.skip = true; - return null; - } - try { - MulticastSocket socket = new MulticastSocket(); - socket.joinGroup(new InetSocketAddress(this.group, 0), nic); - socket.close(); - } - catch (Exception e) { - this.skip = true; - // Ignore. Assume no Multicast - skip the test. - } - return nic; - } - - public String getGroup() { - return group; - } - - @Nullable - public NetworkInterface getNic() { - return nic; - } - - @Override - public Statement apply(Statement base, Description description) { - if (this.skip) { - LogFactory.getLog(getClass()).info("No Multicast support; test skipped"); - } - Assume.assumeFalse(this.skip); - return super.apply(base, description); - } - -} diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/UdpChannelAdapterTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/UdpChannelAdapterTests.java index 632471eb8ef..0b5e8bb60ba 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/UdpChannelAdapterTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/UdpChannelAdapterTests.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. @@ -30,8 +30,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.context.ConfigurableApplicationContext; @@ -43,7 +42,7 @@ import org.springframework.integration.ip.IpHeaders; import org.springframework.integration.ip.util.SocketTestUtils; import org.springframework.integration.support.MessageBuilder; -import org.springframework.integration.test.rule.Log4j2LevelAdjuster; +import org.springframework.integration.test.condition.LogLevels; import org.springframework.messaging.Message; import org.springframework.messaging.SubscribableChannel; @@ -60,14 +59,10 @@ * @since 2.0 * */ +@Multicast +@LogLevels(categories = "org.springframework.integration.ip.udp", level = "TRACE") public class UdpChannelAdapterTests { - @Rule - public Log4j2LevelAdjuster adjuster = Log4j2LevelAdjuster.trace(); - - @Rule - public MulticastRule multicastRule = new MulticastRule(); - @Test public void testUnicastReceiver() throws Exception { testUnicastReceiver(false, false); @@ -250,12 +245,12 @@ public void testUnicastSender() { @SuppressWarnings("unchecked") @Test - public void testMulticastReceiver() throws Exception { + public void testMulticastReceiver(MulticastCondition multicastCondition) throws Exception { QueueChannel channel = new QueueChannel(2); MulticastReceivingChannelAdapter adapter = - new MulticastReceivingChannelAdapter(this.multicastRule.getGroup(), 0); + new MulticastReceivingChannelAdapter(multicastCondition.getGroup(), 0); adapter.setOutputChannel(channel); - NetworkInterface nic = this.multicastRule.getNic(); + NetworkInterface nic = multicastCondition.getNic(); if (nic != null) { adapter.setLocalAddress(nic.getInetAddresses().nextElement().getHostName()); } @@ -266,7 +261,7 @@ public void testMulticastReceiver() throws Exception { Message message = MessageBuilder.withPayload("ABCD".getBytes()).build(); DatagramPacketMessageMapper mapper = new DatagramPacketMessageMapper(); DatagramPacket packet = mapper.fromMessage(message); - packet.setSocketAddress(new InetSocketAddress(this.multicastRule.getGroup(), port)); + packet.setSocketAddress(new InetSocketAddress(multicastCondition.getGroup(), port)); InetAddress inetAddress = null; if (nic != null) { Enumeration addressesFromNetworkInterface = nic.getInetAddresses(); @@ -295,12 +290,12 @@ public void testMulticastReceiver() throws Exception { @SuppressWarnings("unchecked") @Test - public void testMulticastSender() { + public void testMulticastSender(MulticastCondition multicastCondition) { QueueChannel channel = new QueueChannel(2); UnicastReceivingChannelAdapter adapter = - new MulticastReceivingChannelAdapter(this.multicastRule.getGroup(), 0); + new MulticastReceivingChannelAdapter(multicastCondition.getGroup(), 0); adapter.setOutputChannel(channel); - NetworkInterface nic = this.multicastRule.getNic(); + NetworkInterface nic = multicastCondition.getNic(); if (nic != null) { adapter.setLocalAddress(nic.getInetAddresses().nextElement().getHostName()); } @@ -308,7 +303,7 @@ public void testMulticastSender() { SocketTestUtils.waitListening(adapter); MulticastSendingMessageHandler handler = - new MulticastSendingMessageHandler(this.multicastRule.getGroup(), adapter.getPort()); + new MulticastSendingMessageHandler(multicastCondition.getGroup(), adapter.getPort()); if (nic != null) { handler.setLocalAddress(nic.getInetAddresses().nextElement().getHostName()); } diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/UdpMulticastEndToEndTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/UdpMulticastEndToEndTests.java index e8f651fe03a..e8e301127ee 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/UdpMulticastEndToEndTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/UdpMulticastEndToEndTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,8 +22,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.AbstractApplicationContext; @@ -56,11 +55,9 @@ * * @since 2.0 */ +@Multicast public class UdpMulticastEndToEndTests implements Runnable { - @Rule - public MulticastRule multicastRule = new MulticastRule(); - private Message finalMessage; private CountDownLatch sentFirst = new CountDownLatch(1); diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/UdpUnicastEndToEndTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/UdpUnicastEndToEndTests.java index 7b4c64a7873..f74f3a749bc 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/UdpUnicastEndToEndTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/UdpUnicastEndToEndTests.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.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.AbstractApplicationContext; @@ -77,7 +77,7 @@ public class UdpUnicastEndToEndTests implements Runnable { private static long hangAroundFor = 10; - @Before + @BeforeEach public void setup() { this.testingIpText = null; this.finalMessage = null; diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/util/RegexUtilsTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/util/RegexUtilsTests.java index 7bc9d72f28a..129c5119fb7 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/util/RegexUtilsTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/util/RegexUtilsTests.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.ip.util; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat;