diff --git a/plugin/trino-mongodb/pom.xml b/plugin/trino-mongodb/pom.xml
index 92966117d0cd..3a2abec52f53 100644
--- a/plugin/trino-mongodb/pom.xml
+++ b/plugin/trino-mongodb/pom.xml
@@ -237,33 +237,5 @@
testcontainers
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/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoConnectorTest.java b/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoConnectorTest.java
index 675f3d5eedde..89581bdd381b 100644
--- a/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoConnectorTest.java
+++ b/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoConnectorTest.java
@@ -62,9 +62,6 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assumptions.abort;
import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotNull;
@TestInstance(PER_CLASS)
public class TestMongoConnectorTest
@@ -213,20 +210,30 @@ public void createTableWithEveryType()
assertUpdate(query, 1);
MaterializedResult results = getQueryRunner().execute(getSession(), "SELECT * FROM " + tableName).toTestTypes();
- assertEquals(results.getRowCount(), 1);
+ assertThat(results.getRowCount())
+ .isEqualTo(1);
MaterializedRow row = results.getMaterializedRows().get(0);
- assertEquals(row.getField(0), "foo");
- assertEquals(row.getField(1), "bar".getBytes(UTF_8));
- assertEquals(row.getField(2), 1L);
- assertEquals(row.getField(3), 3.14);
- assertEquals(row.getField(4), true);
- assertEquals(row.getField(5), LocalDate.of(1980, 5, 7));
- assertEquals(row.getField(6), LocalDateTime.of(1980, 5, 7, 11, 22, 33, 456_000_000));
- assertEquals(row.getField(8), "{\"name\":\"alice\"}");
- assertEquals(row.getField(9), new BigDecimal("12.30000"));
+ assertThat(row.getField(0))
+ .isEqualTo("foo");
+ assertThat(row.getField(1))
+ .isEqualTo("bar".getBytes(UTF_8));
+ assertThat(row.getField(2))
+ .isEqualTo(1L);
+ assertThat(row.getField(3))
+ .isEqualTo(3.14);
+ assertThat(row.getField(4))
+ .isEqualTo(true);
+ assertThat(row.getField(5))
+ .isEqualTo(LocalDate.of(1980, 5, 7));
+ assertThat(row.getField(6))
+ .isEqualTo(LocalDateTime.of(1980, 5, 7, 11, 22, 33, 456_000_000));
+ assertThat(row.getField(8))
+ .isEqualTo("{\"name\":\"alice\"}");
+ assertThat(row.getField(9))
+ .isEqualTo(new BigDecimal("12.30000"));
assertUpdate("DROP TABLE " + tableName);
- assertFalse(getQueryRunner().tableExists(getSession(), tableName));
+ assertThat(getQueryRunner().tableExists(getSession(), tableName)).isFalse();
}
@Test
@@ -263,18 +270,27 @@ public void testInsertWithEveryType()
getQueryRunner().execute(getSession(), insertSql);
MaterializedResult results = getQueryRunner().execute(getSession(), "SELECT * FROM " + tableName).toTestTypes();
- assertEquals(results.getRowCount(), 1);
+ assertThat(results.getRowCount())
+ .isEqualTo(1);
MaterializedRow row = results.getMaterializedRows().get(0);
- assertEquals(row.getField(0), "foo");
- assertEquals(row.getField(1), "bar".getBytes(UTF_8));
- assertEquals(row.getField(2), 1L);
- assertEquals(row.getField(3), 3.14);
- assertEquals(row.getField(4), true);
- assertEquals(row.getField(5), LocalDate.of(1980, 5, 7));
- assertEquals(row.getField(6), LocalDateTime.of(1980, 5, 7, 11, 22, 33, 456_000_000));
- assertEquals(row.getField(8), "{\"name\":\"alice\"}");
+ assertThat(row.getField(0))
+ .isEqualTo("foo");
+ assertThat(row.getField(1))
+ .isEqualTo("bar".getBytes(UTF_8));
+ assertThat(row.getField(2))
+ .isEqualTo(1L);
+ assertThat(row.getField(3))
+ .isEqualTo(3.14);
+ assertThat(row.getField(4))
+ .isEqualTo(true);
+ assertThat(row.getField(5))
+ .isEqualTo(LocalDate.of(1980, 5, 7));
+ assertThat(row.getField(6))
+ .isEqualTo(LocalDateTime.of(1980, 5, 7, 11, 22, 33, 456_000_000));
+ assertThat(row.getField(8))
+ .isEqualTo("{\"name\":\"alice\"}");
assertUpdate("DROP TABLE " + tableName);
- assertFalse(getQueryRunner().tableExists(getSession(), tableName));
+ assertThat(getQueryRunner().tableExists(getSession(), tableName)).isFalse();
}
@Test
@@ -1356,13 +1372,17 @@ private void testFiltersOnDereferenceColumnReadsLessData(String expectedValue, S
sessionWithoutPushdown,
format("SELECT 1 FROM %s WHERE col_0.col_1 = %s", table.getName(), expectedValue),
statsWithoutPushdown -> {
- assertEquals(statsWithoutPushdown.getProcessedInputPositions(), 3);
- assertEquals(processedInputPositionWithPushdown, 2);
+ assertThat(statsWithoutPushdown.getProcessedInputPositions())
+ .isEqualTo(3);
+ assertThat(processedInputPositionWithPushdown)
+ .isEqualTo(2);
assertThat(statsWithoutPushdown.getProcessedInputPositions()).isGreaterThan(processedInputPositionWithPushdown);
},
- results -> assertEquals(results.getOnlyColumnAsSet(), expected));
+ results -> assertThat(results.getOnlyColumnAsSet())
+ .isEqualTo(expected));
},
- results -> assertEquals(results.getOnlyColumnAsSet(), expected));
+ results -> assertThat(results.getOnlyColumnAsSet())
+ .isEqualTo(expected));
assertQueryStats(
getSession(),
@@ -1373,13 +1393,17 @@ private void testFiltersOnDereferenceColumnReadsLessData(String expectedValue, S
sessionWithoutPushdown,
format("SELECT 1 FROM %s WHERE col_0.col_2.col_3 = %s", table.getName(), expectedValue),
statsWithoutPushdown -> {
- assertEquals(statsWithoutPushdown.getProcessedInputPositions(), 3);
- assertEquals(processedInputPositionWithPushdown, 1);
+ assertThat(statsWithoutPushdown.getProcessedInputPositions())
+ .isEqualTo(3);
+ assertThat(processedInputPositionWithPushdown)
+ .isEqualTo(1);
assertThat(statsWithoutPushdown.getProcessedInputPositions()).isGreaterThan(processedInputPositionWithPushdown);
},
- results -> assertEquals(results.getOnlyColumnAsSet(), expected));
+ results -> assertThat(results.getOnlyColumnAsSet())
+ .isEqualTo(expected));
},
- results -> assertEquals(results.getOnlyColumnAsSet(), expected));
+ results -> assertThat(results.getOnlyColumnAsSet())
+ .isEqualTo(expected));
assertQueryStats(
getSession(),
@@ -1390,13 +1414,17 @@ private void testFiltersOnDereferenceColumnReadsLessData(String expectedValue, S
sessionWithoutPushdown,
format("SELECT 1 FROM %s WHERE col_0.col_2.col_4.col_5 = %s", table.getName(), expectedValue),
statsWithoutPushdown -> {
- assertEquals(statsWithoutPushdown.getProcessedInputPositions(), 3);
- assertEquals(processedInputPositionWithPushdown, 2);
+ assertThat(statsWithoutPushdown.getProcessedInputPositions())
+ .isEqualTo(3);
+ assertThat(processedInputPositionWithPushdown)
+ .isEqualTo(2);
assertThat(statsWithoutPushdown.getProcessedInputPositions()).isGreaterThan(processedInputPositionWithPushdown);
},
- results -> assertEquals(results.getOnlyColumnAsSet(), expected));
+ results -> assertThat(results.getOnlyColumnAsSet())
+ .isEqualTo(expected));
},
- results -> assertEquals(results.getOnlyColumnAsSet(), expected));
+ results -> assertThat(results.getOnlyColumnAsSet())
+ .isEqualTo(expected));
}
}
@@ -1413,8 +1441,10 @@ public void testFiltersOnDereferenceColumnReadsLessDataNativeQuery()
assertQueryStats(
getSession(),
"SELECT row_field.first.second FROM TABLE(mongodb.system.query(database => 'test', collection => '" + tableName + "', filter => '{ \"row_field.first.second\": 1 }'))",
- stats -> assertEquals(stats.getProcessedInputPositions(), 1L),
- results -> assertEquals(results.getOnlyColumnAsSet(), ImmutableSet.of(1L)));
+ stats -> assertThat(stats.getProcessedInputPositions())
+ .isEqualTo(1L),
+ results -> assertThat(results.getOnlyColumnAsSet())
+ .isEqualTo(ImmutableSet.of(1L)));
assertUpdate("DROP TABLE test." + tableName);
}
@@ -1847,8 +1877,10 @@ protected Optional filterSetColumnTypesDataProvider(SetColum
private void assertOneNotNullResult(String query)
{
MaterializedResult results = getQueryRunner().execute(getSession(), query).toTestTypes();
- assertEquals(results.getRowCount(), 1);
- assertEquals(results.getMaterializedRows().get(0).getFieldCount(), 1);
- assertNotNull(results.getMaterializedRows().get(0).getField(0));
+ assertThat(results.getRowCount())
+ .isEqualTo(1);
+ assertThat(results.getMaterializedRows().get(0).getFieldCount())
+ .isEqualTo(1);
+ assertThat(results.getMaterializedRows().get(0).getField(0)).isNotNull();
}
}
diff --git a/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoPlugin.java b/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoPlugin.java
index 4da82167001a..f71fae5fcc34 100644
--- a/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoPlugin.java
+++ b/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoPlugin.java
@@ -22,7 +22,7 @@
import static com.google.common.collect.Iterables.getOnlyElement;
import static io.trino.plugin.mongodb.ObjectIdType.OBJECT_ID;
-import static org.testng.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThat;
public class TestMongoPlugin
{
@@ -40,7 +40,7 @@ public void testCreateConnector()
new TestingConnectorContext());
Type type = getOnlyElement(plugin.getTypes());
- assertEquals(type, OBJECT_ID);
+ assertThat(type).isEqualTo(OBJECT_ID);
connector.shutdown();
}
diff --git a/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoPrivileges.java b/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoPrivileges.java
index e7b920c47ab3..5f70dcd9a373 100644
--- a/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoPrivileges.java
+++ b/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoPrivileges.java
@@ -22,8 +22,7 @@
import io.trino.testing.DistributedQueryRunner;
import io.trino.testing.QueryRunner;
import org.bson.Document;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.Optional;
@@ -34,7 +33,6 @@
import static io.trino.plugin.mongodb.AuthenticatedMongoServer.privilege;
import static io.trino.plugin.mongodb.AuthenticatedMongoServer.resource;
import static io.trino.plugin.mongodb.AuthenticatedMongoServer.role;
-import static io.trino.testing.DataProviders.toDataProvider;
import static io.trino.testing.TestingSession.testSessionBuilder;
import static java.util.Locale.ENGLISH;
import static org.assertj.core.api.Assertions.assertThat;
@@ -71,22 +69,28 @@ protected QueryRunner createQueryRunner()
}
}
- @Test(dataProvider = "databases")
- public void testSchemasVisibility(String database)
+ @Test
+ public void testSchemasVisibility()
{
- assertQuery("SHOW SCHEMAS FROM " + getCatalogName(database), "VALUES 'information_schema','%s'".formatted(database.toLowerCase(ENGLISH)));
+ for (String database : DATABASES) {
+ assertQuery("SHOW SCHEMAS FROM " + getCatalogName(database), "VALUES 'information_schema','%s'".formatted(database.toLowerCase(ENGLISH)));
+ }
}
- @Test(dataProvider = "databases")
- public void testTablesVisibility(String database)
+ @Test
+ public void testTablesVisibility()
{
- assertQuery("SHOW TABLES FROM %s.%s".formatted(getCatalogName(database), database), "VALUES '%s'".formatted(TEST_COLLECTION.toLowerCase(ENGLISH)));
+ for (String database : DATABASES) {
+ assertQuery("SHOW TABLES FROM %s.%s".formatted(getCatalogName(database), database), "VALUES '%s'".formatted(TEST_COLLECTION.toLowerCase(ENGLISH)));
+ }
}
- @Test(dataProvider = "databases")
- public void testSelectFromTable(String database)
+ @Test
+ public void testSelectFromTable()
{
- assertQuery("SELECT * from %s.%s.%s".formatted(getCatalogName(database), database, TEST_COLLECTION), "VALUES ('abc', 1)");
+ for (String database : DATABASES) {
+ assertQuery("SELECT * from %s.%s.%s".formatted(getCatalogName(database), database, TEST_COLLECTION), "VALUES ('abc', 1)");
+ }
}
private static AuthenticatedMongoServer setupMongoServer()
@@ -157,10 +161,4 @@ private static String getPassword(String database)
{
return database + "pass";
}
-
- @DataProvider
- public static Object[][] databases()
- {
- return DATABASES.stream().collect(toDataProvider());
- }
}
diff --git a/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoSession.java b/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoSession.java
index c5fb6146481c..546937809a42 100644
--- a/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoSession.java
+++ b/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoSession.java
@@ -38,7 +38,6 @@
import static io.trino.spi.type.VarcharType.createUnboundedVarcharType;
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.testng.Assert.assertEquals;
public class TestMongoSession
{
@@ -61,7 +60,8 @@ public void testBuildProjectionWithoutId()
.append(COL1.getBaseName(), 1)
.append(COL2.getBaseName(), 1)
.append(ID_COL.getBaseName(), 0);
- assertEquals(output, expected);
+ assertThat(output)
+ .isEqualTo(expected);
}
@Test
@@ -74,7 +74,8 @@ public void testBuildProjectionWithId()
.append(COL1.getBaseName(), 1)
.append(COL2.getBaseName(), 1)
.append(ID_COL.getBaseName(), 1);
- assertEquals(output, expected);
+ assertThat(output)
+ .isEqualTo(expected);
}
@Test
@@ -89,7 +90,8 @@ public void testBuildQuery()
.append("$and", ImmutableList.of(
new Document(COL1.getBaseName(), new Document().append("$gt", 100L).append("$lte", 200L)),
new Document(COL2.getBaseName(), new Document("$eq", "a value"))));
- assertEquals(query, expected);
+ assertThat(query)
+ .isEqualTo(expected);
}
@Test
@@ -104,7 +106,8 @@ public void testBuildQueryStringType()
.append("$and", ImmutableList.of(
new Document(COL3.getBaseName(), new Document().append("$gt", "hello").append("$lte", "world")),
new Document(COL2.getBaseName(), new Document("$gte", "a value"))));
- assertEquals(query, expected);
+ assertThat(query)
+ .isEqualTo(expected);
}
@Test
@@ -115,7 +118,8 @@ public void testBuildQueryIn()
Document query = MongoSession.buildQuery(tupleDomain);
Document expected = new Document(COL2.getBaseName(), new Document("$in", ImmutableList.of("hello", "world")));
- assertEquals(query, expected);
+ assertThat(query)
+ .isEqualTo(expected);
}
@Test
@@ -128,7 +132,8 @@ public void testBuildQueryOr()
Document expected = new Document("$or", asList(
new Document(COL1.getBaseName(), new Document("$lt", 100L)),
new Document(COL1.getBaseName(), new Document("$gt", 200L))));
- assertEquals(query, expected);
+ assertThat(query)
+ .isEqualTo(expected);
}
@Test
@@ -141,7 +146,8 @@ public void testBuildQueryNull()
Document expected = new Document("$or", asList(
new Document(COL1.getBaseName(), new Document("$gt", 200L)),
new Document(COL1.getBaseName(), new Document("$eq", null))));
- assertEquals(query, expected);
+ assertThat(query)
+ .isEqualTo(expected);
}
@Test
@@ -151,7 +157,8 @@ public void testBooleanPredicatePushdown()
Document query = MongoSession.buildQuery(tupleDomain);
Document expected = new Document().append(COL4.getBaseName(), new Document("$eq", true));
- assertEquals(query, expected);
+ assertThat(query)
+ .isEqualTo(expected);
}
@Test
@@ -168,7 +175,8 @@ public void testBuildQueryNestedField()
new Document(COL5.getQualifiedName(), new Document("$gt", 200L)),
new Document(COL5.getQualifiedName(), new Document("$eq", null)))),
new Document(COL6.getQualifiedName(), new Document("$eq", "a value"))));
- assertEquals(query, expected);
+ assertThat(query)
+ .isEqualTo(expected);
}
@Test
diff --git a/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoSplit.java b/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoSplit.java
index d5ecf9c2db81..a2d4fc76e8a1 100644
--- a/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoSplit.java
+++ b/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoSplit.java
@@ -17,7 +17,7 @@
import io.airlift.json.JsonCodec;
import org.junit.jupiter.api.Test;
-import static org.testng.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThat;
public class TestMongoSplit
{
@@ -31,6 +31,7 @@ public void testJsonRoundTrip()
String json = codec.toJson(expected);
MongoSplit actual = codec.fromJson(json);
- assertEquals(actual.getAddresses(), ImmutableList.of());
+ assertThat(actual.getAddresses())
+ .isEqualTo(ImmutableList.of());
}
}
diff --git a/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoTableHandle.java b/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoTableHandle.java
index e3777733f21c..bdeab116b8ad 100644
--- a/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoTableHandle.java
+++ b/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoTableHandle.java
@@ -33,7 +33,7 @@
import static io.trino.spi.type.IntegerType.INTEGER;
import static io.trino.spi.type.VarcharType.VARCHAR;
import static io.trino.type.InternalTypeManager.TESTING_TYPE_MANAGER;
-import static org.testng.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThat;
public class TestMongoTableHandle
{
@@ -56,7 +56,8 @@ public void testRoundTripWithoutQuery()
String json = codec.toJson(expected);
MongoTableHandle actual = codec.fromJson(json);
- assertEquals(actual.getSchemaTableName(), expected.getSchemaTableName());
+ assertThat(actual.getSchemaTableName())
+ .isEqualTo(expected.getSchemaTableName());
}
@Test
@@ -69,7 +70,8 @@ public void testRoundTripNonLowercaseWithoutQuery()
String json = codec.toJson(expected);
MongoTableHandle actual = codec.fromJson(json);
- assertEquals(actual.getSchemaTableName(), expected.getSchemaTableName());
+ assertThat(actual.getSchemaTableName())
+ .isEqualTo(expected.getSchemaTableName());
}
@Test
@@ -82,7 +84,8 @@ public void testRoundTripWithQuery()
String json = codec.toJson(expected);
MongoTableHandle actual = codec.fromJson(json);
- assertEquals(actual.getSchemaTableName(), expected.getSchemaTableName());
+ assertThat(actual.getSchemaTableName())
+ .isEqualTo(expected.getSchemaTableName());
}
@Test
@@ -95,7 +98,8 @@ public void testRoundTripWithQueryHavingHelperFunction()
String json = codec.toJson(expected);
MongoTableHandle actual = codec.fromJson(json);
- assertEquals(actual.getSchemaTableName(), expected.getSchemaTableName());
+ assertThat(actual.getSchemaTableName())
+ .isEqualTo(expected.getSchemaTableName());
}
@Test
@@ -126,6 +130,7 @@ public void testRoundTripWithProjectedColumns()
String json = codec.toJson(expected);
MongoTableHandle actual = codec.fromJson(json);
- assertEquals(actual, expected);
+ assertThat(actual)
+ .isEqualTo(expected);
}
}
diff --git a/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoTypeMapping.java b/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoTypeMapping.java
index 5cbe1a3d893b..92fcf5fea78f 100644
--- a/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoTypeMapping.java
+++ b/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoTypeMapping.java
@@ -28,8 +28,7 @@
import io.trino.testing.datatype.SqlDataTypeTest;
import io.trino.testing.sql.TestTable;
import io.trino.testing.sql.TrinoSqlExecutor;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
import java.time.ZoneId;
@@ -266,8 +265,19 @@ public void testTime()
.execute(getQueryRunner(), trinoCreateAndInsert("test_time"));
}
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testDate(ZoneId sessionZone)
+ @Test
+ public void testDate()
+ {
+ testDate(UTC);
+ testDate(ZoneId.systemDefault());
+ // no DST in 1970, but has DST in later years (e.g. 2018)
+ testDate(ZoneId.of("Europe/Vilnius"));
+ // minutes offset change since 1970-01-01, no DST
+ testDate(ZoneId.of("Asia/Kathmandu"));
+ testDate(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testDate(ZoneId sessionZone)
{
Session session = Session.builder(getSession())
.setTimeZoneKey(TimeZoneKey.getTimeZoneKey(sessionZone.getId()))
@@ -297,8 +307,19 @@ public void testDate(ZoneId sessionZone)
.execute(getQueryRunner(), session, trinoCreateAndInsert("test_date"));
}
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testTimestamp(ZoneId sessionZone)
+ @Test
+ public void testTimestamp()
+ {
+ testTimestamp(UTC);
+ testTimestamp(ZoneId.systemDefault());
+ // no DST in 1970, but has DST in later years (e.g. 2018)
+ testTimestamp(ZoneId.of("Europe/Vilnius"));
+ // minutes offset change since 1970-01-01, no DST
+ testTimestamp(ZoneId.of("Asia/Kathmandu"));
+ testTimestamp(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testTimestamp(ZoneId sessionZone)
{
Session session = Session.builder(getSession())
.setTimeZoneKey(TimeZoneKey.getTimeZoneKey(sessionZone.getId()))
@@ -322,8 +343,19 @@ public void testTimestamp(ZoneId sessionZone)
.execute(getQueryRunner(), session, trinoCreateAndInsert("test_timestamp"));
}
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testTimestampWithTimeZoneMapping(ZoneId sessionZone)
+ @Test
+ public void testTimestampWithTimeZoneMapping()
+ {
+ testTimestampWithTimeZoneMapping(UTC);
+ testTimestampWithTimeZoneMapping(ZoneId.systemDefault());
+ // no DST in 1970, but has DST in later years (e.g. 2018)
+ testTimestampWithTimeZoneMapping(ZoneId.of("Europe/Vilnius"));
+ // minutes offset change since 1970-01-01, no DST
+ testTimestampWithTimeZoneMapping(ZoneId.of("Asia/Kathmandu"));
+ testTimestampWithTimeZoneMapping(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testTimestampWithTimeZoneMapping(ZoneId sessionZone)
{
Session session = Session.builder(getSession())
.setTimeZoneKey(TimeZoneKey.getTimeZoneKey(sessionZone.getId()))
@@ -385,20 +417,6 @@ public void testJson()
.execute(getQueryRunner(), trinoCreateAndInsert("test_json"));
}
- @DataProvider
- public Object[][] sessionZonesDataProvider()
- {
- return new Object[][] {
- {UTC},
- {ZoneId.systemDefault()},
- // no DST in 1970, but has DST in later years (e.g. 2018)
- {ZoneId.of("Europe/Vilnius")},
- // minutes offset change since 1970-01-01, no DST
- {ZoneId.of("Asia/Kathmandu")},
- {TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId()},
- };
- }
-
private DataSetup trinoCreateAsSelect(String tableNamePrefix)
{
return trinoCreateAsSelect(getSession(), tableNamePrefix);
diff --git a/plugin/trino-mysql/pom.xml b/plugin/trino-mysql/pom.xml
index 12c3a606c23f..e446e34f5fec 100644
--- a/plugin/trino-mysql/pom.xml
+++ b/plugin/trino-mysql/pom.xml
@@ -232,33 +232,5 @@
testcontainers
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/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/BaseMySqlConnectorTest.java b/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/BaseMySqlConnectorTest.java
index cc0322f29c5a..8a93907a4298 100644
--- a/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/BaseMySqlConnectorTest.java
+++ b/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/BaseMySqlConnectorTest.java
@@ -45,9 +45,6 @@
import static java.util.stream.IntStream.range;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
public abstract class BaseMySqlConnectorTest
extends BaseJdbcConnectorTest
@@ -206,15 +203,15 @@ public void testNameEscaping()
.setSchema(getSession().getSchema())
.build();
- assertFalse(getQueryRunner().tableExists(session, "test_table"));
+ assertThat(getQueryRunner().tableExists(session, "test_table")).isFalse();
assertUpdate(session, "CREATE TABLE test_table AS SELECT 123 x", 1);
- assertTrue(getQueryRunner().tableExists(session, "test_table"));
+ assertThat(getQueryRunner().tableExists(session, "test_table")).isTrue();
assertQuery(session, "SELECT * FROM test_table", "SELECT 123");
assertUpdate(session, "DROP TABLE test_table");
- assertFalse(getQueryRunner().tableExists(session, "test_table"));
+ assertThat(getQueryRunner().tableExists(session, "test_table")).isFalse();
}
@Test
@@ -226,7 +223,8 @@ public void testMySqlTinyint()
onRemoteDatabase().execute("INSERT INTO tpch.mysql_test_tinyint1 VALUES (127), (-128)");
MaterializedResult materializedRows = computeActual("SELECT * FROM tpch.mysql_test_tinyint1 WHERE c_tinyint = 127");
- assertEquals(materializedRows.getOnlyValue(), (byte) 127);
+ assertThat(materializedRows.getOnlyValue())
+ .isEqualTo((byte) 127);
assertUpdate("DROP TABLE mysql_test_tinyint1");
}
@@ -517,7 +515,7 @@ public void testNativeMultipleInClauses()
public void testNativeQueryInsertStatementTableDoesNotExist()
{
// override because MySQL succeeds in preparing query, and then fails because of no metadata available
- assertFalse(getQueryRunner().tableExists(getSession(), "non_existent_table"));
+ assertThat(getQueryRunner().tableExists(getSession(), "non_existent_table")).isFalse();
assertThatThrownBy(() -> query("SELECT * FROM TABLE(system.query(query => 'INSERT INTO non_existent_table VALUES (1)'))"))
.hasMessageContaining("Query not supported: ResultSetMetaData not available for query: INSERT INTO non_existent_table VALUES (1)");
}
diff --git a/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/BaseTestMySqlTableStatisticsTest.java b/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/BaseTestMySqlTableStatisticsTest.java
index 16c38585aa9f..adf256e67f79 100644
--- a/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/BaseTestMySqlTableStatisticsTest.java
+++ b/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/BaseTestMySqlTableStatisticsTest.java
@@ -42,9 +42,6 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.withinPercentage;
import static org.junit.jupiter.api.Assumptions.abort;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
public abstract class BaseTestMySqlTableStatisticsTest
extends BaseJdbcTableStatisticsTest
@@ -163,17 +160,29 @@ public void testAllNulls()
}
if ((columnName.equals("orderpriority") || columnName.equals("comment")) && varcharNdvToExpected.apply(2) == null) {
- assertNull(row.getField(2), "NDV for " + columnName);
- assertNull(row.getField(3), "null fraction for " + columnName);
+ assertThat(row.getField(2))
+ .describedAs("NDV for " + columnName)
+ .isNull();
+ assertThat(row.getField(3))
+ .describedAs("null fraction for " + columnName)
+ .isNull();
}
else {
- assertNotNull(row.getField(2), "NDV for " + columnName);
+ assertThat(row.getField(2))
+ .describedAs("NDV for " + columnName)
+ .isNotNull();
assertThat((Double) row.getField(2)).as("NDV for " + columnName).isBetween(0.0, 2.0);
- assertEquals(row.getField(3), nullFractionToExpected.apply(1.0), "null fraction for " + columnName);
+ assertThat(row.getField(3))
+ .describedAs("null fraction for " + columnName)
+ .isEqualTo(nullFractionToExpected.apply(1.0));
}
- assertNull(row.getField(4), "min");
- assertNull(row.getField(5), "max");
+ assertThat(row.getField(4))
+ .describedAs("min")
+ .isNull();
+ assertThat(row.getField(5))
+ .describedAs("max")
+ .isNull();
}
double cardinality = getTableCardinalityFromStats(statsResult);
if (cardinality != 15.0) {
@@ -362,7 +371,8 @@ protected void assertColumnStats(MaterializedResult statsResult, Map columnNdvs, Map columnNullFractions)
{
- assertEquals(columnNdvs.keySet(), columnNullFractions.keySet());
+ assertThat(columnNdvs.keySet())
+ .isEqualTo(columnNullFractions.keySet());
List reportedColumns = stream(statsResult)
.map(row -> row.getField(0)) // column name
.filter(Objects::nonNull)
@@ -393,7 +403,9 @@ protected void assertColumnStats(MaterializedResult statsResult, Map ndvAssertion = assertThat(distinctCount).as("NDV for " + columnName);
if (expectedNdv == null) {
ndvAssertion.isNull();
- assertNull(nullsFraction, "null fraction for " + columnName);
+ assertThat(nullsFraction)
+ .describedAs("null fraction for " + columnName)
+ .isNull();
}
else {
ndvAssertion.isBetween(expectedNdv * 0.5, min(expectedNdv * 4.0, tableCardinality)); // [-50%, +300%] but no more than row count
@@ -408,22 +420,27 @@ protected void assertColumnStats(MaterializedResult statsResult, Map columnMapping = JDBC_CLIENT.toColumnMapping(SESSION, null, result.get().getJdbcTypeHandle());
- assertTrue(columnMapping.isPresent(), "No mapping for: " + result.get().getJdbcTypeHandle());
- assertEquals(columnMapping.get().getType(), aggregateFunction.getOutputType());
+ assertThat(columnMapping.isPresent())
+ .describedAs("No mapping for: " + result.get().getJdbcTypeHandle())
+ .isTrue();
+ assertThat(columnMapping.get().getType())
+ .isEqualTo(aggregateFunction.getOutputType());
}
}
}
diff --git a/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlJdbcConfig.java b/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlJdbcConfig.java
index 99afceb7294a..c0823df797d4 100644
--- a/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlJdbcConfig.java
+++ b/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlJdbcConfig.java
@@ -15,17 +15,16 @@
import org.junit.jupiter.api.Test;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
public class TestMySqlJdbcConfig
{
@Test
public void testIsUrlWithoutDatabase()
{
- assertTrue(isUrlWithoutDatabase("jdbc:mysql://example.net:3306"));
- assertTrue(isUrlWithoutDatabase("jdbc:mysql://example.net:3306/"));
- assertFalse(isUrlWithoutDatabase("jdbc:mysql://example.net:3306/somedatabase"));
+ assertThat(isUrlWithoutDatabase("jdbc:mysql://example.net:3306")).isTrue();
+ assertThat(isUrlWithoutDatabase("jdbc:mysql://example.net:3306/")).isTrue();
+ assertThat(isUrlWithoutDatabase("jdbc:mysql://example.net:3306/somedatabase")).isFalse();
}
private static boolean isUrlWithoutDatabase(String url)
diff --git a/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlTimeMappingsWithServerTimeZone.java b/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlTimeMappingsWithServerTimeZone.java
index af7844f723ff..471991196c64 100644
--- a/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlTimeMappingsWithServerTimeZone.java
+++ b/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlTimeMappingsWithServerTimeZone.java
@@ -28,8 +28,7 @@
import io.trino.testing.sql.TestTable;
import io.trino.testing.sql.TrinoSqlExecutor;
import org.intellij.lang.annotations.Language;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
import java.sql.Connection;
import java.sql.DriverManager;
@@ -62,8 +61,19 @@ protected QueryRunner createQueryRunner()
return createMySqlQueryRunner(mySqlServer, ImmutableMap.of(), ImmutableMap.of(), ImmutableList.of());
}
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testDate(ZoneId sessionZone)
+ @Test
+ public void testDate()
+ {
+ testDate(UTC);
+ testDate(ZoneId.systemDefault());
+ // no DST in 1970, but has DST in later years (e.g. 2018)
+ testDate(ZoneId.of("Europe/Vilnius"));
+ // minutes offset change since 1970-01-01, no DST
+ testDate(ZoneId.of("Asia/Kathmandu"));
+ testDate(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testDate(ZoneId sessionZone)
{
Session session = Session.builder(getSession())
.setTimeZoneKey(TimeZoneKey.getTimeZoneKey(sessionZone.getId()))
@@ -89,8 +99,19 @@ public void testDate(ZoneId sessionZone)
.execute(getQueryRunner(), session, trinoCreateAndInsert("test_date"));
}
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testTimeFromMySql(ZoneId sessionZone)
+ @Test
+ public void testTimeFromMySql()
+ {
+ testTimeFromMySql(UTC);
+ testTimeFromMySql(ZoneId.systemDefault());
+ // no DST in 1970, but has DST in later years (e.g. 2018)
+ testTimeFromMySql(ZoneId.of("Europe/Vilnius"));
+ // minutes offset change since 1970-01-01, no DST
+ testTimeFromMySql(ZoneId.of("Asia/Kathmandu"));
+ testTimeFromMySql(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testTimeFromMySql(ZoneId sessionZone)
{
Session session = Session.builder(getSession())
.setTimeZoneKey(TimeZoneKey.getTimeZoneKey(sessionZone.getId()))
@@ -114,8 +135,19 @@ public void testTimeFromMySql(ZoneId sessionZone)
.execute(getQueryRunner(), session, mysqlCreateAndInsert("tpch.test_time"));
}
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testTimeFromTrino(ZoneId sessionZone)
+ @Test
+ public void testTimeFromTrino()
+ {
+ testTimeFromTrino(UTC);
+ testTimeFromTrino(ZoneId.systemDefault());
+ // no DST in 1970, but has DST in later years (e.g. 2018)
+ testTimeFromTrino(ZoneId.of("Europe/Vilnius"));
+ // minutes offset change since 1970-01-01, no DST
+ testTimeFromTrino(ZoneId.of("Asia/Kathmandu"));
+ testTimeFromTrino(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testTimeFromTrino(ZoneId sessionZone)
{
Session session = Session.builder(getSession())
.setTimeZoneKey(TimeZoneKey.getTimeZoneKey(sessionZone.getId()))
@@ -209,8 +241,19 @@ public void testTimeFromTrino(ZoneId sessionZone)
/**
* Read {@code DATETIME}s inserted by MySQL as Trino {@code TIMESTAMP}s
*/
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testMySqlDatetimeType(ZoneId sessionZone)
+ @Test
+ public void testMySqlDatetimeType()
+ {
+ testMySqlDatetimeType(UTC);
+ testMySqlDatetimeType(ZoneId.systemDefault());
+ // no DST in 1970, but has DST in later years (e.g. 2018)
+ testMySqlDatetimeType(ZoneId.of("Europe/Vilnius"));
+ // minutes offset change since 1970-01-01, no DST
+ testMySqlDatetimeType(ZoneId.of("Asia/Kathmandu"));
+ testMySqlDatetimeType(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testMySqlDatetimeType(ZoneId sessionZone)
{
Session session = Session.builder(getSession())
.setTimeZoneKey(TimeZoneKey.getTimeZoneKey(sessionZone.getId()))
@@ -274,8 +317,19 @@ public void testMySqlDatetimeType(ZoneId sessionZone)
/**
* Read {@code TIMESTAMP}s inserted by MySQL as Trino {@code TIMESTAMP WITH TIME ZONE}s
*/
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testTimestampFromMySql(ZoneId sessionZone)
+ @Test
+ public void testTimestampFromMySql()
+ {
+ testTimestampFromMySql(UTC);
+ testTimestampFromMySql(ZoneId.systemDefault());
+ // no DST in 1970, but has DST in later years (e.g. 2018)
+ testTimestampFromMySql(ZoneId.of("Europe/Vilnius"));
+ // minutes offset change since 1970-01-01, no DST
+ testTimestampFromMySql(ZoneId.of("Asia/Kathmandu"));
+ testTimestampFromMySql(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testTimestampFromMySql(ZoneId sessionZone)
{
Session session = Session.builder(getSession())
.setTimeZoneKey(TimeZoneKey.getTimeZoneKey(sessionZone.getId()))
@@ -324,8 +378,19 @@ public void testTimestampFromMySql(ZoneId sessionZone)
.execute(getQueryRunner(), session, mysqlCreateAndInsert("tpch.test_timestamp"));
}
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testTimestampFromTrino(ZoneId sessionZone)
+ @Test
+ public void testTimestampFromTrino()
+ {
+ testTimestampFromTrino(UTC);
+ testTimestampFromTrino(ZoneId.systemDefault());
+ // no DST in 1970, but has DST in later years (e.g. 2018)
+ testTimestampFromTrino(ZoneId.of("Europe/Vilnius"));
+ // minutes offset change since 1970-01-01, no DST
+ testTimestampFromTrino(ZoneId.of("Asia/Kathmandu"));
+ testTimestampFromTrino(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testTimestampFromTrino(ZoneId sessionZone)
{
Session session = Session.builder(getSession())
.setTimeZoneKey(TimeZoneKey.getTimeZoneKey(sessionZone.getId()))
@@ -612,20 +677,6 @@ public void testTimestampWithTimeZoneCoercion()
.execute(getQueryRunner(), trinoCreateAndInsert("test_timestamp_with_time_zone_coercion"));
}
- @DataProvider
- public Object[][] sessionZonesDataProvider()
- {
- return new Object[][] {
- {UTC},
- {ZoneId.systemDefault()},
- // no DST in 1970, but has DST in later years (e.g. 2018)
- {ZoneId.of("Europe/Vilnius")},
- // minutes offset change since 1970-01-01, no DST
- {ZoneId.of("Asia/Kathmandu")},
- {TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId()},
- };
- }
-
@Test
public void testZeroTimestamp()
throws Exception
diff --git a/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlTypeMapping.java b/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlTypeMapping.java
index 0102a40dc64c..a650a0c742cc 100644
--- a/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlTypeMapping.java
+++ b/plugin/trino-mysql/src/test/java/io/trino/plugin/mysql/TestMySqlTypeMapping.java
@@ -30,9 +30,10 @@
import io.trino.testing.sql.TestTable;
import io.trino.testing.sql.TrinoSqlExecutor;
import org.intellij.lang.annotations.Language;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.parallel.Execution;
import java.math.RoundingMode;
import java.sql.Connection;
@@ -76,7 +77,11 @@
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
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;
+@TestInstance(PER_CLASS)
+@Execution(CONCURRENT)
public class TestMySqlTypeMapping
extends AbstractTestQueryFramework
{
@@ -86,7 +91,7 @@ public class TestMySqlTypeMapping
// no DST in 1970, but has DST in later years (e.g. 2018)
private final ZoneId vilnius = ZoneId.of("Europe/Vilnius");
- @BeforeClass
+ @BeforeAll
public void setUp()
{
checkState(jvmZone.getId().equals("America/Bahia_Banderas"), "This test assumes certain JVM time zone");
@@ -431,8 +436,14 @@ public void testDecimalExceedingPrecisionMaxWithNonExceedingIntegerValues()
}
}
- @Test(dataProvider = "testDecimalExceedingPrecisionMaxProvider")
- public void testDecimalExceedingPrecisionMaxWithSupportedValues(int typePrecision, int typeScale)
+ @Test
+ public void testDecimalExceedingPrecisionMaxWithSupportedValues()
+ {
+ testDecimalExceedingPrecisionMaxWithSupportedValues(40, 8);
+ testDecimalExceedingPrecisionMaxWithSupportedValues(50, 10);
+ }
+
+ private void testDecimalExceedingPrecisionMaxWithSupportedValues(int typePrecision, int typeScale)
{
try (TestTable testTable = new TestTable(
mySqlServer::execute,
@@ -482,15 +493,6 @@ public void testDecimalExceedingPrecisionMaxWithSupportedValues(int typePrecisio
}
}
- @DataProvider
- public Object[][] testDecimalExceedingPrecisionMaxProvider()
- {
- return new Object[][] {
- {40, 8},
- {50, 10},
- };
- }
-
private Session sessionWithDecimalMappingAllowOverflow(RoundingMode roundingMode, int scale)
{
return Session.builder(getSession())
@@ -556,8 +558,19 @@ public void testBinary()
.execute(getQueryRunner(), mysqlCreateAndInsert("tpch.test_binary"));
}
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testDate(ZoneId sessionZone)
+ @Test
+ public void testDate()
+ {
+ testDate(UTC);
+ testDate(ZoneId.systemDefault());
+ // no DST in 1970, but has DST in later years (e.g. 2018)
+ testDate(ZoneId.of("Europe/Vilnius"));
+ // minutes offset change since 1970-01-01, no DST
+ testDate(ZoneId.of("Asia/Kathmandu"));
+ testDate(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testDate(ZoneId sessionZone)
{
Session session = Session.builder(getSession())
.setTimeZoneKey(TimeZoneKey.getTimeZoneKey(sessionZone.getId()))
@@ -583,8 +596,19 @@ public void testDate(ZoneId sessionZone)
.execute(getQueryRunner(), session, trinoCreateAndInsert("test_date"));
}
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testTimeFromMySql(ZoneId sessionZone)
+ @Test
+ public void testTimeFromMySql()
+ {
+ testTimestampFromMySql(UTC);
+ testTimestampFromMySql(ZoneId.systemDefault());
+ // no DST in 1970, but has DST in later years (e.g. 2018)
+ testTimestampFromMySql(ZoneId.of("Europe/Vilnius"));
+ // minutes offset change since 1970-01-01, no DST
+ testTimestampFromMySql(ZoneId.of("Asia/Kathmandu"));
+ testTimestampFromMySql(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testTimeFromMySql(ZoneId sessionZone)
{
Session session = Session.builder(getSession())
.setTimeZoneKey(TimeZoneKey.getTimeZoneKey(sessionZone.getId()))
@@ -608,8 +632,19 @@ public void testTimeFromMySql(ZoneId sessionZone)
.execute(getQueryRunner(), session, mysqlCreateAndInsert("tpch.test_time"));
}
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testTimeFromTrino(ZoneId sessionZone)
+ @Test
+ public void testTimeFromTrino()
+ {
+ testTimeFromTrino(UTC);
+ testTimeFromTrino(ZoneId.systemDefault());
+ // no DST in 1970, but has DST in later years (e.g. 2018)
+ testTimeFromTrino(ZoneId.of("Europe/Vilnius"));
+ // minutes offset change since 1970-01-01, no DST
+ testTimeFromTrino(ZoneId.of("Asia/Kathmandu"));
+ testTimeFromTrino(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testTimeFromTrino(ZoneId sessionZone)
{
Session session = Session.builder(getSession())
.setTimeZoneKey(TimeZoneKey.getTimeZoneKey(sessionZone.getId()))
@@ -703,8 +738,19 @@ public void testTimeFromTrino(ZoneId sessionZone)
/**
* Read {@code DATETIME}s inserted by MySQL as Trino {@code TIMESTAMP}s
*/
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testMySqlDatetimeType(ZoneId sessionZone)
+ @Test
+ public void testMySqlDatetimeType()
+ {
+ testMySqlDatetimeType(UTC);
+ testMySqlDatetimeType(ZoneId.systemDefault());
+ // no DST in 1970, but has DST in later years (e.g. 2018)
+ testMySqlDatetimeType(ZoneId.of("Europe/Vilnius"));
+ // minutes offset change since 1970-01-01, no DST
+ testMySqlDatetimeType(ZoneId.of("Asia/Kathmandu"));
+ testMySqlDatetimeType(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testMySqlDatetimeType(ZoneId sessionZone)
{
Session session = Session.builder(getSession())
.setTimeZoneKey(TimeZoneKey.getTimeZoneKey(sessionZone.getId()))
@@ -768,8 +814,19 @@ public void testMySqlDatetimeType(ZoneId sessionZone)
/**
* Read {@code TIMESTAMP}s inserted by MySQL as Trino {@code TIMESTAMP WITH TIME ZONE}s
*/
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testTimestampFromMySql(ZoneId sessionZone)
+ @Test
+ public void testTimestampFromMySql()
+ {
+ testTimestampFromMySql(UTC);
+ testTimestampFromMySql(ZoneId.systemDefault());
+ // no DST in 1970, but has DST in later years (e.g. 2018)
+ testTimestampFromMySql(ZoneId.of("Europe/Vilnius"));
+ // minutes offset change since 1970-01-01, no DST
+ testTimestampFromMySql(ZoneId.of("Asia/Kathmandu"));
+ testTimestampFromMySql(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testTimestampFromMySql(ZoneId sessionZone)
{
Session session = Session.builder(getSession())
.setTimeZoneKey(TimeZoneKey.getTimeZoneKey(sessionZone.getId()))
@@ -817,8 +874,19 @@ public void testTimestampFromMySql(ZoneId sessionZone)
.execute(getQueryRunner(), session, mysqlCreateAndInsert("tpch.test_timestamp"));
}
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testTimestampFromTrino(ZoneId sessionZone)
+ @Test
+ public void testTimestampFromTrino()
+ {
+ testTimestampFromTrino(UTC);
+ testTimestampFromTrino(ZoneId.systemDefault());
+ // no DST in 1970, but has DST in later years (e.g. 2018)
+ testTimestampFromTrino(ZoneId.of("Europe/Vilnius"));
+ // minutes offset change since 1970-01-01, no DST
+ testTimestampFromTrino(ZoneId.of("Asia/Kathmandu"));
+ testTimestampFromTrino(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testTimestampFromTrino(ZoneId sessionZone)
{
Session session = Session.builder(getSession())
.setTimeZoneKey(TimeZoneKey.getTimeZoneKey(sessionZone.getId()))
@@ -1105,20 +1173,6 @@ public void testTimestampWithTimeZoneCoercion()
.execute(getQueryRunner(), trinoCreateAndInsert("test_timestamp_with_time_zone_coercion"));
}
- @DataProvider
- public Object[][] sessionZonesDataProvider()
- {
- return new Object[][] {
- {UTC},
- {ZoneId.systemDefault()},
- // no DST in 1970, but has DST in later years (e.g. 2018)
- {ZoneId.of("Europe/Vilnius")},
- // minutes offset change since 1970-01-01, no DST
- {ZoneId.of("Asia/Kathmandu")},
- {TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId()},
- };
- }
-
@Test
public void testZeroTimestamp()
throws Exception
diff --git a/plugin/trino-oracle/pom.xml b/plugin/trino-oracle/pom.xml
index eaf458272ee3..b985032e558e 100644
--- a/plugin/trino-oracle/pom.xml
+++ b/plugin/trino-oracle/pom.xml
@@ -242,33 +242,5 @@
testcontainers
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/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/AbstractTestOracleTypeMapping.java b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/AbstractTestOracleTypeMapping.java
index 55ddb20ab1e5..45b3740cd38b 100644
--- a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/AbstractTestOracleTypeMapping.java
+++ b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/AbstractTestOracleTypeMapping.java
@@ -28,9 +28,10 @@
import io.trino.testing.sql.SqlExecutor;
import io.trino.testing.sql.TestTable;
import io.trino.testing.sql.TrinoSqlExecutor;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.parallel.Execution;
import java.math.RoundingMode;
import java.time.LocalDate;
@@ -66,7 +67,11 @@
import static java.math.RoundingMode.HALF_UP;
import static java.math.RoundingMode.UNNECESSARY;
import static java.time.ZoneOffset.UTC;
+import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS;
+import static org.junit.jupiter.api.parallel.ExecutionMode.CONCURRENT;
+@TestInstance(PER_CLASS)
+@Execution(CONCURRENT)
public abstract class AbstractTestOracleTypeMapping
extends AbstractTestQueryFramework
{
@@ -95,7 +100,7 @@ public abstract class AbstractTestOracleTypeMapping
private final ZoneId kathmandu = ZoneId.of("Asia/Kathmandu");
private final LocalDateTime timeGapInKathmandu = LocalDateTime.of(1986, 1, 1, 0, 13, 7);
- @BeforeClass
+ @BeforeAll
public void setUp()
{
checkState(jvmZone.getId().equals("America/Bahia_Banderas"), "This test assumes certain JVM time zone");
@@ -636,8 +641,18 @@ public void testVarbinary()
.execute(getQueryRunner(), oracleCreateAndInsert("test_blob"));
}
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testDate(ZoneId sessionZone)
+ @Test
+ public void testDate()
+ {
+ testDate(UTC);
+ testDate(jvmZone);
+ // using two non-JVM zones so that we don't need to worry what Oracle system zone is
+ testDate(vilnius);
+ testDate(kathmandu);
+ testDate(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testDate(ZoneId sessionZone)
{
// Note: these test cases are duplicates of those for PostgreSQL and MySQL.
@@ -700,8 +715,18 @@ public void testUnsupportedDate()
}
}
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testTimestamp(ZoneId sessionZone)
+ @Test
+ public void testTimestamp()
+ {
+ testTimestamp(UTC);
+ testTimestamp(jvmZone);
+ // using two non-JVM zones so that we don't need to worry what Oracle system zone is
+ testTimestamp(vilnius);
+ testTimestamp(kathmandu);
+ testTimestamp(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testTimestamp(ZoneId sessionZone)
{
Session session = Session.builder(getSession())
.setTimeZoneKey(getTimeZoneKey(sessionZone.getId()))
@@ -734,8 +759,18 @@ public void testTimestamp(ZoneId sessionZone)
.execute(getQueryRunner(), session, trinoCreateAndInsert(session, "test_timestamp"));
}
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testTimestampNanos(ZoneId sessionZone)
+ @Test
+ public void testTimestampNanos()
+ {
+ testTimestampNanos(UTC);
+ testTimestampNanos(jvmZone);
+ // using two non-JVM zones so that we don't need to worry what Oracle system zone is
+ testTimestampNanos(vilnius);
+ testTimestampNanos(kathmandu);
+ testTimestampNanos(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testTimestampNanos(ZoneId sessionZone)
{
Session session = Session.builder(getSession())
.setTimeZoneKey(getTimeZoneKey(sessionZone.getId()))
@@ -769,8 +804,18 @@ public void testTimestampNanos(ZoneId sessionZone)
.execute(getQueryRunner(), session, trinoCreateAndInsert(session, "test_timestamp_nano"));
}
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testTimestampAllPrecisions(ZoneId sessionZone)
+ @Test
+ public void testTimestampAllPrecisions()
+ {
+ testTimestampAllPrecisions(UTC);
+ testTimestampAllPrecisions(jvmZone);
+ // using two non-JVM zones so that we don't need to worry what Oracle system zone is
+ testTimestampAllPrecisions(vilnius);
+ testTimestampAllPrecisions(kathmandu);
+ testTimestampAllPrecisions(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testTimestampAllPrecisions(ZoneId sessionZone)
{
SqlDataTypeTest tests = SqlDataTypeTest.create()
// before epoch
@@ -925,19 +970,6 @@ public void testUnsupportedTimestamp()
}
}
- @DataProvider
- public Object[][] sessionZonesDataProvider()
- {
- return new Object[][] {
- {UTC},
- {jvmZone},
- // using two non-JVM zones so that we don't need to worry what Oracle system zone is
- {vilnius},
- {kathmandu},
- {TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId()},
- };
- }
-
@Test
public void testTimestampWithTimeZoneFromTrino()
{
diff --git a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/BaseOracleConnectorTest.java b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/BaseOracleConnectorTest.java
index 644959e2d8e1..183f451aa0d6 100644
--- a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/BaseOracleConnectorTest.java
+++ b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/BaseOracleConnectorTest.java
@@ -38,8 +38,6 @@
import static java.util.Locale.ENGLISH;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
public abstract class BaseOracleConnectorTest
extends BaseJdbcConnectorTest
@@ -186,7 +184,8 @@ public void testTimestampOutOfPrecisionRounded()
assertUpdate("CREATE TABLE " + tableName + " (t timestamp(12))");
- assertEquals(getColumnType(tableName, "t"), "timestamp(9)");
+ assertThat(getColumnType(tableName, "t"))
+ .isEqualTo("timestamp(9)");
assertUpdate("DROP TABLE " + tableName);
}
@@ -402,7 +401,7 @@ public void testNativeQueryParameters()
public void testNativeQueryInsertStatementTableDoesNotExist()
{
// override because Oracle succeeds in preparing query, and then fails because of no metadata available
- assertFalse(getQueryRunner().tableExists(getSession(), "non_existent_table"));
+ assertThat(getQueryRunner().tableExists(getSession(), "non_existent_table")).isFalse();
assertThatThrownBy(() -> query("SELECT * FROM TABLE(system.query(query => 'INSERT INTO non_existent_table VALUES (1)'))"))
.hasMessageContaining("Query not supported: ResultSetMetaData not available for query: INSERT INTO non_existent_table VALUES (1)");
}
diff --git a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOracleCaseInsensitiveMapping.java b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOracleCaseInsensitiveMapping.java
index d5b3b2fe0dfa..ec6674c5fa90 100644
--- a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOracleCaseInsensitiveMapping.java
+++ b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOracleCaseInsensitiveMapping.java
@@ -18,7 +18,6 @@
import io.trino.plugin.jdbc.BaseCaseInsensitiveMappingTest;
import io.trino.testing.QueryRunner;
import io.trino.testing.sql.SqlExecutor;
-import org.junit.jupiter.api.Test;
import java.nio.file.Path;
import java.util.Optional;
@@ -94,12 +93,4 @@ protected SqlExecutor onRemoteDatabase()
{
return oracleServer::execute;
}
-
- @Test
- public void forceTestNgToRespectSingleThreaded()
- {
- // TODO: Remove after updating TestNG to 7.4.0+ (https://github.com/trinodb/trino/issues/8571)
- // TestNG doesn't enforce @Test(singleThreaded = true) when tests are defined in base class. According to
- // https://github.com/cbeust/testng/issues/2361#issuecomment-688393166 a workaround it to add a dummy test to the leaf test class.
- }
}
diff --git a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOracleClient.java b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOracleClient.java
index 9685fa756e2d..28706d97facc 100644
--- a/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOracleClient.java
+++ b/plugin/trino-oracle/src/test/java/io/trino/plugin/oracle/TestOracleClient.java
@@ -24,8 +24,7 @@
import io.trino.spi.type.Type;
import io.trino.testing.TestingConnectorSession;
import oracle.jdbc.OracleTypes;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
import java.sql.PreparedStatement;
import java.sql.SQLException;
@@ -66,8 +65,32 @@ public class TestOracleClient
private static final ConnectorSession SESSION = TestingConnectorSession.SESSION;
- @Test(dataProvider = "writeMappingsProvider")
- public void testTypedNullWriteMapping(Type type, String bindExpression, int nullJdbcType)
+ @Test
+ public void testTypedNullWriteMapping()
+ throws SQLException
+ {
+ testTypedNullWriteMapping(BOOLEAN, "?", Types.TINYINT);
+ testTypedNullWriteMapping(TINYINT, "?", Types.TINYINT);
+ testTypedNullWriteMapping(SMALLINT, "?", Types.SMALLINT);
+ testTypedNullWriteMapping(INTEGER, "?", Types.INTEGER);
+ testTypedNullWriteMapping(BIGINT, "?", Types.BIGINT);
+ testTypedNullWriteMapping(REAL, "?", Types.REAL);
+ testTypedNullWriteMapping(DOUBLE, "?", Types.DOUBLE);
+ testTypedNullWriteMapping(VARBINARY, "?", Types.VARBINARY);
+ testTypedNullWriteMapping(createCharType(25), "?", Types.NCHAR);
+ testTypedNullWriteMapping(createDecimalType(16, 6), "?", Types.DECIMAL);
+ testTypedNullWriteMapping(createDecimalType(36, 12), "?", Types.DECIMAL);
+ testTypedNullWriteMapping(createUnboundedVarcharType(), "?", Types.VARCHAR);
+ testTypedNullWriteMapping(createVarcharType(123), "?", Types.VARCHAR);
+ testTypedNullWriteMapping(TIMESTAMP_SECONDS, "TO_DATE(?, 'SYYYY-MM-DD HH24:MI:SS')", Types.VARCHAR);
+ testTypedNullWriteMapping(TIMESTAMP_MILLIS, "TO_TIMESTAMP(?, 'SYYYY-MM-DD HH24:MI:SS.FF3')", Types.VARCHAR);
+ testTypedNullWriteMapping(TIMESTAMP_MICROS, "TO_TIMESTAMP(?, 'SYYYY-MM-DD HH24:MI:SS.FF6')", Types.VARCHAR);
+ testTypedNullWriteMapping(TIMESTAMP_NANOS, "TO_TIMESTAMP(?, 'SYYYY-MM-DD HH24:MI:SS.FF9')", Types.VARCHAR);
+ testTypedNullWriteMapping(TIMESTAMP_TZ_MILLIS, "?", OracleTypes.TIMESTAMPTZ);
+ testTypedNullWriteMapping(DATE, "TO_DATE(?, 'SYYYY-MM-DD')", Types.VARCHAR);
+ }
+
+ private void testTypedNullWriteMapping(Type type, String bindExpression, int nullJdbcType)
throws SQLException
{
WriteMapping writeMapping = CLIENT.toWriteMapping(SESSION, type);
@@ -95,30 +118,4 @@ public void testTypedNullWriteMapping(Type type, String bindExpression, int null
writeFunction.setNull(statementProxy, 1325);
}
-
- @DataProvider
- public Object[][] writeMappingsProvider()
- {
- return new Object[][]{
- {BOOLEAN, "?", Types.TINYINT},
- {TINYINT, "?", Types.TINYINT},
- {SMALLINT, "?", Types.SMALLINT},
- {INTEGER, "?", Types.INTEGER},
- {BIGINT, "?", Types.BIGINT},
- {REAL, "?", Types.REAL},
- {DOUBLE, "?", Types.DOUBLE},
- {VARBINARY, "?", Types.VARBINARY},
- {createCharType(25), "?", Types.NCHAR},
- {createDecimalType(16, 6), "?", Types.DECIMAL},
- {createDecimalType(36, 12), "?", Types.DECIMAL},
- {createUnboundedVarcharType(), "?", Types.VARCHAR},
- {createVarcharType(123), "?", Types.VARCHAR},
- {TIMESTAMP_SECONDS, "TO_DATE(?, 'SYYYY-MM-DD HH24:MI:SS')", Types.VARCHAR},
- {TIMESTAMP_MILLIS, "TO_TIMESTAMP(?, 'SYYYY-MM-DD HH24:MI:SS.FF3')", Types.VARCHAR},
- {TIMESTAMP_MICROS, "TO_TIMESTAMP(?, 'SYYYY-MM-DD HH24:MI:SS.FF6')", Types.VARCHAR},
- {TIMESTAMP_NANOS, "TO_TIMESTAMP(?, 'SYYYY-MM-DD HH24:MI:SS.FF9')", Types.VARCHAR},
- {TIMESTAMP_TZ_MILLIS, "?", OracleTypes.TIMESTAMPTZ},
- {DATE, "TO_DATE(?, 'SYYYY-MM-DD')", Types.VARCHAR},
- };
- }
}
diff --git a/plugin/trino-phoenix5/pom.xml b/plugin/trino-phoenix5/pom.xml
index d85fc8732d7f..c2af43e4b25d 100644
--- a/plugin/trino-phoenix5/pom.xml
+++ b/plugin/trino-phoenix5/pom.xml
@@ -378,33 +378,10 @@
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}
-
-
-
org.basepom.maven
duplicate-finder-maven-plugin
diff --git a/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixConnectorTest.java b/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixConnectorTest.java
index 02a206a5297e..50a3d2335e14 100644
--- a/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixConnectorTest.java
+++ b/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixConnectorTest.java
@@ -65,7 +65,6 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assumptions.abort;
-import static org.testng.Assert.assertTrue;
public class TestPhoenixConnectorTest
extends BaseJdbcConnectorTest
@@ -600,7 +599,7 @@ private Session withUnsupportedType(UnsupportedTypeHandling unsupportedTypeHandl
public void testCreateTableWithProperties()
{
assertUpdate("CREATE TABLE test_create_table_with_properties (created_date date, a bigint, b double, c varchar(10), d varchar(10)) WITH(rowkeys = 'created_date row_timestamp, a,b,c', salt_buckets=10)");
- assertTrue(getQueryRunner().tableExists(getSession(), "test_create_table_with_properties"));
+ assertThat(getQueryRunner().tableExists(getSession(), "test_create_table_with_properties")).isTrue();
assertTableColumnNames("test_create_table_with_properties", "created_date", "a", "b", "c", "d");
assertThat(computeActual("SHOW CREATE TABLE test_create_table_with_properties").getOnlyValue())
.isEqualTo("CREATE TABLE phoenix.tpch.test_create_table_with_properties (\n" +
@@ -624,7 +623,7 @@ public void testCreateTableWithProperties()
public void testCreateTableWithPresplits()
{
assertUpdate("CREATE TABLE test_create_table_with_presplits (rid varchar(10), val1 varchar(10)) with(rowkeys = 'rid', SPLIT_ON='\"1\",\"2\",\"3\"')");
- assertTrue(getQueryRunner().tableExists(getSession(), "test_create_table_with_presplits"));
+ assertThat(getQueryRunner().tableExists(getSession(), "test_create_table_with_presplits")).isTrue();
assertTableColumnNames("test_create_table_with_presplits", "rid", "val1");
assertUpdate("DROP TABLE test_create_table_with_presplits");
}
diff --git a/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixSplit.java b/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixSplit.java
index f9311bc48047..dea8625592ef 100644
--- a/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixSplit.java
+++ b/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixSplit.java
@@ -24,8 +24,7 @@
import java.util.List;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
public class TestPhoenixSplit
{
@@ -42,11 +41,11 @@ public void testPhoenixSplitJsonRoundtrip()
addresses,
SerializedPhoenixInputSplit.serialize(phoenixInputSplit));
- assertTrue(objectMapper.canSerialize(PhoenixSplit.class));
+ assertThat(objectMapper.canSerialize(PhoenixSplit.class)).isTrue();
String json = objectMapper.writeValueAsString(expected);
PhoenixSplit actual = objectMapper.readValue(json, PhoenixSplit.class);
- assertEquals(actual.getPhoenixInputSplit(), expected.getPhoenixInputSplit());
- assertEquals(actual.getAddresses(), expected.getAddresses());
+ assertThat(actual.getPhoenixInputSplit()).isEqualTo(expected.getPhoenixInputSplit());
+ assertThat(actual.getAddresses()).isEqualTo(expected.getAddresses());
}
}
diff --git a/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixTypeMapping.java b/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixTypeMapping.java
index a61f8e260073..672b4e75fea4 100644
--- a/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixTypeMapping.java
+++ b/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestPhoenixTypeMapping.java
@@ -29,9 +29,10 @@
import io.trino.testing.sql.TestTable;
import io.trino.testing.sql.TrinoSqlExecutor;
import org.intellij.lang.annotations.Language;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.parallel.Execution;
import java.math.RoundingMode;
import java.time.LocalDate;
@@ -69,10 +70,14 @@
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
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;
/**
* @see Phoenix data types
*/
+@TestInstance(PER_CLASS)
+@Execution(CONCURRENT)
public class TestPhoenixTypeMapping
extends AbstractTestQueryFramework
{
@@ -84,7 +89,7 @@ public class TestPhoenixTypeMapping
// minutes offset change since 1970-01-01, no DST
private final ZoneId kathmandu = ZoneId.of("Asia/Kathmandu");
- @BeforeClass
+ @BeforeAll
public void setUp()
{
checkState(jvmZone.getId().equals("America/Bahia_Banderas"), "This test assumes certain JVM time zone");
@@ -519,8 +524,18 @@ public void testDecimalUnspecifiedPrecision()
}
}
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testDate(ZoneId sessionZone)
+ @Test
+ public void testDate()
+ {
+ testDate(UTC);
+ testDate(jvmZone);
+ // using two non-JVM zones so that we don't need to worry what Phoenix system zone is
+ testDate(vilnius);
+ testDate(kathmandu);
+ testDate(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testDate(ZoneId sessionZone)
{
Session session = Session.builder(getSession())
.setTimeZoneKey(getTimeZoneKey(sessionZone.getId()))
@@ -575,8 +590,18 @@ public void testDate(ZoneId sessionZone)
.execute(getQueryRunner(), session, phoenixCreateAndInsert("tpch.test_date"));
}
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testUnsignedDate(ZoneId sessionZone)
+ @Test
+ public void testUnsignedDate()
+ {
+ testUnsignedDate(UTC);
+ testUnsignedDate(jvmZone);
+ // using two non-JVM zones so that we don't need to worry what Phoenix system zone is
+ testUnsignedDate(vilnius);
+ testUnsignedDate(kathmandu);
+ testUnsignedDate(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testUnsignedDate(ZoneId sessionZone)
{
Session session = Session.builder(getSession())
.setTimeZoneKey(getTimeZoneKey(sessionZone.getId()))
@@ -698,19 +723,6 @@ public void testArrayNulls()
}
}
- @DataProvider
- public Object[][] sessionZonesDataProvider()
- {
- return new Object[][] {
- {UTC},
- {jvmZone},
- // using two non-JVM zones so that we don't need to worry what Phoenix system zone is
- {vilnius},
- {kathmandu},
- {TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId()},
- };
- }
-
private static void checkIsGap(ZoneId zone, LocalDateTime dateTime)
{
verify(isGap(zone, dateTime), "Expected %s to be a gap in %s", dateTime, zone);
diff --git a/plugin/trino-postgresql/pom.xml b/plugin/trino-postgresql/pom.xml
index fb6b2fec4ef5..ab6716e0d5ac 100644
--- a/plugin/trino-postgresql/pom.xml
+++ b/plugin/trino-postgresql/pom.xml
@@ -257,33 +257,5 @@
testcontainers
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/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlCaseInsensitiveMapping.java b/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlCaseInsensitiveMapping.java
index 9e115ab6dbf6..b670d0e903d0 100644
--- a/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlCaseInsensitiveMapping.java
+++ b/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlCaseInsensitiveMapping.java
@@ -18,7 +18,6 @@
import io.trino.plugin.jdbc.BaseCaseInsensitiveMappingTest;
import io.trino.testing.QueryRunner;
import io.trino.testing.sql.SqlExecutor;
-import org.junit.jupiter.api.Test;
import java.nio.file.Path;
@@ -62,12 +61,4 @@ protected SqlExecutor onRemoteDatabase()
{
return postgreSqlServer::execute;
}
-
- @Test
- public void forceTestNgToRespectSingleThreaded()
- {
- // TODO: Remove after updating TestNG to 7.4.0+ (https://github.com/trinodb/trino/issues/8571)
- // TestNG doesn't enforce @Test(singleThreaded = true) when tests are defined in base class. According to
- // https://github.com/cbeust/testng/issues/2361#issuecomment-688393166 a workaround it to add a dummy test to the leaf test class.
- }
}
diff --git a/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlClient.java b/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlClient.java
index 45cfc6bcafeb..fd47c631f77d 100644
--- a/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlClient.java
+++ b/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlClient.java
@@ -53,15 +53,13 @@
import io.trino.sql.tree.StringLiteral;
import io.trino.sql.tree.SymbolReference;
import io.trino.testing.TestingConnectorSession;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
import java.sql.Types;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
-import java.util.stream.Stream;
import static com.google.common.collect.ImmutableMap.toImmutableMap;
import static io.airlift.slice.Slices.utf8Slice;
@@ -72,12 +70,9 @@
import static io.trino.spi.type.VarcharType.createVarcharType;
import static io.trino.sql.planner.TestingPlannerContext.PLANNER_CONTEXT;
import static io.trino.sql.planner.TypeAnalyzer.createTestingTypeAnalyzer;
-import static io.trino.testing.DataProviders.toDataProvider;
import static io.trino.type.InternalTypeManager.TESTING_TYPE_MANAGER;
import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
public class TestPostgreSqlClient
{
@@ -217,10 +212,12 @@ private static void testImplementAggregation(AggregateFunction aggregateFunction
}
else {
assertThat(result).isPresent();
- assertEquals(result.get().getExpression(), expectedExpression.get());
+ assertThat(result.get().getExpression()).isEqualTo(expectedExpression.get());
Optional columnMapping = JDBC_CLIENT.toColumnMapping(SESSION, null, result.get().getJdbcTypeHandle());
- assertTrue(columnMapping.isPresent(), "No mapping for: " + result.get().getJdbcTypeHandle());
- assertEquals(columnMapping.get().getType(), aggregateFunction.getOutputType());
+ assertThat(columnMapping.isPresent())
+ .describedAs("No mapping for: " + result.get().getJdbcTypeHandle())
+ .isTrue();
+ assertThat(columnMapping.get().getType()).isEqualTo(aggregateFunction.getOutputType());
}
}
@@ -292,68 +289,58 @@ public void testConvertOrWithAnd()
new QueryParameter(BIGINT, Optional.of(44L))));
}
- @Test(dataProvider = "testConvertComparisonDataProvider")
- public void testConvertComparison(ComparisonExpression.Operator operator)
+ @Test
+ public void testConvertComparison()
{
- Optional converted = JDBC_CLIENT.convertPredicate(
- SESSION,
- translateToConnectorExpression(
- new ComparisonExpression(
- operator,
- new SymbolReference("c_bigint_symbol"),
- LITERAL_ENCODER.toExpression(42L, BIGINT)),
- Map.of("c_bigint_symbol", BIGINT)),
- Map.of("c_bigint_symbol", BIGINT_COLUMN));
-
- switch (operator) {
- case EQUAL:
- case NOT_EQUAL:
- assertThat(converted).isPresent();
- assertThat(converted.get().expression()).isEqualTo(format("(\"c_bigint\") %s (?)", operator.getValue()));
- assertThat(converted.get().parameters()).isEqualTo(List.of(new QueryParameter(BIGINT, Optional.of(42L))));
- return;
- case LESS_THAN:
- case LESS_THAN_OR_EQUAL:
- case GREATER_THAN:
- case GREATER_THAN_OR_EQUAL:
- case IS_DISTINCT_FROM:
- // Not supported yet, even for bigint
- assertThat(converted).isEmpty();
- return;
+ for (ComparisonExpression.Operator operator : ComparisonExpression.Operator.values()) {
+ Optional converted = JDBC_CLIENT.convertPredicate(
+ SESSION,
+ translateToConnectorExpression(
+ new ComparisonExpression(
+ operator,
+ new SymbolReference("c_bigint_symbol"),
+ LITERAL_ENCODER.toExpression(42L, BIGINT)),
+ Map.of("c_bigint_symbol", BIGINT)),
+ Map.of("c_bigint_symbol", BIGINT_COLUMN));
+
+ switch (operator) {
+ case EQUAL:
+ case NOT_EQUAL:
+ assertThat(converted).isPresent();
+ assertThat(converted.get().expression()).isEqualTo(format("(\"c_bigint\") %s (?)", operator.getValue()));
+ assertThat(converted.get().parameters()).isEqualTo(List.of(new QueryParameter(BIGINT, Optional.of(42L))));
+ return;
+ case LESS_THAN:
+ case LESS_THAN_OR_EQUAL:
+ case GREATER_THAN:
+ case GREATER_THAN_OR_EQUAL:
+ case IS_DISTINCT_FROM:
+ // Not supported yet, even for bigint
+ assertThat(converted).isEmpty();
+ return;
+ }
+ throw new UnsupportedOperationException("Unsupported operator: " + operator);
}
- throw new UnsupportedOperationException("Unsupported operator: " + operator);
- }
-
- @DataProvider
- public static Object[][] testConvertComparisonDataProvider()
- {
- return Stream.of(ComparisonExpression.Operator.values())
- .collect(toDataProvider());
- }
-
- @Test(dataProvider = "testConvertArithmeticBinaryDataProvider")
- public void testConvertArithmeticBinary(ArithmeticBinaryExpression.Operator operator)
- {
- ParameterizedExpression converted = JDBC_CLIENT.convertPredicate(
- SESSION,
- translateToConnectorExpression(
- new ArithmeticBinaryExpression(
- operator,
- new SymbolReference("c_bigint_symbol"),
- LITERAL_ENCODER.toExpression(42L, BIGINT)),
- Map.of("c_bigint_symbol", BIGINT)),
- Map.of("c_bigint_symbol", BIGINT_COLUMN))
- .orElseThrow();
-
- assertThat(converted.expression()).isEqualTo(format("(\"c_bigint\") %s (?)", operator.getValue()));
- assertThat(converted.parameters()).isEqualTo(List.of(new QueryParameter(BIGINT, Optional.of(42L))));
}
- @DataProvider
- public static Object[][] testConvertArithmeticBinaryDataProvider()
+ @Test
+ public void testConvertArithmeticBinary()
{
- return Stream.of(ArithmeticBinaryExpression.Operator.values())
- .collect(toDataProvider());
+ for (ArithmeticBinaryExpression.Operator operator : ArithmeticBinaryExpression.Operator.values()) {
+ ParameterizedExpression converted = JDBC_CLIENT.convertPredicate(
+ SESSION,
+ translateToConnectorExpression(
+ new ArithmeticBinaryExpression(
+ operator,
+ new SymbolReference("c_bigint_symbol"),
+ LITERAL_ENCODER.toExpression(42L, BIGINT)),
+ Map.of("c_bigint_symbol", BIGINT)),
+ Map.of("c_bigint_symbol", BIGINT_COLUMN))
+ .orElseThrow();
+
+ assertThat(converted.expression()).isEqualTo(format("(\"c_bigint\") %s (?)", operator.getValue()));
+ assertThat(converted.parameters()).isEqualTo(List.of(new QueryParameter(BIGINT, Optional.of(42L))));
+ }
}
@Test
diff --git a/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlConnectorTest.java b/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlConnectorTest.java
index 0e1ebe8faec1..8170cdcff5f2 100644
--- a/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlConnectorTest.java
+++ b/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlConnectorTest.java
@@ -75,8 +75,6 @@
import static java.util.stream.IntStream.range;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
@TestInstance(PER_CLASS)
public class TestPostgreSqlConnectorTest
@@ -170,7 +168,7 @@ private void testTimestampPrecisionOnCreateTable(String inputType, String expect
getQueryRunner()::execute,
"test_coercion_show_create_table",
format("(a %s)", inputType))) {
- assertEquals(getColumnType(testTable.getName(), "a"), expectedType);
+ assertThat(getColumnType(testTable.getName(), "a")).isEqualTo(expectedType);
}
}
@@ -210,7 +208,7 @@ private void testTimestampPrecisionOnCreateTableAsSelect(String inputType, Strin
getQueryRunner()::execute,
"test_coercion_show_create_table",
format("AS SELECT %s a", inputType))) {
- assertEquals(getColumnType(testTable.getName(), "a"), tableType);
+ assertThat(getColumnType(testTable.getName(), "a")).isEqualTo(tableType);
assertQuery(
format("SELECT * FROM %s", testTable.getName()),
format("VALUES (%s)", tableValue));
@@ -253,7 +251,7 @@ private void testTimestampPrecisionOnCreateTableAsSelectWithNoData(String inputT
getQueryRunner()::execute,
"test_coercion_show_create_table",
format("AS SELECT %s a WITH NO DATA", inputType))) {
- assertEquals(getColumnType(testTable.getName(), "a"), tableType);
+ assertThat(getColumnType(testTable.getName(), "a")).isEqualTo(tableType);
}
}
@@ -267,7 +265,7 @@ protected void verifyAddNotNullColumnToNonEmptyTableFailurePermissible(Throwable
public void testViews()
{
onRemoteDatabase().execute("CREATE OR REPLACE VIEW test_view AS SELECT * FROM orders");
- assertTrue(getQueryRunner().tableExists(getSession(), "test_view"));
+ assertThat(getQueryRunner().tableExists(getSession(), "test_view")).isTrue();
assertQuery("SELECT orderkey FROM test_view", "SELECT orderkey FROM orders");
onRemoteDatabase().execute("DROP VIEW IF EXISTS test_view");
}
@@ -276,7 +274,7 @@ public void testViews()
public void testPostgreSqlMaterializedView()
{
onRemoteDatabase().execute("CREATE MATERIALIZED VIEW test_mv as SELECT * FROM orders");
- assertTrue(getQueryRunner().tableExists(getSession(), "test_mv"));
+ assertThat(getQueryRunner().tableExists(getSession(), "test_mv")).isTrue();
assertQuery("SELECT orderkey FROM test_mv", "SELECT orderkey FROM orders");
onRemoteDatabase().execute("DROP MATERIALIZED VIEW test_mv");
}
@@ -286,7 +284,7 @@ public void testForeignTable()
{
onRemoteDatabase().execute("CREATE SERVER devnull FOREIGN DATA WRAPPER file_fdw");
onRemoteDatabase().execute("CREATE FOREIGN TABLE test_ft (x bigint) SERVER devnull OPTIONS (filename '/dev/null')");
- assertTrue(getQueryRunner().tableExists(getSession(), "test_ft"));
+ assertThat(getQueryRunner().tableExists(getSession(), "test_ft")).isTrue();
computeActual("SELECT * FROM test_ft");
onRemoteDatabase().execute("DROP FOREIGN TABLE test_ft");
onRemoteDatabase().execute("DROP SERVER devnull");
@@ -296,13 +294,13 @@ public void testForeignTable()
public void testErrorDuringInsert()
{
onRemoteDatabase().execute("CREATE TABLE test_with_constraint (x bigint primary key)");
- assertTrue(getQueryRunner().tableExists(getSession(), "test_with_constraint"));
+ assertThat(getQueryRunner().tableExists(getSession(), "test_with_constraint")).isTrue();
Session nonTransactional = Session.builder(getSession())
.setCatalogSessionProperty("postgresql", "non_transactional_insert", "true")
.build();
assertUpdate(nonTransactional, "INSERT INTO test_with_constraint VALUES (1)", 1);
assertQueryFails(nonTransactional, "INSERT INTO test_with_constraint VALUES (1)", "[\\s\\S]*ERROR: duplicate key value[\\s\\S]*");
- assertTrue(getQueryRunner().tableExists(getSession(), "test_with_constraint"));
+ assertThat(getQueryRunner().tableExists(getSession(), "test_with_constraint")).isTrue();
onRemoteDatabase().execute("DROP TABLE test_with_constraint");
}
diff --git a/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlTypeMapping.java b/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlTypeMapping.java
index d14f146cba2a..49db947ecb56 100644
--- a/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlTypeMapping.java
+++ b/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlTypeMapping.java
@@ -25,7 +25,6 @@
import io.trino.sql.planner.plan.FilterNode;
import io.trino.sql.planner.plan.TopNNode;
import io.trino.testing.AbstractTestQueryFramework;
-import io.trino.testing.DataProviders;
import io.trino.testing.QueryRunner;
import io.trino.testing.TestingSession;
import io.trino.testing.datatype.CreateAndInsertDataSetup;
@@ -39,9 +38,10 @@
import io.trino.testing.sql.TestTable;
import io.trino.testing.sql.TrinoSqlExecutor;
import org.intellij.lang.annotations.Language;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.parallel.Execution;
import java.math.BigDecimal;
import java.math.RoundingMode;
@@ -107,7 +107,11 @@
import static java.util.stream.Collectors.toList;
import static org.assertj.core.api.Assertions.assertThat;
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;
+@TestInstance(PER_CLASS)
+@Execution(CONCURRENT)
public class TestPostgreSqlTypeMapping
extends AbstractTestQueryFramework
{
@@ -148,7 +152,7 @@ protected QueryRunner createQueryRunner()
ImmutableList.of());
}
- @BeforeClass
+ @BeforeAll
public void setUp()
{
checkState(jvmZone.getId().equals("America/Bahia_Banderas"), "This test assumes certain JVM time zone");
@@ -626,8 +630,14 @@ public void testDecimalExceedingPrecisionMaxWithNonExceedingIntegerValues()
}
}
- @Test(dataProvider = "testDecimalExceedingPrecisionMaxProvider")
- public void testDecimalExceedingPrecisionMaxWithSupportedValues(int typePrecision, int typeScale)
+ @Test
+ public void testDecimalExceedingPrecisionMaxWithSupportedValues()
+ {
+ testDecimalExceedingPrecisionMaxWithSupportedValues(40, 8);
+ testDecimalExceedingPrecisionMaxWithSupportedValues(50, 10);
+ }
+
+ private void testDecimalExceedingPrecisionMaxWithSupportedValues(int typePrecision, int typeScale)
{
JdbcSqlExecutor jdbcSqlExecutor = new JdbcSqlExecutor(postgreSqlServer.getJdbcUrl(), postgreSqlServer.getProperties());
@@ -679,15 +689,6 @@ public void testDecimalExceedingPrecisionMaxWithSupportedValues(int typePrecisio
}
}
- @DataProvider
- public Object[][] testDecimalExceedingPrecisionMaxProvider()
- {
- return new Object[][] {
- {40, 8},
- {50, 10},
- };
- }
-
@Test
public void testDecimalUnspecifiedPrecisionWithSupportedValues()
{
@@ -1070,8 +1071,18 @@ private static DataType> arrayDataType(DataType elementType, Stri
valuesList -> valuesList == null ? null : valuesList.stream().map(elementType::toTrinoQueryResult).collect(toList()));
}
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testDate(ZoneId sessionZone)
+ @Test
+ public void testDate()
+ {
+ testDate(UTC);
+ testDate(jvmZone);
+ // using two non-JVM zones so that we don't need to worry what Postgres system zone is
+ testDate(vilnius);
+ testDate(kathmandu);
+ testDate(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testDate(ZoneId sessionZone)
{
Session session = Session.builder(getSession())
.setTimeZoneKey(TimeZoneKey.getTimeZoneKey(sessionZone.getId()))
@@ -1152,8 +1163,18 @@ public void testEnum()
/**
* @see #testTimeCoercion
*/
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testTime(ZoneId sessionZone)
+ @Test
+ public void testTime()
+ {
+ testTime(UTC);
+ testTime(jvmZone);
+ // using two non-JVM zones so that we don't need to worry what Postgres system zone is
+ testTime(vilnius);
+ testTime(kathmandu);
+ testTime(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testTime(ZoneId sessionZone)
{
LocalTime timeGapInJvmZone = LocalTime.of(0, 12, 34, 567_000_000);
checkIsGap(jvmZone, timeGapInJvmZone.atDate(EPOCH_DAY));
@@ -1324,8 +1345,18 @@ public void testTime24()
/**
* @see #testTimestampCoercion
*/
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testTimestamp(ZoneId sessionZone)
+ @Test
+ public void testTimestamp()
+ {
+ testTimestamp(UTC);
+ testTimestamp(jvmZone);
+ // using two non-JVM zones so that we don't need to worry what Postgres system zone is
+ testTimestamp(vilnius);
+ testTimestamp(kathmandu);
+ testTimestamp(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testTimestamp(ZoneId sessionZone)
{
// no need to test gap for multiple precisions as both Trino and PostgreSql JDBC
// uses same representation for all precisions 1-6
@@ -1425,8 +1456,18 @@ public void testTimestampCoercion()
.execute(getQueryRunner(), trinoCreateAndInsert("test_timestamp_coercion"));
}
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testArrayTimestamp(ZoneId sessionZone)
+ @Test
+ public void testArrayTimestamp()
+ {
+ testArrayTimestamp(UTC);
+ testArrayTimestamp(jvmZone);
+ // using two non-JVM zones so that we don't need to worry what Postgres system zone is
+ testArrayTimestamp(vilnius);
+ testArrayTimestamp(kathmandu);
+ testArrayTimestamp(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testArrayTimestamp(ZoneId sessionZone)
{
// no need to test gap for multiple precisions as both Trino and PostgreSql JDBC
// uses same representation for all precisions 1-6
@@ -1475,24 +1516,17 @@ public void testArrayTimestamp(ZoneId sessionZone)
.execute(getQueryRunner(), session, postgresCreateAndInsert("test_array_timestamp"));
}
- @DataProvider
- public Object[][] sessionZonesDataProvider()
- {
- return new Object[][] {
- {UTC},
- {jvmZone},
- // using two non-JVM zones so that we don't need to worry what Postgres system zone is
- {vilnius},
- {kathmandu},
- {TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId()},
- };
- }
-
/**
* @see #testTimestampWithTimeZoneCoercion
*/
- @Test(dataProvider = "trueFalse", dataProviderClass = DataProviders.class)
- public void testTimestampWithTimeZone(boolean insertWithTrino)
+ @Test
+ public void testTimestampWithTimeZone()
+ {
+ testTimestampWithTimeZone(true);
+ testTimestampWithTimeZone(false);
+ }
+
+ private void testTimestampWithTimeZone(boolean insertWithTrino)
{
DataTypeTest tests = DataTypeTest.create(true);
for (int precision : List.of(3, 6)) {
@@ -1604,8 +1638,14 @@ public void testTimestampWithTimeZoneCoercion()
.execute(getQueryRunner(), trinoCreateAndInsert("test_timestamp_tz_coercion"));
}
- @Test(dataProvider = "trueFalse", dataProviderClass = DataProviders.class)
- public void testArrayTimestampWithTimeZone(boolean insertWithTrino)
+ @Test
+ public void testArrayTimestampWithTimeZone()
+ {
+ testArrayTimestampWithTimeZone(true);
+ testArrayTimestampWithTimeZone(false);
+ }
+
+ private void testArrayTimestampWithTimeZone(boolean insertWithTrino)
{
DataTypeTest tests = DataTypeTest.create();
for (int precision : List.of(3, 6)) {
diff --git a/plugin/trino-singlestore/pom.xml b/plugin/trino-singlestore/pom.xml
index 5038f4b47417..0ef29ecc78b4 100644
--- a/plugin/trino-singlestore/pom.xml
+++ b/plugin/trino-singlestore/pom.xml
@@ -211,33 +211,5 @@
testcontainers
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/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreCaseInsensitiveMapping.java b/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreCaseInsensitiveMapping.java
index 698ad64bb05e..cfa0439dc71b 100644
--- a/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreCaseInsensitiveMapping.java
+++ b/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreCaseInsensitiveMapping.java
@@ -18,7 +18,6 @@
import io.trino.plugin.jdbc.BaseCaseInsensitiveMappingTest;
import io.trino.testing.QueryRunner;
import io.trino.testing.sql.SqlExecutor;
-import org.junit.jupiter.api.Test;
import java.nio.file.Path;
@@ -70,12 +69,4 @@ protected String quoted(String name)
name = name.replace(identifierQuote, identifierQuote + identifierQuote);
return identifierQuote + name + identifierQuote;
}
-
- @Test
- public void forceTestNgToRespectSingleThreaded()
- {
- // TODO: Remove after updating TestNG to 7.4.0+ (https://github.com/trinodb/trino/issues/8571)
- // TestNG doesn't enforce @Test(singleThreaded = true) when tests are defined in base class. According to
- // https://github.com/cbeust/testng/issues/2361#issuecomment-688393166 a workaround it to add a dummy test to the leaf test class.
- }
}
diff --git a/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreConnectorTest.java b/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreConnectorTest.java
index 92f8e672279f..ebfbed69a8e3 100644
--- a/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreConnectorTest.java
+++ b/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreConnectorTest.java
@@ -42,9 +42,6 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assumptions.abort;
import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
@TestInstance(PER_CLASS)
public class TestSingleStoreConnectorTest
@@ -182,15 +179,15 @@ public void testReadFromView()
@Test
public void testNameEscaping()
{
- assertFalse(getQueryRunner().tableExists(getSession(), "test_table"));
+ assertThat(getQueryRunner().tableExists(getSession(), "test_table")).isFalse();
assertUpdate(getSession(), "CREATE TABLE test_table AS SELECT 123 x", 1);
- assertTrue(getQueryRunner().tableExists(getSession(), "test_table"));
+ assertThat(getQueryRunner().tableExists(getSession(), "test_table")).isTrue();
assertQuery(getSession(), "SELECT * FROM test_table", "SELECT 123");
assertUpdate(getSession(), "DROP TABLE test_table");
- assertFalse(getQueryRunner().tableExists(getSession(), "test_table"));
+ assertThat(getQueryRunner().tableExists(getSession(), "test_table")).isFalse();
}
@Test
@@ -205,11 +202,14 @@ public void testSingleStoreTinyint()
onRemoteDatabase().execute("INSERT INTO tpch.mysql_test_tinyint1 VALUES (127), (-128)");
MaterializedResult materializedRows = computeActual("SELECT * FROM tpch.mysql_test_tinyint1 WHERE c_tinyint = 127");
- assertEquals(materializedRows.getRowCount(), 1);
+ assertThat(materializedRows.getRowCount())
+ .isEqualTo(1);
MaterializedRow row = getOnlyElement(materializedRows);
- assertEquals(row.getFields().size(), 1);
- assertEquals(row.getField(0), (byte) 127);
+ assertThat(row.getFields().size())
+ .isEqualTo(1);
+ assertThat(row.getField(0))
+ .isEqualTo((byte) 127);
assertUpdate("DROP TABLE mysql_test_tinyint1");
}
@@ -350,10 +350,10 @@ public void testNativeQueryCreateStatement()
// This is unusual, because other connectors don't produce a ResultSet metadata for CREATE TABLE at all.
// The query fails because there are no columns, but even if columns were not required, the query would fail
// to execute in SingleStore because the connector wraps it in additional syntax, which causes syntax error.
- assertFalse(getQueryRunner().tableExists(getSession(), "numbers"));
+ assertThat(getQueryRunner().tableExists(getSession(), "numbers")).isFalse();
assertThatThrownBy(() -> query("SELECT * FROM TABLE(system.query(query => 'CREATE TABLE numbers(n INTEGER)'))"))
.hasMessageContaining("descriptor has no fields");
- assertFalse(getQueryRunner().tableExists(getSession(), "numbers"));
+ assertThat(getQueryRunner().tableExists(getSession(), "numbers")).isFalse();
}
@Test
diff --git a/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreJdbcConfig.java b/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreJdbcConfig.java
index 8f5717189a01..b00272937150 100644
--- a/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreJdbcConfig.java
+++ b/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreJdbcConfig.java
@@ -23,9 +23,8 @@
import static com.google.common.collect.MoreCollectors.toOptional;
import static com.google.common.collect.Streams.stream;
import static io.trino.plugin.singlestore.SingleStoreJdbcConfig.DRIVER_PROTOCOL_ERROR;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
public class TestSingleStoreJdbcConfig
{
@@ -49,10 +48,10 @@ public void testCreateConnectorLegacyUrl()
@Test
public void testLegacyConnectionUrl()
{
- assertTrue(isLegacyDriverSubprotocol("jdbc:mariadb:"));
- assertTrue(isLegacyDriverSubprotocol("JDBC:MARIADB:"));
- assertTrue(isLegacyDriverSubprotocol("jdbc:mariadb:test"));
- assertFalse(isLegacyDriverSubprotocol("jdbc:singlestore:test"));
+ assertThat(isLegacyDriverSubprotocol("jdbc:mariadb:")).isTrue();
+ assertThat(isLegacyDriverSubprotocol("JDBC:MARIADB:")).isTrue();
+ assertThat(isLegacyDriverSubprotocol("jdbc:mariadb:test")).isTrue();
+ assertThat(isLegacyDriverSubprotocol("jdbc:singlestore:test")).isFalse();
}
private static boolean isLegacyDriverSubprotocol(String url)
diff --git a/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreTypeMapping.java b/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreTypeMapping.java
index 8535626273b7..9c89484014d8 100644
--- a/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreTypeMapping.java
+++ b/plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestSingleStoreTypeMapping.java
@@ -29,9 +29,10 @@
import io.trino.testing.sql.SqlExecutor;
import io.trino.testing.sql.TestTable;
import io.trino.testing.sql.TrinoSqlExecutor;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.parallel.Execution;
import java.math.RoundingMode;
import java.time.LocalDate;
@@ -73,10 +74,14 @@
import static java.time.ZoneOffset.UTC;
import static java.util.Arrays.asList;
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;
/**
* @see SingleStore (MemSQL) data types
*/
+@TestInstance(PER_CLASS)
+@Execution(CONCURRENT)
public class TestSingleStoreTypeMapping
extends AbstractTestQueryFramework
{
@@ -100,7 +105,7 @@ protected QueryRunner createQueryRunner()
return createSingleStoreQueryRunner(singleStoreServer, ImmutableMap.of(), ImmutableMap.of(), ImmutableList.of());
}
- @BeforeClass
+ @BeforeAll
public void setUp()
{
checkState(jvmZone.getId().equals("America/Bahia_Banderas"), "This test assumes certain JVM time zone");
@@ -414,8 +419,14 @@ public void testDecimalExceedingPrecisionMaxWithNonExceedingIntegerValues()
}
}
- @Test(dataProvider = "testDecimalExceedingPrecisionMaxProvider")
- public void testDecimalExceedingPrecisionMaxWithSupportedValues(int typePrecision, int typeScale)
+ @Test
+ public void testDecimalExceedingPrecisionMaxWithSupportedValues()
+ {
+ testDecimalExceedingPrecisionMaxWithSupportedValues(40, 8);
+ testDecimalExceedingPrecisionMaxWithSupportedValues(50, 10);
+ }
+
+ private void testDecimalExceedingPrecisionMaxWithSupportedValues(int typePrecision, int typeScale)
{
try (TestTable testTable = new TestTable(
singleStoreServer::execute,
@@ -465,15 +476,6 @@ public void testDecimalExceedingPrecisionMaxWithSupportedValues(int typePrecisio
}
}
- @DataProvider
- public Object[][] testDecimalExceedingPrecisionMaxProvider()
- {
- return new Object[][] {
- {40, 8},
- {50, 10},
- };
- }
-
private Session sessionWithDecimalMappingAllowOverflow(RoundingMode roundingMode, int scale)
{
return Session.builder(getSession())
@@ -628,8 +630,19 @@ public void testBinary()
.execute(getQueryRunner(), singleStoreCreateAndInsert("tpch.test_binary"));
}
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testDate(ZoneId sessionZone)
+ @Test
+ public void testDate()
+ {
+ testDate(UTC);
+ testDate(ZoneId.systemDefault());
+ // no DST in 1970, but has DST in later years (e.g. 2018)
+ testDate(ZoneId.of("Europe/Vilnius"));
+ // minutes offset change since 1970-01-01, no DST
+ testDate(ZoneId.of("Asia/Kathmandu"));
+ testDate(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testDate(ZoneId sessionZone)
{
Session session = Session.builder(getSession())
.setTimeZoneKey(TimeZoneKey.getTimeZoneKey(sessionZone.getId()))
@@ -658,8 +671,19 @@ public void testDate(ZoneId sessionZone)
.execute(getQueryRunner(), session, trinoCreateAndInsert("test_date"));
}
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testTime(ZoneId sessionZone)
+ @Test
+ public void testTime()
+ {
+ testTime(UTC);
+ testTime(ZoneId.systemDefault());
+ // no DST in 1970, but has DST in later years (e.g. 2018)
+ testTime(ZoneId.of("Europe/Vilnius"));
+ // minutes offset change since 1970-01-01, no DST
+ testTime(ZoneId.of("Asia/Kathmandu"));
+ testTime(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testTime(ZoneId sessionZone)
{
Session session = Session.builder(getSession())
.setTimeZoneKey(getTimeZoneKey(sessionZone.getId()))
@@ -712,8 +736,16 @@ public void testTime(ZoneId sessionZone)
.execute(getQueryRunner(), session, singleStoreCreateAndInsert("tpch.test_time"));
}
- @Test(dataProvider = "unsupportedTimeDataProvider")
- public void testUnsupportedTime(String unsupportedTime)
+ @Test
+ public void testUnsupportedTime()
+ {
+ testUnsupportedTime("-838:59:59"); // min value in SingleStore
+ testUnsupportedTime("-00:00:01");
+ testUnsupportedTime("24:00:00");
+ testUnsupportedTime("838:59:59"); // max value in SingleStore
+ }
+
+ private void testUnsupportedTime(String unsupportedTime)
{
// SingleStore stores incorrect results when the values are out of supported range. This test should be fixed when SingleStore changes the behavior
try (TestTable table = new TestTable(singleStoreServer::execute, "tpch.test_unsupported_time", "(col time)", ImmutableList.of(format("'%s'", unsupportedTime)))) {
@@ -729,18 +761,19 @@ public void testUnsupportedTime(String unsupportedTime)
}
}
- @DataProvider
- public Object[][] unsupportedTimeDataProvider()
+ @Test
+ public void testUnsupportedTimePrecision()
{
- return new Object[][] {
- {"-838:59:59"}, // min value in SingleStore
- {"-00:00:01"},
- {"24:00:00"},
- {"838:59:59"}, // max value in SingleStore
- };
+ testUnsupportedTimePrecision(1);
+ testUnsupportedTimePrecision(2);
+ testUnsupportedTimePrecision(3);
+ testUnsupportedTimePrecision(4);
+ testUnsupportedTimePrecision(5);
+ testUnsupportedTimePrecision(7);
+ testUnsupportedTimePrecision(8);
+ testUnsupportedTimePrecision(9);
}
- @Test(dataProvider = "unsupportedDateTimePrecisions")
public void testUnsupportedTimePrecision(int precision)
{
// This test should be fixed if future SingleStore supports those precisions
@@ -748,8 +781,19 @@ public void testUnsupportedTimePrecision(int precision)
.hasMessageContaining("Feature 'TIME type with precision other than 0 or 6' is not supported by MemSQL.");
}
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testDatetime(ZoneId sessionZone)
+ @Test
+ public void testDatetime()
+ {
+ testDatetime(UTC);
+ testDatetime(ZoneId.systemDefault());
+ // no DST in 1970, but has DST in later years (e.g. 2018)
+ testDatetime(ZoneId.of("Europe/Vilnius"));
+ // minutes offset change since 1970-01-01, no DST
+ testDatetime(ZoneId.of("Asia/Kathmandu"));
+ testDatetime(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testDatetime(ZoneId sessionZone)
{
Session session = Session.builder(getSession())
.setTimeZoneKey(getTimeZoneKey(sessionZone.getId()))
@@ -805,8 +849,19 @@ public void testDatetime(ZoneId sessionZone)
.execute(getQueryRunner(), session, singleStoreCreateAndInsert("tpch.test_datetime"));
}
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testTimestamp(ZoneId sessionZone)
+ @Test
+ public void testTimestamp()
+ {
+ testTimestamp(UTC);
+ testTimestamp(ZoneId.systemDefault());
+ // no DST in 1970, but has DST in later years (e.g. 2018)
+ testTimestamp(ZoneId.of("Europe/Vilnius"));
+ // minutes offset change since 1970-01-01, no DST
+ testTimestamp(ZoneId.of("Asia/Kathmandu"));
+ testTimestamp(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testTimestamp(ZoneId sessionZone)
{
Session session = Session.builder(getSession())
.setTimeZoneKey(getTimeZoneKey(sessionZone.getId()))
@@ -852,8 +907,19 @@ public void testTimestamp(ZoneId sessionZone)
.execute(getQueryRunner(), session, singleStoreCreateAndInsert("tpch.test_timestamp"));
}
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testTimestampWrite(ZoneId sessionZone)
+ @Test
+ public void testTimestampWrite()
+ {
+ testTimestampWrite(UTC);
+ testTimestampWrite(ZoneId.systemDefault());
+ // no DST in 1970, but has DST in later years (e.g. 2018)
+ testTimestampWrite(ZoneId.of("Europe/Vilnius"));
+ // minutes offset change since 1970-01-01, no DST
+ testTimestampWrite(ZoneId.of("Asia/Kathmandu"));
+ testTimestampWrite(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testTimestampWrite(ZoneId sessionZone)
{
Session session = Session.builder(getSession())
.setTimeZoneKey(getTimeZoneKey(sessionZone.getId()))
@@ -914,22 +980,20 @@ public void testTimestampWrite(ZoneId sessionZone)
.execute(getQueryRunner(), session, trinoCreateAndInsert("test_datetime"));
}
- @DataProvider
- public Object[][] sessionZonesDataProvider()
+ @Test
+ public void testUnsupportedDateTimePrecision()
{
- return new Object[][] {
- {UTC},
- {ZoneId.systemDefault()},
- // no DST in 1970, but has DST in later years (e.g. 2018)
- {ZoneId.of("Europe/Vilnius")},
- // minutes offset change since 1970-01-01, no DST
- {ZoneId.of("Asia/Kathmandu")},
- {TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId()},
- };
+ testUnsupportedDateTimePrecision(1);
+ testUnsupportedDateTimePrecision(2);
+ testUnsupportedDateTimePrecision(3);
+ testUnsupportedDateTimePrecision(4);
+ testUnsupportedDateTimePrecision(5);
+ testUnsupportedDateTimePrecision(7);
+ testUnsupportedDateTimePrecision(8);
+ testUnsupportedDateTimePrecision(9);
}
- @Test(dataProvider = "unsupportedDateTimePrecisions")
- public void testUnsupportedDateTimePrecision(int precision)
+ private void testUnsupportedDateTimePrecision(int precision)
{
// This test should be fixed if future SingleStore supports those precisions
assertThatThrownBy(() -> singleStoreServer.execute(format("CREATE TABLE test_unsupported_timestamp_precision (col1 TIMESTAMP(%s))", precision)))
@@ -939,21 +1003,6 @@ public void testUnsupportedDateTimePrecision(int precision)
.hasMessageContaining("Feature 'DATETIME type with precision other than 0 or 6' is not supported by MemSQL.");
}
- @DataProvider
- public Object[][] unsupportedDateTimePrecisions()
- {
- return new Object[][] {
- {1},
- {2},
- {3},
- {4},
- {5},
- {7},
- {8},
- {9},
- };
- }
-
@Test
public void testJson()
{
diff --git a/plugin/trino-sqlserver/pom.xml b/plugin/trino-sqlserver/pom.xml
index a9781ff81f7a..0787eceaaa62 100644
--- a/plugin/trino-sqlserver/pom.xml
+++ b/plugin/trino-sqlserver/pom.xml
@@ -253,33 +253,5 @@
testcontainers
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/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/BaseSqlServerConnectorTest.java b/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/BaseSqlServerConnectorTest.java
index bc4d2e96a04f..237dd55659cf 100644
--- a/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/BaseSqlServerConnectorTest.java
+++ b/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/BaseSqlServerConnectorTest.java
@@ -42,8 +42,6 @@
import static java.util.stream.IntStream.range;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assumptions.abort;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
public abstract class BaseSqlServerConnectorTest
extends BaseJdbcConnectorTest
@@ -122,7 +120,7 @@ protected Optional filterDataMappingSmokeTestData(DataMapp
public void testReadFromView()
{
onRemoteDatabase().execute("CREATE VIEW test_view AS SELECT * FROM orders");
- assertTrue(getQueryRunner().tableExists(getSession(), "test_view"));
+ assertThat(getQueryRunner().tableExists(getSession(), "test_view")).isTrue();
assertQuery("SELECT orderkey FROM test_view", "SELECT orderkey FROM orders");
onRemoteDatabase().execute("DROP VIEW IF EXISTS test_view");
}
@@ -489,7 +487,8 @@ private void testCreateWithDataCompression(DataCompression dataCompression)
dataCompression);
assertUpdate(createQuery);
- assertEquals(getQueryRunner().execute("SHOW CREATE TABLE " + tableName).getOnlyValue(), createQuery);
+ assertThat(getQueryRunner().execute("SHOW CREATE TABLE " + tableName).getOnlyValue())
+ .isEqualTo(createQuery);
assertUpdate("DROP TABLE " + tableName);
}
diff --git a/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/BaseSqlServerTypeMapping.java b/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/BaseSqlServerTypeMapping.java
index efa58425c123..c762e783337d 100644
--- a/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/BaseSqlServerTypeMapping.java
+++ b/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/BaseSqlServerTypeMapping.java
@@ -27,9 +27,10 @@
import io.trino.testing.sql.TestTable;
import io.trino.testing.sql.TrinoSqlExecutor;
import org.intellij.lang.annotations.Language;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.parallel.Execution;
import java.time.LocalDate;
import java.time.LocalDateTime;
@@ -57,7 +58,11 @@
import static java.lang.String.format;
import static java.time.ZoneOffset.UTC;
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;
+@TestInstance(PER_CLASS)
+@Execution(CONCURRENT)
public abstract class BaseSqlServerTypeMapping
extends AbstractTestQueryFramework
{
@@ -77,7 +82,7 @@ public abstract class BaseSqlServerTypeMapping
protected TestingSqlServer sqlServer;
- @BeforeClass
+ @BeforeAll
public void setUp()
{
checkState(jvmZone.getId().equals("America/Bahia_Banderas"), "This test assumes certain JVM time zone");
@@ -437,8 +442,20 @@ public void testVarbinary()
.execute(getQueryRunner(), sqlServerCreateAndInsert("test_varbinary"));
}
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testDate(ZoneId sessionZone)
+ @Test
+ public void testDate()
+ {
+ testDate(UTC);
+ testDate(ZoneId.systemDefault());
+ // using two non-JVM zones so that we don't need to worry what SQL Server system zone is
+ // no DST in 1970, but has DST in later years (e.g. 2018)
+ testDate(ZoneId.of("Europe/Vilnius"));
+ // minutes offset change since 1970-01-01, no DST
+ testDate(ZoneId.of("Asia/Kathmandu"));
+ testDate(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testDate(ZoneId sessionZone)
{
Session session = Session.builder(getSession())
.setTimeZoneKey(TimeZoneKey.getTimeZoneKey(sessionZone.getId()))
@@ -578,8 +595,20 @@ public void testTime()
.execute(getQueryRunner(), trinoCreateAsSelect("test_time"));
}
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testTimestamp(ZoneId sessionZone)
+ @Test
+ public void testTimestamp()
+ {
+ testTimestamp(UTC);
+ testTimestamp(ZoneId.systemDefault());
+ // using two non-JVM zones so that we don't need to worry what SQL Server system zone is
+ // no DST in 1970, but has DST in later years (e.g. 2018)
+ testTimestamp(ZoneId.of("Europe/Vilnius"));
+ // minutes offset change since 1970-01-01, no DST
+ testTimestamp(ZoneId.of("Asia/Kathmandu"));
+ testTimestamp(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testTimestamp(ZoneId sessionZone)
{
SqlDataTypeTest tests = SqlDataTypeTest.create()
@@ -719,8 +748,20 @@ public void testSqlServerDatetime2()
.execute(getQueryRunner(), sqlServerCreateAndInsert("test_sqlserver_timestamp"));
}
- @Test(dataProvider = "sessionZonesDataProvider")
- public void testSqlServerDatetimeOffset(ZoneId sessionZone)
+ @Test
+ public void testSqlServerDatetimeOffset()
+ {
+ testSqlServerDatetimeOffset(UTC);
+ testSqlServerDatetimeOffset(ZoneId.systemDefault());
+ // using two non-JVM zones so that we don't need to worry what SQL Server system zone is
+ // no DST in 1970, but has DST in later years (e.g. 2018)
+ testSqlServerDatetimeOffset(ZoneId.of("Europe/Vilnius"));
+ // minutes offset change since 1970-01-01, no DST
+ testSqlServerDatetimeOffset(ZoneId.of("Asia/Kathmandu"));
+ testSqlServerDatetimeOffset(TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId());
+ }
+
+ private void testSqlServerDatetimeOffset(ZoneId sessionZone)
{
Session session = Session.builder(getSession())
.setTimeZoneKey(TimeZoneKey.getTimeZoneKey(sessionZone.getId()))
@@ -804,21 +845,6 @@ public void testSqlServerDatetimeOffset(ZoneId sessionZone)
.execute(getQueryRunner(), session, sqlServerCreateAndInsert("test_sqlserver_datetimeoffset"));
}
- @DataProvider
- public Object[][] sessionZonesDataProvider()
- {
- return new Object[][] {
- {UTC},
- {ZoneId.systemDefault()},
- // using two non-JVM zones so that we don't need to worry what SQL Server system zone is
- // no DST in 1970, but has DST in later years (e.g. 2018)
- {ZoneId.of("Europe/Vilnius")},
- // minutes offset change since 1970-01-01, no DST
- {ZoneId.of("Asia/Kathmandu")},
- {TestingSession.DEFAULT_TIME_ZONE_KEY.getZoneId()},
- };
- }
-
protected DataSetup trinoCreateAsSelect(String tableNamePrefix)
{
return trinoCreateAsSelect(getSession(), tableNamePrefix);
diff --git a/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/TestSqlServerClient.java b/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/TestSqlServerClient.java
index 7b050b5bac86..50958eed81d9 100644
--- a/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/TestSqlServerClient.java
+++ b/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/TestSqlServerClient.java
@@ -39,8 +39,6 @@
import static io.trino.spi.type.DoubleType.DOUBLE;
import static io.trino.testing.TestingConnectorSession.SESSION;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
public class TestSqlServerClient
{
@@ -159,10 +157,14 @@ private static void testImplementAggregation(AggregateFunction aggregateFunction
}
else {
assertThat(result).isPresent();
- assertEquals(result.get().getExpression(), expectedExpression.get());
+ assertThat(result.get().getExpression())
+ .isEqualTo(expectedExpression.get());
Optional columnMapping = JDBC_CLIENT.toColumnMapping(SESSION, null, result.get().getJdbcTypeHandle());
- assertTrue(columnMapping.isPresent(), "No mapping for: " + result.get().getJdbcTypeHandle());
- assertEquals(columnMapping.get().getType(), aggregateFunction.getOutputType());
+ assertThat(columnMapping.isPresent())
+ .describedAs("No mapping for: " + result.get().getJdbcTypeHandle())
+ .isTrue();
+ assertThat(columnMapping.get().getType())
+ .isEqualTo(aggregateFunction.getOutputType());
}
}
}
diff --git a/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/TestSqlServerConnectorTest.java b/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/TestSqlServerConnectorTest.java
index 434da9cc1f69..93a16229f5a9 100644
--- a/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/TestSqlServerConnectorTest.java
+++ b/plugin/trino-sqlserver/src/test/java/io/trino/plugin/sqlserver/TestSqlServerConnectorTest.java
@@ -38,8 +38,6 @@
import static java.util.Locale.ENGLISH;
import static java.util.stream.Collectors.joining;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
public class TestSqlServerConnectorTest
extends BaseSqlServerConnectorTest
@@ -197,11 +195,11 @@ public void testCreateAndDropTableWithSpecialCharacterName()
// Until https://github.com/trinodb/trino/issues/17 the table name is effectively lowercase
tableName = tableName.toLowerCase(ENGLISH);
assertUpdate("CREATE TABLE " + tableNameInSql + " (a bigint, b double, c varchar(50))");
- assertTrue(getQueryRunner().tableExists(getSession(), tableName));
+ assertThat(getQueryRunner().tableExists(getSession(), tableName)).isTrue();
assertTableColumnNames(tableNameInSql, "a", "b", "c");
assertUpdate("DROP TABLE " + tableNameInSql);
- assertFalse(getQueryRunner().tableExists(getSession(), tableName));
+ assertThat(getQueryRunner().tableExists(getSession(), tableName)).isFalse();
}
}
diff --git a/testing/trino-tests/src/test/java/io/trino/execution/TestDenyOnSchema.java b/testing/trino-tests/src/test/java/io/trino/execution/TestDenyOnSchema.java
index 8f972c4e8341..02f3d24b6b39 100644
--- a/testing/trino-tests/src/test/java/io/trino/execution/TestDenyOnSchema.java
+++ b/testing/trino-tests/src/test/java/io/trino/execution/TestDenyOnSchema.java
@@ -30,10 +30,11 @@
import io.trino.spi.security.TrinoPrincipal;
import io.trino.sql.query.QueryAssertions;
import io.trino.testing.DistributedQueryRunner;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.parallel.Execution;
import java.util.EnumSet;
import java.util.Set;
@@ -46,8 +47,11 @@
import static java.util.Locale.ROOT;
import static org.assertj.core.api.Assertions.assertThat;
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.SAME_THREAD;
-@Test(singleThreaded = true)
+@TestInstance(PER_CLASS)
+@Execution(SAME_THREAD)
public class TestDenyOnSchema
{
private final SchemaTableName table = new SchemaTableName("default", "table_one");
@@ -61,7 +65,7 @@ public class TestDenyOnSchema
private TrinoPrincipal expectedGrantee;
private boolean denyCalled;
- @BeforeClass
+ @BeforeAll
public void initClass()
throws Exception
{
@@ -97,7 +101,7 @@ public void denySchemaPrivileges(Session session,
tableGrants.grant(new TrinoPrincipal(USER, "admin"), table, EnumSet.allOf(Privilege.class), true);
}
- @AfterClass(alwaysRun = true)
+ @AfterAll
public void teardown()
{
assertions.close();
@@ -105,8 +109,18 @@ public void teardown()
queryRunner = null; // closed by assertions.close
}
- @Test(dataProvider = "privileges")
- public void testValidDenySchema(String privilege)
+ @Test
+ public void testValidDenySchema()
+ {
+ testValidDenySchema("CREATE");
+ testValidDenySchema("SELECT");
+ testValidDenySchema("INSERT");
+ testValidDenySchema("UPDATE");
+ testValidDenySchema("DELETE");
+ testValidDenySchema("ALL PRIVILEGES");
+ }
+
+ private void testValidDenySchema(String privilege)
{
String username = randomUsername();
@@ -124,31 +138,38 @@ public void testValidDenySchema(String privilege)
assertThat(denyCalled).isTrue();
}
- @Test(dataProvider = "privileges")
- public void testDenyOnNonExistingCatalog(String privilege)
+ @Test
+ public void testDenyOnNonExistingCatalog()
{
- assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY %s ON SCHEMA missing_catalog.missing_schema TO %s", privilege, randomUsername())))
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY CREATE ON SCHEMA missing_catalog.missing_schema TO %s", randomUsername())))
+ .hasMessageContaining("Schema 'missing_catalog.missing_schema' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY SELECT ON SCHEMA missing_catalog.missing_schema TO %s", randomUsername())))
+ .hasMessageContaining("Schema 'missing_catalog.missing_schema' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY INSERT ON SCHEMA missing_catalog.missing_schema TO %s", randomUsername())))
+ .hasMessageContaining("Schema 'missing_catalog.missing_schema' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY UPDATE ON SCHEMA missing_catalog.missing_schema TO %s", randomUsername())))
+ .hasMessageContaining("Schema 'missing_catalog.missing_schema' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY DELETE ON SCHEMA missing_catalog.missing_schema TO %s", randomUsername())))
+ .hasMessageContaining("Schema 'missing_catalog.missing_schema' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY ALL PRIVILEGES ON SCHEMA missing_catalog.missing_schema TO %s", randomUsername())))
.hasMessageContaining("Schema 'missing_catalog.missing_schema' does not exist");
}
- @Test(dataProvider = "privileges")
- public void testDenyOnNonExistingSchema(String privilege)
+ @Test
+ public void testDenyOnNonExistingSchema()
{
- assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY %s ON SCHEMA missing_schema TO %s", privilege, randomUsername())))
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY CREATE ON SCHEMA missing_schema TO %s", randomUsername())))
+ .hasMessageContaining("Schema 'local.missing_schema' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY SELECT ON SCHEMA missing_schema TO %s", randomUsername())))
+ .hasMessageContaining("Schema 'local.missing_schema' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY INSERT ON SCHEMA missing_schema TO %s", randomUsername())))
+ .hasMessageContaining("Schema 'local.missing_schema' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY UPDATE ON SCHEMA missing_schema TO %s", randomUsername())))
+ .hasMessageContaining("Schema 'local.missing_schema' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY DELETE ON SCHEMA missing_schema TO %s", randomUsername())))
+ .hasMessageContaining("Schema 'local.missing_schema' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY ALL PRIVILEGES ON SCHEMA missing_schema TO %s", randomUsername())))
.hasMessageContaining("Schema 'local.missing_schema' does not exist");
- }
-
- @DataProvider(name = "privileges")
- public static Object[][] privileges()
- {
- return new Object[][] {
- {"CREATE"},
- {"SELECT"},
- {"INSERT"},
- {"UPDATE"},
- {"DELETE"},
- {"ALL PRIVILEGES"}
- };
}
private static Session sessionOf(String username)
diff --git a/testing/trino-tests/src/test/java/io/trino/execution/TestDenyOnTable.java b/testing/trino-tests/src/test/java/io/trino/execution/TestDenyOnTable.java
index ecadc95a1f15..84aa8d0ba354 100644
--- a/testing/trino-tests/src/test/java/io/trino/execution/TestDenyOnTable.java
+++ b/testing/trino-tests/src/test/java/io/trino/execution/TestDenyOnTable.java
@@ -30,10 +30,11 @@
import io.trino.spi.security.TrinoPrincipal;
import io.trino.sql.query.QueryAssertions;
import io.trino.testing.DistributedQueryRunner;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.parallel.Execution;
import java.util.EnumSet;
import java.util.Set;
@@ -46,8 +47,11 @@
import static java.util.Locale.ROOT;
import static org.assertj.core.api.Assertions.assertThat;
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.SAME_THREAD;
-@Test(singleThreaded = true)
+@TestInstance(PER_CLASS)
+@Execution(SAME_THREAD)
public class TestDenyOnTable
{
private final SchemaTableName table = new SchemaTableName("default", "table_one");
@@ -61,7 +65,7 @@ public class TestDenyOnTable
private TrinoPrincipal expectedGrantee;
private boolean denyCalled;
- @BeforeClass
+ @BeforeAll
public void initClass()
throws Exception
{
@@ -94,7 +98,7 @@ public void denyTablePrivileges(Session session, QualifiedObjectName tableName,
tableGrants.grant(new TrinoPrincipal(USER, "admin"), table, EnumSet.allOf(Privilege.class), true);
}
- @AfterClass(alwaysRun = true)
+ @AfterAll
public void teardown()
{
assertions.close();
@@ -102,8 +106,18 @@ public void teardown()
queryRunner = null; // closed by assertions.close
}
- @Test(dataProvider = "privileges")
- public void testValidDenyTable(String privilege)
+ @Test
+ public void testValidDenyTable()
+ {
+ testValidDenyTable("CREATE");
+ testValidDenyTable("SELECT");
+ testValidDenyTable("INSERT");
+ testValidDenyTable("UPDATE");
+ testValidDenyTable("DELETE");
+ testValidDenyTable("ALL PRIVILEGES");
+ }
+
+ private void testValidDenyTable(String privilege)
{
String username = randomUsername();
@@ -121,38 +135,55 @@ public void testValidDenyTable(String privilege)
assertThat(denyCalled).isTrue();
}
- @Test(dataProvider = "privileges")
- public void testDenyOnNonExistingCatalog(String privilege)
+ @Test
+ public void testDenyOnNonExistingCatalog()
{
- assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY %s ON TABLE missing_catalog.missing_schema.missing_table TO %s", privilege, randomUsername())))
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY CREATE ON TABLE missing_catalog.missing_schema.missing_table TO %s", randomUsername())))
+ .hasMessageContaining("Table 'missing_catalog.missing_schema.missing_table' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY SELECT ON TABLE missing_catalog.missing_schema.missing_table TO %s", randomUsername())))
+ .hasMessageContaining("Table 'missing_catalog.missing_schema.missing_table' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY INSERT ON TABLE missing_catalog.missing_schema.missing_table TO %s", randomUsername())))
+ .hasMessageContaining("Table 'missing_catalog.missing_schema.missing_table' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY UPDATE ON TABLE missing_catalog.missing_schema.missing_table TO %s", randomUsername())))
+ .hasMessageContaining("Table 'missing_catalog.missing_schema.missing_table' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY DELETE ON TABLE missing_catalog.missing_schema.missing_table TO %s", randomUsername())))
+ .hasMessageContaining("Table 'missing_catalog.missing_schema.missing_table' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY ALL PRIVILEGES ON TABLE missing_catalog.missing_schema.missing_table TO %s", randomUsername())))
.hasMessageContaining("Table 'missing_catalog.missing_schema.missing_table' does not exist");
}
- @Test(dataProvider = "privileges")
- public void testDenyOnNonExistingSchema(String privilege)
+ @Test
+ public void testDenyOnNonExistingSchema()
{
- assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY %s ON TABLE missing_schema.missing_table TO %s", privilege, randomUsername())))
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY CREATE ON TABLE missing_schema.missing_table TO %s", randomUsername())))
+ .hasMessageContaining("Table 'local.missing_schema.missing_table' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY SELECT ON TABLE missing_schema.missing_table TO %s", randomUsername())))
+ .hasMessageContaining("Table 'local.missing_schema.missing_table' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY INSERT ON TABLE missing_schema.missing_table TO %s", randomUsername())))
+ .hasMessageContaining("Table 'local.missing_schema.missing_table' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY UPDATE ON TABLE missing_schema.missing_table TO %s", randomUsername())))
+ .hasMessageContaining("Table 'local.missing_schema.missing_table' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY DELETE ON TABLE missing_schema.missing_table TO %s", randomUsername())))
+ .hasMessageContaining("Table 'local.missing_schema.missing_table' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY ALL PRIVILEGES ON TABLE missing_schema.missing_table TO %s", randomUsername())))
.hasMessageContaining("Table 'local.missing_schema.missing_table' does not exist");
}
- @Test(dataProvider = "privileges")
- public void testDenyOnNonExistingTable(String privilege)
+ @Test
+ public void testDenyOnNonExistingTable()
{
- assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY %s ON TABLE default.missing_table TO %s", privilege, randomUsername())))
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY CREATE ON TABLE default.missing_table TO %s", randomUsername())))
+ .hasMessageContaining("Table 'local.default.missing_table' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY SELECT ON TABLE default.missing_table TO %s", randomUsername())))
+ .hasMessageContaining("Table 'local.default.missing_table' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY INSERT ON TABLE default.missing_table TO %s", randomUsername())))
+ .hasMessageContaining("Table 'local.default.missing_table' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY UPDATE ON TABLE default.missing_table TO %s", randomUsername())))
+ .hasMessageContaining("Table 'local.default.missing_table' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY DELETE ON TABLE default.missing_table TO %s", randomUsername())))
+ .hasMessageContaining("Table 'local.default.missing_table' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("DENY ALL PRIVILEGES ON TABLE default.missing_table TO %s", randomUsername())))
.hasMessageContaining("Table 'local.default.missing_table' does not exist");
- }
-
- @DataProvider(name = "privileges")
- public static Object[][] privileges()
- {
- return new Object[][] {
- {"CREATE"},
- {"SELECT"},
- {"INSERT"},
- {"UPDATE"},
- {"DELETE"},
- {"ALL PRIVILEGES"}
- };
}
private static Session sessionOf(String username)
diff --git a/testing/trino-tests/src/test/java/io/trino/execution/TestGrantOnSchema.java b/testing/trino-tests/src/test/java/io/trino/execution/TestGrantOnSchema.java
index d551aa0903fc..9014df44aac7 100644
--- a/testing/trino-tests/src/test/java/io/trino/execution/TestGrantOnSchema.java
+++ b/testing/trino-tests/src/test/java/io/trino/execution/TestGrantOnSchema.java
@@ -23,12 +23,12 @@
import io.trino.spi.security.Privilege;
import io.trino.spi.security.TrinoPrincipal;
import io.trino.sql.query.QueryAssertions;
-import io.trino.testing.DataProviders;
import io.trino.testing.DistributedQueryRunner;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.parallel.Execution;
import java.util.EnumSet;
@@ -38,7 +38,11 @@
import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
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;
+@TestInstance(PER_CLASS)
+@Execution(CONCURRENT)
public class TestGrantOnSchema
{
private final Session admin = sessionOf("admin");
@@ -46,7 +50,7 @@ public class TestGrantOnSchema
private DistributedQueryRunner queryRunner;
private QueryAssertions assertions;
- @BeforeClass
+ @BeforeAll
public void initClass()
throws Exception
{
@@ -63,7 +67,7 @@ public void initClass()
schemaGrants.grant(new TrinoPrincipal(USER, admin.getUser()), "default", EnumSet.allOf(Privilege.class), true);
}
- @AfterClass(alwaysRun = true)
+ @AfterAll
public void teardown()
{
assertions.close();
@@ -71,8 +75,14 @@ public void teardown()
queryRunner = null; // closed by assertions.close
}
- @Test(dataProviderClass = DataProviders.class, dataProvider = "trueFalse")
- public void testExistingGrants(boolean grantOption)
+ @Test
+ public void testExistingGrants()
+ {
+ testExistingGrants(true);
+ testExistingGrants(false);
+ }
+
+ private void testExistingGrants(boolean grantOption)
{
String username = randomUsername();
Session user = sessionOf(username);
@@ -84,8 +94,15 @@ public void testExistingGrants(boolean grantOption)
assertThat(assertions.query(user, "SHOW TABLES FROM default")).matches("VALUES (VARCHAR 'table_one')");
}
- @Test(dataProvider = "privileges")
- public void testValidGrant(String privilege)
+ @Test
+ public void testValidGrant()
+ {
+ testValidGrant("SELECT");
+ testValidGrant("CREATE");
+ testValidGrant("ALL PRIVILEGES");
+ }
+
+ private void testValidGrant(String privilege)
{
String username = randomUsername();
Session user = sessionOf(username);
@@ -97,8 +114,15 @@ public void testValidGrant(String privilege)
assertThat(assertions.query(user, "SHOW TABLES FROM default")).matches("VALUES (VARCHAR 'table_one')");
}
- @Test(dataProvider = "privileges")
- public void testValidGrantWithGrantOption(String privilege)
+ @Test
+ public void testValidGrantWithGrantOption()
+ {
+ testValidGrantWithGrantOption("SELECT");
+ testValidGrantWithGrantOption("CREATE");
+ testValidGrantWithGrantOption("ALL PRIVILEGES");
+ }
+
+ private void testValidGrantWithGrantOption(String privilege)
{
String username = randomUsername();
Session user = sessionOf(username);
@@ -110,37 +134,37 @@ public void testValidGrantWithGrantOption(String privilege)
assertions.query(user, format("GRANT %s ON SCHEMA default TO %s WITH GRANT OPTION", privilege, randomUsername()));
}
- @Test(dataProvider = "privileges")
- public void testGrantOnNonExistingCatalog(String privilege)
+ @Test
+ public void testGrantOnNonExistingCatalog()
{
- assertThatThrownBy(() -> queryRunner.execute(admin, format("GRANT %s ON SCHEMA missing_catalog.missing_schema TO %s", privilege, randomUsername())))
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("GRANT SELECT ON SCHEMA missing_catalog.missing_schema TO %s", randomUsername())))
+ .hasMessageContaining("Schema 'missing_catalog.missing_schema' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("GRANT CREATE ON SCHEMA missing_catalog.missing_schema TO %s", randomUsername())))
+ .hasMessageContaining("Schema 'missing_catalog.missing_schema' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("GRANT ALL PRIVILEGES ON SCHEMA missing_catalog.missing_schema TO %s", randomUsername())))
.hasMessageContaining("Schema 'missing_catalog.missing_schema' does not exist");
}
- @Test(dataProvider = "privileges")
- public void testGrantOnNonExistingSchema(String privilege)
+ @Test
+ public void testGrantOnNonExistingSchema()
{
- assertThatThrownBy(() -> queryRunner.execute(admin, format("GRANT %s ON SCHEMA missing_schema TO %s", privilege, randomUsername())))
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("GRANT SELECT ON SCHEMA missing_schema TO %s", randomUsername())))
+ .hasMessageContaining("Schema 'local.missing_schema' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("GRANT CREATE ON SCHEMA missing_schema TO %s", randomUsername())))
+ .hasMessageContaining("Schema 'local.missing_schema' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("GRANT ALL PRIVILEGES ON SCHEMA missing_schema TO %s", randomUsername())))
.hasMessageContaining("Schema 'local.missing_schema' does not exist");
}
- @Test(dataProvider = "privileges")
- public void testAccessDenied(String privilege)
- {
- assertThatThrownBy(() -> queryRunner.execute(sessionOf(randomUsername()), format("GRANT %s ON SCHEMA default TO %s", privilege, randomUsername())))
- .hasMessageContaining(
- "Access Denied: Cannot grant privilege %s on schema default",
- privilege.equals("ALL PRIVILEGES") ? "CREATE" : privilege);
- }
-
- @DataProvider(name = "privileges")
- public static Object[][] privileges()
+ @Test
+ public void testAccessDenied()
{
- return new Object[][] {
- {"SELECT"},
- {"CREATE"},
- {"ALL PRIVILEGES"}
- };
+ assertThatThrownBy(() -> queryRunner.execute(sessionOf(randomUsername()), format("GRANT SELECT ON SCHEMA default TO %s", randomUsername())))
+ .hasMessageContaining("Access Denied: Cannot grant privilege SELECT on schema default");
+ assertThatThrownBy(() -> queryRunner.execute(sessionOf(randomUsername()), format("GRANT CREATE ON SCHEMA default TO %s", randomUsername())))
+ .hasMessageContaining("Access Denied: Cannot grant privilege CREATE on schema default");
+ assertThatThrownBy(() -> queryRunner.execute(sessionOf(randomUsername()), format("GRANT ALL PRIVILEGES ON SCHEMA default TO %s", randomUsername())))
+ .hasMessageContaining("Access Denied: Cannot grant privilege CREATE on schema default");
}
private static Session sessionOf(String username)
diff --git a/testing/trino-tests/src/test/java/io/trino/execution/TestGrantOnTable.java b/testing/trino-tests/src/test/java/io/trino/execution/TestGrantOnTable.java
index b4bc745dfc82..07865f93a020 100644
--- a/testing/trino-tests/src/test/java/io/trino/execution/TestGrantOnTable.java
+++ b/testing/trino-tests/src/test/java/io/trino/execution/TestGrantOnTable.java
@@ -25,12 +25,12 @@
import io.trino.spi.security.Privilege;
import io.trino.spi.security.TrinoPrincipal;
import io.trino.sql.query.QueryAssertions;
-import io.trino.testing.DataProviders;
import io.trino.testing.DistributedQueryRunner;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.parallel.Execution;
import java.util.EnumSet;
import java.util.Optional;
@@ -43,7 +43,11 @@
import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
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;
+@TestInstance(PER_CLASS)
+@Execution(CONCURRENT)
public class TestGrantOnTable
{
private final SchemaTableName table = new SchemaTableName("default", "table_one");
@@ -52,7 +56,7 @@ public class TestGrantOnTable
private DistributedQueryRunner queryRunner;
private QueryAssertions assertions;
- @BeforeClass
+ @BeforeAll
public void initClass()
throws Exception
{
@@ -70,7 +74,7 @@ public void initClass()
tableGrants.grant(new TrinoPrincipal(USER, "admin"), table, EnumSet.allOf(Privilege.class), true);
}
- @AfterClass(alwaysRun = true)
+ @AfterAll
public void teardown()
{
assertions.close();
@@ -78,8 +82,14 @@ public void teardown()
queryRunner = null; // closed by assertions.close
}
- @Test(dataProviderClass = DataProviders.class, dataProvider = "trueFalse")
- public void testExistingGrants(boolean grantOption)
+ @Test
+ public void testExistingGrants()
+ {
+ testExistingGrants(true);
+ testExistingGrants(false);
+ }
+
+ private void testExistingGrants(boolean grantOption)
{
String username = randomUsername();
Session user = sessionOf(username);
@@ -89,8 +99,18 @@ public void testExistingGrants(boolean grantOption)
assertThat(assertions.query(user, "SHOW TABLES FROM local.default")).matches("VALUES (VARCHAR 'table_one')");
}
- @Test(dataProvider = "privileges")
- public void testValidGrant(String privilege)
+ @Test
+ public void testValidGrant()
+ {
+ testValidGrant("CREATE");
+ testValidGrant("SELECT");
+ testValidGrant("INSERT");
+ testValidGrant("UPDATE");
+ testValidGrant("DELETE");
+ testValidGrant("ALL PRIVILEGES");
+ }
+
+ private void testValidGrant(String privilege)
{
String username = randomUsername();
Session user = sessionOf(username);
@@ -100,8 +120,18 @@ public void testValidGrant(String privilege)
assertThat(assertions.query(user, "SHOW TABLES FROM default")).matches("VALUES (VARCHAR 'table_one')");
}
- @Test(dataProvider = "privileges")
- public void testValidGrantWithGrantOption(String privilege)
+ @Test
+ public void testValidGrantWithGrantOption()
+ {
+ testValidGrantWithGrantOption("CREATE");
+ testValidGrantWithGrantOption("SELECT");
+ testValidGrantWithGrantOption("INSERT");
+ testValidGrantWithGrantOption("UPDATE");
+ testValidGrantWithGrantOption("DELETE");
+ testValidGrantWithGrantOption("ALL PRIVILEGES");
+ }
+
+ private void testValidGrantWithGrantOption(String privilege)
{
String username = randomUsername();
Session user = sessionOf(username);
@@ -113,38 +143,55 @@ public void testValidGrantWithGrantOption(String privilege)
assertUpdate(queryRunner, user, format("GRANT %s ON TABLE table_one TO %s WITH GRANT OPTION", privilege, randomUsername()), OptionalLong.empty(), Optional.empty());
}
- @Test(dataProvider = "privileges")
- public void testGrantOnNonExistingCatalog(String privilege)
+ @Test
+ public void testGrantOnNonExistingCatalog()
{
- assertThatThrownBy(() -> queryRunner.execute(admin, format("GRANT %s ON TABLE missing_catalog.missing_schema.missing_table TO %s", privilege, randomUsername())))
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("GRANT CREATE ON TABLE missing_catalog.missing_schema.missing_table TO %s", randomUsername())))
+ .hasMessageContaining("Table 'missing_catalog.missing_schema.missing_table' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("GRANT SELECT ON TABLE missing_catalog.missing_schema.missing_table TO %s", randomUsername())))
+ .hasMessageContaining("Table 'missing_catalog.missing_schema.missing_table' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("GRANT INSERT ON TABLE missing_catalog.missing_schema.missing_table TO %s", randomUsername())))
+ .hasMessageContaining("Table 'missing_catalog.missing_schema.missing_table' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("GRANT UPDATE ON TABLE missing_catalog.missing_schema.missing_table TO %s", randomUsername())))
+ .hasMessageContaining("Table 'missing_catalog.missing_schema.missing_table' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("GRANT DELETE ON TABLE missing_catalog.missing_schema.missing_table TO %s", randomUsername())))
+ .hasMessageContaining("Table 'missing_catalog.missing_schema.missing_table' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("GRANT ALL PRIVILEGES ON TABLE missing_catalog.missing_schema.missing_table TO %s", randomUsername())))
.hasMessageContaining("Table 'missing_catalog.missing_schema.missing_table' does not exist");
}
- @Test(dataProvider = "privileges")
- public void testGrantOnNonExistingSchema(String privilege)
+ @Test
+ public void testGrantOnNonExistingSchema()
{
- assertThatThrownBy(() -> queryRunner.execute(admin, format("GRANT %s ON TABLE missing_schema.missing_table TO %s", privilege, randomUsername())))
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("GRANT CREATE ON TABLE missing_schema.missing_table TO %s", randomUsername())))
+ .hasMessageContaining("Table 'local.missing_schema.missing_table' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("GRANT SELECT ON TABLE missing_schema.missing_table TO %s", randomUsername())))
+ .hasMessageContaining("Table 'local.missing_schema.missing_table' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("GRANT INSERT ON TABLE missing_schema.missing_table TO %s", randomUsername())))
+ .hasMessageContaining("Table 'local.missing_schema.missing_table' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("GRANT UPDATE ON TABLE missing_schema.missing_table TO %s", randomUsername())))
+ .hasMessageContaining("Table 'local.missing_schema.missing_table' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("GRANT DELETE ON TABLE missing_schema.missing_table TO %s", randomUsername())))
+ .hasMessageContaining("Table 'local.missing_schema.missing_table' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("GRANT ALL PRIVILEGES ON TABLE missing_schema.missing_table TO %s", randomUsername())))
.hasMessageContaining("Table 'local.missing_schema.missing_table' does not exist");
}
- @Test(dataProvider = "privileges")
- public void testGrantOnNonExistingTable(String privilege)
+ @Test
+ public void testGrantOnNonExistingTable()
{
- assertThatThrownBy(() -> queryRunner.execute(admin, format("GRANT %s ON TABLE default.missing_table TO %s", privilege, randomUsername())))
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("GRANT CREATE ON TABLE default.missing_table TO %s", randomUsername())))
+ .hasMessageContaining("Table 'local.default.missing_table' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("GRANT SELECT ON TABLE default.missing_table TO %s", randomUsername())))
+ .hasMessageContaining("Table 'local.default.missing_table' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("GRANT INSERT ON TABLE default.missing_table TO %s", randomUsername())))
+ .hasMessageContaining("Table 'local.default.missing_table' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("GRANT UPDATE ON TABLE default.missing_table TO %s", randomUsername())))
+ .hasMessageContaining("Table 'local.default.missing_table' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("GRANT DELETE ON TABLE default.missing_table TO %s", randomUsername())))
+ .hasMessageContaining("Table 'local.default.missing_table' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("GRANT ALL PRIVILEGES ON TABLE default.missing_table TO %s", randomUsername())))
.hasMessageContaining("Table 'local.default.missing_table' does not exist");
- }
-
- @DataProvider(name = "privileges")
- public static Object[][] privileges()
- {
- return new Object[][] {
- {"CREATE"},
- {"SELECT"},
- {"INSERT"},
- {"UPDATE"},
- {"DELETE"},
- {"ALL PRIVILEGES"}
- };
}
private static Session sessionOf(String username)
diff --git a/testing/trino-tests/src/test/java/io/trino/execution/TestRevokeOnSchema.java b/testing/trino-tests/src/test/java/io/trino/execution/TestRevokeOnSchema.java
index 2ab6172d5fcc..8a02451ae34d 100644
--- a/testing/trino-tests/src/test/java/io/trino/execution/TestRevokeOnSchema.java
+++ b/testing/trino-tests/src/test/java/io/trino/execution/TestRevokeOnSchema.java
@@ -25,10 +25,11 @@
import io.trino.spi.security.TrinoPrincipal;
import io.trino.sql.query.QueryAssertions;
import io.trino.testing.DistributedQueryRunner;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.parallel.Execution;
import java.util.EnumSet;
@@ -38,7 +39,11 @@
import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
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;
+@TestInstance(PER_CLASS)
+@Execution(CONCURRENT)
public class TestRevokeOnSchema
{
private static final Session admin = sessionOf("admin");
@@ -47,7 +52,7 @@ public class TestRevokeOnSchema
private DistributedQueryRunner queryRunner;
private QueryAssertions assertions;
- @BeforeClass
+ @BeforeAll
public void initClass()
throws Exception
{
@@ -65,7 +70,7 @@ public void initClass()
assertions = new QueryAssertions(queryRunner);
}
- @AfterClass(alwaysRun = true)
+ @AfterAll
public void teardown()
{
assertions.close();
@@ -73,8 +78,14 @@ public void teardown()
queryRunner = null; // closed by assertions.close
}
- @Test(dataProvider = "privilegesAndUsers")
- public void testRevokeOnSchema(String privilege, Session user)
+ @Test
+ public void testRevokeOnSchema()
+ {
+ testRevokeOnSchema("SELECT", userWithSelect);
+ testRevokeOnSchema("ALL PRIVILEGES", userWithAllPrivileges);
+ }
+
+ private void testRevokeOnSchema(String privilege, Session user)
{
assertThat(assertions.query(user, "SHOW SCHEMAS FROM local")).matches("VALUES (VARCHAR 'information_schema'), (VARCHAR 'default')");
@@ -83,46 +94,33 @@ public void testRevokeOnSchema(String privilege, Session user)
assertThat(assertions.query(user, "SHOW SCHEMAS FROM local")).matches("VALUES (VARCHAR 'information_schema')");
}
- @Test(dataProvider = "privilegesAndUsers")
- public void testRevokeOnNonExistingCatalog(String privilege, Session user)
+ @Test
+ public void testRevokeOnNonExistingCatalog()
{
- assertThatThrownBy(() -> queryRunner.execute(admin, format("REVOKE %s ON SCHEMA missing_catalog.missing_schema FROM %s", privilege, user.getUser())))
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("REVOKE SELECT ON SCHEMA missing_catalog.missing_schema FROM %s", userWithSelect.getUser())))
+ .hasMessageContaining("Schema 'missing_catalog.missing_schema' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("REVOKE ALL PRIVILEGES ON SCHEMA missing_catalog.missing_schema FROM %s", userWithAllPrivileges.getUser())))
.hasMessageContaining("Schema 'missing_catalog.missing_schema' does not exist");
}
- @Test(dataProvider = "privilegesAndUsers")
- public void testRevokeOnNonExistingSchema(String privilege, Session user)
+ @Test
+ public void testRevokeOnNonExistingSchema()
{
- assertThatThrownBy(() -> queryRunner.execute(admin, format("REVOKE %s ON SCHEMA missing_schema FROM %s", privilege, user.getUser())))
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("REVOKE SELECT ON SCHEMA missing_schema FROM %s", userWithSelect.getUser())))
+ .hasMessageContaining("Schema 'local.missing_schema' does not exist");
+ assertThatThrownBy(() -> queryRunner.execute(admin, format("REVOKE ALL PRIVILEGES ON SCHEMA missing_schema FROM %s", userWithAllPrivileges.getUser())))
.hasMessageContaining("Schema 'local.missing_schema' does not exist");
}
- @Test(dataProvider = "privileges")
- public void testAccessDenied(String privilege)
- {
- assertThatThrownBy(() -> queryRunner.execute(sessionOf(randomUsername()), format("REVOKE %s ON SCHEMA default FROM %s", privilege, randomUsername())))
- .hasMessageContaining(
- "Access Denied: Cannot revoke privilege %s on schema default",
- privilege.equals("ALL PRIVILEGES") ? "CREATE" : privilege);
- }
-
- @DataProvider(name = "privilegesAndUsers")
- public static Object[][] privilegesAndUsers()
- {
- return new Object[][] {
- {"SELECT", userWithSelect},
- {"ALL PRIVILEGES", userWithAllPrivileges}
- };
- }
-
- @DataProvider(name = "privileges")
- public static Object[][] privileges()
+ @Test
+ public void testAccessDenied()
{
- return new Object[][] {
- {"CREATE"},
- {"SELECT"},
- {"ALL PRIVILEGES"}
- };
+ assertThatThrownBy(() -> queryRunner.execute(sessionOf(randomUsername()), format("REVOKE CREATE ON SCHEMA default FROM %s", randomUsername())))
+ .hasMessageContaining("Access Denied: Cannot revoke privilege CREATE on schema default");
+ assertThatThrownBy(() -> queryRunner.execute(sessionOf(randomUsername()), format("REVOKE SELECT ON SCHEMA default FROM %s", randomUsername())))
+ .hasMessageContaining("Access Denied: Cannot revoke privilege SELECT on schema default");
+ assertThatThrownBy(() -> queryRunner.execute(sessionOf(randomUsername()), format("REVOKE ALL PRIVILEGES ON SCHEMA default FROM %s", randomUsername())))
+ .hasMessageContaining("Access Denied: Cannot revoke privilege CREATE on schema default");
}
private static Session sessionOf(String username)