Skip to content
This repository was archived by the owner on Mar 30, 2023. It is now read-only.

Commit 7c6edee

Browse files
committed
Upgrade to latest GAs
* Move all the test to JUnit 5; remove redundant JUnit 4 dependencies
1 parent 7e38788 commit 7c6edee

11 files changed

Lines changed: 527 additions & 519 deletions

File tree

build.gradle

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,12 @@ compileTestKotlin {
5555
}
5656

5757
ext {
58-
assertkVersion = '0.19'
58+
assertkVersion = '0.20'
5959
jacksonVersion = '2.10.0'
60-
junitJupiterVersion = '5.5.1'
61-
junitPlatformVersion = '1.5.1'
60+
junitJupiterVersion = '5.5.2'
6261
log4jVersion = '2.12.1'
63-
springIntegrationVersion = '5.2.0.BUILD-SNAPSHOT'
64-
springKafkaVersion = '2.3.0.BUILD-SNAPSHOT'
62+
springIntegrationVersion = '5.2.0.RELEASE'
63+
springKafkaVersion = '2.3.0.RELEASE'
6564

6665
idPrefix = 'kafka'
6766

@@ -86,37 +85,36 @@ dependencyManagement {
8685
}
8786
imports {
8887
mavenBom "com.fasterxml.jackson:jackson-bom:$jacksonVersion"
88+
mavenBom "org.junit:junit-bom:$junitJupiterVersion"
89+
mavenBom "org.springframework.integration:spring-integration-bom:$springIntegrationVersion"
8990
}
9091
}
9192

9293

9394
eclipse.project.natures += 'org.springframework.ide.eclipse.core.springnature'
9495

9596
jacoco {
96-
toolVersion = "0.8.4"
97+
toolVersion = '0.8.4'
9798
}
9899

99100
dependencies {
100-
compile "org.springframework.integration:spring-integration-core:$springIntegrationVersion"
101+
compile 'org.springframework.integration:spring-integration-core'
101102
compile "org.springframework.kafka:spring-kafka:$springKafkaVersion"
102103

103104
testCompile "org.springframework.kafka:spring-kafka-test:$springKafkaVersion"
104-
testCompile "org.springframework.integration:spring-integration-test:$springIntegrationVersion"
105+
testCompile 'org.springframework.integration:spring-integration-test'
105106
testCompile "com.willowtreeapps.assertk:assertk-jvm:$assertkVersion"
106-
testCompile "org.jetbrains.kotlin:kotlin-reflect"
107-
testCompile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
108-
testCompile "org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion"
109-
testRuntime "org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion"
110-
testRuntime "org.junit.platform:junit-platform-launcher:$junitPlatformVersion"
111-
112-
// To support JUnit 4 tests
113-
testRuntime "org.junit.vintage:junit-vintage-engine:$junitJupiterVersion"
107+
testCompile 'org.jetbrains.kotlin:kotlin-reflect'
108+
testCompile 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
109+
testCompile 'org.junit.jupiter:junit-jupiter-api'
110+
testRuntime 'org.junit.jupiter:junit-jupiter-engine'
111+
testRuntime 'org.junit.platform:junit-platform-launcher'
114112

115113
// To avoid compiler warnings about @API annotations in JUnit code
116114
testCompileOnly 'org.apiguardian:apiguardian-api:1.0.0'
117115

118-
testRuntime "com.fasterxml.jackson.core:jackson-core"
119-
testRuntime "com.fasterxml.jackson.core:jackson-databind"
116+
testRuntime 'com.fasterxml.jackson.core:jackson-core'
117+
testRuntime 'com.fasterxml.jackson.core:jackson-databind'
120118
testRuntime "org.apache.logging.log4j:log4j-slf4j-impl:$log4jVersion"
121119
}
122120

