1
1
package com .clickhouse .jdbc .internal ;
2
2
3
+ import com .clickhouse .client .api .Client ;
3
4
import com .clickhouse .client .api .ClientConfigProperties ;
5
+
4
6
import org .testng .Assert ;
5
7
import org .testng .annotations .DataProvider ;
6
8
import org .testng .annotations .Test ;
@@ -23,15 +25,17 @@ public class JdbcConfigurationTest {
23
25
new JdbcConfigurationTestData ("jdbc:clickhouse://localhost" ),
24
26
new JdbcConfigurationTestData ("jdbc:clickhouse:http://localhost" ),
25
27
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" ),
27
31
new JdbcConfigurationTestData ("jdbc:clickhouse://localhost" )
28
32
.withAdditionalConnectionParameters (
29
33
Map .of (JdbcConfiguration .USE_SSL_PROP , "true" ))
30
- .withExpectedConnectionURL ("https://localhost" )
34
+ .withExpectedConnectionURL ("https://localhost:8443 " )
31
35
.withAdditionalExpectedClientProperties (
32
36
Map .of ("ssl" , "true" )),
33
37
new JdbcConfigurationTestData ("jdbc:clickhouse://[::1]" )
34
- .withExpectedConnectionURL ("http://[::1]" ),
38
+ .withExpectedConnectionURL ("http://[::1]:8123 " ),
35
39
new JdbcConfigurationTestData ("jdbc:clickhouse://[::1]:8123" )
36
40
.withExpectedConnectionURL ("http://[::1]:8123" ),
37
41
new JdbcConfigurationTestData ("jdbc:clickhouse://localhost:8443" )
@@ -111,14 +115,22 @@ public class JdbcConfigurationTest {
111
115
))
112
116
};
113
117
118
+ @ SuppressWarnings ("deprecation" )
114
119
@ Test (dataProvider = "validURLTestData" )
115
120
public void testParseURLValid (String jdbcURL , Properties properties ,
116
- String connectionUrl , Map <String , String > expectedClientProps )
121
+ String connectionURL , Map <String , String > expectedClientProps )
117
122
throws Exception
118
123
{
119
124
JdbcConfiguration configuration = new JdbcConfiguration (jdbcURL , properties );
120
- assertEquals (configuration .getConnectionUrl (), connectionUrl );
125
+ assertEquals (configuration .getConnectionUrl (), connectionURL );
121
126
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 );
122
134
}
123
135
124
136
@ Test (dataProvider = "invalidURLs" )
@@ -198,6 +210,9 @@ public Object[][] createInvalidConnectionURLs() {
198
210
{ "jdbc:clickhouse://foo.bar?x&y=z" },
199
211
{ "jdbc:clickhouse://foo.bar?x==&y=z" },
200
212
{ "jdbc:clickhouse://localhost?☺=value1" },
213
+ // multiple endpoints are invalid
214
+ { "jdbc:clickhouse://foo,bar" },
215
+ { "jdbc:clickhouse://foo,bar.com:8123" },
201
216
};
202
217
}
203
218
@@ -210,7 +225,7 @@ private static final class JdbcConfigurationTestData {
210
225
Map .of ( "user" , "default" , "password" , "" );
211
226
212
227
private static final String DEFAULT_EXPECTED_CONNECTION_URL =
213
- "http://localhost" ;
228
+ "http://localhost:8123 " ;
214
229
215
230
private final String url ;
216
231
private final Properties connectionParameters ;
0 commit comments