Skip to content

Commit 4faeec0

Browse files
committed
migrate to Junit Jupiter.
including: `spring-integration-http`, `spring-integration-jdbc`, `spring-integration-jms` Signed-off-by: Jiandong Ma <[email protected]>
1 parent d9fbf04 commit 4faeec0

File tree

34 files changed

+170
-188
lines changed

34 files changed

+170
-188
lines changed

spring-integration-amqp/src/test/java/org/springframework/integration/amqp/inbound/ManualAckTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,14 @@
4747

4848
import static org.assertj.core.api.Assertions.assertThat;
4949
import static org.mockito.Mockito.mock;
50-
import static org.springframework.integration.amqp.inbound.ManualAckTests.ManualAckConfig;
5150

5251
/**
5352
* @author Gary Russell
5453
* @since 4.0
5554
*
5655
*/
5756
@RabbitAvailable
58-
@SpringJUnitConfig(ManualAckConfig.class)
57+
@SpringJUnitConfig(ManualAckTests.ManualAckConfig.class)
5958
@DirtiesContext
6059
public class ManualAckTests {
6160

spring-integration-file/src/test/java/org/springframework/integration/file/tail/FileTailingMessageProducerTests.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.junit.jupiter.api.AfterEach;
2929
import org.junit.jupiter.api.BeforeEach;
3030
import org.junit.jupiter.api.Test;
31-
import org.junit.jupiter.api.extension.ExtendWith;
3231

3332
import org.springframework.beans.DirectFieldAccessor;
3433
import org.springframework.beans.factory.BeanFactory;
@@ -53,7 +52,6 @@
5352
*
5453
* @since 3.0
5554
*/
56-
@ExtendWith(TailCondition.class)
5755
public class FileTailingMessageProducerTests {
5856

5957
private static final String TAIL_OPTIONS_FOLLOW_NAME_ALL_LINES = "-F -n +0";

spring-integration-file/src/test/java/org/springframework/integration/file/tail/TailAvailable.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@
2121
import java.lang.annotation.RetentionPolicy;
2222
import java.lang.annotation.Target;
2323

24+
import org.junit.jupiter.api.extension.ExtendWith;
25+
2426
/**
2527
* @author Gary Russell
2628
* @since 3.0
2729
*
2830
*/
31+
@ExtendWith(TailCondition.class)
2932
@Retention(RetentionPolicy.RUNTIME)
3033
@Target({ElementType.METHOD})
3134
public @interface TailAvailable {

spring-integration-file/src/test/java/org/springframework/integration/file/tail/TailCondition.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2025 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.

spring-integration-http/src/test/java/org/springframework/integration/http/config/ChainElementsTests.java

Lines changed: 2 additions & 2 deletions
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.
@@ -19,7 +19,7 @@
1919
import java.io.ByteArrayInputStream;
2020
import java.util.Properties;
2121

22-
import org.junit.Test;
22+
import org.junit.jupiter.api.Test;
2323

2424
import org.springframework.beans.factory.config.PropertiesFactoryBean;
2525
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;

spring-integration-http/src/test/java/org/springframework/integration/http/config/HttpOutboundGatewayWithMethodExpressionTests.java

Lines changed: 11 additions & 13 deletions
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.
@@ -16,9 +16,8 @@
1616

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

19-
import org.junit.Before;
20-
import org.junit.Test;
21-
import org.junit.runner.RunWith;
19+
import org.junit.jupiter.api.BeforeEach;
20+
import org.junit.jupiter.api.Test;
2221

2322
import org.springframework.beans.factory.annotation.Autowired;
2423
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
@@ -30,12 +29,12 @@
3029
import org.springframework.messaging.PollableChannel;
3130
import org.springframework.messaging.support.GenericMessage;
3231
import org.springframework.test.annotation.DirtiesContext;
33-
import org.springframework.test.context.ContextConfiguration;
34-
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
32+
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
3533
import org.springframework.test.web.client.MockRestServiceServer;
3634
import org.springframework.web.client.RestTemplate;
3735

3836
import static org.assertj.core.api.Assertions.assertThat;
37+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
3938
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
4039
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
4140
import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
@@ -44,8 +43,7 @@
4443
* @author Oleg Zhurakousky
4544
* @author Artem Bilan
4645
*/
47-
@RunWith(SpringJUnit4ClassRunner.class)
48-
@ContextConfiguration
46+
@SpringJUnitConfig
4947
@DirtiesContext
5048
public class HttpOutboundGatewayWithMethodExpressionTests {
5149

@@ -63,7 +61,7 @@ public class HttpOutboundGatewayWithMethodExpressionTests {
6361

6462
private MockRestServiceServer mockServer;
6563

66-
@Before
64+
@BeforeEach
6765
public void setup() {
6866
this.mockServer = MockRestServiceServer.createServer(this.restTemplate);
6967
}
@@ -96,11 +94,11 @@ public void testExplicitlySetMethod() {
9694
this.mockServer.verify();
9795
}
9896

99-
@Test(expected = BeanDefinitionParsingException.class)
97+
@Test
10098
public void testMutuallyExclusivityInMethodAndMethodExpression() {
101-
new ClassPathXmlApplicationContext(
102-
"http-outbound-gateway-with-httpmethod-expression-fail.xml", getClass())
103-
.close();
99+
assertThatExceptionOfType(BeanDefinitionParsingException.class)
100+
.isThrownBy(() -> new ClassPathXmlApplicationContext(
101+
"http-outbound-gateway-with-httpmethod-expression-fail.xml", getClass()));
104102
}
105103

106104
}

spring-integration-http/src/test/java/org/springframework/integration/http/outbound/UriVariableExpressionTests.java

Lines changed: 2 additions & 2 deletions
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.
@@ -22,7 +22,7 @@
2222
import java.util.Map;
2323
import java.util.concurrent.atomic.AtomicReference;
2424

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

2727
import org.springframework.beans.factory.BeanFactory;
2828
import org.springframework.beans.factory.support.BeanDefinitionRegistry;

spring-integration-http/src/test/java/org/springframework/integration/http/support/DefaultHttpHeaderMapperFromMessageOutboundTests.java

Lines changed: 22 additions & 12 deletions
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.
@@ -29,8 +29,8 @@
2929
import java.util.Map;
3030
import java.util.TimeZone;
3131

32-
import org.junit.Ignore;
33-
import org.junit.Test;
32+
import org.junit.jupiter.api.Disabled;
33+
import org.junit.jupiter.api.Test;
3434

3535
import org.springframework.http.HttpHeaders;
3636
import org.springframework.http.MediaType;
@@ -42,6 +42,8 @@
4242
import org.springframework.util.StopWatch;
4343

4444
import static org.assertj.core.api.Assertions.assertThat;
45+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
46+
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
4547

4648
/**
4749
* @author Oleg Zhurakousky
@@ -55,14 +57,16 @@
5557
public class DefaultHttpHeaderMapperFromMessageOutboundTests {
5658

5759
// ACCEPT tests
58-
@Test(expected = IllegalArgumentException.class)
60+
@Test
5961
public void validateAcceptHeaderWithNoSlash() {
6062
HeaderMapper<HttpHeaders> mapper = DefaultHttpHeaderMapper.outboundMapper();
6163
Map<String, Object> messageHeaders = new HashMap<>();
6264
messageHeaders.put("Accept", "bar");
6365
HttpHeaders headers = new HttpHeaders();
6466

65-
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
67+
MessageHeaders messageHeadersObj = new MessageHeaders(messageHeaders);
68+
assertThatIllegalArgumentException()
69+
.isThrownBy(() -> mapper.fromHeaders(messageHeadersObj, headers));
6670
}
6771

6872
@Test
@@ -158,13 +162,15 @@ public void validateAcceptHeaderMultipleAsMediaTypeCollection() {
158162

159163
// ACCEPT_CHARSET tests
160164

161-
@Test(expected = UnsupportedCharsetException.class)
165+
@Test
162166
public void validateAcceptCharsetHeaderWithWrongCharset() {
163167
HeaderMapper<HttpHeaders> mapper = DefaultHttpHeaderMapper.outboundMapper();
164168
Map<String, Object> messageHeaders = new HashMap<>();
165169
messageHeaders.put("Accept-Charset", "foo");
166170
HttpHeaders headers = new HttpHeaders();
167-
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
171+
MessageHeaders messageHeadersObj = new MessageHeaders(messageHeaders);
172+
assertThatExceptionOfType(UnsupportedCharsetException.class)
173+
.isThrownBy(() -> mapper.fromHeaders(messageHeadersObj, headers));
168174
}
169175

170176
@Test
@@ -298,26 +304,30 @@ public void validateContentLengthAsNumber() {
298304
assertThat(headers.getContentLength()).isEqualTo(1);
299305
}
300306

301-
@Test(expected = NumberFormatException.class)
307+
@Test
302308
public void validateContentLengthAsNonNumericString() {
303309
HeaderMapper<HttpHeaders> mapper = DefaultHttpHeaderMapper.outboundMapper();
304310
Map<String, Object> messageHeaders = new HashMap<>();
305311
messageHeaders.put("Content-Length", "foo");
306312
HttpHeaders headers = new HttpHeaders();
307313

308-
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
314+
MessageHeaders messageHeadersObj = new MessageHeaders(messageHeaders);
315+
assertThatExceptionOfType(NumberFormatException.class)
316+
.isThrownBy(() -> mapper.fromHeaders(messageHeadersObj, headers));
309317
}
310318

311319
// Content-Type test
312320

313-
@Test(expected = IllegalArgumentException.class)
321+
@Test
314322
public void validateContentTypeWrongValue() {
315323
HeaderMapper<HttpHeaders> mapper = DefaultHttpHeaderMapper.outboundMapper();
316324
Map<String, Object> messageHeaders = new HashMap<>();
317325
messageHeaders.put(MessageHeaders.CONTENT_TYPE, "foo");
318326
HttpHeaders headers = new HttpHeaders();
319327

320-
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
328+
MessageHeaders messageHeadersObj = new MessageHeaders(messageHeaders);
329+
assertThatIllegalArgumentException()
330+
.isThrownBy(() -> mapper.fromHeaders(messageHeadersObj, headers));
321331
}
322332

323333
@Test
@@ -542,7 +552,7 @@ public void validateTransferEncodingToHeaders() {
542552
}
543553

544554
@Test
545-
@Ignore
555+
@Disabled
546556
public void perf() {
547557
HeaderMapper<HttpHeaders> mapper = DefaultHttpHeaderMapper.outboundMapper();
548558

spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/JdbcOutboundGatewayTests.java

Lines changed: 6 additions & 6 deletions
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.
@@ -16,9 +16,9 @@
1616

1717
package org.springframework.integration.jdbc;
1818

19-
import org.junit.AfterClass;
20-
import org.junit.BeforeClass;
21-
import org.junit.Test;
19+
import org.junit.jupiter.api.AfterAll;
20+
import org.junit.jupiter.api.BeforeAll;
21+
import org.junit.jupiter.api.Test;
2222

2323
import org.springframework.beans.factory.BeanFactory;
2424
import org.springframework.jdbc.core.JdbcOperations;
@@ -42,12 +42,12 @@ public class JdbcOutboundGatewayTests {
4242

4343
private static EmbeddedDatabase dataSource;
4444

45-
@BeforeClass
45+
@BeforeAll
4646
public static void setup() {
4747
dataSource = new EmbeddedDatabaseBuilder().build();
4848
}
4949

50-
@AfterClass
50+
@AfterAll
5151
public static void teardown() {
5252
dataSource.shutdown();
5353
}

spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/JdbcPollingChannelAdapterIntegrationTests.java

Lines changed: 8 additions & 8 deletions
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.
@@ -22,10 +22,10 @@
2222
import java.util.List;
2323
import java.util.Map;
2424

25-
import org.junit.After;
26-
import org.junit.AfterClass;
27-
import org.junit.BeforeClass;
28-
import org.junit.Test;
25+
import org.junit.jupiter.api.AfterAll;
26+
import org.junit.jupiter.api.AfterEach;
27+
import org.junit.jupiter.api.BeforeAll;
28+
import org.junit.jupiter.api.Test;
2929

3030
import org.springframework.beans.factory.BeanFactory;
3131
import org.springframework.jdbc.core.JdbcTemplate;
@@ -50,7 +50,7 @@ public class JdbcPollingChannelAdapterIntegrationTests {
5050

5151
private static JdbcTemplate jdbcTemplate;
5252

53-
@BeforeClass
53+
@BeforeAll
5454
public static void setUp() {
5555
EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
5656
builder.setType(EmbeddedDatabaseType.DERBY)
@@ -59,12 +59,12 @@ public static void setUp() {
5959
jdbcTemplate = new JdbcTemplate(embeddedDatabase);
6060
}
6161

62-
@AfterClass
62+
@AfterAll
6363
public static void tearDown() {
6464
embeddedDatabase.shutdown();
6565
}
6666

67-
@After
67+
@AfterEach
6868
public void cleanup() {
6969
jdbcTemplate.execute("DELETE FROM item");
7070
jdbcTemplate.execute("DELETE FROM copy");

spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/MessageGroupQueueTests.java

Lines changed: 4 additions & 7 deletions
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.
@@ -20,15 +20,14 @@
2020
import java.util.concurrent.atomic.AtomicReference;
2121

2222
import org.apache.commons.logging.LogFactory;
23-
import org.junit.ClassRule;
24-
import org.junit.Test;
23+
import org.junit.jupiter.api.Test;
2524
import org.mockito.Mockito;
2625

2726
import org.springframework.integration.store.MessageGroup;
2827
import org.springframework.integration.store.MessageGroupQueue;
2928
import org.springframework.integration.store.MessageGroupStore;
3029
import org.springframework.integration.store.SimpleMessageStore;
31-
import org.springframework.integration.test.support.LongRunningIntegrationTest;
30+
import org.springframework.integration.test.condition.LongRunningTest;
3231
import org.springframework.messaging.Message;
3332
import org.springframework.messaging.support.GenericMessage;
3433

@@ -38,11 +37,9 @@
3837
* @author Oleg Zhurakousky
3938
* @author Artem Bilan
4039
*/
40+
@LongRunningTest
4141
public class MessageGroupQueueTests {
4242

43-
@ClassRule
44-
public static LongRunningIntegrationTest longTests = new LongRunningIntegrationTest();
45-
4643
@Test
4744
public void validateMgqInterruption() throws Exception {
4845

spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/StoredProcExecutorTests.java

Lines changed: 2 additions & 2 deletions
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,7 +23,7 @@
2323

2424
import javax.sql.DataSource;
2525

26-
import org.junit.Test;
26+
import org.junit.jupiter.api.Test;
2727

2828
import org.springframework.beans.DirectFieldAccessor;
2929
import org.springframework.beans.factory.BeanFactory;

0 commit comments

Comments
 (0)