Skip to content

Commit ebbf097

Browse files
author
Paultagoras
committed
Update ConnectionTest.java
1 parent 5e23ead commit ebbf097

File tree

1 file changed

+41
-42
lines changed

1 file changed

+41
-42
lines changed

jdbc-v2/src/test/java/com/clickhouse/jdbc/ConnectionTest.java

Lines changed: 41 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
package com.clickhouse.jdbc;
22

33
import java.sql.*;
4-
import java.util.Properties;
5-
6-
import com.clickhouse.client.api.ClientConfigProperties;
74
import com.clickhouse.jdbc.internal.ClientInfoProperties;
85
import org.testng.Assert;
96
import org.testng.annotations.Test;
107

8+
import static org.testng.Assert.assertThrows;
9+
1110

1211
public class ConnectionTest extends JdbcIntegrationTest {
1312

@@ -17,28 +16,28 @@ public void createAndCloseStatementTest() throws SQLException {
1716
Statement statement = localConnection.createStatement();
1817
Assert.assertNotNull(statement);
1918

20-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY));
21-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.CLOSE_CURSORS_AT_COMMIT));
19+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY));
20+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.CLOSE_CURSORS_AT_COMMIT));
2221
}
2322

2423
@Test(groups = { "integration" })
2524
public void prepareStatementTest() throws SQLException {
2625
Connection localConnection = this.getJdbcConnection();
2726
PreparedStatement statement = localConnection.prepareStatement("SELECT 1");
2827
Assert.assertNotNull(statement);
29-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.prepareStatement("SELECT 1", Statement.RETURN_GENERATED_KEYS));
30-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.prepareStatement("SELECT 1", new int[] { 1 }));
31-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.prepareStatement("SELECT 1", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY));
32-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.prepareStatement("SELECT 1", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.CLOSE_CURSORS_AT_COMMIT));
33-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.prepareStatement("SELECT 1", new String[] { "1" }));
28+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.prepareStatement("SELECT 1", Statement.RETURN_GENERATED_KEYS));
29+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.prepareStatement("SELECT 1", new int[] { 1 }));
30+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.prepareStatement("SELECT 1", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY));
31+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.prepareStatement("SELECT 1", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.CLOSE_CURSORS_AT_COMMIT));
32+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.prepareStatement("SELECT 1", new String[] { "1" }));
3433
}
3534

3635
@Test(groups = { "integration" })
3736
public void prepareCallTest() throws SQLException {
3837
Connection localConnection = this.getJdbcConnection();
39-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.prepareCall("SELECT 1"));
40-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.prepareCall("SELECT 1", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY));
41-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.prepareCall("SELECT 1", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.CLOSE_CURSORS_AT_COMMIT));
38+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.prepareCall("SELECT 1"));
39+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.prepareCall("SELECT 1", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY));
40+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.prepareCall("SELECT 1", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.CLOSE_CURSORS_AT_COMMIT));
4241
}
4342

4443
@Test(groups = { "integration" }, enabled = false)
@@ -52,7 +51,7 @@ public void nativeSQLTest() throws SQLException {
5251
@Test(groups = { "integration" })
5352
public void setAutoCommitTest() throws SQLException {
5453
Connection localConnection = this.getJdbcConnection();
55-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setAutoCommit(false));
54+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setAutoCommit(false));
5655
localConnection.setAutoCommit(true);
5756
}
5857

@@ -65,14 +64,14 @@ public void getAutoCommitTest() throws SQLException {
6564
@Test(groups = { "integration" })
6665
public void commitTest() throws SQLException {
6766
Connection localConnection = this.getJdbcConnection();
68-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.commit());
67+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.commit());
6968
}
7069

7170
@Test(groups = { "integration" })
7271
public void rollbackTest() throws SQLException {
7372
Connection localConnection = this.getJdbcConnection();
74-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.rollback());
75-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.rollback(null));
73+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.rollback());
74+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.rollback(null));
7675
}
7776

7877
@Test(groups = { "integration" })
@@ -81,8 +80,8 @@ public void closeTest() throws SQLException {
8180
Assert.assertFalse(localConnection.isClosed());
8281
localConnection.close();
8382
Assert.assertTrue(localConnection.isClosed());
84-
Assert.assertThrows(SQLException.class, localConnection::createStatement);
85-
Assert.assertThrows(SQLException.class, () -> localConnection.prepareStatement("SELECT 1"));
83+
assertThrows(SQLException.class, localConnection::createStatement);
84+
assertThrows(SQLException.class, () -> localConnection.prepareStatement("SELECT 1"));
8685
}
8786

8887
@Test(groups = { "integration" })
@@ -97,7 +96,7 @@ public void getMetaDataTest() throws SQLException {
9796
public void setReadOnlyTest() throws SQLException {
9897
Connection localConnection = this.getJdbcConnection();
9998
localConnection.setReadOnly(false);
100-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setReadOnly(true));
99+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setReadOnly(true));
101100
}
102101

103102
@Test(groups = { "integration" })
@@ -118,10 +117,10 @@ public void setTransactionIsolationTest() throws SQLException {
118117
Connection localConnection = this.getJdbcConnection();
119118
localConnection.setTransactionIsolation(Connection.TRANSACTION_NONE);
120119
Assert.assertEquals(localConnection.getTransactionIsolation(), Connection.TRANSACTION_NONE);
121-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED));
122-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED));
123-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ));
124-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE));
120+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED));
121+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED));
122+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ));
123+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE));
125124
}
126125

