db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject svn commit: r1242904 - in /db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting: functionTests/master/ functionTests/suites/ functionTests/tests/store/ junit/
Date Fri, 10 Feb 2012 19:58:12 GMT
Author: mikem
Date: Fri Feb 10 19:58:12 2012
New Revision: 1242904

URL: http://svn.apache.org/viewvc?rev=1242904&view=rev
Log:
DERBY-5305 Convert store/updatelocks.sql to JUnit

backporting changes #1142626, #1143768, #1143939 from trunk to 10.8 branch.

Patch DERBY-5305-b, which adds a new test store/UpdateLocksTest to
store._Suite and removes the old harness test updatelocks.sql and its
auxiliary files. The patch also fixes a bug in
JDBC#assertUnorderedResultSet exposed by usage in the new
UpdateLocksTest. 

Trivial cleanup: removed two unused imports and one unused variable. 

Follow-up patch: commented out the unused debug method "show". 


Added:
    db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/store/UpdateLocksTest.java
      - copied, changed from r1142626, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/UpdateLocksTest.java
Removed:
    db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/master/updatelocks.out
    db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/store/updateBtreeCursorLocks.subsql
    db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/store/updateBtreeSetLocks.subsql
    db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/store/updatecursorlocks.subsql
    db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/store/updatelocks.sql
    db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/store/updatesetlocks.subsql
Modified:
    db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/suites/storemats.runall
    db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java
    db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/junit/JDBC.java

Modified: db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/suites/storemats.runall
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/suites/storemats.runall?rev=1242904&r1=1242903&r2=1242904&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/suites/storemats.runall
(original)
+++ db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/suites/storemats.runall
Fri Feb 10 19:58:12 2012
@@ -2,4 +2,3 @@ store/RowLockBasic.sql
 store/TableLockBasic.sql
 store/longColumn.sql
 store/updatelocksJDBC30.sql
-store/updatelocks.sql

Copied: db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/store/UpdateLocksTest.java
(from r1142626, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/UpdateLocksTest.java)
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/store/UpdateLocksTest.java?p2=db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/store/UpdateLocksTest.java&p1=db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/UpdateLocksTest.java&r1=1142626&r2=1242904&rev=1242904&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/UpdateLocksTest.java
(original)
+++ db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/store/UpdateLocksTest.java
Fri Feb 10 19:58:12 2012
@@ -19,7 +19,6 @@
  */
 package org.apache.derbyTesting.functionTests.tests.store;
 
-import java.sql.CallableStatement;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
@@ -32,7 +31,6 @@ import java.util.Arrays;
 
 import junit.framework.Test;
 
-import org.apache.derbyTesting.functionTests.util.Formatters;
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
 import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
 import org.apache.derbyTesting.junit.JDBC;
