1616 */
1717package com .dbeaver .jdbc .upd .driver .test ;
1818
19+ import com .dbeaver .jdbc .driver .libsql .LibSqlConnection ;
20+ import com .dbeaver .jdbc .driver .libsql .LibSqlDriver ;
21+
1922import java .sql .*;
23+ import java .util .Collections ;
24+ import java .util .Hashtable ;
25+ import java .util .Properties ;
2026
2127public class LibSqlDriverTest {
2228 /**
@@ -25,11 +31,33 @@ public class LibSqlDriverTest {
2531 * @param args mvn exec:java "-Dexec.args=database-url [token]"
2632 */
2733 public static void main (String [] args ) throws Exception {
34+ // String databaseUrl = args[0];
35+ // String token = args.length > 1 ? args[1] : null;
36+ // runBasicQuery(databaseUrl, token);
37+
38+ var driver = new LibSqlDriver ();
39+ assertConnectionUrl (driver ,
40+ "jdbc:dbeaver:libsql:localhost" ,
41+ "https://localhost"
42+ );
43+ // assertConnectionUrl(driver,
44+ // "jdbc:dbeaver:libsql:localhost:8080",
45+ // "https://localhost:8080"
46+ // );
47+ // assertConnectionUrl(driver,
48+ // "jdbc:dbeaver:libsql:http://localhost:8080",
49+ // "http://localhost:8080"
50+ // );
51+ // assertConnectionUrl(driver,
52+ // "jdbc:dbeaver:libsql:http://localhost:8080",
53+ // "http://localhost:8080"
54+ // );
55+ }
56+
57+ private static void runBasicQuery (String databaseUrl , String token ) throws Exception {
2858 long startTime = System .currentTimeMillis ();
2959
3060 try {
31- String databaseUrl = args [0 ];
32- String token = args .length > 1 ? args [1 ] : null ;
3361 try (Connection connection = DriverManager .getConnection ("jdbc:dbeaver:libsql:" + databaseUrl , null , token )) {
3462 DatabaseMetaData metaData = connection .getMetaData ();
3563 System .out .println ("Driver: " + metaData .getDriverName ());
@@ -84,4 +112,11 @@ private static void printResultSet(ResultSet dbResults) throws SQLException {
84112 System .out .println ();
85113 }
86114 }
115+
116+ private static void assertConnectionUrl (LibSqlDriver driver , String input , String output ) throws SQLException {
117+ Connection connection = driver .connect (input , new Properties ());
118+ assert connection instanceof LibSqlConnection ;
119+ LibSqlConnection libSqlConnection = (LibSqlConnection ) connection ;
120+ assert libSqlConnection .getUrl ().equals (output );
121+ }
87122}
0 commit comments