db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r611295 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: master/ suites/ tests/store/
Date Fri, 11 Jan 2008 20:42:41 GMT
Author: mamta
Date: Fri Jan 11 12:42:38 2008
New Revision: 611295

URL: http://svn.apache.org/viewvc?rev=611295&view=rev
Log:
Adding a test case for DERBY-3302. There are two sub-test case classes involved here,
col_rec1.java and col_rec2.java

The purpose of col_rec1 test and col_rec2 test is to create a territory based database and

create some objects with collation sensitive character types. Then, make the database crash

so that during the recovery, store engine has to do collation related operations. Those 
collation related operations are going to require that we use correct Collator object. 
DERBY-3302 demonstrated a npe during this operation because Derby was relying on database

context to get the correct Collator object. But database context is not available at this

point in the recovery. With the fix for DERBY-3302, the Collator object will now be 
obtained from collation sensitive datatypes itself rather than looking at database context

which is not available at this point in recovery. 

col_rec1 class will do the steps of create a territory based database and create some 
objects with collation sensitive character types. Then, make the database crash. 
col_rec2 class will do the part of rebooting the crashed db which will require store to go

through recovery.



Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/col_rec1.out
  (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/col_rec2.out
  (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storeCollationDBrecovery.properties
  (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storeCollationDBrecovery.runall
  (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/col_rec1.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/col_rec1_app.properties
  (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/col_rec2.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/col_rec2_app.properties
  (with props)

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/col_rec1.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/col_rec1.out?rev=611295&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/col_rec1.out
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/col_rec1.out
Fri Jan 11 12:42:38 2008
@@ -0,0 +1,2 @@
+Beginning test: test1
+Ending test: test1

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/col_rec1.out
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/col_rec2.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/col_rec2.out?rev=611295&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/col_rec2.out
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/col_rec2.out
Fri Jan 11 12:42:38 2008
@@ -0,0 +1,2 @@
+Beginning test: test1
+Ending test: test1

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/col_rec2.out
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storeCollationDBrecovery.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storeCollationDBrecovery.properties?rev=611295&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storeCollationDBrecovery.properties
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storeCollationDBrecovery.properties
Fri Jan 11 12:42:38 2008
@@ -0,0 +1,17 @@
+# 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.
+
+usesystem=storeCollationDBRecovery
+

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storeCollationDBrecovery.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storeCollationDBrecovery.runall
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storeCollationDBrecovery.runall?rev=611295&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storeCollationDBrecovery.runall
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storeCollationDBrecovery.runall
Fri Jan 11 12:42:38 2008
@@ -0,0 +1,2 @@
+store/col_rec1.java
+store/col_rec2.java

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/storeCollationDBrecovery.runall
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/col_rec1.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/col_rec1.java?rev=611295&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/col_rec1.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/col_rec1.java
Fri Jan 11 12:42:38 2008
@@ -0,0 +1,115 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.functionTests.tests.store.col_rec1
+
+   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.store;
+
+import org.apache.derby.iapi.services.sanity.SanityManager;
+
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import org.apache.derby.tools.ij;
+
+/**
+ * The purpose of this test and col_rec2 test is to create a territory based 
+ * database and create some objects with collation sensitive character types. 
+ * Then, make the database crash so that during the recovery, store engine has 
+ * to do collation related operations. Those collation related operations are 
+ * going to require that we use correct Collator object. DERBY-3302 
+ * demonstrated a npe during this operation because Derby was relying on
+ * database context to get the correct Collator object. But database context
+ * is not available at this point in the recovery. With the fix for DERBY-3302, 
+ * the Collator object will now be obtained from collation sensitive datatypes 
+ * itself rather than looking at database context which is not available at 
+ * this point in recovery. 
+ * 
+ * This particular class will do the steps of create a territory based database
+ * and create some objects with collation sensitive character types. Then, make 
+ * the database crash. col_rec2.java will do the part of rebooting the crashed
+ * db which will require store to go through recovery.
+ */
+
+public class col_rec1 extends BaseTest
+{
+
+    public col_rec1()
+    {
+    }
+
+    /**
+     * setup for restart recovery test which will require the use of correct
+     * Collator object during recovery of territory based database that will 
+     * be created and crashed in this test and later will be recovered in
+     * col_rec2.
+     **/
+    private void test1(
+    Connection  conn,
+    String      test_name,
+    String      table_name)
+        throws SQLException
+    {
+        beginTest(conn, test_name);
+        Statement s = conn.createStatement();
+        s.execute(
+                "create table t(x varchar(100) primary key)");
+        conn.commit();
+        conn.setAutoCommit(false);
+        s.execute("insert into t values 'xxxx'");
+		Connection connSecond = DriverManager.getConnection
+		("jdbc:derby:collationDB");
+        connSecond.setAutoCommit(false);
+        Statement sSecond = connSecond.createStatement();
+        sSecond.execute("insert into t values 'abab'");
+        endTest(conn, test_name);
+    }
+
+    public void testList(Connection conn)
+        throws SQLException
+    {
+        test1(conn, "test1", "T");
+    }
+
+    public static void main(String[] argv) 
+        throws Throwable
+    {
+    	col_rec1 test = new col_rec1();
+
+   		ij.getPropertyArg(argv); 
+        Connection conn = ij.startJBMS();
+        conn.setAutoCommit(false);
+
+        try
+        {
+            test.testList(conn);
+        }
+        catch (SQLException sqle)
+        {
+			org.apache.derby.tools.JDBCDisplayUtil.ShowSQLException(
+                System.out, sqle);
+			sqle.printStackTrace(System.out);
+		}
+    }
+}

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/col_rec1_app.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/col_rec1_app.properties?rev=611295&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/col_rec1_app.properties
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/col_rec1_app.properties
Fri Jan 11 12:42:38 2008
@@ -0,0 +1,17 @@
+# 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.
+
+ij.database=jdbc:derby:collationDB;create=true;territory=no_NO;collation=TERRITORY_BASED
+

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

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/col_rec2.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/col_rec2.java?rev=611295&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/col_rec2.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/col_rec2.java
Fri Jan 11 12:42:38 2008
@@ -0,0 +1,119 @@
+/*
+
+  Derby - Class org.apache.derbyTesting.functionTests.tests.store.col_rec2
+
+   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.store;
+
+import org.apache.derby.iapi.services.sanity.SanityManager;
+
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import org.apache.derby.tools.ij;
+
+/**
+ * The purpose of this test and col_rec1 test is to create a territory based 
+ * database and create some objects with collation sensitive character types. 
+ * Then, make the database crash so that during the recovery, store engine has 
+ * to do collation related operations. Those collation related operations are 
+ * going to require that we use correct Collator object. DERBY-3302 
+ * demonstrated a npe during this operation because Derby was relying on
+ * database context to get the correct Collator object. But database context
+ * is not available at this point in the recovery. With the fix for DERBY-3302, 
+ * the Collator object will now be obtained from collation sensitive datatypes 
+ * itself rather than looking at database context which is not available at 
+ * this point in recovery. 
+ * 
+ * col_rec1 class will do the steps of create a territory based database
+ * and create some objects with collation sensitive character types. Then, make 
+ * the database crash. This test will do the part of rebooting the crashed
+ * db which will require store to go through recovery.
+ */
+
+public class col_rec2 extends BaseTest
+{
+
+    public col_rec2()
+    {
+    }
+
+    /**
+     * setup for restart recovery test which will require the use of correct
+     * Collator object during recovery of territory based database that was 
+     * created and crashed in this col_rec1
+     **/
+    private void test1(
+    Connection  conn,
+    String      test_name,
+    String      table_name)
+        throws SQLException
+    {
+        beginTest(conn, test_name);
+        Statement s = conn.createStatement();
+        ResultSet rs = s.executeQuery("VALUES SYSCS_UTIL.SYSCS_GET_DATABASE_PROPERTY" + 
+                    "('derby.database.collation')");
+        rs.next();
+        String collation = rs.getString(1);
+        if (!collation.equals("TERRITORY_BASED"))
+            logError("Collation should have been territory based but it is "
+            		+ collation);
+
+        rs = s.executeQuery("select count(*) from t");
+        rs.next();
+        int numberOfRows = rs.getInt(1);
+        if (numberOfRows > 1)
+        	 logError("Expected 1 row in T but found " + numberOfRows +
+        			 " rows");
+        rs.close();
+        s.close();
+        endTest(conn, test_name);
+    }
+
+    public void testList(Connection conn)
+        throws SQLException
+    {
+        test1(conn, "test1", "T");
+    }
+
+    public static void main(String[] argv) 
+        throws Throwable
+    {
+    	col_rec2 test = new col_rec2();
+
+   		ij.getPropertyArg(argv); 
+        Connection conn = ij.startJBMS();
+        conn.setAutoCommit(false);
+
+        try
+        {
+            test.testList(conn);
+        }
+        catch (SQLException sqle)
+        {
+			org.apache.derby.tools.JDBCDisplayUtil.ShowSQLException(
+                System.out, sqle);
+			sqle.printStackTrace(System.out);
+		}
+    }
+}

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/col_rec2_app.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/col_rec2_app.properties?rev=611295&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/col_rec2_app.properties
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/col_rec2_app.properties
Fri Jan 11 12:42:38 2008
@@ -0,0 +1,17 @@
+# 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.
+
+ij.database=jdbc:derby:collationDB
+

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



Mime
View raw message