db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1610406 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: junit/BaseTestCase.java unitTests/junit/MissingPermissionsTest.java
Date Mon, 14 Jul 2014 13:17:07 GMT
Author: rhillegas
Date: Mon Jul 14 13:17:06 2014
New Revision: 1610406

URL: http://svn.apache.org/r1610406
Log:
DERBY-6617: Make MissingPermissionsTest look for different error text on Java 6; commit derby-6617-04-aa-platformSpecificErrorText.diff.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java?rev=1610406&r1=1610405&r2=1610406&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java Mon Jul
14 13:17:06 2014
@@ -863,6 +863,10 @@ public abstract class BaseTestCase
         return getSystemProperty("java.version").startsWith("1.5");
     }
    
+    public static final boolean isJava6() {
+        return getSystemProperty("java.version").startsWith("1.6");
+    }
+   
     public static final boolean isJava7() {
         return getSystemProperty("java.version").startsWith("1.7");
     }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest.java?rev=1610406&r1=1610405&r2=1610406&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/MissingPermissionsTest.java
Mon Jul 14 13:17:06 2014
@@ -226,16 +226,21 @@ public class MissingPermissionsTest exte
         assertTrue(
             spawned.getFailMessage("subprocess run failed: "), exitCode == 0);
 
-        final String expectedMessageOnConsole =
-                "The file or directory system/nested could not be created " +
-                "due to a security exception: " +
-                "java.security.AccessControlException: access denied " +
-                "(\"java.io.FilePermission\" \"system/nested\" \"write\").";
+        final String expectedMessageOnConsole = isJava6() ?
+            "The file or directory system/nested could not be created " +
+            "due to a security exception: " +
+            "java.security.AccessControlException: access denied " +
+            "(java.io.FilePermission system/nested write)."
+            :
+            "The file or directory system/nested could not be created " +
+            "due to a security exception: " +
+            "java.security.AccessControlException: access denied " +
+            "(\"java.io.FilePermission\" \"system/nested\" \"write\").";
 
         final String output = spawned.getFullServerOutput(); // ignore
         final String err    = spawned.getFullServerError();
 
-        assertTrue(err.contains(expectedMessageOnConsole));
+        assertTrue( err, err.contains( expectedMessageOnConsole ) );
     }
 
     private String makeMessage(String property) {
@@ -243,14 +248,22 @@ public class MissingPermissionsTest exte
         sb.append("WARNING: the property ");
         sb.append(property);
         sb.append(" could not be read due to a security exception: ");
-        sb.append("java.security.AccessControlException: access denied (\"");
-        sb.append("java.util.PropertyPermission\" ");
-        sb.append("\"");
-        sb.append(property);
-        sb.append("\" \"read\")");
+        sb.append("java.security.AccessControlException: access denied (");
+        sb.append( doubleQuoteIfNotJava6( "java.util.PropertyPermission" ) );
+        sb.append(" ");
+        sb.append( doubleQuoteIfNotJava6( property ) );
+        sb.append(" ");
+        sb.append( doubleQuoteIfNotJava6( "read" ) );
         return sb.toString();
     }
 
+    private String  doubleQuoteIfNotJava6( String text )
+    {
+        if ( isJava6() ) { return text; }
+        else { return "\"" + text + "\""; }
+    }
+    
+
 
     private void verifyMessagesInDerbyLog(int kind) throws
             FileNotFoundException,



Mime
View raw message