db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From myrn...@apache.org
Subject svn commit: r557423 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: tests/lang/ReleaseCompileLocksTest.java util/StaticInitializers/DMLInStaticInitializer.java util/StaticInitializers/InsertInStaticInitializer.java
Date Wed, 18 Jul 2007 22:51:25 GMT
Author: myrnavl
Date: Wed Jul 18 15:51:24 2007
New Revision: 557423

URL: http://svn.apache.org/viewvc?view=rev&rev=557423
Log:
DERBY-2518 - adjust junit test ReleaseCompileLocksTest to call appropriate
  methods and report failures where needed.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ReleaseCompileLocksTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/StaticInitializers/DMLInStaticInitializer.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/StaticInitializers/InsertInStaticInitializer.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ReleaseCompileLocksTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ReleaseCompileLocksTest.java?view=diff&rev=557423&r1=557422&r2=557423
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ReleaseCompileLocksTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ReleaseCompileLocksTest.java
Wed Jul 18 15:51:24 2007
@@ -31,7 +31,6 @@
 import org.apache.derbyTesting.junit.JDBC;
 import org.apache.derbyTesting.junit.TestConfiguration;
 
-import junit.framework.Assert;
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
@@ -60,13 +59,15 @@
 	protected void setUp() throws SQLException {
 	    Statement stmt = createStatement();
 
-	    stmt.execute("create function dmlstatic() returns INT parameter style java language
java external name " +							  "'org.apache.derbyTesting.functionTests.tests.lang." + 
-                 	this.getANumber() +
-			"' no sql");
+	    stmt.execute("create function dmlstatic() returns INT " +
+	    	"parameter style java language java external name " +
+	    	"'org.apache.derbyTesting.functionTests.util.StaticInitializers." +
+	    	"DMLInStaticInitializer.getANumber' no sql");
                   
-	    stmt.execute("create function insertstatic() returns INT parameter style java language
java external name " +					"'org.apache.derbyTesting.functionTests.tests.lang." +
-			this.getANumber() +
-			"' no sql");
+	    stmt.execute("create function insertstatic() returns INT " +
+	    	"parameter style java language java external name " +
+	    	"'org.apache.derbyTesting.functionTests.util.StaticInitializers." +
+	    	"InsertInStaticInitializer.getANumber' no sql");
         
         stmt.close();
         commit();
@@ -78,9 +79,9 @@
          * Create a suite of tests.
          **/
         public static Test suite() {
-        	TestSuite suite = new TestSuite("ForUpdateTest");
+        	TestSuite suite = new TestSuite("ReleasecompileLocksTest");
         	suite.addTest(baseSuite("ReleaseCompileLocksTest:embedded"));
-                suite.addTest(TestConfiguration.clientServerDecorator(baseSuite("ReleaseCompileLocksTest:client")));
+        	suite.addTest(TestConfiguration.clientServerDecorator(baseSuite("ReleaseCompileLocksTest:client")));
         	return suite;
     	}
 
@@ -102,12 +103,13 @@
             
             Statement stmt = createStatement();
 
-		try {
-                	stmt.executeQuery("select (dmlstatic()) from sys.systables where tablename
= 'SYSCONGLOMERATES'");          
-		} catch (SQLException sqle) {
-			assertSQLState("42X51", sqle);
-		}
-		
+        	try {    
+        		JDBC.assertFullResultSet(stmt.executeQuery(
+        			"select (dmlstatic()) from sys.systables where " +
+        			"tablename = 'SYSCONGLOMERATES'"), new String[][] {{"1"}});
+        	} catch (Throwable ie) {
+        		fail("unexpected problem, cause: " +ie.getCause());
+        	}
 
                 JDBC.assertEmpty(stmt.executeQuery("select TYPE, MODE, TABLENAME, LOCKNAME,
STATE from syscs_diag.lock_table order by 1"));
 		commit();
@@ -116,13 +118,13 @@
 		stmt.execute("create table t1 (s int)");
 		commit();
 
-		
 		try {
-                	stmt.executeQuery("select (insertstatic()) from sys.systables where tablename
= 'SYSCONGLOMERATES'"); 
-		} catch (SQLException sqle) {
-			assertSQLState("42X51", sqle);
-		}
-		
+        		JDBC.assertFullResultSet(stmt.executeQuery(
+        			"select (insertstatic()) from sys.systables where " +
+        			"tablename = 'SYSCONGLOMERATES'"), new String[][] {{"1"}});
+        	} catch (Throwable ie) {
+        		fail("unexpected problem; cause: " + ie.getCause());
+        	}
 
                 JDBC.assertEmpty(stmt.executeQuery("select TYPE, MODE, TABLENAME, LOCKNAME,
STATE from syscs_diag.lock_table order by 1"));
 
@@ -149,6 +151,7 @@
 
 		try { 
 		  	stmt.execute("drop table t1");
+		  	fail ("expected SQLException; table t should not exist");
 		} catch (SQLException e) {
 			assertSQLState("42Y55", e);
 		}
@@ -235,11 +238,5 @@
 		ps.close();
 		stmt.close();
        }
-
        
-        private static int getANumber()
-	{
-		return 1;
-	}
-        
 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/StaticInitializers/DMLInStaticInitializer.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/StaticInitializers/DMLInStaticInitializer.java?view=diff&rev=557423&r1=557422&r2=557423
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/StaticInitializers/DMLInStaticInitializer.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/StaticInitializers/DMLInStaticInitializer.java
Wed Jul 18 15:51:24 2007
@@ -64,8 +64,9 @@
 		}
 		catch (SQLException se)
 		{
-			System.out.println("Caught exception " + se);
-			se.printStackTrace(System.out);
+			if (!se.getSQLState().equals("38001")){
+				throw new ExceptionInInitializerError(se);
+			}
 		}
 		finally
 		{
@@ -76,8 +77,9 @@
 			}
 			catch (SQLException se)
 			{
-				System.out.println("Caught exception " + se);
-				se.printStackTrace(System.out);
+				if (!se.getSQLState().equals("38001")) {
+					throw new ExceptionInInitializerError(se);
+				}
 			}
 		}
 	}

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/StaticInitializers/InsertInStaticInitializer.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/StaticInitializers/InsertInStaticInitializer.java?view=diff&rev=557423&r1=557422&r2=557423
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/StaticInitializers/InsertInStaticInitializer.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/StaticInitializers/InsertInStaticInitializer.java
Wed Jul 18 15:51:24 2007
@@ -67,8 +67,10 @@
 		}
 		catch (SQLException se)
 		{
-			System.out.println("Caught exception " + se);
-			se.printStackTrace(System.out);
+			// we expected the above s.execute(INSERT) to fail
+			if (!se.getSQLState().equals("38001")) {
+				throw new ExceptionInInitializerError(se);
+			}
 		}
 		finally
 		{
@@ -79,8 +81,8 @@
 			}
 			catch (SQLException se)
 			{
-				System.out.println("Caught exception " + se);
-				se.printStackTrace(System.out);
+				if (!se.getSQLState().equals("38001"))
+					throw new ExceptionInInitializerError(se);
 			}
 		}
 	}



Mime
View raw message