Skip to content

Commit a906643

Browse files
committed
Remove JUnit 4 dependency
* Rework remaining JUnit 4 tests to JUnit Jupiter * Migrate used yet JUnit 4 assertions to AssertJ * Re-generate POMs to reflect JUnit 4 removal
1 parent f1532cc commit a906643

File tree

117 files changed

+396
-1213
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+396
-1213
lines changed

advanced/advanced-testing-examples/pom.xml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,6 @@
7474
<version>2.24.3</version>
7575
<scope>compile</scope>
7676
</dependency>
77-
<dependency>
78-
<groupId>junit</groupId>
79-
<artifactId>junit</artifactId>
80-
<version>4.13.2</version>
81-
<scope>test</scope>
82-
</dependency>
8377
<dependency>
8478
<groupId>org.hamcrest</groupId>
8579
<artifactId>hamcrest-library</artifactId>
@@ -112,11 +106,6 @@
112106
<artifactId>junit-platform-launcher</artifactId>
113107
<scope>runtime</scope>
114108
</dependency>
115-
<dependency>
116-
<groupId>org.junit.vintage</groupId>
117-
<artifactId>junit-vintage-engine</artifactId>
118-
<scope>runtime</scope>
119-
</dependency>
120109
</dependencies>
121110
<dependencyManagement>
122111
<dependencies>

advanced/dynamic-ftp/pom.xml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,6 @@
6363
<version>2.24.3</version>
6464
<scope>compile</scope>
6565
</dependency>
66-
<dependency>
67-
<groupId>junit</groupId>
68-
<artifactId>junit</artifactId>
69-
<version>4.13.2</version>
70-
<scope>test</scope>
71-
</dependency>
7266
<dependency>
7367
<groupId>org.hamcrest</groupId>
7468
<artifactId>hamcrest-library</artifactId>
@@ -101,11 +95,6 @@
10195
<artifactId>junit-platform-launcher</artifactId>
10296
<scope>runtime</scope>
10397
</dependency>
104-
<dependency>
105-
<groupId>org.junit.vintage</groupId>
106-
<artifactId>junit-vintage-engine</artifactId>
107-
<scope>runtime</scope>
108-
</dependency>
10998
</dependencies>
11099
<dependencyManagement>
111100
<dependencies>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.springframework.integration.samples.ftp;
16+
package org.springframework.integration.samples.dynamicftp;
1717

1818
import java.util.HashMap;
1919
import java.util.LinkedHashMap;
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.springframework.integration.samples.ftp;
16+
package org.springframework.integration.samples.dynamicftp;
1717

18-
import static org.junit.Assert.*;
18+
import org.junit.jupiter.api.Test;
1919

20-
import org.junit.Test;
20+
import org.springframework.integration.samples.dynamicftp.DynamicFtpChannelResolver;
2121
import org.springframework.messaging.MessageChannel;
2222

23+
import static org.assertj.core.api.Assertions.assertThat;
24+
2325
/**
2426
* @author Gary Russell
2527
* @since 2.1
@@ -28,18 +30,17 @@
2830
public class DynamicFtpChannelResolverTests {
2931

3032
/**
31-
* Test method for {@link org.springframework.integration.samples.ftp.DynamicFtpChannelResolver#resolve(java.lang.String)}.
33+
* Test method for {@link DynamicFtpChannelResolver#resolve(java.lang.String)}.
3234
*/
3335
@Test
3436
public void testResolve() {
3537
DynamicFtpChannelResolver dynamicFtpChannelResolver = new DynamicFtpChannelResolver();
3638
MessageChannel channel1 = dynamicFtpChannelResolver.resolve("customer1");
37-
assertNotNull(channel1);
39+
assertThat(channel1).isNotNull();
3840
MessageChannel channel2 = dynamicFtpChannelResolver.resolve("customer2");
39-
assertNotNull(channel2);
40-
assertNotSame(channel1, channel2);
41+
assertThat(channel1).isNotSameAs(channel2);
4142
MessageChannel channel1a = dynamicFtpChannelResolver.resolve("customer1");
42-
assertSame(channel1, channel1a);
43+
assertThat(channel1).isSameAs(channel1a);
4344
}
4445

