Skip to content

Commit 2714c11

Browse files
committed
fix tests
1 parent 6cb5cc6 commit 2714c11

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.clickhouse.jdbc;
22

33
import com.clickhouse.client.api.Client;
4+
import com.clickhouse.client.api.ClientConfigProperties;
45
import com.clickhouse.client.api.query.GenericRecord;
56
import com.clickhouse.client.api.query.QuerySettings;
67
import com.clickhouse.jdbc.internal.ClientInfoProperties;
@@ -384,18 +385,19 @@ public void setClientInfo(Properties properties) throws SQLClientInfoException {
384385
@Override
385386
public String getClientInfo(String name) throws SQLException {
386387
checkOpen();
387-
// Object value = this.defaultQuerySettings.getAllSettings().get(name);
388-
// return value == null ? null : String.valueOf(value);
389-
throw new SQLFeatureNotSupportedException("getClientInfo not supported");
388+
if (ClientInfoProperties.APPLICATION_NAME.getKey().equals(name)) {
389+
return client.getConfiguration().get(ClientConfigProperties.CLIENT_NAME.getKey());
390+
} else {
391+
return null;
392+
}
390393
}
391394

392395
@Override
393396
public Properties getClientInfo() throws SQLException {
394397
checkOpen();
395-
// Properties clientInfo = new Properties();
396-
// clientInfo.putAll(this.defaultQuerySettings.getAllSettings());
397-
// return clientInfo;
398-
throw new SQLFeatureNotSupportedException("getClientInfo not supported");
398+
Properties clientInfo = new Properties();
399+
clientInfo.put(ClientInfoProperties.APPLICATION_NAME.getKey(), getClientInfo(ClientInfoProperties.APPLICATION_NAME.getKey()));
400+
return clientInfo;
399401
}
400402

401403
@Override

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import java.sql.*;
44
import java.util.Properties;
55

6+
import com.clickhouse.client.api.ClientConfigProperties;
7+
import com.clickhouse.jdbc.internal.ClientInfoProperties;
68
import org.testng.Assert;
79
import org.testng.annotations.Test;
810

@@ -108,7 +110,7 @@ public void isReadOnlyTest() throws SQLException {
108110
public void setCatalogTest() throws SQLException {
109111
Connection localConnection = this.getJdbcConnection();
110112
localConnection.setCatalog("catalog-name");
111-
Assert.assertEquals(localConnection.getCatalog(), "catalog-name");
113+
Assert.assertNull(localConnection.getCatalog());
112114
}
113115

114116
@Test(groups = { "integration" })
@@ -212,10 +214,10 @@ public void isValidTest() throws SQLException {
212214
@Test(groups = { "integration" })
213215
public void setAndGetClientInfoTest() throws SQLException {
214216
Connection localConnection = this.getJdbcConnection();
215-
Assert.assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.getClientInfo("name"));
216-
Assert.assertThrows(SQLFeatureNotSupportedException.class, localConnection::getClientInfo);
217-
Assert.assertThrows(SQLClientInfoException.class, () -> localConnection.setClientInfo("name", "value"));
218-
Assert.assertThrows(SQLClientInfoException.class, () -> localConnection.setClientInfo(new Properties()));
217+
localConnection.setClientInfo("custom-property", "client-name");
218+
Assert.assertNull(localConnection.getClientInfo("custom-property"));
219+
localConnection.setClientInfo(ClientInfoProperties.APPLICATION_NAME.getKey(), "client-name");
220+
Assert.assertEquals(localConnection.getClientInfo(ClientInfoProperties.APPLICATION_NAME.getKey()), "client-name");
219221
}
220222

221223

0 commit comments

Comments
 (0)