Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 26 additions & 37 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,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'
Expand Down Expand Up @@ -536,8 +533,7 @@ subprojects {

exclude testsToExclude

if (shouldUseJUnit5)
useJUnitPlatform()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep this line ...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I misunderstand the shouldUseJUnit5 variable logic, so I rollback it

useJUnitPlatform()

retry {
maxRetries = userMaxTestRetries
Expand All @@ -564,23 +560,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'
}
}

Expand All @@ -607,23 +598,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'
}
}

Expand Down Expand Up @@ -3243,10 +3229,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
Comment thread
chia7712 marked this conversation as resolved.
testImplementation libs.mockitoJunitJupiter
testImplementation libs.mockitoCore
testImplementation libs.hamcrest
testImplementation libs.mockitoJunitJupiter
testImplementation libs.httpclient

testRuntimeOnly libs.slf4jlog4j
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
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;
Expand All @@ -30,8 +30,8 @@
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 {

Expand All @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
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();
Expand All @@ -50,10 +51,10 @@ private List<ConfigValue> configValues(Map<String, Object> clientConfig) {
}

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()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,29 @@

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;

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";
private static final byte[] TRUE = new byte[] {0x01};
private static final byte[] FALSE = new byte[] {0x00};
private final BooleanConverter converter = new BooleanConverter();

@Before
@BeforeEach
public void setUp() {
converter.configure(Collections.emptyMap(), false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@
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";
private static final byte[] SAMPLE_BYTES = "sample string".getBytes(StandardCharsets.UTF_8);

private final ByteArrayConverter converter = new ByteArrayConverter();

@Before
@BeforeEach
public void setUp() {
converter.configure(Collections.emptyMap(), false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
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";
Expand All @@ -46,7 +46,7 @@ public abstract class NumberConverterTest<T extends Number> {

protected abstract Schema schema();

@Before
@BeforeEach
public void setup() {
converter = createConverter();
serializer = createSerializer();
Expand Down