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 my...@apache.org on 2008/10/11 01:45:23 UTC

svn commit: r703608 - in /db/derby/code/branches/10.4/java: engine/org/apache/derby/impl/store/raw/data/ testing/org/apache/derbyTesting/functionTests/tests/store/ testing/org/apache/derbyTesting/functionTests/util/ testing/org/apache/derbyTesting/junit/

Author: myrnavl
Date: Fri Oct 10 16:45:23 2008
New Revision: 703608

URL: http://svn.apache.org/viewvc?rev=703608&view=rev
Log:
DERBY-3875; backport from trunk revision 703246 with adjustments for missing
  backports to PrivilegedFileOpsForTests.java

Added:
    db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/store/BackupRestoreTest.java
      - copied unchanged from r703246, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BackupRestoreTest.java
Modified:
    db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/RAFContainer.java
    db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java
    db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/util/PrivilegedFileOpsForTests.java
    db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/junit/Utilities.java

Modified: db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/RAFContainer.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/RAFContainer.java?rev=703608&r1=703607&r2=703608&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/RAFContainer.java (original)
+++ db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/RAFContainer.java Fri Oct 10 16:45:23 2008
@@ -852,8 +852,18 @@
         {
             return AccessController.doPrivileged( this) != null;
         }
-        catch( PrivilegedActionException pae){ throw (StandardException) pae.getException();}
-        finally{ actionIdentity = null; }
+        catch( PrivilegedActionException pae) { 
+            closeContainer();
+            throw (StandardException) pae.getException();
+        }
+        catch (RuntimeException e) {
+            closeContainer();
+            throw e;
+        }
+        finally
+        { 
+            actionIdentity = null; 
+        }
     }
 
 	private synchronized void stubbify(LogInstant instant)

Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java?rev=703608&r1=703607&r2=703608&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java Fri Oct 10 16:45:23 2008
@@ -55,6 +55,7 @@
 
         suite.addTest(Derby3625Test.suite());
         suite.addTest(PositionedStoreStreamTest.suite());
+        suite.addTest(BackupRestoreTest.suite());
         // Encryption only supported for Derby in J2SE/J2EE environments.
         // J2ME (JSR169) does not support encryption.
         if (JDBC.vmSupportsJDBC3()) {

Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/util/PrivilegedFileOpsForTests.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/util/PrivilegedFileOpsForTests.java?rev=703608&r1=703607&r2=703608&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/util/PrivilegedFileOpsForTests.java (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/util/PrivilegedFileOpsForTests.java Fri Oct 10 16:45:23 2008
@@ -23,6 +23,8 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileReader;
 import java.security.AccessController;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
@@ -129,4 +131,31 @@
             throw (SecurityException)pae.getException();
         }
     }
+
+    /**
+     * Returns a file output stream for the specified file.
+     *
+     * @param file the file to create a stream for
+     * @return An output stream.
+     * @throws FileNotFoundException if the specified file does not exist
+     * @throws SecurityException if the required permissions to write the file,
+     *      or the path it is in, are missing
+     */
+    public static FileOutputStream getFileOutputStream(final File file)
+            throws FileNotFoundException {
+        if (file == null) {
+            throw new IllegalArgumentException("file cannot be <null>");
+        }
+        try {
+            return (FileOutputStream)AccessController.doPrivileged(
+                    new PrivilegedExceptionAction() {
+                        public Object run()
+                                throws FileNotFoundException {
+                            return new FileOutputStream(file);
+                        }
+                    });
+        } catch (PrivilegedActionException pae) {
+            throw (FileNotFoundException)pae.getCause();
+        }
+    }
 }

Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/junit/Utilities.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/junit/Utilities.java?rev=703608&r1=703607&r2=703608&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/junit/Utilities.java (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/junit/Utilities.java Fri Oct 10 16:45:23 2008
@@ -33,6 +33,7 @@
 import java.sql.ResultSet;
 import java.sql.ResultSetMetaData;
 import java.sql.SQLException;
+import java.util.StringTokenizer;
 
 
 /**
@@ -240,5 +241,39 @@
         return new BufferedReader(new StringReader(
                 NetworkServerTestSetup.getNetworkServerControl().getSysinfo()));
     }
+    
+    /**
+     * Splits a string around matches of the given delimiter character.
+     * Copied from org.apache.derby.iapi.util.StringUtil
+     *
+     * Where applicable, this method can be used as a substitute for
+     * <code>String.split(String regex)</code>, which is not available
+     * on a JSR169/Java ME platform.
+     *
+     * @param str the string to be split
+     * @param delim the delimiter
+     * @throws NullPointerException if str is null
+     */
+    static public String[] split(String str, char delim)
+    {
+        if (str == null) {
+            throw new NullPointerException("str can't be null");
+        }
+
+        // Note the javadoc on StringTokenizer:
+        //     StringTokenizer is a legacy class that is retained for
+        //     compatibility reasons although its use is discouraged in
+        //     new code.
+        // In other words, if StringTokenizer is ever removed from the JDK,
+        // we need to have a look at String.split() (or java.util.regex)
+        // if it is supported on a JSR169/Java ME platform by then.
+        StringTokenizer st = new StringTokenizer(str, String.valueOf(delim));
+        int n = st.countTokens();
+        String[] s = new String[n];
+        for (int i = 0; i < n; i++) {
+            s[i] = st.nextToken();
+        }
+        return s;
+    }
 
 }