db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1079805 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ProcedureInTriggerTest.java
Date Wed, 09 Mar 2011 14:06:32 GMT
Author: kahatlen
Date: Wed Mar  9 14:06:31 2011
New Revision: 1079805

URL: http://svn.apache.org/viewvc?rev=1079805&view=rev
Log:
DERBY-5103: ProcedureInTriggerTest depends on implicit ordering of test cases

Change the test cases to be self-contained and not depend on the side effects of the other
test cases.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ProcedureInTriggerTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ProcedureInTriggerTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ProcedureInTriggerTest.java?rev=1079805&r1=1079804&r2=1079805&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ProcedureInTriggerTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ProcedureInTriggerTest.java
Wed Mar  9 14:06:31 2011
@@ -102,7 +102,6 @@ public class ProcedureInTriggerTest exte
         JDBC.assertEmpty(rs);
         s.execute("drop trigger before_stmt_trig_no_sql");
         s.execute("drop trigger before_row_trig_no_sql");
-        s.execute("insert into t2 values (1,2), (2,4)");
         s.close();
     }
     
@@ -114,6 +113,7 @@ public class ProcedureInTriggerTest exte
      */
     public void testTriggerContainsSql() throws SQLException{
         Statement s = createStatement();
+        s.execute("insert into t2 values (1,2), (2,4)");
         s.execute("create trigger after_row_trig_contains_sql AFTER update on t2 for each
ROW call proc_contains_sql()");
         // --- update 2 rows. check that trigger is fired - procedure should be called twice
         s.execute("update t2 set x = x*2");
@@ -306,6 +306,10 @@ public class ProcedureInTriggerTest exte
      */
     public void testTriggerNegative() throws SQLException {
         Statement s = createStatement();
+
+        // Insert some test data.
+        s.execute("insert into t1 values (5,'two'), (6,'four'), (8,'eight')");
+
         ResultSet rs;
         assertStatementError("42Y03",s,"create trigger call_non_existent_proc1 AFTER insert
on t2 for each ROW call non_existent_proc()");
           rs = s.executeQuery("select count(*) from SYS.SYSTRIGGERS where CAST(triggername
AS VARCHAR(128))='CALL_NON_EXISTENT_PROC1'");
@@ -449,6 +453,12 @@ public class ProcedureInTriggerTest exte
          // -- check index is not dropped
          rs = s.executeQuery("select count(*) from SYS.SYSCONGLOMERATES where CAST(CONGLOMERATENAME
AS VARCHAR(128))='IX' and ISINDEX");
          JDBC.assertFullResultSet(rs, new String[][] {{"1"}});
+
+         // Clean up triggers.
+         s.execute("drop trigger alter_table_trig");
+         s.execute("drop trigger test_trig");
+         s.execute("drop trigger drop_index_trig");
+
          s.close();
     }
     
@@ -497,6 +507,27 @@ public class ProcedureInTriggerTest exte
             return suite;
         }
 
+        /**
+         * Tear down the test environment.
+         */
+        protected void tearDown() throws Exception {
+            rollback();
+
+            // Remove all rows in the test tables, so that each test case
+            // sees the same initial state.
+            Statement stmt = createStatement();
+            stmt.execute("truncate table t1");
+            stmt.execute("truncate table t2");
+            commit();
+
+            // Reset the counters.
+            zeroArgCount = 0;
+            getConnectionProcCount = 0;
+            selectRowsCount = 0;
+
+            super.tearDown();
+        }
+
         private void checkAndResetZeroArgCount(int count) {
             assertEquals(count, zeroArgCount);
             zeroArgCount = 0;



Mime
View raw message