comparison tests/JDBC_API_Tester.java @ 931:df18aa5c8a61

Add test for MonetDriver.getPropertyInfo(url, props). The implementation is moved to Parameter.java which contains the list of connection parameters. It currently only returns the mandatory connection parameters.
author Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
date Thu, 24 Oct 2024 19:10:06 +0200 (5 months ago)
parents ea15f10eaa61
children f16966084980
comparison
equal deleted inserted replaced
930:8611e23d2771 931:df18aa5c8a61
8 * Copyright 2024 MonetDB Foundation; 8 * Copyright 2024 MonetDB Foundation;
9 * Copyright August 2008 - 2023 MonetDB B.V.; 9 * Copyright August 2008 - 2023 MonetDB B.V.;
10 * Copyright 1997 - July 2008 CWI. 10 * Copyright 1997 - July 2008 CWI.
11 */ 11 */
12 12
13 import java.sql.*;
14
15 import java.io.StringReader; 13 import java.io.StringReader;
16 import java.math.BigDecimal; 14 import java.math.BigDecimal;
17 import java.math.BigInteger; 15 import java.math.BigInteger;
18 import java.nio.charset.StandardCharsets; 16 import java.nio.charset.StandardCharsets;
19 import java.sql.Date; 17 import java.sql.*;
20 import java.text.SimpleDateFormat; 18 import java.text.SimpleDateFormat;
21 import java.util.*; 19 import java.util.*;
22 20
23 import org.monetdb.jdbc.MonetConnection; 21 import org.monetdb.jdbc.MonetConnection;
24 import org.monetdb.jdbc.types.INET; 22 import org.monetdb.jdbc.types.INET;
91 jt.Test_Clargequery(); 89 jt.Test_Clargequery();
92 jt.Test_Cmanycon(con_URL); 90 jt.Test_Cmanycon(con_URL);
93 jt.Test_Creplysize(); 91 jt.Test_Creplysize();
94 jt.Test_Csavepoints(); 92 jt.Test_Csavepoints();
95 jt.Test_Ctransaction(); 93 jt.Test_Ctransaction();
94 jt.Test_Driver(con_URL);
96 jt.Test_Dobjects(); 95 jt.Test_Dobjects();
97 jt.Test_DBCmetadata(); 96 jt.Test_DBCmetadata();
98 jt.Test_EmptySql(); 97 jt.Test_EmptySql();
99 jt.Test_FetchSize(); 98 jt.Test_FetchSize();
100 jt.Test_Int128(); 99 jt.Test_Int128();
728 "10. start transaction...passed\n" + 727 "10. start transaction...passed\n" +
729 "11. rollback...passed\n" + 728 "11. rollback...passed\n" +
730 "12. true true\n" + 729 "12. true true\n" +
731 "13. commit...failed as expected: COMMIT: not allowed in auto commit mode\n"); 730 "13. commit...failed as expected: COMMIT: not allowed in auto commit mode\n");
732 } 731 }
732
733 private void Test_Driver(String con_URL) {
734 sb.setLength(0); // clear the output log buffer
735
736 try {
737 final Driver driver = DriverManager.getDriver(con_URL);
738 DriverPropertyInfo[] props = driver.getPropertyInfo(con_URL, null);
739 DriverPropertyInfo prop;
740 final String space = " ";
741 for (int i = 0; i < props.length; i++) {
742 prop = props[i];
743 sb.append(i).append(space);
744 sb.append(prop.name).append(space);
745 sb.append(prop.required).append(space);
746 sb.append(prop.value).append(space);
747 sb.append(prop.description).append("\n");
748 }
749 // also test against monetdbs, this should make tls and cert required.
750 props = driver.getPropertyInfo("jdbc:monetdbs:", null);
751 sb.append("getPropertyInfo of jdbc:monetdbs:").append("\n");
752 for (int i = 0; i < props.length; i++) {
753 prop = props[i];
754 sb.append(i).append(space);
755 sb.append(prop.name).append(space);
756 sb.append(prop.required).append(space);
757 sb.append(prop.value).append(space);
758 sb.append(prop.description).append("\n");
759 }
760 } catch (SQLException e) {
761 // this means we get what we expect
762 sb.append("failed to get Driver class: ").append(e.getMessage());
763 sb.append("\n");
764 }
765
766 compareExpectedOutput("Test_Driver",
767 "0 user true null User loginname to use when authenticating on the database server\n" +
768 "1 password true null Password to use when authenticating on the database server\n" +
769 "getPropertyInfo of jdbc:monetdbs:\n" +
770 "0 user true null User loginname to use when authenticating on the database server\n" +
771 "1 password true null Password to use when authenticating on the database server\n" +
772 "2 tls true null secure the connection using TLS\n" +
773 "3 cert true null path to TLS certificate to authenticate server with\n");
774 }
775
733 776
734 private void handleExecuteDDL(Statement stmt, String action, String objtype, String objname, String sql) { 777 private void handleExecuteDDL(Statement stmt, String action, String objtype, String objname, String sql) {
735 try { 778 try {
736 int response = stmt.executeUpdate(sql); 779 int response = stmt.executeUpdate(sql);
737 if (response != Statement.SUCCESS_NO_INFO) 780 if (response != Statement.SUCCESS_NO_INFO)