@@ -126,7 +124,7 @@ dependencies {
126124
test {
127125
// suppress all console output during testing unless running `gradle -i`
128126
logging.captureStandardOutput(LogLevel.INFO)
129-
maxHeapSize = "1024m"
127+
maxHeapSize = '1024m'
130128
jacoco {
131129
append = false
132130
destinationFile = file("$buildDir/jacoco.exec")
@@ -135,7 +133,7 @@ test {
135133
}
136134

137135
checkstyle {
138-
configFile = new File(rootDir, "src/checkstyle/checkstyle.xml")
136+
configFile = new File(rootDir, 'src/checkstyle/checkstyle.xml')
139137
toolVersion = '8.24'
140138
}
141139

@@ -211,13 +209,13 @@ artifacts {
211209

212210
sonarqube {
213211
properties {
214-
property "sonar.jacoco.reportPath", "${buildDir.name}/jacoco.exec"
215-
property "sonar.links.homepage", linkHomepage
216-
property "sonar.links.ci", linkCi
217-
property "sonar.links.issue", linkIssue
218-
property "sonar.links.scm", linkScmUrl
219-
property "sonar.links.scm_dev", linkScmDevConnection
220-
property "sonar.java.coveragePlugin", "jacoco"
212+
property 'sonar.jacoco.reportPath', "${buildDir.name}/jacoco.exec"
213+
property 'sonar.links.homepage', linkHomepage
214+
property 'sonar.links.ci', linkCi
215+
property 'sonar.links.issue', linkIssue
216+
property 'sonar.links.scm', linkScmUrl
217+
property 'sonar.links.scm_dev', linkScmDevConnection
218+
property 'sonar.java.coveragePlugin', 'jacoco'
221219
}
222220
}
223221

@@ -232,7 +230,7 @@ task api(type: Javadoc) {
232230

233231
source = sourceSets.main.allJava
234232
classpath = project.sourceSets.main.compileClasspath
235-
destinationDir = new File(buildDir, "api")
233+
destinationDir = new File(buildDir, 'api')
236234
}
237235

238236
task schemaZip(type: Zip) {

publish-maven.gradle

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,26 @@ def customizePom(pom, gradleProject) {
5757

5858
scm {
5959
url = linkScmUrl
60-
connection = 'scm:git:' + linkScmConnection
61-
developerConnection = 'scm:git:' + linkScmDevConnection
60+
connection = "scm:git:$linkScmConnection"
61+
developerConnection = "scm:git:$linkScmDevConnection"
62+
}
63+
64+
issueManagement {
65+
system = 'GutHub'
66+
url = linkIssue
6267
}
6368

6469
developers {
6570
developer {
66-
id = 'schacko'
67-
name = 'Soby Chacko'
68-
email = 'schacko@pivotal.io'
71+
id = 'garyrussell'
72+
name = 'Gary Russell'
73+
email = 'grussell@pivotal.io'
74+
roles = ['project lead']
75+
}
76+
developer {
77+
id = 'abilan'
78+
name = 'Artem Bilan'
79+
email = 'abilan@pivotal.io'
6980
}
7081
}
7182
}

src/test/java/org/springframework/integration/kafka/config/xml/KafkaMessageDrivenChannelAdapterParserTests.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121

2222
import java.util.Collections;
2323

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

2726
import org.springframework.beans.factory.annotation.Autowired;
2827
import org.springframework.integration.channel.NullChannel;
@@ -40,16 +39,16 @@
4039
import org.springframework.kafka.listener.adapter.RetryingMessageListenerAdapter;
4140
import org.springframework.retry.RecoveryCallback;
4241
import org.springframework.retry.support.RetryTemplate;
43-
import org.springframework.test.context.ContextConfiguration;
44-
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
42+
import org.springframework.test.annotation.DirtiesContext;
43+
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
4544

4645
/**
4746
* @author Artem Bilan.
4847
* @author Gary Russell
4948
*/
50-
@RunWith(SpringJUnit4ClassRunner.class)
51-
@ContextConfiguration
52-
public class KafkaMessageDrivenChannelAdapterParserTests {
49+
@SpringJUnitConfig
50+
@DirtiesContext
51+
class KafkaMessageDrivenChannelAdapterParserTests {
5352

5453
@Autowired
5554
private NullChannel nullChannel;
@@ -73,7 +72,7 @@ public class KafkaMessageDrivenChannelAdapterParserTests {
7372
private RecoveryCallback<?> recoveryCallback;
7473

7574
@Test
76-
public void testKafkaMessageDrivenChannelAdapterParser() {
75+
void testKafkaMessageDrivenChannelAdapterParser() {
7776
assertThat(this.kafkaListener.isAutoStartup()).isFalse();
7877
assertThat(this.kafkaListener.isRunning()).isFalse();
7978
assertThat(this.kafkaListener.getPhase()).isEqualTo(100);
@@ -94,7 +93,7 @@ public void testKafkaMessageDrivenChannelAdapterParser() {
9493
}
9594

9695
@Test
97-
public void testKafkaBatchMessageDrivenChannelAdapterParser() {
96+
void testKafkaBatchMessageDrivenChannelAdapterParser() {
9897
assertThat(this.kafkaBatchListener.isAutoStartup()).isFalse();
9998
assertThat(this.kafkaBatchListener.isRunning()).isFalse();
10099
assertThat(this.kafkaBatchListener.getPhase()).isEqualTo(100);
@@ -110,7 +109,7 @@ public void testKafkaBatchMessageDrivenChannelAdapterParser() {
110109

111110
@Test
112111
@SuppressWarnings("unchecked")
113-
public void testKafkaMessageDrivenChannelAdapterOptions() {
112+
void testKafkaMessageDrivenChannelAdapterOptions() {
114113
DefaultKafkaConsumerFactory<Integer, String> cf =
115114
new DefaultKafkaConsumerFactory<>(Collections.emptyMap());
116115
ContainerProperties containerProps = new ContainerProperties("foo");

src/test/java/org/springframework/integration/kafka/config/xml/KafkaOutboundAdapterParserTests.java

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package org.springframework.integration.kafka.config.xml;
1818

1919
import static org.assertj.core.api.Assertions.assertThat;
20-
import static org.junit.Assert.fail;
20+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
2121
import static org.mockito.ArgumentMatchers.isNull;
2222
import static org.mockito.BDDMockito.given;
2323
import static org.mockito.Mockito.mock;
@@ -29,8 +29,7 @@
2929
import org.apache.kafka.clients.producer.MockProducer;
3030
import org.apache.kafka.common.serialization.IntegerSerializer;
3131
import org.apache.kafka.common.serialization.StringSerializer;
32-
import org.junit.Test;
33-
import org.junit.runner.RunWith;
32+
import org.junit.jupiter.api.Test;
3433

3534
import org.springframework.beans.factory.BeanFactory;
3635
import org.springframework.beans.factory.annotation.Autowired;
@@ -45,8 +44,7 @@
4544
import org.springframework.messaging.MessageHandlingException;
4645
import org.springframework.messaging.support.GenericMessage;
4746
import org.springframework.test.annotation.DirtiesContext;
48-
import org.springframework.test.context.ContextConfiguration;
49-
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
47+
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
5048

5149
/**
5250
* @author Soby Chacko
@@ -57,18 +55,17 @@
5755
*
5856
* @since 0.5
5957
*/
60-
@RunWith(SpringJUnit4ClassRunner.class)
61-
@ContextConfiguration
58+
@SpringJUnitConfig
6259
@DirtiesContext
63-
public class KafkaOutboundAdapterParserTests {
60+
class KafkaOutboundAdapterParserTests {
6461

6562
@Autowired
6663
private ApplicationContext appContext;
6764

6865
@Test
69-
public void testOutboundAdapterConfiguration() {
66+
void testOutboundAdapterConfiguration() {
7067
KafkaProducerMessageHandler<?, ?> messageHandler
71-
= this.appContext.getBean("kafkaOutboundChannelAdapter.handler", KafkaProducerMessageHandler.class);
68+
= this.appContext.getBean("kafkaOutboundChannelAdapter.handler", KafkaProducerMessageHandler.class);
7269
assertThat(messageHandler).isNotNull();
7370
assertThat(messageHandler.getOrder()).isEqualTo(3);
7471
assertThat(TestUtils.getPropertyValue(messageHandler, "topicExpression.literalValue")).isEqualTo("foo");
@@ -98,7 +95,7 @@ public void testOutboundAdapterConfiguration() {
9895
}
9996

10097
@Test
101-
public void testSyncMode() {
98+
void testSyncMode() {
10299
MockProducer<Integer, String> mockProducer =
103100
new MockProducer<Integer, String>(false, new IntegerSerializer(), new StringSerializer()) {
104101

@@ -128,28 +125,18 @@ public void close(Duration timeout) {
128125
return null;
129126
});
130127

131-
try {
132-
handler.handleMessage(new GenericMessage<>("foo"));
133-
fail("MessageHandlingException expected");
134-
}
135-
catch (Exception e) {
136-
assertThat(e).isInstanceOf(MessageHandlingException.class);
137-
assertThat(e.getCause()).isExactlyInstanceOf(KafkaProducerException.class);
138-
assertThat(e.getCause().getCause()).isInstanceOf(RuntimeException.class);
139-
assertThat(e.getMessage()).contains("Async Producer Mock exception");
140-
}
128+
assertThatExceptionOfType(MessageHandlingException.class)
129+
.isThrownBy(() -> handler.handleMessage(new GenericMessage<>("foo")))
130+
.withCauseInstanceOf(KafkaProducerException.class)
131+
.withRootCauseInstanceOf(RuntimeException.class)
132+
.withMessageContaining("Async Producer Mock exception");
141133

142134
handler.setSendTimeout(1);
143135

144-
try {
145-
handler.handleMessage(new GenericMessage<>("foo"));
146-
fail("MessageTimeoutException expected");
147-
}
148-
catch (Exception e) {
149-
assertThat(e).isInstanceOf(MessageTimeoutException.class);
150-
assertThat(e.getCause()).isExactlyInstanceOf(TimeoutException.class);
151-
assertThat(e.getMessage()).contains("Timeout waiting for response from KafkaProducer");
152-
}
136+
assertThatExceptionOfType(MessageTimeoutException.class)
137+
.isThrownBy(() -> handler.handleMessage(new GenericMessage<>("foo")))
138+
.withCauseInstanceOf(TimeoutException.class)
139+
.withMessageContaining("Timeout waiting for response from KafkaProducer");
153140
}
154141

155142
}

0 commit comments

Comments
 (0)