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

Commit

Permalink
Upgrade to latest GAs
Browse files Browse the repository at this point in the history
* Move all the test to JUnit 5; remove redundant JUnit 4 dependencies
  • Loading branch information
artembilan committed Oct 1, 2019
1 parent 7e38788 commit 7c6edee
Show file tree
Hide file tree
Showing 11 changed files with 527 additions and 519 deletions.
54 changes: 26 additions & 28 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,12 @@ compileTestKotlin {
}

ext {
assertkVersion = '0.19'
assertkVersion = '0.20'
jacksonVersion = '2.10.0'
junitJupiterVersion = '5.5.1'
junitPlatformVersion = '1.5.1'
junitJupiterVersion = '5.5.2'
log4jVersion = '2.12.1'
springIntegrationVersion = '5.2.0.BUILD-SNAPSHOT'
springKafkaVersion = '2.3.0.BUILD-SNAPSHOT'
springIntegrationVersion = '5.2.0.RELEASE'
springKafkaVersion = '2.3.0.RELEASE'

idPrefix = 'kafka'

Expand All @@ -86,37 +85,36 @@ dependencyManagement {
}
imports {
mavenBom "com.fasterxml.jackson:jackson-bom:$jacksonVersion"
mavenBom "org.junit:junit-bom:$junitJupiterVersion"
mavenBom "org.springframework.integration:spring-integration-bom:$springIntegrationVersion"
}
}


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

jacoco {
toolVersion = "0.8.4"
toolVersion = '0.8.4'
}

dependencies {
compile "org.springframework.integration:spring-integration-core:$springIntegrationVersion"
compile 'org.springframework.integration:spring-integration-core'
compile "org.springframework.kafka:spring-kafka:$springKafkaVersion"

testCompile "org.springframework.kafka:spring-kafka-test:$springKafkaVersion"
testCompile "org.springframework.integration:spring-integration-test:$springIntegrationVersion"
testCompile 'org.springframework.integration:spring-integration-test'
testCompile "com.willowtreeapps.assertk:assertk-jvm:$assertkVersion"
testCompile "org.jetbrains.kotlin:kotlin-reflect"
testCompile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
testCompile "org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion"
testRuntime "org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion"
testRuntime "org.junit.platform:junit-platform-launcher:$junitPlatformVersion"

// To support JUnit 4 tests
testRuntime "org.junit.vintage:junit-vintage-engine:$junitJupiterVersion"
testCompile 'org.jetbrains.kotlin:kotlin-reflect'
testCompile 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
testCompile 'org.junit.jupiter:junit-jupiter-api'
testRuntime 'org.junit.jupiter:junit-jupiter-engine'
testRuntime 'org.junit.platform:junit-platform-launcher'

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

testRuntime "com.fasterxml.jackson.core:jackson-core"
testRuntime "com.fasterxml.jackson.core:jackson-databind"
testRuntime 'com.fasterxml.jackson.core:jackson-core'
testRuntime 'com.fasterxml.jackson.core:jackson-databind'
testRuntime "org.apache.logging.log4j:log4j-slf4j-impl:$log4jVersion"
}

