1111
1212import tech .ydb .jdbc .connection .YdbConnectionImpl ;
1313import tech .ydb .jdbc .connection .YdbContext ;
14+ import tech .ydb .jdbc .impl .helper .JdbcUrlHelper ;
1415import tech .ydb .test .junit5 .YdbHelperExtension ;
1516
1617/**
@@ -21,27 +22,11 @@ public class YdbDriverIntegrationTest {
2122 @ RegisterExtension
2223 private static final YdbHelperExtension ydb = new YdbHelperExtension ();
2324
24- private static String jdbcURL (String ... extras ) {
25- StringBuilder jdbc = new StringBuilder ("jdbc:ydb:" )
26- .append (ydb .useTls () ? "grpcs://" : "grpc://" )
27- .append (ydb .endpoint ())
28- .append (ydb .database ())
29- .append ("?" );
30-
31- if (ydb .authToken () != null ) {
32- jdbc .append ("token=" ).append (ydb .authToken ()).append ("&" );
33- }
34-
35- for (String extra : extras ) {
36- jdbc .append (extra ).append ("=" ).append (extra ).append ("&" );
37- }
38-
39- return jdbc .toString ();
40- }
25+ private static final JdbcUrlHelper jdbcURL = new JdbcUrlHelper (ydb );
4126
4227 @ Test
4328 public void connect () throws SQLException {
44- try (Connection connection = DriverManager .getConnection (jdbcURL ())) {
29+ try (Connection connection = DriverManager .getConnection (jdbcURL . build ())) {
4530 Assertions .assertTrue (connection instanceof YdbConnectionImpl );
4631
4732 YdbConnection unwrapped = connection .unwrap (YdbConnection .class );
@@ -54,7 +39,7 @@ public void connect() throws SQLException {
5439 @ Test
5540 public void testContextCache () throws SQLException {
5641 YdbContext ctx ;
57- try (Connection conn1 = DriverManager .getConnection (jdbcURL ())) {
42+ try (Connection conn1 = DriverManager .getConnection (jdbcURL . build ())) {
5843 Assertions .assertTrue (conn1 .isValid (5000 ));
5944
6045 YdbConnection unwrapped = conn1 .unwrap (YdbConnection .class );
@@ -63,7 +48,7 @@ public void testContextCache() throws SQLException {
6348 ctx = unwrapped .getCtx ();
6449 }
6550
66- try (Connection conn2 = DriverManager .getConnection (jdbcURL ())) {
51+ try (Connection conn2 = DriverManager .getConnection (jdbcURL . build ())) {
6752 Assertions .assertTrue (conn2 .isValid (5000 ));
6853
6954 YdbConnection unwrapped = conn2 .unwrap (YdbConnection .class );
@@ -72,7 +57,7 @@ public void testContextCache() throws SQLException {
7257 }
7358
7459 Properties props = new Properties ();
75- try (Connection conn3 = DriverManager .getConnection (jdbcURL (), props )) {
60+ try (Connection conn3 = DriverManager .getConnection (jdbcURL . build (), props )) {
7661 Assertions .assertTrue (conn3 .isValid (5000 ));
7762
7863 YdbConnection unwrapped = conn3 .unwrap (YdbConnection .class );
@@ -81,15 +66,15 @@ public void testContextCache() throws SQLException {
8166 }
8267
8368 props .setProperty ("TEST_KEY" , "TEST_VALUE" );
84- try (Connection conn4 = DriverManager .getConnection (jdbcURL (), props )) {
69+ try (Connection conn4 = DriverManager .getConnection (jdbcURL . build (), props )) {
8570 Assertions .assertTrue (conn4 .isValid (5000 ));
8671
8772 YdbConnection unwrapped = conn4 .unwrap (YdbConnection .class );
8873 Assertions .assertNotNull (unwrapped .getCtx ());
8974 Assertions .assertNotSame (ctx , unwrapped .getCtx ());
9075 }
9176
92- try (Connection conn5 = DriverManager .getConnection (jdbcURL ("test" ))) {
77+ try (Connection conn5 = DriverManager .getConnection (jdbcURL . withArg ("test" , "false" ). build ( ))) {
9378 Assertions .assertTrue (conn5 .isValid (5000 ));
9479
9580 YdbConnection unwrapped = conn5 .unwrap (YdbConnection .class );
@@ -102,7 +87,7 @@ public void testContextCache() throws SQLException {
10287 YdbDriver .register ();
10388 }
10489
105- try (Connection conn6 = DriverManager .getConnection (jdbcURL ())) {
90+ try (Connection conn6 = DriverManager .getConnection (jdbcURL . build ())) {
10691 Assertions .assertTrue (conn6 .isValid (5000 ));
10792
10893 YdbConnection unwrapped = conn6 .unwrap (YdbConnection .class );
0 commit comments