Changeset: 796957385008 for monetdb-java
URL: https://dev.monetdb.org/hg/monetdb-java/rev/796957385008
Modified Files:
pom.xml
src/test/java/JDBC_API_Tester.java
Branch: mvn
Log Message:
Run JDBC_API_Tester from Junit
diffs (truncated from 879 to 300 lines):
diff --git a/pom.xml b/pom.xml
--- a/pom.xml
+++ b/pom.xml
@@ -268,6 +268,22 @@
</configuration>
</plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <!-- set this explicitly because JDBC_API_Tester does not
match the default patterns -->
+ <includes>
+ <include>JDBC_API_Tester.java</include>
+ <include>**/Test*.java</include>
+ <include>**/*Test.java</include>
+ <include>**/*Tests.java</include>
+ <include>**/*TestCase.java</include>
+ </includes>
+ <!-- skip the slow tests by default -->
+ <groups>!slow</groups>
+ </configuration>
+ </plugin>
+
<!--
Temporarily dropped the following plugins until I've figured
out
how they work and if we still need them
diff --git a/src/test/java/JDBC_API_Tester.java
b/src/test/java/JDBC_API_Tester.java
--- a/src/test/java/JDBC_API_Tester.java
+++ b/src/test/java/JDBC_API_Tester.java
@@ -18,9 +18,12 @@ import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.*;
+import org.junit.jupiter.api.*;
+import org.junit.jupiter.api.condition.EnabledIf;
import org.monetdb.jdbc.MonetConnection;
import org.monetdb.jdbc.types.INET;
import org.monetdb.jdbc.types.URL;
+import org.monetdb.testinfra.Config;
/**
* class to test JDBC Driver API methods and behavior of MonetDB server.
@@ -37,26 +40,32 @@ import org.monetdb.jdbc.types.URL;
* @author Martin van Dinther
* @version 0.3
*/
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+@Tag("api")
public final class JDBC_API_Tester {
- private StringBuilder sb; // buffer to collect the test output
+ // This is where we gather test output which is then verified
+ // in compareExpectedOutput()
+ private StringBuilder sb = new StringBuilder(sbInitLen);
+ private boolean foundDifferences = false;
+
+ // Connection state set in connect()
+ private String jdbcUrl;
private Connection con; // main connection shared by all tests
- final private int dbmsMajorVersion;
- final private int dbmsMinorVersion;
- final private boolean isPostDec2023; // flag to support version
specific output
- private boolean foundDifferences = false;
+ private int dbmsMajorVersion;
+ private int dbmsMinorVersion;
+ private boolean isPostDec2023; // flag to support version specific
output
+ private boolean skipMALoutput = false;
final private static int sbInitLen = 5468; // max needed size of sb
- /**
- * constructor
- * @param con_ an active connection
- * @throws SQLException if a connection or database access error occurs
- */
- JDBC_API_Tester(Connection con_) throws SQLException {
- this.con = con_;
+ JDBC_API_Tester() {
sb = new StringBuilder(sbInitLen);
-
- DatabaseMetaData dbmd = con_.getMetaData();
+ }
+
+ private void connect(String url) throws SQLException {
+ jdbcUrl = url;
+ con = DriverManager.getConnection(jdbcUrl);
+ DatabaseMetaData dbmd = con.getMetaData();
dbmsMajorVersion = dbmd.getDatabaseMajorVersion();
dbmsMinorVersion = dbmd.getDatabaseMinorVersion();
// from version 11.50 on, the MonetDB server returns different
metadata for
@@ -64,6 +73,17 @@ public final class JDBC_API_Tester {
isPostDec2023 = versionIsAtLeast(11, 50);
}
+ @BeforeAll
+ public void openConnection() throws SQLException {
+ String url = Config.getServerURL();
+ connect(url);
+ }
+
+ @AfterAll
+ public void closeConnection() {
+ closeConx(con);
+ }
+
/**
* main function
* @param args args[0] should contain the connectionURL string, args[1]
an optional flag: -skipMALoutput
@@ -76,36 +96,35 @@ public final class JDBC_API_Tester {
}
final String con_URL = args[0];
- final boolean skipMALoutput = (args.length >= 2) ?
args[1].equals("-skipMALoutput") : false;
- // System.err.println("skipMALoutput = " + skipMALoutput);
// Test this before trying to connect
UrlTester.runAllTests();
- final Connection conn = DriverManager.getConnection(con_URL);
- JDBC_API_Tester jt = new JDBC_API_Tester(conn);
+ JDBC_API_Tester jt = new JDBC_API_Tester();
+ jt.connect(con_URL);
+ jt.skipMALoutput = (args.length >= 2) ?
args[1].equals("-skipMALoutput") : false;
// run the tests
- jt.Test_Cautocommit(con_URL);
+ jt.Test_Cautocommit();
jt.Test_CisValid();
jt.Test_Clargequery();
- jt.Test_Cmanycon(con_URL);
+ jt.Test_Cmanycon();
jt.Test_Creplysize();
jt.Test_Csavepoints();
jt.Test_Ctransaction();
- jt.Test_Driver(con_URL);
+ jt.Test_Driver();
jt.Test_Dobjects();
jt.Test_DBCmetadata();
jt.Test_EmptySql();
jt.Test_FetchSize();
jt.Test_Int128();
jt.Test_Interval_Types();
- jt.Test_PlanExplainTraceDebugCmds(skipMALoutput);
+ jt.Test_PlanExplainTraceDebugCmds();
jt.Test_PSgeneratedkeys();
jt.Test_PSgetObject();
jt.Test_PSlargebatchval();
- jt.Test_PSlargeresponse(con_URL);
- jt.Test_PSmanycon(con_URL);
+ jt.Test_PSlargeresponse();
+ jt.Test_PSmanycon();
jt.Test_PSmetadata();
jt.Test_PSsetBytes();
jt.Test_PSsomeamount();
@@ -126,23 +145,23 @@ public final class JDBC_API_Tester {
jt.Test_Smoreresults();
jt.Test_Wrapper();
if (jt.isPostDec2023)
- jt.Test_ClientInfo(con_URL);
+ jt.Test_ClientInfo();
jt.bogus_auto_generated_keys();
- jt.BugConcurrent_clients_SF_1504657(con_URL);
- jt.BugConcurrent_sequences(con_URL);
- jt.Bug_Connect_as_voc_getMetaData_Failure_Bug_6388(con_URL);
+ jt.BugConcurrent_clients_SF_1504657();
+ jt.BugConcurrent_sequences();
+ jt.Bug_Connect_as_voc_getMetaData_Failure_Bug_6388();
jt.BugDatabaseMetaData_Bug_3356();
jt.BugDecimalRound_Bug_3561();
jt.BugExecuteUpdate_Bug_3350();
- jt.Bug_IsValid_Timeout_Bug_6782(con_URL);
- jt.Bug_LargeQueries_6571_6693(con_URL);
+ jt.Bug_IsValid_Timeout_Bug_6782();
+ jt.Bug_LargeQueries_6571_6693();
jt.Bug_PrepStmtManyParams_7337(480);
jt.Bug_PrepStmtSetObject_CLOB_6349();
jt.Bug_PrepStmtSetString_6382();
jt.Bug_PrepStmt_With_Errors_Jira292();
jt.BugResultSetMetaData_Bug_6183();
jt.BugSetQueryTimeout_Bug_3357();
- jt.SQLcopyinto(con_URL);
+ jt.SQLcopyinto();
jt.DecimalPrecisionAndScale();
/* run next long running test (11 minutes) only before a new
release */
@@ -168,7 +187,13 @@ public final class JDBC_API_Tester {
return (dbmsMajorVersion > major || (dbmsMajorVersion == major
&& dbmsMinorVersion >= minor));
}
- private void Test_Cautocommit(String arg0) {
+ // getter is used by the @EnabledIf attribute on Test_ClientInfo
+ public boolean isPostDec2023() {
+ return isPostDec2023;
+ }
+
+ @Test
+ public void Test_Cautocommit() {
sb.setLength(0); // clear the output log buffer
Connection con1 = con;
@@ -177,7 +202,7 @@ public final class JDBC_API_Tester {
Statement stmt2 = null;
ResultSet rs = null;
try {
- con2 = DriverManager.getConnection(arg0);
+ con2 = DriverManager.getConnection(jdbcUrl);
// >> true: auto commit should be on by default
if (con1.getAutoCommit() != true)
@@ -258,7 +283,8 @@ public final class JDBC_API_Tester {
"7. commit...passed :)\n");
}
- private void Test_CisValid() {
+ @Test
+ public void Test_CisValid() {
sb.setLength(0); // clear the output log buffer
Statement stmt = null;
@@ -293,7 +319,8 @@ public final class JDBC_API_Tester {
"Validating connection: con.isValid? true");
}
- private void Test_Clargequery() {
+ @Test
+ public void Test_Clargequery() {
sb.setLength(0); // clear the output log buffer
final String query =
"-- When a query larger than the send buffer is being "
+
@@ -348,7 +375,8 @@ public final class JDBC_API_Tester {
"2. queries processed\n");
}
- private void Test_Cmanycon(String arg0) {
+ @Test
+ public void Test_Cmanycon() {
sb.setLength(0); // clear the output log buffer
final int maxCons = 60; // default max_clients is 64, 2
connections are already open from this program
@@ -359,7 +387,7 @@ public final class JDBC_API_Tester {
sb.append("Establishing Connection ");
for (; i <= maxCons; i++) {
sb.append(i);
- Connection conx =
DriverManager.getConnection(arg0);
+ Connection conx =
DriverManager.getConnection(jdbcUrl);
sb.append(",");
cons.add(conx);
@@ -401,7 +429,8 @@ public final class JDBC_API_Tester {
"51, 52, 53, 54, 55, 56, 57, 58, 59, 60, ");
}
- private void Test_Creplysize() {
+ @Test
+ public void Test_Creplysize() {
sb.setLength(0); // clear the output log buffer
Statement stmt1 = null;
@@ -505,7 +534,8 @@ public final class JDBC_API_Tester {
"10. drop... passed\n");
}
- private void Test_Csavepoints() {
+ @Test
+ public void Test_Csavepoints() {
sb.setLength(0); // clear the output log buffer
Statement stmt = null;
@@ -633,7 +663,8 @@ public final class JDBC_API_Tester {
"10. table 0 items passed");
}
- private void Test_Ctransaction() {
+ @Test
+ public void Test_Ctransaction() {
sb.setLength(0); // clear the output log buffer
try {
@@ -732,11 +763,12 @@ public final class JDBC_API_Tester {
"13. commit...failed as expected: COMMIT: not allowed
in auto commit mode\n");
}
- private void Test_Driver(String con_URL) {
+ @Test
+ public void Test_Driver() {
sb.setLength(0); // clear the output log buffer
try {
- listDriverProperties(con_URL);
+ listDriverProperties(jdbcUrl);
// also test against monetdbs, this should make tls and
cert required.
sb.append("getPropertyInfo of
jdbc:monetdbs:").append("\n");
listDriverProperties("jdbc:monetdbs:");
@@ -815,7 +847,8 @@ public final class JDBC_API_Tester {
}
}
- private void Test_Dobjects() {
+ @Test
+ public void Test_Dobjects() {
sb.setLength(0); // clear the output log buffer
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]