db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r530951 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: master/ master/jdk16/ suites/ tests/lang/
Date Sat, 21 Apr 2007 00:01:58 GMT
Author: kmarsden
Date: Fri Apr 20 17:01:57 2007
New Revision: 530951

URL: http://svn.apache.org/viewvc?view=rev&rev=530951
Log:
DERBY-2518 convert lang/releaseCompileLocks.sql to JUnit

contributed by Ramandeep Kaur (ramandhindsa@gmail.com)
I modified the original patch to remove the old test and masters.


Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ReleaseCompileLocksTest.java
  (with props)
Removed:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/jdk16/releaseCompileLocks.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/releaseCompileLocks.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/releaseCompileLocks.sql
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/releaseCompileLocks_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/releaseCompileLocks_sed.properties
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall?view=diff&rev=530951&r1=530950&r2=530951
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall
Fri Apr 20 17:01:57 2007
@@ -54,7 +54,6 @@
 lang/refActions.sql
 lang/refActions2.sql
 lang/refActions3.sql
-lang/releaseCompileLocks.sql
 lang/renameIndex.sql
 lang/renameTable.sql
 lang/reopenScan.sql

Added: 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=auto&rev=530951
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ReleaseCompileLocksTest.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ReleaseCompileLocksTest.java
Fri Apr 20 17:01:57 2007
@@ -0,0 +1,243 @@
+/*
+Derby - Class org.apache.derbyTesting.functionTests.tests.lang.ReleaseCompileLocksTest
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+*/
+
+package org.apache.derbyTesting.functionTests.tests.lang;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
+import org.apache.derbyTesting.junit.JDBC;
+import org.apache.derbyTesting.junit.TestConfiguration;
+
+import junit.framework.Assert;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+
+/**
+ * Tests for forupdate. 
+ *
+ */
+public class ReleaseCompileLocksTest extends BaseJDBCTestCase {
+
+	public Statement stmt = null;
+	Connection conn = null;
+
+
+	/* Public constructor required for running test as standalone JUnit. */    
+	public ReleaseCompileLocksTest(String name) {
+		super(name);
+	}
+
+
+	/* Set up fixture */ 
+	protected void setUp() throws SQLException {
+	    stmt = createStatement();
+	    conn = getConnection();
+	    conn.setAutoCommit(false);
+
+	    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 insertstatic() returns INT parameter style java language
java external name " +					"'org.apache.derbyTesting.functionTests.tests.lang." +
+			this.getANumber() +
+			"' no sql");
+	}
+
+
+	/* Tear down the fixture */
+	protected void tearDown() throws Exception {
+                stmt.close();
+		super.tearDown();
+	}
+
+	/**
+         * Create a suite of tests.
+         **/
+        public static Test suite() {
+        	TestSuite suite = new TestSuite("ForUpdateTest");
+        	suite.addTest(baseSuite("ReleaseCompileLocksTest:embedded"));
+                suite.addTest(TestConfiguration.clientServerDecorator(baseSuite("ReleaseCompileLocksTest:client")));
+        	return suite;
+    	}
+
+	protected static Test baseSuite(String name) {
+        	TestSuite suite = new TestSuite(name);
+        	suite.addTestSuite(ReleaseCompileLocksTest.class);
+        	
+		return new CleanDatabaseTestSetup(suite) 
+        	{
+            		protected void decorateSQL(Statement s) throws SQLException
+            		{
+				s.execute("create table t1 (s int)");	
+            		}
+        	};
+    	} 
+
+        /*Fixtures*/
+        public void testReleaseCompileLocks() throws Exception {
+        	conn.commit();
+
+		try {
+                	stmt.executeQuery("select (dmlstatic()) from sys.systables where tablename
= 'SYSCONGLOMERATES'");          
+		} catch (SQLException sqle) {
+			assertSQLState("42X51", sqle);
+		}
+		
+
+                JDBC.assertEmpty(stmt.executeQuery("select TYPE, MODE, TABLENAME, LOCKNAME,
STATE from syscs_diag.lock_table order by 1"));
+		conn.commit();
+
+		stmt.execute("drop table t1");
+		stmt.execute("create table t1 (s int)");
+		conn.commit();
+
+		
+		try {
+                	stmt.executeQuery("select (insertstatic()) from sys.systables where tablename
= 'SYSCONGLOMERATES'"); 
+		} catch (SQLException sqle) {
+			assertSQLState("42X51", sqle);
+		}
+		
+
+                JDBC.assertEmpty(stmt.executeQuery("select TYPE, MODE, TABLENAME, LOCKNAME,
STATE from syscs_diag.lock_table order by 1"));
+
+		JDBC.assertEmpty(stmt.executeQuery("select * from t1"));
+		stmt.execute("drop table t1");
+		conn.commit();
+	
+		JDBC.assertEmpty(stmt.executeQuery("select TYPE, MODE, TABLENAME, LOCKNAME, STATE from
syscs_diag.lock_table order by 1"));
+		conn.commit();
+
+		stmt.execute("create table test_tab (x int)");
+		stmt.executeUpdate("insert into test_tab values (1)");
+		conn.commit();
+
+		JDBC.assertSingleValueResultSet(stmt.executeQuery("select count(*) from syscs_diag.lock_table"),
"0");
+		JDBC.assertSingleValueResultSet(stmt.executeQuery("select count(*) from sys.sysviews"),
"0");
+		JDBC.assertSingleValueResultSet(stmt.executeQuery("select count(*) from syscs_diag.lock_table"),
"0");
+		stmt.execute("insert into test_tab values (2)");
+
+                ResultSet rs = stmt.executeQuery("select TYPE, MODE, TABLENAME, LOCKNAME,
STATE from syscs_diag.lock_table order by 1");
+		
+		String expectedValues[][] = {{"ROW", "X", "TEST_TAB", "(1,8)", "GRANT" }, {"TABLE", "IX",
"TEST_TAB", "Tablelock","GRANT"}};
+                JDBC.assertFullResultSet(rs, expectedValues);
+
+		try { 
+		  	stmt.execute("drop table t1");
+		} catch (SQLException e) {
+			assertSQLState("42Y55", e);
+		}
+		stmt.execute("create table t1 (x int)");
+		conn.commit();
+		
+		JDBC.assertEmpty(stmt.executeQuery("select * from t1"));
+
+		Connection conn1 = openDefaultConnection();
+                Statement stmt2 = conn1.createStatement();
+		stmt2.execute("create table t2 (x int)");
+		stmt2.execute("drop table t2");
+		stmt2.close();
+		conn1.close();
+
+		stmt.execute("drop table test_tab");
+		stmt.execute("create table test_tab (x int)");
+		stmt.execute("insert into test_tab values (1)");
+		conn.commit();
+
+		PreparedStatement ps = prepareStatement("update test_tab set x=2 where x=?");
+		ps.setCursorName("cursor1");
+		ps.setInt(1, 1);
+
+		JDBC.assertSingleValueResultSet(stmt.executeQuery("select count(*) from syscs_diag.lock_table"),
"0");
+		ps.executeUpdate();
+		
+		rs = stmt.executeQuery("select TYPE, MODE, TABLENAME, LOCKNAME, STATE from syscs_diag.lock_table
order by 1");
+		String expectedValues1[][] = {{"ROW", "X", "TEST_TAB", "(1,7)", "GRANT" }, {"TABLE", "IX",
"TEST_TAB", "Tablelock","GRANT"}};
+                JDBC.assertFullResultSet(rs, expectedValues1);
+		conn.commit();
+
+		
+		stmt.execute("create table t (c1 int not null primary key, c2 int references t)");
+		stmt.executeUpdate("insert into t values (1,1)");
+		stmt.executeUpdate("insert into t values (2,1)");
+		conn.commit();
+
+		ps = prepareStatement("select * from t where c1 = ? and c2 = ?");
+		ps.setCursorName("ps");
+		JDBC.assertEmpty(stmt.executeQuery("select * from syscs_diag.lock_table"));
+
+		
+		stmt.execute("create table x(c1 int)");
+		stmt.execute("drop table x");
+		conn.commit();
+
+		ps = prepareStatement("insert into t values (3,2)");
+		ps.setCursorName("pi");
+		JDBC.assertEmpty(stmt.executeQuery("select * from syscs_diag.lock_table"));
+		conn.commit();
+
+
+		stmt.execute("create table x(c1 int)");
+		stmt.execute("drop table x");
+		conn.commit();
+
+		ps = prepareStatement("update t set c2 = c1, c1 = c2");
+		ps.setCursorName("p1");
+		JDBC.assertEmpty(stmt.executeQuery("select * from syscs_diag.lock_table"));
+		conn.commit();
+
+		
+		stmt.execute("create table x(c1 int)");
+		stmt.execute("drop table x");
+		conn.commit();
+
+		ps = prepareStatement("delete from t");
+		ps.setCursorName("p1");
+		JDBC.assertEmpty(stmt.executeQuery("select * from syscs_diag.lock_table"));
+		conn.commit();
+		
+		stmt.execute("create trigger update_of_t after update on t for each row values 2");
+		stmt.execute("create trigger insert_of_t after insert on t for each row values 3");
+		conn.commit();
+	
+		ps = prepareStatement("update t set c2=2 where c1=2");
+		ps.setCursorName("pu");
+		JDBC.assertEmpty(stmt.executeQuery("select * from syscs_diag.lock_table"));
+		conn.commit();
+
+		rs.close();
+		ps.close();
+		stmt.close();
+       }
+
+       
+        private static int getANumber()
+	{
+		return 1;
+	}
+        
+}

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ReleaseCompileLocksTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java?view=diff&rev=530951&r1=530950&r2=530951
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
Fri Apr 20 17:01:57 2007
@@ -99,7 +99,7 @@
         suite.addTest(CollationTest.suite());
         suite.addTest(ScrollCursors1Test.suite());
         suite.addTest(SimpleTest.suite());
-
+        suite.addTest(ReleaseCompileLocksTest.suite());
         suite.addTest(ErrorCodeTest.suite());
 
         // Add the XML tests, which exist as a separate suite



Mime
View raw message