Expand All @@ -126,7 +124,7 @@ dependencies {
test {
// suppress all console output during testing unless running `gradle -i`
logging.captureStandardOutput(LogLevel.INFO)
maxHeapSize = "1024m"
maxHeapSize = '1024m'
jacoco {
append = false
destinationFile = file("$buildDir/jacoco.exec")
Expand All @@ -135,7 +133,7 @@ test {
}

checkstyle {
configFile = new File(rootDir, "src/checkstyle/checkstyle.xml")
configFile = new File(rootDir, 'src/checkstyle/checkstyle.xml')
toolVersion = '8.24'
}

Expand Down Expand Up @@ -211,13 +209,13 @@ artifacts {

sonarqube {
properties {
property "sonar.jacoco.reportPath", "${buildDir.name}/jacoco.exec"
property "sonar.links.homepage", linkHomepage
property "sonar.links.ci", linkCi
property "sonar.links.issue", linkIssue
property "sonar.links.scm", linkScmUrl
property "sonar.links.scm_dev", linkScmDevConnection
property "sonar.java.coveragePlugin", "jacoco"
property 'sonar.jacoco.reportPath', "${buildDir.name}/jacoco.exec"
property 'sonar.links.homepage', linkHomepage
property 'sonar.links.ci', linkCi
property 'sonar.links.issue', linkIssue
property 'sonar.links.scm', linkScmUrl
property 'sonar.links.scm_dev', linkScmDevConnection
property 'sonar.java.coveragePlugin', 'jacoco'
}
}

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

source = sourceSets.main.allJava
classpath = project.sourceSets.main.compileClasspath
destinationDir = new File(buildDir, "api")
destinationDir = new File(buildDir, 'api')
}

task schemaZip(type: Zip) {
Expand Down
21 changes: 16 additions & 5 deletions publish-maven.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,26 @@ def customizePom(pom, gradleProject) {

scm {
url = linkScmUrl
connection = 'scm:git:' + linkScmConnection
developerConnection = 'scm:git:' + linkScmDevConnection
connection = "scm:git:$linkScmConnection"
developerConnection = "scm:git:$linkScmDevConnection"
}

issueManagement {
system = 'GutHub'
url = linkIssue
}

developers {
developer {
id = 'schacko'
name = 'Soby Chacko'
email = 'schacko@pivotal.io'
id = 'garyrussell'
name = 'Gary Russell'
email = 'grussell@pivotal.io'
roles = ['project lead']
}
developer {
id = 'abilan'
name = 'Artem Bilan'
email = 'abilan@pivotal.io'
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@

import java.util.Collections;

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.channel.NullChannel;
Expand All @@ -40,16 +39,16 @@
import org.springframework.kafka.listener.adapter.RetryingMessageListenerAdapter;
import org.springframework.retry.RecoveryCallback;
import org.springframework.retry.support.RetryTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;

/**
* @author Artem Bilan.
* @author Gary Russell
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
public class KafkaMessageDrivenChannelAdapterParserTests {
@SpringJUnitConfig
@DirtiesContext
class KafkaMessageDrivenChannelAdapterParserTests {

@Autowired
private NullChannel nullChannel;
Expand All @@ -73,7 +72,7 @@ public class KafkaMessageDrivenChannelAdapterParserTests {
private RecoveryCallback<?> recoveryCallback;

@Test
public void testKafkaMessageDrivenChannelAdapterParser() {
void testKafkaMessageDrivenChannelAdapterParser() {
assertThat(this.kafkaListener.isAutoStartup()).isFalse();
assertThat(this.kafkaListener.isRunning()).isFalse();
assertThat(this.kafkaListener.getPhase()).isEqualTo(100);
Expand All @@ -94,7 +93,7 @@ public void testKafkaMessageDrivenChannelAdapterParser() {
}

@Test
public void testKafkaBatchMessageDrivenChannelAdapterParser() {
void testKafkaBatchMessageDrivenChannelAdapterParser() {
assertThat(this.kafkaBatchListener.isAutoStartup()).isFalse();
assertThat(this.kafkaBatchListener.isRunning()).isFalse();
assertThat(this.kafkaBatchListener.getPhase()).isEqualTo(100);
Expand All @@ -110,7 +109,7 @@ public void testKafkaBatchMessageDrivenChannelAdapterParser() {

@Test
@SuppressWarnings("unchecked")
public void testKafkaMessageDrivenChannelAdapterOptions() {
void testKafkaMessageDrivenChannelAdapterOptions() {
DefaultKafkaConsumerFactory<Integer, String> cf =
new DefaultKafkaConsumerFactory<>(Collections.emptyMap());
ContainerProperties containerProps = new ContainerProperties("foo");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package org.springframework.integration.kafka.config.xml;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
Expand All @@ -29,8 +29,7 @@
import org.apache.kafka.clients.producer.MockProducer;
import org.apache.kafka.common.serialization.IntegerSerializer;
import org.apache.kafka.common.serialization.StringSerializer;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -45,8 +44,7 @@
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;

/**
* @author Soby Chacko
Expand All @@ -57,18 +55,17 @@
*
* @since 0.5
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@SpringJUnitConfig
@DirtiesContext
public class KafkaOutboundAdapterParserTests {
class KafkaOutboundAdapterParserTests {

@Autowired
private ApplicationContext appContext;

@Test
public void testOutboundAdapterConfiguration() {
void testOutboundAdapterConfiguration() {
KafkaProducerMessageHandler<?, ?> messageHandler
= this.appContext.getBean("kafkaOutboundChannelAdapter.handler", KafkaProducerMessageHandler.class);
= this.appContext.getBean("kafkaOutboundChannelAdapter.handler", KafkaProducerMessageHandler.class);
assertThat(messageHandler).isNotNull();
assertThat(messageHandler.getOrder()).isEqualTo(3);
assertThat(TestUtils.getPropertyValue(messageHandler, "topicExpression.literalValue")).isEqualTo("foo");
Expand Down Expand Up @@ -98,7 +95,7 @@ public void testOutboundAdapterConfiguration() {
}

@Test
public void testSyncMode() {
void testSyncMode() {
MockProducer<Integer, String> mockProducer =
new MockProducer<Integer, String>(false, new IntegerSerializer(), new StringSerializer()) {

Expand Down Expand Up @@ -128,28 +125,18 @@ public void close(Duration timeout) {
return null;
});

try {
handler.handleMessage(new GenericMessage<>("foo"));
fail("MessageHandlingException expected");
}
catch (Exception e) {
assertThat(e).isInstanceOf(MessageHandlingException.class);
assertThat(e.getCause()).isExactlyInstanceOf(KafkaProducerException.class);
assertThat(e.getCause().getCause()).isInstanceOf(RuntimeException.class);
assertThat(e.getMessage()).contains("Async Producer Mock exception");
}
assertThatExceptionOfType(MessageHandlingException.class)
.isThrownBy(() -> handler.handleMessage(new GenericMessage<>("foo")))
.withCauseInstanceOf(KafkaProducerException.class)
.withRootCauseInstanceOf(RuntimeException.class)
.withMessageContaining("Async Producer Mock exception");

handler.setSendTimeout(1);

try {
handler.handleMessage(new GenericMessage<>("foo"));
fail("MessageTimeoutException expected");
}
catch (Exception e) {
assertThat(e).isInstanceOf(MessageTimeoutException.class);
assertThat(e.getCause()).isExactlyInstanceOf(TimeoutException.class);
assertThat(e.getMessage()).contains("Timeout waiting for response from KafkaProducer");
}
assertThatExceptionOfType(MessageTimeoutException.class)
.isThrownBy(() -> handler.handleMessage(new GenericMessage<>("foo")))
.withCauseInstanceOf(TimeoutException.class)
.withMessageContaining("Timeout waiting for response from KafkaProducer");
}

}
Loading

0 comments on commit 7c6edee

Please sign in to comment.