Skip to content

Commit 2467370

Browse files
authored
Migrate spring-integration-ip tests from Junit 4 to Junit Jupiter
Signed-off-by: Jiandong Ma <[email protected]>
1 parent b6be345 commit 2467370

32 files changed

+292
-257
lines changed

spring-integration-ip/src/test/java/org/springframework/integration/ip/config/TcpConnectionFactoryFactoryBeanTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2024 the original author or authors.
2+
* Copyright 2014-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
1616

1717
package org.springframework.integration.ip.config;
1818

19-
import org.junit.Test;
19+
import org.junit.jupiter.api.Test;
2020

2121
import org.springframework.beans.factory.BeanFactory;
2222
import org.springframework.integration.test.util.TestUtils;

spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/AutoStartTests.java

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,16 +16,14 @@
1616

1717
package org.springframework.integration.ip.tcp;
1818

19-
import org.junit.Test;
20-
import org.junit.runner.RunWith;
19+
import org.junit.jupiter.api.Test;
2120

2221
import org.springframework.beans.DirectFieldAccessor;
2322
import org.springframework.beans.factory.annotation.Autowired;
2423
import org.springframework.integration.ip.tcp.connection.AbstractServerConnectionFactory;
2524
import org.springframework.integration.ip.util.TestingUtilities;
2625
import org.springframework.test.annotation.DirtiesContext;
27-
import org.springframework.test.context.ContextConfiguration;
28-
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
26+
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
2927

3028
import static org.assertj.core.api.Assertions.assertThat;
3129

