Skip to content

Commit 19946ce

Browse files
authored
Adding issue #2245 test (#2296)
* Adding issue #2245 test * Adding to readVersionFromResource the ability to load from a different classloader for those cases when the thread is running in a different classloader
1 parent 5758ec5 commit 19946ce

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

clickhouse-client/src/main/java/com/clickhouse/client/config/ClickHouseClientOption.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,17 @@ public static String readVersionFromResource(String resourceFilePath) {
532532
tmpVersion = tmp;
533533
}
534534
} catch (Exception e) {
535-
// ignore
535+
try(InputStream in = ClickHouseClientOption.class.getClassLoader().getResourceAsStream(resourceFilePath)) {
536+
Properties p = new Properties();
537+
p.load(in);
538+
539+
String tmp = p.getProperty("version");
540+
if (tmp != null && !tmp.isEmpty() && !tmp.equals("${revision}")) {
541+
tmpVersion = tmp;
542+
}
543+
} catch (Exception ee) {
544+
// ignore
545+
}
536546
}
537547
return tmpVersion;
538548
}

jdbc-v2/src/test/java/com/clickhouse/jdbc/metadata/DatabaseMetaDataTest.java

+10-5
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@
2424
import java.util.Properties;
2525
import java.util.Set;
2626

27-
import static org.testng.Assert.assertEquals;
28-
import static org.testng.Assert.assertFalse;
29-
import static org.testng.Assert.assertNull;
30-
import static org.testng.Assert.assertTrue;
31-
27+
import static org.testng.Assert.*;
3228

3329

3430
public class DatabaseMetaDataTest extends JdbcIntegrationTest {
@@ -315,4 +311,13 @@ public void testGetClientInfoProperties() throws Exception {
315311
}
316312
}
317313
}
314+
315+
@Test(groups = { "integration" })
316+
public void testGetDriverVersion() throws Exception {
317+
try (Connection conn = getJdbcConnection()) {
318+
DatabaseMetaData dbmd = conn.getMetaData();
319+
String version = dbmd.getDriverVersion();
320+
assertNotEquals(version, "unknown");
321+
}
322+
}
318323
}

0 commit comments

Comments
 (0)