mirror of https://github.com/apache/kafka.git
KAFKA-16921 [1/N] Migrate all junit 4 code to junit 5 for connect module (#16253)
Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
This commit is contained in:
parent
596b945072
commit
ea60666513
63
build.gradle
63
build.gradle
|
@ -427,9 +427,6 @@ subprojects {
|
|||
}
|
||||
}
|
||||
|
||||
// Remove the relevant project name once it's converted to JUnit 5
|
||||
def shouldUseJUnit5 = !(["runtime"].contains(it.project.name))
|
||||
|
||||
def testLoggingEvents = ["passed", "skipped", "failed"]
|
||||
def testShowStandardStreams = false
|
||||
def testExceptionFormat = 'full'
|
||||
|
@ -522,8 +519,7 @@ subprojects {
|
|||
|
||||
exclude testsToExclude
|
||||
|
||||
if (shouldUseJUnit5)
|
||||
useJUnitPlatform()
|
||||
useJUnitPlatform()
|
||||
|
||||
retry {
|
||||
maxRetries = userMaxTestRetries
|
||||
|
@ -550,23 +546,18 @@ subprojects {
|
|||
|
||||
exclude testsToExclude
|
||||
|
||||
if (shouldUseJUnit5) {
|
||||
if (project.name == 'streams') {
|
||||
useJUnitPlatform {
|
||||
includeTags "integration"
|
||||
includeTags "org.apache.kafka.test.IntegrationTest"
|
||||
// Both engines are needed to run JUnit 4 tests alongside JUnit 5 tests.
|
||||
// junit-vintage (JUnit 4) can be removed once the JUnit 4 migration is complete.
|
||||
includeEngines "junit-vintage", "junit-jupiter"
|
||||
}
|
||||
} else {
|
||||
useJUnitPlatform {
|
||||
includeTags "integration"
|
||||
}
|
||||
if (project.name == 'streams') {
|
||||
useJUnitPlatform {
|
||||
includeTags "integration"
|
||||
includeTags "org.apache.kafka.test.IntegrationTest"
|
||||
// Both engines are needed to run JUnit 4 tests alongside JUnit 5 tests.
|
||||
// junit-vintage (JUnit 4) can be removed once the JUnit 4 migration is complete.
|
||||
includeEngines "junit-vintage", "junit-jupiter"
|
||||
}
|
||||
} else {
|
||||
useJUnit {
|
||||
includeCategories 'org.apache.kafka.test.IntegrationTest'
|
||||
useJUnitPlatform {
|
||||
includeTags "integration"
|
||||
includeTags 'org.apache.kafka.test.IntegrationTest'
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -593,23 +584,18 @@ subprojects {
|
|||
|
||||
exclude testsToExclude
|
||||
|
||||
if (shouldUseJUnit5) {
|
||||
if (project.name == 'streams') {
|
||||
useJUnitPlatform {
|
||||
excludeTags "integration"
|
||||
excludeTags "org.apache.kafka.test.IntegrationTest"
|
||||
// Both engines are needed to run JUnit 4 tests alongside JUnit 5 tests.
|
||||
// junit-vintage (JUnit 4) can be removed once the JUnit 4 migration is complete.
|
||||
includeEngines "junit-vintage", "junit-jupiter"
|
||||
}
|
||||
} else {
|
||||
useJUnitPlatform {
|
||||
excludeTags "integration"
|
||||
}
|
||||
if (project.name == 'streams') {
|
||||
useJUnitPlatform {
|
||||
excludeTags "integration"
|
||||
excludeTags "org.apache.kafka.test.IntegrationTest"
|
||||
// Both engines are needed to run JUnit 4 tests alongside JUnit 5 tests.
|
||||
// junit-vintage (JUnit 4) can be removed once the JUnit 4 migration is complete.
|
||||
includeEngines "junit-vintage", "junit-jupiter"
|
||||
}
|
||||
} else {
|
||||
useJUnit {
|
||||
excludeCategories 'org.apache.kafka.test.IntegrationTest'
|
||||
useJUnitPlatform {
|
||||
excludeTags "integration"
|
||||
excludeTags 'org.apache.kafka.test.IntegrationTest'
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3229,10 +3215,13 @@ project(':connect:runtime') {
|
|||
testImplementation project(':storage')
|
||||
testImplementation project(':connect:test-plugins')
|
||||
testImplementation project(':group-coordinator')
|
||||
|
||||
testImplementation libs.junitJupiterApi
|
||||
|
||||
testImplementation libs.junitJupiter
|
||||
testImplementation libs.junitVintageEngine
|
||||
testImplementation libs.mockitoJunitJupiter
|
||||
testImplementation libs.mockitoCore
|
||||
testImplementation libs.hamcrest
|
||||
testImplementation libs.mockitoJunitJupiter
|
||||
testImplementation libs.httpclient
|
||||
|
||||
testRuntimeOnly libs.slf4jlog4j
|
||||
|
|
|
@ -19,8 +19,8 @@ package org.apache.kafka.connect.cli;
|
|||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.apache.kafka.connect.runtime.rest.entities.CreateConnectorRequest;
|
||||
import org.apache.kafka.test.TestUtils;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
|
@ -30,8 +30,8 @@ import java.util.Map;
|
|||
import java.util.Properties;
|
||||
|
||||
import static org.apache.kafka.connect.runtime.ConnectorConfig.NAME_CONFIG;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
public class ConnectStandaloneTest {
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class ConnectStandaloneTest {
|
|||
private final ConnectStandalone connectStandalone = new ConnectStandalone();
|
||||
private File connectorConfigurationFile;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws IOException {
|
||||
connectorConfigurationFile = TestUtils.tempFile();
|
||||
}
|
||||
|
|
|
@ -20,11 +20,12 @@ package org.apache.kafka.connect.connector.policy;
|
|||
import org.apache.kafka.common.config.ConfigValue;
|
||||
import org.apache.kafka.connect.health.ConnectorType;
|
||||
import org.apache.kafka.connect.runtime.SampleSourceConnector;
|
||||
import org.junit.Assert;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public abstract class BaseConnectorClientConfigOverridePolicyTest {
|
||||
|
||||
protected abstract ConnectorClientConfigOverridePolicy policyToTest();
|
||||
|
@ -50,10 +51,10 @@ public abstract class BaseConnectorClientConfigOverridePolicyTest {
|
|||
}
|
||||
|
||||
protected void assertNoError(List<ConfigValue> configValues) {
|
||||
Assert.assertTrue(configValues.stream().allMatch(configValue -> configValue.errorMessages().isEmpty()));
|
||||
assertTrue(configValues.stream().allMatch(configValue -> configValue.errorMessages().isEmpty()));
|
||||
}
|
||||
|
||||
protected void assertError(List<ConfigValue> configValues) {
|
||||
Assert.assertTrue(configValues.stream().anyMatch(configValue -> !configValue.errorMessages().isEmpty()));
|
||||
assertTrue(configValues.stream().anyMatch(configValue -> !configValue.errorMessages().isEmpty()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.kafka.connect.connector.policy;
|
|||
|
||||
import org.apache.kafka.clients.producer.ProducerConfig;
|
||||
import org.apache.kafka.common.config.SaslConfigs;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.kafka.connect.connector.policy;
|
|||
|
||||
import org.apache.kafka.clients.producer.ProducerConfig;
|
||||
import org.apache.kafka.common.config.SaslConfigs;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
|
||||
package org.apache.kafka.connect.converters;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collections;
|
||||
|
@ -30,8 +30,8 @@ import java.util.Collections;
|
|||
import org.apache.kafka.common.utils.AppInfoParser;
|
||||
import org.apache.kafka.connect.data.Schema;
|
||||
import org.apache.kafka.connect.errors.DataException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class BooleanConverterTest {
|
||||
private static final String TOPIC = "topic";
|
||||
|
@ -39,7 +39,7 @@ public class BooleanConverterTest {
|
|||
private static final byte[] FALSE = new byte[] {0x00};
|
||||
private final BooleanConverter converter = new BooleanConverter();
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
converter.configure(Collections.emptyMap(), false);
|
||||
}
|
||||
|
|
|
@ -21,17 +21,17 @@ import org.apache.kafka.common.utils.AppInfoParser;
|
|||
import org.apache.kafka.connect.data.Schema;
|
||||
import org.apache.kafka.connect.data.SchemaAndValue;
|
||||
import org.apache.kafka.connect.errors.DataException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
public class ByteArrayConverterTest {
|
||||
private static final String TOPIC = "topic";
|
||||
|
@ -39,7 +39,7 @@ public class ByteArrayConverterTest {
|
|||
|
||||
private final ByteArrayConverter converter = new ByteArrayConverter();
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
converter.configure(Collections.emptyMap(), false);
|
||||
}
|
||||
|
|
|
@ -21,13 +21,13 @@ import org.apache.kafka.common.utils.AppInfoParser;
|
|||
import org.apache.kafka.connect.data.Schema;
|
||||
import org.apache.kafka.connect.data.SchemaAndValue;
|
||||
import org.apache.kafka.connect.errors.DataException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
public abstract class NumberConverterTest<T extends Number> {
|
||||
private static final String TOPIC = "topic";
|
||||
|
@ -46,7 +46,7 @@ public abstract class NumberConverterTest<T extends Number> {
|
|||
|
||||
protected abstract Schema schema();
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
converter = createConverter();
|
||||
serializer = createSerializer();
|
||||
|
|
Loading…
Reference in New Issue