@@ -34,8 +32,7 @@
3432
* @since 2.1
3533
*
3634
*/
37-
@ContextConfiguration
38-
@RunWith(SpringJUnit4ClassRunner.class)
35+
@SpringJUnitConfig
3936
@DirtiesContext
4037
public class AutoStartTests {
4138

spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/ClientModeControlBusTests.java

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,9 +18,8 @@
1818

1919
import java.time.Duration;
2020

21-
import org.junit.Before;
22-
import org.junit.Test;
23-
import org.junit.runner.RunWith;
21+
import org.junit.jupiter.api.BeforeEach;
22+
import org.junit.jupiter.api.Test;
2423

2524
import org.springframework.beans.factory.annotation.Autowired;
2625
import org.springframework.integration.ip.tcp.connection.AbstractClientConnectionFactory;
@@ -29,8 +28,7 @@
2928
import org.springframework.integration.test.util.TestUtils;
3029
import org.springframework.scheduling.TaskScheduler;
3130
import org.springframework.test.annotation.DirtiesContext;
32-
import org.springframework.test.context.ContextConfiguration;
33-
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
31+
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
3432

3533
import static org.assertj.core.api.Assertions.assertThat;
3634
import static org.awaitility.Awaitility.await;
@@ -40,8 +38,7 @@
4038
* @since 2.1
4139
*
4240
*/
43-
@ContextConfiguration
44-
@RunWith(SpringJUnit4ClassRunner.class)
41+
@SpringJUnitConfig
4542
@DirtiesContext
4643
public class ClientModeControlBusTests {
4744

@@ -60,7 +57,7 @@ public class ClientModeControlBusTests {
6057
@Autowired
6158
TaskScheduler taskScheduler; // default
6259

63-
@Before
60+
@BeforeEach
6461
public void before() {
6562
TestingUtilities.waitListening(this.server, null);
6663
this.client.setPort(this.server.getPort());

spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/ConnectionToConnectionTests.java

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,10 +18,9 @@
1818

1919
import java.util.Properties;
2020

21-
import org.junit.FixMethodOrder;
22-
import org.junit.Test;
23-
import org.junit.runner.RunWith;
24-
import org.junit.runners.MethodSorters;
21+
import org.junit.jupiter.api.MethodOrderer.MethodName;
22+
import org.junit.jupiter.api.Test;
23+
import org.junit.jupiter.api.TestMethodOrder;
2524

2625
import org.springframework.beans.factory.annotation.Autowired;
2726
import org.springframework.context.ConfigurableApplicationContext;
@@ -42,8 +41,7 @@
4241
import org.springframework.integration.test.util.TestUtils;
4342
import org.springframework.messaging.Message;
4443
import org.springframework.test.annotation.DirtiesContext;
45-
import org.springframework.test.context.ContextConfiguration;
46-
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
44+
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
4745

4846
import static org.assertj.core.api.Assertions.assertThat;
4947

@@ -53,9 +51,8 @@
5351
* @since 2.0
5452
*
5553
*/
56-
@ContextConfiguration
57-
@RunWith(SpringJUnit4ClassRunner.class)
58-
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
54+
@SpringJUnitConfig
55+
@TestMethodOrder(MethodName.class)
5956
@DirtiesContext
6057
public class ConnectionToConnectionTests {
6158

spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/FactoryStopStartTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
1616

1717
package org.springframework.integration.ip.tcp;
1818

19-
import org.junit.Test;
19+
import org.junit.jupiter.api.Test;
2020

2121
import org.springframework.integration.ip.tcp.connection.AbstractServerConnectionFactory;
2222
import org.springframework.integration.ip.tcp.connection.TcpNetServerConnectionFactory;

spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/SharedConnectionTests.java

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,8 +18,7 @@
1818

1919
import java.util.Properties;
2020

21-
import org.junit.Test;
22-
import org.junit.runner.RunWith;
21+
import org.junit.jupiter.api.Test;
2322

2423
import org.springframework.beans.factory.annotation.Autowired;
2524
import org.springframework.context.support.AbstractApplicationContext;
@@ -34,17 +33,15 @@
3433
import org.springframework.messaging.Message;
3534
import org.springframework.messaging.MessageChannel;
3635
import org.springframework.test.annotation.DirtiesContext;
37-
import org.springframework.test.context.ContextConfiguration;
38-
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
36+
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
3937

4038
import static org.assertj.core.api.Assertions.assertThat;
4139

4240
/**
4341
* @author Gary Russell
4442
* @since 2.0
4543
*/
46-
@ContextConfiguration
47-
@RunWith(SpringJUnit4ClassRunner.class)
44+
@SpringJUnitConfig
4845
@DirtiesContext
4946
public class SharedConnectionTests {
5047

spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/TcpConfigInboundGatewayTests.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,16 +23,15 @@
2323

2424
import javax.net.SocketFactory;
2525

26-
import org.junit.Test;
27-
import org.junit.runner.RunWith;
26+
import org.junit.jupiter.api.Test;
2827

2928
import org.springframework.beans.factory.annotation.Autowired;
3029
import org.springframework.beans.factory.annotation.Qualifier;
3130
import org.springframework.integration.ip.tcp.connection.AbstractClientConnectionFactory;
3231
import org.springframework.integration.ip.tcp.connection.AbstractServerConnectionFactory;
3332
import org.springframework.integration.ip.tcp.serializer.ByteArrayStxEtxSerializer;
3433
import org.springframework.test.annotation.DirtiesContext;
35-
import org.springframework.test.context.junit4.SpringRunner;
34+
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
3635

3736
import static org.assertj.core.api.Assertions.assertThat;
3837

@@ -42,7 +41,7 @@
4241
*
4342
* @since 2.0
4443
*/
45-
@RunWith(SpringRunner.class)
44+
@SpringJUnitConfig
4645
@DirtiesContext
4746
public class TcpConfigInboundGatewayTests {
4847

spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/TcpConfigOutboundGatewayTests.java

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,9 +18,8 @@
1818

1919
import java.util.Map;
2020

21-
import org.junit.Before;
22-
import org.junit.Test;
23-
import org.junit.runner.RunWith;
21+
import org.junit.jupiter.api.BeforeEach;
22+
import org.junit.jupiter.api.Test;
2423

2524
import org.springframework.beans.factory.annotation.Autowired;
2625
import org.springframework.beans.factory.annotation.Qualifier;
@@ -35,8 +34,7 @@
3534
import org.springframework.messaging.PollableChannel;
3635
import org.springframework.messaging.SubscribableChannel;
3736
import org.springframework.test.annotation.DirtiesContext;
38-
import org.springframework.test.context.ContextConfiguration;
39-
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
37+
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
4038

4139
import static org.assertj.core.api.Assertions.assertThat;
4240
import static org.assertj.core.api.Assertions.fail;
@@ -46,8 +44,7 @@
4644
* @author Artem Bilan
4745
* @since 2.0
4846
*/
49-
@ContextConfiguration
50-
@RunWith(SpringJUnit4ClassRunner.class)
47+
@SpringJUnitConfig
5148
@DirtiesContext
5249
public class TcpConfigOutboundGatewayTests {
5350

@@ -123,7 +120,7 @@ public class TcpConfigOutboundGatewayTests {
123120
@Autowired
124121
MessageChannel tcpOutboundGatewayInsideChain;
125122

126-
@Before
123+
@BeforeEach
127124
public void before() {
128125
if (initializedFactories) {
129126
return;

spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/TcpSendingNoSocketTests.java

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,16 +16,14 @@
1616

1717
package org.springframework.integration.ip.tcp;
1818

19-
import org.junit.Test;
20-
import org.junit.runner.RunWith;
19+
import org.junit.jupiter.api.Test;
2120

2221
import org.springframework.beans.factory.annotation.Autowired;
2322
import org.springframework.messaging.MessageChannel;
2423
import org.springframework.messaging.MessageHandlingException;
2524
import org.springframework.messaging.support.GenericMessage;
2625
import org.springframework.test.annotation.DirtiesContext;
27-
import org.springframework.test.context.ContextConfiguration;
28-
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
26+
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
2927

3028
import static org.assertj.core.api.Assertions.assertThat;
3129
import static org.assertj.core.api.Assertions.fail;
@@ -35,8 +33,7 @@
3533
* @since 2.2
3634
*
3735
*/
38-
@ContextConfiguration
39-
@RunWith(SpringJUnit4ClassRunner.class)
36+
@SpringJUnitConfig
4037
@DirtiesContext
4138
public class TcpSendingNoSocketTests {
4239

spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/ConnectionTimeoutTests.java

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,14 +21,13 @@
2121
import java.util.concurrent.TimeUnit;
2222
import java.util.concurrent.atomic.AtomicReference;
2323

24-
import org.junit.Rule;
25-
import org.junit.Test;
24+
import org.junit.jupiter.api.Test;
2625

2726
import org.springframework.context.ApplicationEvent;
2827
import org.springframework.context.ApplicationEventPublisher;
2928
import org.springframework.integration.ip.util.TestingUtilities;
3029
import org.springframework.integration.support.MessageBuilder;
31-
import org.springframework.integration.test.support.LongRunningIntegrationTest;
30+
import org.springframework.integration.test.condition.LongRunningTest;
3231
import org.springframework.integration.test.util.TestUtils;
3332
import org.springframework.messaging.Message;
3433
import org.springframework.messaging.support.ErrorMessage;
@@ -39,11 +38,9 @@
3938
* @author Gary Russell
4039
* @since 2.2
4140
*/
41+
@LongRunningTest
4242
public class ConnectionTimeoutTests {
4343

44-
@Rule
45-
public LongRunningIntegrationTest longTests = new LongRunningIntegrationTest();
46-
4744
@Test
4845
public void testDefaultTimeout() throws Exception {
4946
TcpNetServerConnectionFactory server = new TcpNetServerConnectionFactory(0);

spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/PushbackTcpTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2022 the original author or authors.
2+
* Copyright 2017-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@
2222
import java.time.Duration;
2323
import java.util.Collections;
2424

25-
import org.junit.Test;
25+
import org.junit.jupiter.api.Test;
2626

2727
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
2828
import org.springframework.context.annotation.Bean;

0 commit comments

Comments
 (0)