org.junit.jupiter
junit-jupiter-engine
diff --git a/plugin/trino-thrift-testing-server/src/test/java/io/trino/plugin/thrift/server/TestListBasedRecordSet.java b/plugin/trino-thrift-testing-server/src/test/java/io/trino/plugin/thrift/server/TestListBasedRecordSet.java
index 82157658e630..a6c28fd9fa3e 100644
--- a/plugin/trino-thrift-testing-server/src/test/java/io/trino/plugin/thrift/server/TestListBasedRecordSet.java
+++ b/plugin/trino-thrift-testing-server/src/test/java/io/trino/plugin/thrift/server/TestListBasedRecordSet.java
@@ -16,7 +16,7 @@
import com.google.common.collect.ImmutableList;
import io.airlift.slice.Slices;
import io.trino.spi.connector.RecordCursor;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
diff --git a/pom.xml b/pom.xml
index 5d28b064cf00..1831d653c50d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -652,7 +652,7 @@
io.airlift
junit-extensions
- 1
+ 2
diff --git a/testing/trino-test-jdbc-compatibility-old-driver/pom.xml b/testing/trino-test-jdbc-compatibility-old-driver/pom.xml
index 6f30e13c4a08..8a7ea390324a 100644
--- a/testing/trino-test-jdbc-compatibility-old-driver/pom.xml
+++ b/testing/trino-test-jdbc-compatibility-old-driver/pom.xml
@@ -31,6 +31,12 @@
test
+
+ io.airlift
+ junit-extensions
+ test
+
+
io.airlift
log
@@ -83,10 +89,44 @@
test
+
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
org.testng
testng
test
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+
+ org.apache.maven.surefire
+ surefire-junit-platform
+ ${dep.plugin.surefire.version}
+
+
+ org.apache.maven.surefire
+ surefire-testng
+ ${dep.plugin.surefire.version}
+
+
+
+
+
diff --git a/testing/trino-test-jdbc-compatibility-old-driver/src/test/java/io/trino/TestJdbcCompatibility.java b/testing/trino-test-jdbc-compatibility-old-driver/src/test/java/io/trino/TestJdbcCompatibility.java
index 61b65583b613..a10e22a225e4 100644
--- a/testing/trino-test-jdbc-compatibility-old-driver/src/test/java/io/trino/TestJdbcCompatibility.java
+++ b/testing/trino-test-jdbc-compatibility-old-driver/src/test/java/io/trino/TestJdbcCompatibility.java
@@ -18,10 +18,10 @@
import io.airlift.log.Logging;
import io.trino.plugin.mongodb.MongoPlugin;
import io.trino.server.testing.TestingTrinoServer;
-import org.testng.SkipException;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.parallel.Execution;
import java.io.IOException;
import java.math.BigDecimal;
@@ -55,6 +55,9 @@
import static java.sql.Types.TIMESTAMP;
import static java.sql.Types.TIMESTAMP_WITH_TIMEZONE;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assumptions.abort;
+import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS;
+import static org.junit.jupiter.api.parallel.ExecutionMode.CONCURRENT;
/**
* The main purpose of this class is to test cases when current server implementation breaks older JDBC clients
@@ -65,19 +68,33 @@
*
* This test in turn is run using an old JDBC client against current server implementation.
*/
+@TestInstance(PER_CLASS)
+@Execution(CONCURRENT)
public class TestJdbcCompatibility
{
private static final Optional VERSION_UNDER_TEST = testedVersion();
private static final int TIMESTAMP_DEFAULT_PRECISION = 3;
- private TestingTrinoServer server;
- private String serverUrl;
+ private final TestingTrinoServer server;
+ private final String serverUrl;
+
+ public TestJdbcCompatibility()
+ {
+ Logging.initialize();
+
+ server = TestingTrinoServer.builder()
+ .build();
+
+ server.installPlugin(new MongoPlugin());
+
+ serverUrl = format("jdbc:trino://%s", server.getAddress());
+ }
@Test
public void ensureProperDriverVersionLoaded()
{
if (VERSION_UNDER_TEST.isEmpty()) {
- throw new SkipException("Information about JDBC version under test is missing");
+ abort("Information about JDBC version under test is missing");
}
assertThat(driverVersion())
@@ -87,25 +104,11 @@ public void ensureProperDriverVersionLoaded()
.isEqualTo(VERSION_UNDER_TEST.get().toString());
}
- @BeforeClass
- public void setup()
- {
- Logging.initialize();
-
- server = TestingTrinoServer.builder()
- .build();
-
- server.installPlugin(new MongoPlugin());
-
- serverUrl = format("jdbc:trino://%s", server.getAddress());
- }
-
- @AfterClass(alwaysRun = true)
+ @AfterAll
public void tearDown()
throws IOException
{
server.close();
- server = null;
}
@Test
@@ -134,7 +137,7 @@ public void testSelectTimestamp()
public void testSelectTimestampWithTimeZone()
{
if (hasBrokenParametricTimestampWithTimeZoneSupport()) {
- throw new SkipException("This version reports PARAMETRIC_DATETIME client capability but TIMESTAMP WITH TIME ZONE is not supported");
+ abort("This version reports PARAMETRIC_DATETIME client capability but TIMESTAMP WITH TIME ZONE is not supported");
}
String query = "SELECT timestamp '2012-10-31 01:00 Australia/Eucla'";
@@ -190,7 +193,7 @@ private void testSelectParametricTimestamp(String expression, Object expectedVal
public void testSelectParametricTimestampWithTimeZone()
{
if (hasBrokenParametricTimestampWithTimeZoneSupport()) {
- throw new SkipException("This version reports PARAMETRIC_DATETIME client capability but TIMESTAMP WITH TIME ZONE is not supported");
+ abort("This version reports PARAMETRIC_DATETIME client capability but TIMESTAMP WITH TIME ZONE is not supported");
}
if (!supportsParametricTimestampWithTimeZone()) {
@@ -299,7 +302,7 @@ private void testSelectParametricTimestampInMap(String elementExpression, int ex
public void testSelectParametricTimestampWithTimeZoneInMap()
{
if (hasBrokenParametricTimestampWithTimeZoneSupport()) {
- throw new SkipException("This version reports PARAMETRIC_DATETIME client capability but TIMESTAMP WITH TIME ZONE is not supported");
+ abort("This version reports PARAMETRIC_DATETIME client capability but TIMESTAMP WITH TIME ZONE is not supported");
}
if (!supportsParametricTimestampWithTimeZone()) {
@@ -422,7 +425,7 @@ private void testSelectParametricTimestampInArray(String elementExpression, int
public void testSelectParametricTimestampWithTimeZoneInArray()
{
if (hasBrokenParametricTimestampWithTimeZoneSupport()) {
- throw new SkipException("This version reports PARAMETRIC_DATETIME client capability but TIMESTAMP WITH TIME ZONE is not supported");
+ abort("This version reports PARAMETRIC_DATETIME client capability but TIMESTAMP WITH TIME ZONE is not supported");
}
if (!supportsParametricTimestampWithTimeZone()) {
@@ -544,7 +547,7 @@ private void testSelectParametricTimestampInRow(String elementExpression, int pr
public void testSelectParametricTimestampWithTimeZoneInRow()
{
if (hasBrokenParametricTimestampWithTimeZoneSupport()) {
- throw new SkipException("This version reports PARAMETRIC_DATETIME client capability but TIMESTAMP WITH TIME ZONE is not supported");
+ abort("This version reports PARAMETRIC_DATETIME client capability but TIMESTAMP WITH TIME ZONE is not supported");
}
if (!supportsParametricTimestampWithTimeZone()) {
diff --git a/testing/trino-testing/src/test/java/io/trino/testing/TestH2QueryRunner.java b/testing/trino-testing/src/test/java/io/trino/testing/TestH2QueryRunner.java
index 2ed5f3aa1f55..038ecfc88f39 100644
--- a/testing/trino-testing/src/test/java/io/trino/testing/TestH2QueryRunner.java
+++ b/testing/trino-testing/src/test/java/io/trino/testing/TestH2QueryRunner.java
@@ -14,9 +14,7 @@
package io.trino.testing;
import com.google.common.collect.ImmutableList;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
import java.time.LocalDate;
import java.time.ZoneId;
@@ -29,34 +27,21 @@
public class TestH2QueryRunner
{
- private H2QueryRunner h2QueryRunner;
-
- @BeforeClass
- public void init()
- {
- h2QueryRunner = new H2QueryRunner();
- }
-
- @AfterClass(alwaysRun = true)
- public void close()
- {
- h2QueryRunner.close();
- h2QueryRunner = null;
- }
-
@Test
public void testDateToTimestampCoercion()
{
- // allow running tests with a connector that supports TIMESTAMP but not DATE
-
- // ordinary date
- MaterializedResult rows = h2QueryRunner.execute(TEST_SESSION, "SELECT DATE '2018-01-13'", ImmutableList.of(TIMESTAMP_MILLIS));
- assertEquals(rows.getOnlyValue(), LocalDate.of(2018, 1, 13).atStartOfDay());
-
- // date, which midnight was skipped in JVM zone
- LocalDate forwardOffsetChangeAtMidnightInJvmZone = LocalDate.of(1970, 1, 1);
- checkState(ZoneId.systemDefault().getRules().getValidOffsets(forwardOffsetChangeAtMidnightInJvmZone.atStartOfDay()).size() == 0, "This test assumes certain JVM time zone");
- rows = h2QueryRunner.execute(TEST_SESSION, DateTimeFormatter.ofPattern("'SELECT DATE '''uuuu-MM-dd''").format(forwardOffsetChangeAtMidnightInJvmZone), ImmutableList.of(TIMESTAMP_MILLIS));
- assertEquals(rows.getOnlyValue(), forwardOffsetChangeAtMidnightInJvmZone.atStartOfDay());
+ try (H2QueryRunner h2QueryRunner = new H2QueryRunner()) {
+ // allow running tests with a connector that supports TIMESTAMP but not DATE
+
+ // ordinary date
+ MaterializedResult rows = h2QueryRunner.execute(TEST_SESSION, "SELECT DATE '2018-01-13'", ImmutableList.of(TIMESTAMP_MILLIS));
+ assertEquals(rows.getOnlyValue(), LocalDate.of(2018, 1, 13).atStartOfDay());
+
+ // date, which midnight was skipped in JVM zone
+ LocalDate forwardOffsetChangeAtMidnightInJvmZone = LocalDate.of(1970, 1, 1);
+ checkState(ZoneId.systemDefault().getRules().getValidOffsets(forwardOffsetChangeAtMidnightInJvmZone.atStartOfDay()).size() == 0, "This test assumes certain JVM time zone");
+ rows = h2QueryRunner.execute(TEST_SESSION, DateTimeFormatter.ofPattern("'SELECT DATE '''uuuu-MM-dd''").format(forwardOffsetChangeAtMidnightInJvmZone), ImmutableList.of(TIMESTAMP_MILLIS));
+ assertEquals(rows.getOnlyValue(), forwardOffsetChangeAtMidnightInJvmZone.atStartOfDay());
+ }
}
}
diff --git a/testing/trino-testing/src/test/java/io/trino/testing/TestTestingTrinoClient.java b/testing/trino-testing/src/test/java/io/trino/testing/TestTestingTrinoClient.java
index e356e43fd205..b1c28bdf3fbb 100644
--- a/testing/trino-testing/src/test/java/io/trino/testing/TestTestingTrinoClient.java
+++ b/testing/trino-testing/src/test/java/io/trino/testing/TestTestingTrinoClient.java
@@ -27,9 +27,10 @@
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.parallel.Execution;
import java.io.IOException;
import java.nio.file.Files;
@@ -37,8 +38,12 @@
import java.security.Principal;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS;
+import static org.junit.jupiter.api.parallel.ExecutionMode.CONCURRENT;
import static org.testng.Assert.assertEquals;
+@TestInstance(PER_CLASS)
+@Execution(CONCURRENT)
public class TestTestingTrinoClient
{
private static final String TEST_USER = "test_user";
@@ -51,10 +56,9 @@ public class TestTestingTrinoClient
.setQueryId(queryIdGenerator.createNextQueryId())
.build();
- private TestingTrinoServer server;
+ private final TestingTrinoServer server;
- @BeforeClass
- public void setup()
+ public TestTestingTrinoClient()
throws IOException
{
Path passwordConfigDummy = Files.createTempFile("passwordConfigDummy", "");
@@ -79,12 +83,11 @@ private static Principal authenticate(String user, String password)
throw new AccessDeniedException("Invalid credentials");
}
- @AfterClass(alwaysRun = true)
+ @AfterAll
public void teardown()
throws Exception
{
server.close();
- server = null;
}
@Test
diff --git a/testing/trino-testing/src/test/java/io/trino/testing/datatype/TestDataType.java b/testing/trino-testing/src/test/java/io/trino/testing/datatype/TestDataType.java
index 82e49a25e285..cea9e9e6048b 100644
--- a/testing/trino-testing/src/test/java/io/trino/testing/datatype/TestDataType.java
+++ b/testing/trino-testing/src/test/java/io/trino/testing/datatype/TestDataType.java
@@ -13,7 +13,7 @@
*/
package io.trino.testing.datatype;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
import java.time.LocalTime;