@@ -92,8 +90,6 @@ public class UpdateLocksTest extends Bas
              * Creates the views and procedures used by the test cases.
              */
             protected void decorateSQL(Statement s) throws SQLException {
-                Connection conn = s.getConnection();
-
                 s.executeUpdate(
                     "create function PADSTRING (data varchar(32000), " +
                     "                           length integer) " +
@@ -7585,37 +7581,40 @@ public class UpdateLocksTest extends Bas
 
     }
 
-    private void show(ResultSet rs, boolean unPadded) throws SQLException {
-        System.err.println("Isolation:" +
-                           rs.getStatement().
-                           getConnection().
-                           getTransactionIsolation());
-        System.err.println("UnPadded == " + unPadded);
-        System.err.println("        JDBC.assertUnorderedResultSet(\n" +
-                           "            ltrs,\n" +
-                           "            new String[][]{");
-        int rowNo = 0;
-        while (rs.next()) {
-            if (rowNo++ != 0) {
-                System.err.print(",\n");
-            }
-
-            System.err.print(
-                "                {\"" +
-                rs.getString(1).trim() + "\", \"" +
-                rs.getString(2).trim() + "\", \"" +
-                rs.getString(3).trim() + "\", \"" +
-                rs.getString(4).trim() + "\", \"" +
-                rs.getString(5).trim() + "\", \"" +
-                rs.getString(6).trim() + "\", \"" +
-                rs.getString(7).trim() + "\", \"" +
-                rs.getString(8).trim() + "\", \"" +
-                rs.getString(9).trim() + "\"}");
-        }
-
-        System.err.print("};\n");
-        rs.close();
-    }
+    // /**
+    //  * Useful for debugging result sets if the test fails.
+    //  */
+    // private void show(ResultSet rs, boolean unPadded) throws SQLException {
+    //     System.err.println("Isolation:" +
+    //                        rs.getStatement().
+    //                        getConnection().
+    //                        getTransactionIsolation());
+    //     System.err.println("UnPadded == " + unPadded);
+    //     System.err.println("        JDBC.assertUnorderedResultSet(\n" +
+    //                        "            ltrs,\n" +
+    //                        "            new String[][]{");
+    //     int rowNo = 0;
+    //     while (rs.next()) {
+    //         if (rowNo++ != 0) {
+    //             System.err.print(",\n");
+    //         }
+    //
+    //         System.err.print(
+    //             "                {\"" +
+    //             rs.getString(1).trim() + "\", \"" +
+    //             rs.getString(2).trim() + "\", \"" +
+    //             rs.getString(3).trim() + "\", \"" +
+    //             rs.getString(4).trim() + "\", \"" +
+    //             rs.getString(5).trim() + "\", \"" +
+    //             rs.getString(6).trim() + "\", \"" +
+    //             rs.getString(7).trim() + "\", \"" +
+    //             rs.getString(8).trim() + "\", \"" +
+    //             rs.getString(9).trim() + "\"}");
+    //     }
+    //
+    //     System.err.print("};\n");
+    //     rs.close();
+    // }
 
     private static String pad2(String s, int i) {
         if (i == 0) {

Modified: db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java?rev=1242904&r1=1242903&r2=1242904&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java
(original)
+++ db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java
Fri Feb 10 19:58:12 2012
@@ -60,6 +60,7 @@ public class _Suite extends BaseTestCase
         suite.addTest(InterruptResilienceTest.suite());
         suite.addTest(Derby4676Test.suite());
         suite.addTest(BootLockTest.suite());
+        suite.addTest(UpdateLocksTest.suite());
         suite.addTest(PositionedStoreStreamTest.suite());
         suite.addTest(OSReadOnlyTest.suite());
         suite.addTest(BackupRestoreTest.suite());

Modified: db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/junit/JDBC.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/junit/JDBC.java?rev=1242904&r1=1242903&r2=1242904&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/junit/JDBC.java (original)
+++ db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/junit/JDBC.java Fri Feb
10 19:58:12 2012
@@ -1316,28 +1316,27 @@ public class JDBC {
         for (int i = 0; i < expectedRows.length; i++) {
             Assert.assertEquals("Different column count in expectedRows",
                                 expectedRows[0].length, expectedRows[i].length);
-            if (asTrimmedStrings) {
-                ArrayList row = new ArrayList(expectedRows[i].length);
-                for (int j = 0; j < expectedRows[i].length; j++) {
-                    String val = (String) expectedRows[i][j];
-                    row.add(val == null ? null : val.trim());
-                }
-                expected.add(row);
-            } else {
-                expected.add(Arrays.asList(expectedRows[i]));
+            ArrayList row = new ArrayList(expectedRows[i].length);
+
+            for (int j = 0; j < expectedRows[i].length; j++) {
+                String val = (String) expectedRows[i][j];
+                row.add(asTrimmedStrings ?
+                        (val == null ? null : val.trim()) :
+                        val);
             }
+            expected.add(row);
         }
 
         ArrayList actual = new ArrayList(expectedRows.length);
         while (rs.next()) {
             ArrayList row = new ArrayList(expectedRows[0].length);
             for (int i = 1; i <= expectedRows[0].length; i++) {
-                if (asTrimmedStrings) {
-                    String s = rs.getString(i);
-                    row.add(s == null ? null : s.trim());
-                } else {
-                    row.add(rs.getObject(i));
-                }
+                String s = rs.getString(i);
+
+                row.add(asTrimmedStrings ?
+                        (s == null ? null : s.trim()) :
+                        s);
+
                 if (rs.wasNull())
                     assertResultColumnNullable(rsmd, i);
             }
@@ -1347,7 +1346,6 @@ public class JDBC {
 
         Assert.assertEquals("Unexpected row count",
                             expectedRows.length, actual.size());
-
         Assert.assertTrue("Missing rows in ResultSet",
                           actual.containsAll(expected));
 



Mime
View raw message