11package com .clickhouse .jdbc .internal ;
22
3+ import com .clickhouse .client .api .Client ;
34import com .clickhouse .client .api .ClientConfigProperties ;
5+
46import org .testng .Assert ;
57import org .testng .annotations .DataProvider ;
68import org .testng .annotations .Test ;
@@ -23,15 +25,17 @@ public class JdbcConfigurationTest {
2325 new JdbcConfigurationTestData ("jdbc:clickhouse://localhost" ),
2426 new JdbcConfigurationTestData ("jdbc:clickhouse:http://localhost" ),
2527 new JdbcConfigurationTestData ("jdbc:clickhouse:https://localhost" )
26- .withExpectedConnectionURL ("https://localhost" ),
28+ .withExpectedConnectionURL ("https://localhost:8443" ),
29+ new JdbcConfigurationTestData ("jdbc:clickhouse:https://localhost:8123" )
30+ .withExpectedConnectionURL ("https://localhost:8123" ),
2731 new JdbcConfigurationTestData ("jdbc:clickhouse://localhost" )
2832 .withAdditionalConnectionParameters (
2933 Map .of (JdbcConfiguration .USE_SSL_PROP , "true" ))
30- .withExpectedConnectionURL ("https://localhost" )
34+ .withExpectedConnectionURL ("https://localhost:8443 " )
3135 .withAdditionalExpectedClientProperties (
3236 Map .of ("ssl" , "true" )),
3337 new JdbcConfigurationTestData ("jdbc:clickhouse://[::1]" )
34- .withExpectedConnectionURL ("http://[::1]" ),
38+ .withExpectedConnectionURL ("http://[::1]:8123 " ),
3539 new JdbcConfigurationTestData ("jdbc:clickhouse://[::1]:8123" )
3640 .withExpectedConnectionURL ("http://[::1]:8123" ),
3741 new JdbcConfigurationTestData ("jdbc:clickhouse://localhost:8443" )
@@ -111,14 +115,22 @@ public class JdbcConfigurationTest {
111115 ))
112116 };
113117
118+ @ SuppressWarnings ("deprecation" )
114119 @ Test (dataProvider = "validURLTestData" )
115120 public void testParseURLValid (String jdbcURL , Properties properties ,
116- String connectionUrl , Map <String , String > expectedClientProps )
121+ String connectionURL , Map <String , String > expectedClientProps )
117122 throws Exception
118123 {
119124 JdbcConfiguration configuration = new JdbcConfiguration (jdbcURL , properties );
120- assertEquals (configuration .getConnectionUrl (), connectionUrl );
125+ assertEquals (configuration .getConnectionUrl (), connectionURL );
121126 assertEquals (configuration .clientProperties , expectedClientProps );
127+ Client .Builder bob = new Client .Builder ();
128+ configuration .applyClientProperties (bob );
129+ Client client = bob .build ();
130+ assertEquals (client .getEndpoints ().size (), 1 );
131+ assertEquals (
132+ client .getEndpoints ().iterator ().next (),
133+ connectionURL );
122134 }
123135
124136 @ Test (dataProvider = "invalidURLs" )
@@ -198,6 +210,9 @@ public Object[][] createInvalidConnectionURLs() {
198210 { "jdbc:clickhouse://foo.bar?x&y=z" },
199211 { "jdbc:clickhouse://foo.bar?x==&y=z" },
200212 { "jdbc:clickhouse://localhost?☺=value1" },
213+ // multiple endpoints are invalid
214+ { "jdbc:clickhouse://foo,bar" },
215+ { "jdbc:clickhouse://foo,bar.com:8123" },
201216 };
202217 }
203218
@@ -210,7 +225,7 @@ private static final class JdbcConfigurationTestData {
210225 Map .of ( "user" , "default" , "password" , "" );
211226
212227 private static final String DEFAULT_EXPECTED_CONNECTION_URL =
213- "http://localhost" ;
228+ "http://localhost:8123 " ;
214229
215230 private final String url ;
216231 private final Properties connectionParameters ;
0 commit comments