Modified:
branches/branch_5_0/connector-j/build.xml
branches/branch_5_0/connector-j/src/testsuite/simple/MetadataTest.java
branches/branch_5_0/connector-j/src/testsuite/simple/StatementsTest.java
trunk/connector-j/src/testsuite/simple/MetadataTest.java
trunk/connector-j/src/testsuite/simple/StatementsTest.java
Log:
Make some tests more robust (to avoid false positives), and fail build on testsuite
failure if not running multi tests.
Modified: branches/branch_5_0/connector-j/build.xml
===================================================================
--- branches/branch_5_0/connector-j/build.xml 2006-10-05 16:45:25 UTC (rev 5827)
+++ branches/branch_5_0/connector-j/build.xml 2006-10-05 16:51:31 UTC (rev 5828)
@@ -398,7 +398,11 @@
<mkdir dir="${junit.unitregress.results}/report"/>
- <junit printSummary="yes" fork="on" jvm="${com.mysql.jdbc.testsuite.jvm}">
+ <junit printSummary="yes"
+ fork="on"
+ jvm="${com.mysql.jdbc.testsuite.jvm}"
+ errorProperty="tests.failed"
+ failureProperty="tests.failed">
<jvmarg value="-Xmx256m" />
<!-- For java.sql.SavePoint on old JVMs -->
@@ -420,7 +424,7 @@
<formatter type="xml"/>
- <batchtest fork="yes" todir="${junit.unitregress.results}">
+ <batchtest fork="yes" todir="${junit.unitregress.results}" >
<fileset dir="${buildDir}/${fullProdName}">
<include name="**/*Test.java" />
<exclude name="**/perf/*.java"/>
@@ -434,6 +438,18 @@
</fileset>
<report format="frames" todir="${junit.unitregress.results}/report"/>
</junitreport>
+
+ <!-- Don't fail the build if we're doing multi-tests -->
+ <if>
+ <equals arg1="${test.result.prefix}" arg2="" />
+ <then>
+ <fail message="Tests failed. Check logs and/or reports in ${junit.results}."
if="tests.failed"/>
+ </then>
+ <else>
+ <echo message="Not checking test failures because we're doing a multi-test..."
/>
+ </else>
+ </if>
+
</target>
<!-- Runs compliance testsuite against multiple JVMs and server configs -->
@@ -499,7 +515,9 @@
<mkdir dir="${junit.compliance.results}"/>
<mkdir dir="${junit.compliance.results}/report"/>
- <junit printsummary="yes" jvm="${com.mysql.jdbc.testsuite.jvm}">
+ <junit printsummary="yes" jvm="${com.mysql.jdbc.testsuite.jvm}"
+ errorProperty="tests.compliance.failed"
+ failureProperty="tests.compliance.failed">
<jvmarg value="-Xmx256m"/>
<!-- For java.sql.SavePoint on old JVMs -->
@@ -546,6 +564,18 @@
</fileset>
<report format="frames" todir="${junit.compliance.results}/report"/>
</junitreport>
+
+ <!-- Don't fail the build if we're doing multi-tests -->
+ <if>
+ <equals arg1="${test.result.prefix}" arg2="" />
+ <then>
+ <fail message="Tests failed. Check logs and/or reports in
${junit.compliance.results}." if="tests.compliance.failed"/>
+ </then>
+ <else>
+ <echo message="Not checking test failures because we're doing a multi-test..."
/>
+ </else>
+ </if>
+
</target>
Modified: branches/branch_5_0/connector-j/src/testsuite/simple/MetadataTest.java
===================================================================
--- branches/branch_5_0/connector-j/src/testsuite/simple/MetadataTest.java 2006-10-05
16:45:25 UTC (rev 5827)
+++ branches/branch_5_0/connector-j/src/testsuite/simple/MetadataTest.java 2006-10-05
16:51:31 UTC (rev 5828)
@@ -643,6 +643,8 @@
Statement stmt1 = null;
String userHostQuoted = null;
+ boolean grantFailed = true;
+
try {
conn1 = getConnectionWithProps(props);
stmt1 = conn1.createStatement();
@@ -656,26 +658,36 @@
try {
stmt1.executeUpdate("GRANT update (c1) on t1 to " + userHostQuoted);
+
+ grantFailed = false;
+
} catch (SQLException sqlEx) {
logDebug("This testcase needs to be run with a URL that allows the user
to issue GRANTs "
+ " in the current database. You can skip this test by setting the
system property \""
+ dontRunPropertyName + "\".");
- throw sqlEx;
+ grantFailed = true;
}
- DatabaseMetaData metaData = conn1.getMetaData();
- this.rs = metaData.getColumnPrivileges(null, null, "t1", null);
- this.rs.next();
- assertEquals("t1", this.rs.getString("TABLE_NAME"));
- assertEquals("c1", this.rs.getString("COLUMN_NAME"));
- assertEquals(userHostQuoted, this.rs.getString("GRANTEE"));
- assertEquals("UPDATE", this.rs.getString("PRIVILEGE"));
+ if (!grantFailed) {
+ DatabaseMetaData metaData = conn1.getMetaData();
+ this.rs = metaData.getColumnPrivileges(null, null, "t1", null);
+ this.rs.next();
+ assertEquals("t1", this.rs.getString("TABLE_NAME"));
+ assertEquals("c1", this.rs.getString("COLUMN_NAME"));
+ assertEquals(userHostQuoted, this.rs.getString("GRANTEE"));
+ assertEquals("UPDATE", this.rs.getString("PRIVILEGE"));
+ }
} finally {
- if (stmt1 != null) {
- stmt1.executeUpdate("DROP TABLE IF EXISTS t1");
- stmt1.executeUpdate("REVOKE UPDATE (c1) ON t1 FROM " + userHostQuoted);
- stmt1.close();
+ if (stmt1 != null) {
+
+ stmt1.executeUpdate("DROP TABLE IF EXISTS t1");
+
+ if (!grantFailed) {
+ stmt1.executeUpdate("REVOKE UPDATE (c1) ON t1 FROM " + userHostQuoted);
+ }
+
+ stmt1.close();
}
if (conn1 != null) {
Modified: branches/branch_5_0/connector-j/src/testsuite/simple/StatementsTest.java
===================================================================
--- branches/branch_5_0/connector-j/src/testsuite/simple/StatementsTest.java 2006-10-05
16:45:25 UTC (rev 5827)
+++ branches/branch_5_0/connector-j/src/testsuite/simple/StatementsTest.java 2006-10-05
16:51:31 UTC (rev 5828)
@@ -545,6 +545,14 @@
- begin < 30000);
}
+ for (int i = 0; i < 1000; i++) {
+ try {
+ cancelStmt.executeQuery("SELECT 1");
+ } catch (SQLException timedOutEx) {
+ break;
+ }
+ }
+
// Make sure we can still use the connection...
cancelStmt.setQueryTimeout(0);
@@ -583,6 +591,14 @@
- begin < 30000);
}
+ for (int i = 0; i < 1000; i++) {
+ try {
+ cancelStmt.executeQuery("SELECT 1");
+ } catch (SQLException timedOutEx) {
+ break;
+ }
+ }
+
// Make sure we can still use the connection...
this.rs = cancelStmt.executeQuery("SELECT 1");
@@ -604,6 +620,14 @@
- begin < 30000);
}
+ for (int i = 0; i < 1000; i++) {
+ try {
+ cancelPstmt.executeQuery("SELECT 1");
+ } catch (SQLException timedOutEx) {
+ break;
+ }
+ }
+
// Make sure we can still use the connection...
this.rs = cancelStmt.executeQuery("SELECT 1");
@@ -642,6 +666,14 @@
- begin < 30000);
}
+ for (int i = 0; i < 1000; i++) {
+ try {
+ cancelPstmt.executeQuery("SELECT 1");
+ } catch (SQLException timedOutEx) {
+ break;
+ }
+ }
+
// Make sure we can still use the connection...
this.rs = cancelStmt.executeQuery("SELECT 1");
@@ -663,6 +695,14 @@
- begin < 30000);
}
+ for (int i = 0; i < 1000; i++) {
+ try {
+ cancelStmt.executeQuery("SELECT 1");
+ } catch (SQLException timedOutEx) {
+ break;
+ }
+ }
+
// Make sure we can still use the connection...
this.rs = cancelStmt.executeQuery("SELECT 1");
@@ -701,6 +741,14 @@
- begin < 30000);
}
+ for (int i = 0; i < 1000; i++) {
+ try {
+ cancelClientPstmt.executeQuery("SELECT 1");
+ } catch (SQLException timedOutEx) {
+ break;
+ }
+ }
+
// Make sure we can still use the connection...
this.rs = cancelStmt.executeQuery("SELECT 1");
Modified: trunk/connector-j/src/testsuite/simple/MetadataTest.java
===================================================================
--- trunk/connector-j/src/testsuite/simple/MetadataTest.java 2006-10-05 16:45:25 UTC (rev
5827)
+++ trunk/connector-j/src/testsuite/simple/MetadataTest.java 2006-10-05 16:51:31 UTC (rev
5828)
@@ -651,6 +651,8 @@
Statement stmt1 = null;
String userHostQuoted = null;
+ boolean grantFailed = true;
+
try {
conn1 = getConnectionWithProps(props);
stmt1 = conn1.createStatement();
@@ -660,42 +662,45 @@
this.rs.next();
String user = this.rs.getString(1);
List userHost = StringUtils.split(user, "@", false);
- assertTrue(user, userHost.size() > 1);
userHostQuoted = "'" + userHost.get(0) + "'@'" + userHost.get(1) + "'";
try {
stmt1.executeUpdate("GRANT update (c1) on t1 to " + userHostQuoted);
+
+ grantFailed = false;
+
} catch (SQLException sqlEx) {
logDebug("This testcase needs to be run with a URL that allows the user
to issue GRANTs "
+ " in the current database. You can skip this test by setting the
system property \""
+ dontRunPropertyName + "\".");
- throw sqlEx;
+ grantFailed = true;
}
- DatabaseMetaData metaData = conn1.getMetaData();
- this.rs = metaData.getColumnPrivileges(null, null, "t1", null);
- this.rs.next();
- assertEquals("t1", this.rs.getString("TABLE_NAME"));
- assertEquals("c1", this.rs.getString("COLUMN_NAME"));
- assertEquals(userHostQuoted, this.rs.getString("GRANTEE"));
- assertEquals("UPDATE", this.rs.getString("PRIVILEGE"));
+ if (!grantFailed) {
+ DatabaseMetaData metaData = conn1.getMetaData();
+ this.rs = metaData.getColumnPrivileges(null, null, "t1", null);
+ this.rs.next();
+ assertEquals("t1", this.rs.getString("TABLE_NAME"));
+ assertEquals("c1", this.rs.getString("COLUMN_NAME"));
+ assertEquals(userHostQuoted, this.rs.getString("GRANTEE"));
+ assertEquals("UPDATE", this.rs.getString("PRIVILEGE"));
+ }
} finally {
- try {
- if (stmt1 != null) {
- stmt1.executeUpdate("DROP TABLE IF EXISTS t1");
- if (userHostQuoted != null) {
- String revoke = "REVOKE UPDATE (c1) ON t1 FROM "
- + userHostQuoted;
- stmt1.executeUpdate(revoke);
- }
- stmt1.close();
- }
- } finally {
- if (conn1 != null) {
- conn1.close();
- }
- }
+ if (stmt1 != null) {
+
+ stmt1.executeUpdate("DROP TABLE IF EXISTS t1");
+
+ if (!grantFailed) {
+ stmt1.executeUpdate("REVOKE UPDATE (c1) ON t1 FROM " + userHostQuoted);
+ }
+
+ stmt1.close();
+ }
+
+ if (conn1 != null) {
+ conn1.close();
+ }
}
}
}
Modified: trunk/connector-j/src/testsuite/simple/StatementsTest.java
===================================================================
--- trunk/connector-j/src/testsuite/simple/StatementsTest.java 2006-10-05 16:45:25 UTC
(rev 5827)
+++ trunk/connector-j/src/testsuite/simple/StatementsTest.java 2006-10-05 16:51:31 UTC
(rev 5828)
@@ -546,6 +546,14 @@
- begin < 30000);
}
+ for (int i = 0; i < 1000; i++) {
+ try {
+ cancelStmt.executeQuery("SELECT 1");
+ } catch (SQLException timedOutEx) {
+ break;
+ }
+ }
+
// Make sure we can still use the connection...
cancelStmt.setQueryTimeout(0);
@@ -584,6 +592,14 @@
- begin < 30000);
}
+ for (int i = 0; i < 1000; i++) {
+ try {
+ cancelStmt.executeQuery("SELECT 1");
+ } catch (SQLException timedOutEx) {
+ break;
+ }
+ }
+
// Make sure we can still use the connection...
this.rs = cancelStmt.executeQuery("SELECT 1");
@@ -605,6 +621,14 @@
- begin < 30000);
}
+ for (int i = 0; i < 1000; i++) {
+ try {
+ cancelPstmt.executeQuery("SELECT 1");
+ } catch (SQLException timedOutEx) {
+ break;
+ }
+ }
+
// Make sure we can still use the connection...
this.rs = cancelStmt.executeQuery("SELECT 1");
@@ -643,6 +667,14 @@
- begin < 30000);
}
+ for (int i = 0; i < 1000; i++) {
+ try {
+ cancelPstmt.executeQuery("SELECT 1");
+ } catch (SQLException timedOutEx) {
+ break;
+ }
+ }
+
// Make sure we can still use the connection...
this.rs = cancelStmt.executeQuery("SELECT 1");
@@ -664,6 +696,14 @@
- begin < 30000);
}
+ for (int i = 0; i < 1000; i++) {
+ try {
+ cancelStmt.executeQuery("SELECT 1");
+ } catch (SQLException timedOutEx) {
+ break;
+ }
+ }
+
// Make sure we can still use the connection...
this.rs = cancelStmt.executeQuery("SELECT 1");
@@ -702,6 +742,14 @@
- begin < 30000);
}
+ for (int i = 0; i < 1000; i++) {
+ try {
+ cancelClientPstmt.executeQuery("SELECT 1");
+ } catch (SQLException timedOutEx) {
+ break;
+ }
+ }
+
// Make sure we can still use the connection...
this.rs = cancelStmt.executeQuery("SELECT 1");
| Thread |
|---|
| • Connector/J commit: r5828 - branches/branch_5_0/connector-j branches/branch_5_0/connector-j/src/testsuite/simple trunk/connector-j/src/testsuite/simpl... | mmatthews | 5 Oct |