42
42
import io .trino .testing .sql .TestTable ;
43
43
import io .trino .testing .sql .TestView ;
44
44
import org .intellij .lang .annotations .Language ;
45
- import org .testng .SkipException ;
46
- import org .testng .annotations .AfterClass ;
47
- import org .testng .annotations .Test ;
45
+ import org .junit .jupiter .api .AfterAll ;
46
+ import org .junit .jupiter .api .Test ;
47
+ import org .junit .jupiter .api .TestInstance ;
48
+ import org .junit .jupiter .api .Timeout ;
48
49
49
50
import java .util .ArrayList ;
50
51
import java .util .List ;
116
117
import static java .util .concurrent .TimeUnit .MINUTES ;
117
118
import static org .assertj .core .api .Assertions .assertThat ;
118
119
import static org .assertj .core .api .Assertions .assertThatThrownBy ;
120
+ import static org .junit .jupiter .api .Assumptions .abort ;
121
+ import static org .junit .jupiter .api .TestInstance .Lifecycle .PER_CLASS ;
119
122
123
+ @ TestInstance (PER_CLASS )
120
124
public abstract class BaseJdbcConnectorTest
121
125
extends BaseConnectorTest
122
126
{
123
127
private final ExecutorService executor = newCachedThreadPool (daemonThreadsNamed (getClass ().getName ()));
124
128
125
129
protected abstract SqlExecutor onRemoteDatabase ();
126
130
127
- @ AfterClass ( alwaysRun = true )
131
+ @ AfterAll
128
132
public void afterClass ()
129
133
{
130
134
executor .shutdownNow ();
@@ -167,7 +171,7 @@ public void testInsertInPresenceOfNotSupportedColumn()
167
171
protected TestTable createTableWithUnsupportedColumn ()
168
172
{
169
173
// TODO throw new UnsupportedOperationException();
170
- throw new SkipException ("Not implemented" );
174
+ return abort ("Not implemented" );
171
175
}
172
176
173
177
// TODO move common tests from connector-specific classes here
@@ -577,7 +581,7 @@ public void testNumericAggregationPushdown()
577
581
public void testCountDistinctWithStringTypes ()
578
582
{
579
583
if (!(hasBehavior (SUPPORTS_CREATE_TABLE ) && hasBehavior (SUPPORTS_INSERT ))) {
580
- throw new SkipException ("Unable to CREATE TABLE to test count distinct" );
584
+ abort ("Unable to CREATE TABLE to test count distinct" );
581
585
}
582
586
583
587
List <String > rows = Stream .of ("a" , "b" , "A" , "B" , " a " , "a" , "b" , " b " , "ą" )
@@ -643,7 +647,7 @@ public void testStddevAggregationPushdown()
643
647
String schemaName = getSession ().getSchema ().orElseThrow ();
644
648
if (!hasBehavior (SUPPORTS_AGGREGATION_PUSHDOWN_STDDEV )) {
645
649
if (!hasBehavior (SUPPORTS_CREATE_TABLE )) {
646
- throw new SkipException ("Unable to CREATE TABLE to test aggregation pushdown" );
650
+ abort ("Unable to CREATE TABLE to test aggregation pushdown" );
647
651
}
648
652
649
653
try (TestTable testTable = createTableWithDoubleAndRealColumns (schemaName + ".test_stddev_pushdown" , ImmutableList .of ())) {
@@ -694,7 +698,7 @@ public void testVarianceAggregationPushdown()
694
698
String schemaName = getSession ().getSchema ().orElseThrow ();
695
699
if (!hasBehavior (SUPPORTS_AGGREGATION_PUSHDOWN_VARIANCE )) {
696
700
if (!hasBehavior (SUPPORTS_CREATE_TABLE )) {
697
- throw new SkipException ("Unable to CREATE TABLE to test aggregation pushdown" );
701
+ abort ("Unable to CREATE TABLE to test aggregation pushdown" );
698
702
}
699
703
700
704
try (TestTable testTable = createTableWithDoubleAndRealColumns (schemaName + ".test_var_pushdown" , ImmutableList .of ())) {
@@ -738,7 +742,7 @@ public void testCovarianceAggregationPushdown()
738
742
String schemaName = getSession ().getSchema ().orElseThrow ();
739
743
if (!hasBehavior (SUPPORTS_AGGREGATION_PUSHDOWN_COVARIANCE )) {
740
744
if (!hasBehavior (SUPPORTS_CREATE_TABLE )) {
741
- throw new SkipException ("Unable to CREATE TABLE to test aggregation pushdown" );
745
+ abort ("Unable to CREATE TABLE to test aggregation pushdown" );
742
746
}
743
747
744
748
try (TestTable testTable = createTableWithDoubleAndRealColumns (schemaName + ".test_covar_pushdown" , ImmutableList .of ())) {
@@ -775,7 +779,7 @@ public void testCorrAggregationPushdown()
775
779
String schemaName = getSession ().getSchema ().orElseThrow ();
776
780
if (!hasBehavior (SUPPORTS_AGGREGATION_PUSHDOWN_CORRELATION )) {
777
781
if (!hasBehavior (SUPPORTS_CREATE_TABLE )) {
778
- throw new SkipException ("Unable to CREATE TABLE to test aggregation pushdown" );
782
+ abort ("Unable to CREATE TABLE to test aggregation pushdown" );
779
783
}
780
784
781
785
try (TestTable testTable = createTableWithDoubleAndRealColumns (schemaName + ".test_corr_pushdown" , ImmutableList .of ())) {
@@ -808,7 +812,7 @@ public void testRegrAggregationPushdown()
808
812
String schemaName = getSession ().getSchema ().orElseThrow ();
809
813
if (!hasBehavior (SUPPORTS_AGGREGATION_PUSHDOWN_REGRESSION )) {
810
814
if (!hasBehavior (SUPPORTS_CREATE_TABLE )) {
811
- throw new SkipException ("Unable to CREATE TABLE to test aggregation pushdown" );
815
+ abort ("Unable to CREATE TABLE to test aggregation pushdown" );
812
816
}
813
817
814
818
try (TestTable testTable = createTableWithDoubleAndRealColumns (schemaName + ".test_regr_pushdown" , ImmutableList .of ())) {
@@ -1455,12 +1459,13 @@ protected Session joinPushdownEnabled(Session session)
1455
1459
.build ();
1456
1460
}
1457
1461
1458
- @ Test (timeOut = 60_000 )
1462
+ @ Test
1463
+ @ Timeout (60 )
1459
1464
public void testCancellation ()
1460
1465
throws Exception
1461
1466
{
1462
1467
if (!hasBehavior (SUPPORTS_CANCELLATION )) {
1463
- throw new SkipException ("Cancellation is not supported by given connector" );
1468
+ abort ("Cancellation is not supported by given connector" );
1464
1469
}
1465
1470
1466
1471
try (TestView sleepingView = createSleepingView (new Duration (1 , MINUTES ))) {
@@ -1512,6 +1517,7 @@ protected TestView createSleepingView(Duration minimalSleepDuration)
1512
1517
throw new UnsupportedOperationException ();
1513
1518
}
1514
1519
1520
+ @ Test
1515
1521
@ Override
1516
1522
public void testUpdateNotNullColumn ()
1517
1523
{
@@ -1538,6 +1544,7 @@ public void testUpdateNotNullColumn()
1538
1544
}
1539
1545
}
1540
1546
1547
+ @ Test
1541
1548
@ Override
1542
1549
public void testUpdateRowType ()
1543
1550
{
@@ -1555,6 +1562,7 @@ public void testUpdateRowType()
1555
1562
}
1556
1563
}
1557
1564
1565
+ @ Test
1558
1566
@ Override
1559
1567
public void testUpdateRowConcurrently ()
1560
1568
throws Exception
@@ -1571,6 +1579,7 @@ public void testUpdateRowConcurrently()
1571
1579
}
1572
1580
}
1573
1581
1582
+ @ Test
1574
1583
@ Override
1575
1584
public void testUpdateAllValues ()
1576
1585
{
@@ -1586,6 +1595,7 @@ public void testUpdateAllValues()
1586
1595
}
1587
1596
}
1588
1597
1598
+ @ Test
1589
1599
@ Override
1590
1600
public void testUpdateWithPredicates ()
1591
1601
{
@@ -1744,6 +1754,7 @@ public void testDeleteWithVarcharGreaterAndLowerPredicate()
1744
1754
}
1745
1755
}
1746
1756
1757
+ @ Test
1747
1758
@ Override
1748
1759
public void testDeleteWithComplexPredicate ()
1749
1760
{
@@ -1756,6 +1767,7 @@ public void testDeleteWithComplexPredicate()
1756
1767
.hasStackTraceContaining ("TrinoException: " + MODIFYING_ROWS_MESSAGE );
1757
1768
}
1758
1769
1770
+ @ Test
1759
1771
@ Override
1760
1772
public void testDeleteWithSubquery ()
1761
1773
{
@@ -1768,6 +1780,7 @@ public void testDeleteWithSubquery()
1768
1780
.hasStackTraceContaining ("TrinoException: " + MODIFYING_ROWS_MESSAGE );
1769
1781
}
1770
1782
1783
+ @ Test
1771
1784
@ Override
1772
1785
public void testExplainAnalyzeWithDeleteWithSubquery ()
1773
1786
{
@@ -1780,6 +1793,7 @@ public void testExplainAnalyzeWithDeleteWithSubquery()
1780
1793
.hasStackTraceContaining ("TrinoException: " + MODIFYING_ROWS_MESSAGE );
1781
1794
}
1782
1795
1796
+ @ Test
1783
1797
@ Override
1784
1798
public void testDeleteWithSemiJoin ()
1785
1799
{
@@ -1792,17 +1806,18 @@ public void testDeleteWithSemiJoin()
1792
1806
.hasStackTraceContaining ("TrinoException: " + MODIFYING_ROWS_MESSAGE );
1793
1807
}
1794
1808
1809
+ @ Test
1795
1810
@ Override
1796
1811
public void testDeleteWithVarcharPredicate ()
1797
1812
{
1798
- throw new SkipException ("This is implemented by testDeleteWithVarcharEqualityPredicate" );
1813
+ abort ("This is implemented by testDeleteWithVarcharEqualityPredicate" );
1799
1814
}
1800
1815
1801
1816
@ Test
1802
1817
public void testInsertWithoutTemporaryTable ()
1803
1818
{
1804
1819
if (!hasBehavior (SUPPORTS_CREATE_TABLE )) {
1805
- throw new SkipException ("CREATE TABLE is required for testing non-transactional write support" );
1820
+ abort ("CREATE TABLE is required for testing non-transactional write support" );
1806
1821
}
1807
1822
Session session = Session .builder (getSession ())
1808
1823
.setCatalogSessionProperty (getSession ().getCatalog ().orElseThrow (), "non_transactional_insert" , "false" )
@@ -1832,7 +1847,7 @@ public void testWriteBatchSizeSessionProperty()
1832
1847
private void testWriteBatchSizeSessionProperty (int batchSize , int numberOfRows )
1833
1848
{
1834
1849
if (!hasBehavior (SUPPORTS_CREATE_TABLE )) {
1835
- throw new SkipException ("CREATE TABLE is required for write_batch_size test but is not supported" );
1850
+ abort ("CREATE TABLE is required for write_batch_size test but is not supported" );
1836
1851
}
1837
1852
Session session = Session .builder (getSession ())
1838
1853
.setCatalogSessionProperty (getSession ().getCatalog ().orElseThrow (), "write_batch_size" , Integer .toString (batchSize ))
@@ -1861,7 +1876,7 @@ public void testWriteTaskParallelismSessionProperty()
1861
1876
private void testWriteTaskParallelismSessionProperty (int parallelism , int numberOfRows )
1862
1877
{
1863
1878
if (!hasBehavior (SUPPORTS_CREATE_TABLE )) {
1864
- throw new SkipException ("CREATE TABLE is required for write_parallelism test but is not supported" );
1879
+ abort ("CREATE TABLE is required for write_parallelism test but is not supported" );
1865
1880
}
1866
1881
1867
1882
Session session = Session .builder (getSession ())
0 commit comments