127126
@Test(groups = { "integration" })
@@ -146,13 +145,13 @@ public void clearWarningsTest() throws SQLException {
146145
@Test(groups = { "integration" })
147146
public void getTypeMapTest() throws SQLException {
148147
Connection localConnection = this.getJdbcConnection();
149-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.getTypeMap());
148+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.getTypeMap());
150149
}
151150

152151
@Test(groups = { "integration" })
153152
public void setTypeMapTest() throws SQLException {
154153
Connection localConnection = this.getJdbcConnection();
155-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setTypeMap(null));
154+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setTypeMap(null));
156155
}
157156

158157
@Test(groups = { "integration" })
@@ -170,44 +169,44 @@ public void getHoldabilityTest() throws SQLException {
170169
@Test(groups = { "integration" })
171170
public void setSavepointTest() throws SQLException {
172171
Connection localConnection = this.getJdbcConnection();
173-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setSavepoint());
174-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setSavepoint("savepoint-name"));
172+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setSavepoint());
173+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setSavepoint("savepoint-name"));
175174
}
176175

177176
@Test(groups = { "integration" })
178177
public void releaseSavepointTest() throws SQLException {
179178
Connection localConnection = this.getJdbcConnection();
180-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.releaseSavepoint(null));
179+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.releaseSavepoint(null));
181180
}
182181

183182
@Test(groups = { "integration" })
184183
public void createClobTest() throws SQLException {
185184
Connection localConnection = this.getJdbcConnection();
186-
Assert.assertThrows(SQLFeatureNotSupportedException.class, localConnection::createClob);
185+
assertThrows(SQLFeatureNotSupportedException.class, localConnection::createClob);
187186
}
188187

189188
@Test(groups = { "integration" })
190189
public void createBlobTest() throws SQLException {
191190
Connection localConnection = this.getJdbcConnection();
192-
Assert.assertThrows(SQLFeatureNotSupportedException.class, localConnection::createBlob);
191+
assertThrows(SQLFeatureNotSupportedException.class, localConnection::createBlob);
193192
}
194193

195194
@Test(groups = { "integration" })
196195
public void createNClobTest() throws SQLException {
197196
Connection localConnection = this.getJdbcConnection();
198-
Assert.assertThrows(SQLFeatureNotSupportedException.class, localConnection::createNClob);
197+
assertThrows(SQLFeatureNotSupportedException.class, localConnection::createNClob);
199198
}
200199

201200
@Test(groups = { "integration" })
202201
public void createSQLXMLTest() throws SQLException {
203202
Connection localConnection = this.getJdbcConnection();
204-
Assert.assertThrows(SQLFeatureNotSupportedException.class, localConnection::createSQLXML);
203+
assertThrows(SQLFeatureNotSupportedException.class, localConnection::createSQLXML);
205204
}
206205

207206
@Test(groups = { "integration" })
208207
public void isValidTest() throws SQLException {
209208
Connection localConnection = this.getJdbcConnection();
210-
Assert.assertThrows(SQLException.class, () -> localConnection.isValid(-1));
209+
assertThrows(SQLException.class, () -> localConnection.isValid(-1));
211210
Assert.assertTrue(localConnection.isValid(0));
212211
}
213212

@@ -232,7 +231,7 @@ public void createArrayOfTest() throws SQLException {
232231
@Test(groups = { "integration" })
233232
public void createStructTest() throws SQLException {
234233
Connection localConnection = this.getJdbcConnection();
235-
Assert.assertNull(localConnection.createStruct("type-name", new Object[] { 1, 2, 3 }));
234+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.createStruct("type-name", new Object[] { 1, 2, 3 }));
236235
}
237236

238237
@Test(groups = { "integration" })
@@ -245,19 +244,19 @@ public void setSchemaTest() throws SQLException {
245244
@Test(groups = { "integration" })
246245
public void abortTest() throws SQLException {
247246
Connection localConnection = this.getJdbcConnection();
248-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.abort(null));
247+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.abort(null));
249248
}
250249

251250
@Test(groups = { "integration" })
252251
public void setNetworkTimeoutTest() throws SQLException {
253252
Connection localConnection = this.getJdbcConnection();
254-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setNetworkTimeout(null, 0));
253+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setNetworkTimeout(null, 0));
255254
}
256255

257256
@Test(groups = { "integration" })
258257
public void getNetworkTimeoutTest() throws SQLException {
259258
Connection localConnection = this.getJdbcConnection();
260-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.getNetworkTimeout());
259+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.getNetworkTimeout());
261260
}
262261

263262
@Test(groups = { "integration" })
@@ -275,14 +274,14 @@ public void endRequestTest() throws SQLException {
275274
@Test(groups = { "integration" })
276275
public void setShardingKeyIfValidTest() throws SQLException {
277276
Connection localConnection = this.getJdbcConnection();
278-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setShardingKeyIfValid(null, 0));
279-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setShardingKeyIfValid(null, null, 0));
277+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setShardingKeyIfValid(null, 0));
278+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setShardingKeyIfValid(null, null, 0));
280279
}
281280

282281
@Test(groups = { "integration" })
283282
public void setShardingKeyTest() throws SQLException {
284283
Connection localConnection = this.getJdbcConnection();
285-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setShardingKey(null));
286-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setShardingKey(null, null));
284+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setShardingKey(null));
285+
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setShardingKey(null, null));
287286
}
288287
}

0 commit comments

Comments
 (0)