You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by km...@apache.org on 2006/02/10 20:22:40 UTC

svn commit: r376804 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: tests/store/RecoveryAfterBackup.java tests/store/RecoveryAfterBackupSetup_app.properties tests/store/RecoveryAfterBackup_app.properties util/TestUtil.java

Author: kmarsden
Date: Fri Feb 10 11:22:37 2006
New Revision: 376804

URL: http://svn.apache.org/viewcvs?rev=376804&view=rev
Log:
DERBY-907 regression test failure in RecoveryAfterBackup on wssd5.6 ibm jvm (j2me)

* Modifies app_properties files to add ij.dataSource properties. Also changed 'database' to 'ij.database' property. Removed usedefaults to avoid conflict with default property.
* Adds a method getConnection to TestUtil to get connection using different set of attributes than what is specified in _app.properties file.
* Changes the test store/RecoveryAfterBackup to use the above method to shutdown and get connection. I'll change other tests to use the new method in a later patch.

With the patch, I ran the RecoveryAfterBackup tests with Sun JDK1.4.2, j9 and j9 foundation vm. 

Contributed by Deepa Remesh



Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/RecoveryAfterBackup.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/RecoveryAfterBackupSetup_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/RecoveryAfterBackup_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestUtil.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/RecoveryAfterBackup.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/RecoveryAfterBackup.java?rev=376804&r1=376803&r2=376804&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/RecoveryAfterBackup.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/RecoveryAfterBackup.java Fri Feb 10 11:22:37 2006
@@ -77,12 +77,9 @@
             s.execute ("INSERT INTO t1 SELECT a+128 FROM t1");
 
             // Shut down database
-            Properties shutdownAttrs = new Properties();
-            shutdownAttrs.setProperty("shutdownDatabase", "shutdown");
             System.out.println("Shutting down database ...");
             try {
-                DataSource ds = TestUtil.getDataSource(shutdownAttrs);
-                ds.getConnection();
+            	TestUtil.getConnection("", "shutdown=true");
             } catch(SQLException sqle) {
                 if (sqle.getSQLState() != null 
                     && sqle.getSQLState().equals("XJ015")) {
@@ -94,12 +91,10 @@
 
             // Start up with rollforward-recovery
             System.out.println("Starting restore with roll-forward recovery..");
-            Properties restoreAttrs = new Properties();
-            restoreAttrs.setProperty("DatabaseName", "hairynosedwombat");
-            restoreAttrs.setProperty("connectionAttributes", 
-                  "rollForwardRecoveryFrom=extinout/mybackup/hairynosedwombat");
-            DataSource ds = TestUtil.getDataSource(restoreAttrs);
-            conn = ds.getConnection();
+            String dbName = "hairynosedwombat";
+            String connAttrs = 
+            	"rollForwardRecoveryFrom=extinout/mybackup/hairynosedwombat";
+            conn = TestUtil.getConnection(dbName, connAttrs);
 
             // After restore table should contain all records inserted above
             System.out.println("Verifying database ...");

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/RecoveryAfterBackupSetup_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/RecoveryAfterBackupSetup_app.properties?rev=376804&r1=376803&r2=376804&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/RecoveryAfterBackupSetup_app.properties (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/RecoveryAfterBackupSetup_app.properties Fri Feb 10 11:22:37 2006
@@ -1,5 +1,15 @@
 useextdirs=true
-usedefaults=true
-database=hairynosedwombat;create=true
+ij.database=hairynosedwombat;create=true
+ij.protocol=jdbc:derby:
+
+ij.showNoConnectionsAtStart=true
+ij.showNoCountForSelect=true
+
+ij.defaultResourcePackage=/org/apache/derbyTesting/functionTests/tests/store/
+
 #exclude with SecurityManager
 noSecurityManager=true
+
+# DataSource properties, only used if ij.dataSource is set
+ij.dataSource.databaseName=hairynosedwombat
+ij.dataSource.createDatabase=create

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/RecoveryAfterBackup_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/RecoveryAfterBackup_app.properties?rev=376804&r1=376803&r2=376804&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/RecoveryAfterBackup_app.properties (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/RecoveryAfterBackup_app.properties Fri Feb 10 11:22:37 2006
@@ -1,4 +1,13 @@
-usedefaults=true
-database=hairynosedwombat
+ij.database=hairynosedwombat
+ij.protocol=jdbc:derby:
+
+ij.showNoConnectionsAtStart=true
+ij.showNoCountForSelect=true
+
+ij.defaultResourcePackage=/org/apache/derbyTesting/functionTests/tests/store/
+
 #exclude with SecurityManager
 noSecurityManager=true
+
+# DataSource properties, only used if ij.dataSource is set
+ij.dataSource.databaseName=hairynosedwombat

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestUtil.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestUtil.java?rev=376804&r1=376803&r2=376804&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestUtil.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestUtil.java Fri Feb 10 11:22:37 2006
@@ -694,8 +694,48 @@
         }	
     }
 
-	
-	public static Connection getDataSourceConnection (Properties prop) throws SQLException {
+    
+    /**
+     * Get connection to given database using the connection attributes. This
+     * method is used by tests to get a secondary connection with 
+     * different set of attributes. It does not use what is specified in 
+     * app_properties file or system properties. This method uses DataSource 
+     * class for CDC/Foundation Profile environments, which are based on 
+     * JSR169. Using DataSource will not work with other j9 profiles. So
+     * DriverManager is used for non-JSR169. The method is used as a wrapper to
+     * hide this difference in getting connections in different environments.
+     *  
+     * @param databaseName
+     * @param connAttrs
+     * @return Connection to database 
+     * @throws SQLException on failure to connect.
+     * @throws ClassNotFoundException on failure to load driver.
+     * @throws InstantiationException on failure to load driver.
+     * @throws IllegalAccessException on failure to load driver.
+     */
+    public static Connection getConnection(String databaseName, 
+    									   String connAttrs) 
+    	throws SQLException, ClassNotFoundException, 
+				InstantiationException, IllegalAccessException {
+    	
+    	Connection conn;
+    	if(TestUtil.HAVE_DRIVER_CLASS) {
+    		String driver = "org.apache.derby.jdbc.EmbeddedDriver";
+    		Class.forName(driver).newInstance();
+    		conn = DriverManager.getConnection("jdbc:derby:" + databaseName 
+												+ ";" + connAttrs );
+    	}
+    	else {
+    		//Use DataSource for JSR169
+	    	Properties prop = new Properties();
+	        prop.setProperty("databaseName", databaseName);
+	        prop.setProperty("connectionAttributes", connAttrs);
+	        conn = getDataSourceConnection(prop);
+    	}
+        return conn;
+    }
+    
+    public static Connection getDataSourceConnection (Properties prop) throws SQLException {
 		DataSource ds = TestUtil.getDataSource(prop);
 		try {
 			Connection conn = ds.getConnection();