4546
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
* Copyright 2002-2014 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.integration.samples.dynamicftp;
17+
18+
import java.io.File;
19+
import java.net.UnknownHostException;
20+
21+
import org.junit.jupiter.api.Test;
22+
23+
import org.springframework.context.ConfigurableApplicationContext;
24+
import org.springframework.context.support.ClassPathXmlApplicationContext;
25+
import org.springframework.integration.support.MessageBuilder;
26+
import org.springframework.messaging.Message;
27+
import org.springframework.messaging.MessageChannel;
28+
import org.springframework.messaging.MessagingException;
29+
30+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
31+
32+
/**
33+
* @author Gary Russell
34+
* @author Amol Nayak
35+
* @author Artem Bilan
36+
*
37+
*/
38+
public class FtpOutboundChannelAdapterSampleTests {
39+
40+
@Test
41+
public void runDemo() throws Exception {
42+
ConfigurableApplicationContext ctx =
43+
new ClassPathXmlApplicationContext(
44+
"META-INF/spring/integration/DynamicFtpOutboundChannelAdapterSample-context.xml");
45+
MessageChannel channel = ctx.getBean("toDynRouter", MessageChannel.class);
46+
File file = File.createTempFile("temp", "txt");
47+
Message<File> message = MessageBuilder.withPayload(file)
48+
.setHeader("customer", "cust1")
49+
.build();
50+
51+
assertThatExceptionOfType(MessagingException.class)
52+
.isThrownBy(() -> channel.send(message))
53+
.withRootCauseInstanceOf(UnknownHostException.class)
54+
.withStackTraceContaining("host.for.cust1");
55+
56+
// send another so we can see in the log we don't create the ac again.
57+
assertThatExceptionOfType(MessagingException.class)
58+
.isThrownBy(() -> channel.send(message))
59+
.withRootCauseInstanceOf(UnknownHostException.class)
60+
.withStackTraceContaining("host.for.cust1");
61+
62+
// send to a different customer; again, check the log to see a new ac is built
63+
assertThatExceptionOfType(MessagingException.class)
64+
.isThrownBy(() -> channel.send(
65+
MessageBuilder.withPayload(file)
66+
.setHeader("customer", "cust2")
67+
.build()))
68+
.withRootCauseInstanceOf(UnknownHostException.class)
69+
.withStackTraceContaining("host.for.cust2");
70+
71+
// send to a different customer; again, check the log to see a new ac is built
72+
//and the first one created (cust1) should be closed and removed as per the max cache size restriction
73+
assertThatExceptionOfType(MessagingException.class)
74+
.isThrownBy(() -> channel.send(
75+
MessageBuilder.withPayload(file)
76+
.setHeader("customer", "cust3")
77+
.build()))
78+
.withRootCauseInstanceOf(UnknownHostException.class)
79+
.withStackTraceContaining("host.for.cust3");
80+
81+
//send to cust1 again, since this one has been invalidated before, we should
82+
//see a new ac created (with ac of cust2 destroyed and removed)
83+
assertThatExceptionOfType(MessagingException.class)
84+
.isThrownBy(() -> channel.send(
85+
MessageBuilder.withPayload(file)
86+
.setHeader("customer", "cust1")
87+
.build()))
88+
.withRootCauseInstanceOf(UnknownHostException.class)
89+
.withStackTraceContaining("host.for.cust1");
90+
91+
ctx.close();
92+
}
93+
94+
}

advanced/dynamic-ftp/src/test/java/org/springframework/integration/samples/ftp/FtpOutboundChannelAdapterSample.java

Lines changed: 0 additions & 104 deletions
This file was deleted.

advanced/dynamic-ftp/src/test/resources/META-INF/spring/integration/DynamicFtpOutboundChannelAdapterSample-context.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
88
http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">
99

10-
<bean id="channelResolver" class="org.springframework.integration.samples.ftp.DynamicFtpChannelResolver" />
10+
<bean id="channelResolver" class="org.springframework.integration.samples.dynamicftp.DynamicFtpChannelResolver" />
1111

1212
<int:channel id="toDynRouter" />
1313

advanced/dynamic-tcp-client/pom.xml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,6 @@
6363
<artifactId>spring-integration-ip</artifactId>
6464
<scope>compile</scope>
6565
</dependency>
66-
<dependency>
67-
<groupId>junit</groupId>
68-
<artifactId>junit</artifactId>
69-
<version>4.13.2</version>
70-
<scope>test</scope>
71-
</dependency>
7266
<dependency>
7367
<groupId>org.hamcrest</groupId>
7468
<artifactId>hamcrest-library</artifactId>
@@ -106,11 +100,6 @@
106100
<artifactId>junit-platform-launcher</artifactId>
107101
<scope>runtime</scope>
108102
</dependency>
109-
<dependency>
110-
<groupId>org.junit.vintage</groupId>
111-
<artifactId>junit-vintage-engine</artifactId>
112-
<scope>runtime</scope>
113-
</dependency>
114103
</dependencies>
115104
<dependencyManagement>
116105
<dependencies>

applications/cafe-scripted/pom.xml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,6 @@
102102
<version>2.24.3</version>
103103
<scope>compile</scope>
104104
</dependency>
105-
<dependency>
106-
<groupId>junit</groupId>
107-
<artifactId>junit</artifactId>
108-
<version>4.13.2</version>
109-
<scope>test</scope>
110-
</dependency>
111105
<dependency>
112106
<groupId>org.hamcrest</groupId>
113107
<artifactId>hamcrest-library</artifactId>
@@ -140,11 +134,6 @@
140134
<artifactId>junit-platform-launcher</artifactId>
141135
<scope>runtime</scope>
142136
</dependency>
143-
<dependency>
144-
<groupId>org.junit.vintage</groupId>
145-
<artifactId>junit-vintage-engine</artifactId>
146-
<scope>runtime</scope>
147-
</dependency>
148137
</dependencies>
149138
<dependencyManagement>
150139
<dependencies>

applications/cafe/cafe-amqp/pom.xml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,6 @@
6969
<version>2.24.3</version>
7070
<scope>compile</scope>
7171
</dependency>
72-
<dependency>
73-
<groupId>junit</groupId>
74-
<artifactId>junit</artifactId>
75-
<version>4.13.2</version>
76-
<scope>test</scope>
77-
</dependency>
7872
<dependency>
7973
<groupId>org.hamcrest</groupId>
8074
<artifactId>hamcrest-library</artifactId>
@@ -107,11 +101,6 @@
107101
<artifactId>junit-platform-launcher</artifactId>
108102
<scope>runtime</scope>
109103
</dependency>
110-
<dependency>
111-
<groupId>org.junit.vintage</groupId>
112-
<artifactId>junit-vintage-engine</artifactId>
113-
<scope>runtime</scope>
114-
</dependency>
115104
</dependencies>
116105
<dependencyManagement>
117106
<dependencies>

0 commit comments

Comments
 (0)