Skip to content

Commit 48092d8

Browse files
author
Paultagoras
committed
Fixing older (unimplemented) tests
1 parent 260502d commit 48092d8

File tree

3 files changed

+20
-21
lines changed

3 files changed

+20
-21
lines changed

jdbc-v2/src/main/java/com/clickhouse/jdbc/ConnectionImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,8 @@ public void setClientInfo(Properties properties) throws SQLClientInfoException {
393393
@Override
394394
public String getClientInfo(String name) throws SQLException {
395395
checkOpen();
396-
return String.valueOf(this.defaultQuerySettings.getAllSettings().get(name));
396+
Object value = this.defaultQuerySettings.getAllSettings().get(name);
397+
return value == null ? null : String.valueOf(value);
397398
}
398399

399400
@Override

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

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ public void getMetaDataTest() throws SQLException {
9090
@Test
9191
public void setReadOnlyTest() throws SQLException {
9292
Connection localConnection = this.getJdbcConnection();
93-
localConnection.setReadOnly(true);
94-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setReadOnly(false));
93+
localConnection.setReadOnly(false);
94+
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setReadOnly(true));
9595
}
9696

9797
@Test
@@ -177,25 +177,25 @@ public void releaseSavepointTest() throws SQLException {
177177
@Test
178178
public void createClobTest() throws SQLException {
179179
Connection localConnection = this.getJdbcConnection();
180-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.createClob());
180+
Assert.assertNotNull(localConnection.createClob());
181181
}
182182

183183
@Test
184184
public void createBlobTest() throws SQLException {
185185
Connection localConnection = this.getJdbcConnection();
186-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.createBlob());
186+
Assert.assertNotNull(localConnection.createBlob());
187187
}
188188

189189
@Test
190190
public void createNClobTest() throws SQLException {
191191
Connection localConnection = this.getJdbcConnection();
192-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.createNClob());
192+
Assert.assertNotNull(localConnection.createNClob());
193193
}
194194

195195
@Test
196196
public void createSQLXMLTest() throws SQLException {
197197
Connection localConnection = this.getJdbcConnection();
198-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.createSQLXML());
198+
Assert.assertThrows(SQLFeatureNotSupportedException.class, localConnection::createSQLXML);
199199
}
200200

201201
@Test
@@ -206,23 +206,20 @@ public void isValidTest() throws SQLException {
206206
}
207207

208208
@Test
209-
public void setClientInfoTest() throws SQLException {
210-
Connection localConnection = this.getJdbcConnection();
211-
Assert.assertThrows(SQLClientInfoException.class, () -> localConnection.setClientInfo("key", "value"));
212-
Assert.assertThrows(SQLClientInfoException.class, () -> localConnection.setClientInfo(new Properties()));
213-
}
214-
215-
@Test
216-
public void getClientInfoTest() throws SQLException {
209+
public void setAndGetClientInfoTest() throws SQLException {
217210
Connection localConnection = this.getJdbcConnection();
218211
Assert.assertNull(localConnection.getClientInfo("key"));
219-
Assert.assertNotNull(localConnection.getClientInfo());
212+
localConnection.setClientInfo("key", "value");
213+
Assert.assertNotNull(localConnection.getClientInfo("key"));
220214
}
221215

216+
222217
@Test
223218
public void createArrayOfTest() throws SQLException {
224219
Connection localConnection = this.getJdbcConnection();
225-
Assert.assertNull(localConnection.createArrayOf("type-name", new Object[] { 1, 2, 3 }));
220+
Array array = localConnection.createArrayOf("type-name", new Object[] { 1, 2, 3 });
221+
Assert.assertNotNull(array);
222+
Assert.assertEquals(array.getArray(), new Object[] { 1, 2, 3 });
226223
}
227224

228225
@Test

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.sql.SQLFeatureNotSupportedException;
66
import java.util.Properties;
77

8+
import static org.testng.Assert.assertNull;
89
import static org.testng.Assert.assertThrows;
910
import static org.testng.Assert.assertNotNull;
1011

@@ -46,13 +47,13 @@ public void testGetConnectionWithUserAndPassword() throws SQLException {
4647
}
4748

4849
@Test
49-
public void testGetLogWriter() {
50-
assertThrows(SQLFeatureNotSupportedException.class, () -> dataSource.getLogWriter());
50+
public void testGetLogWriter() throws SQLException {
51+
assertNull(dataSource.getLogWriter());
5152
}
5253

5354
@Test
54-
public void testSetLogWriter() {
55-
assertThrows(SQLFeatureNotSupportedException.class, () -> dataSource.setLogWriter(null));
55+
public void testSetLogWriter() throws SQLException {
56+
dataSource.setLogWriter(null);
5657
}
5758

5859
@Test

0 commit comments

Comments
 (0)