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 ka...@apache.org on 2013/05/31 09:41:02 UTC

svn commit: r1488121 - in /db/derby/code/branches/10.8: ./ java/client/org/apache/derby/client/net/ java/testing/org/apache/derbyTesting/functionTests/tests/lang/ java/testing/org/apache/derbyTesting/junit/

Author: kahatlen
Date: Fri May 31 07:41:02 2013
New Revision: 1488121

URL: http://svn.apache.org/r1488121
Log:
DERBY-6233: XMLBindingTest fails on latest JDK 8 EA

Merged revision 1488116 from trunk.

Modified:
    db/derby/code/branches/10.8/   (props changed)
    db/derby/code/branches/10.8/java/client/org/apache/derby/client/net/NetCursor.java   (props changed)
    db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/XMLBindingTest.java
    db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/junit/SystemPropertyTestSetup.java

Propchange: db/derby/code/branches/10.8/
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk:r1488116

Propchange: db/derby/code/branches/10.8/java/client/org/apache/derby/client/net/NetCursor.java
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk/java/client/org/apache/derby/client/net/NetCursor.java:r1488116

Modified: db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/XMLBindingTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/XMLBindingTest.java?rev=1488121&r1=1488120&r2=1488121&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/XMLBindingTest.java (original)
+++ db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/XMLBindingTest.java Fri May 31 07:41:02 2013
@@ -21,12 +21,9 @@
 
 package org.apache.derbyTesting.functionTests.tests.lang;
 
-import java.io.InputStreamReader;
-
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
-import java.sql.Statement;
 import java.sql.Types;
 
 import junit.framework.Test;
@@ -37,6 +34,7 @@ import org.apache.derbyTesting.junit.XML
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
 import org.apache.derbyTesting.junit.BaseJDBCTestSetup;
 import org.apache.derbyTesting.junit.SupportFilesSetup;
+import org.apache.derbyTesting.junit.SystemPropertyTestSetup;
 import org.apache.derbyTesting.junit.TestConfiguration;
 
 /**
@@ -78,18 +76,27 @@ public class XMLBindingTest extends Base
              * database before the embedded and client suites.  This ensures
              * that we do not remove the objects created by XBindTestSetup.
              */
-            suite.addTest(
-                TestConfiguration.defaultSuite(XMLBindingTest.class, false));
+            Test test =
+                TestConfiguration.defaultSuite(XMLBindingTest.class, false);
 
-            XBindTestSetup wrapper = new XBindTestSetup(suite);
+            test = new XBindTestSetup(test);
 
             /* XML parser needs to read "personal.dtd" for schema-based
              * insertion, so copy it to user directory.
              */
-            return new SupportFilesSetup(wrapper,
+            test = new SupportFilesSetup(test,
                 new String [] {
                     "functionTests/tests/lang/xmlTestFiles/personal.dtd"
                 });
+
+            // JEP 185 (http://openjdk.java.net/jeps/185) in Java SE 8 added
+            // restrictions on access to external resources. This system
+            // property loosens the restriction so that the XML parser is
+            // allowed to read the DTD.
+            test = SystemPropertyTestSetup.singleProperty(
+                    test, "javax.xml.accessExternalDTD", "file");
+
+            suite.addTest(test);
         }
 
         return suite;
@@ -266,8 +273,8 @@ public class XMLBindingTest extends Base
      */
     private static class XBindTestSetup extends BaseJDBCTestSetup
     {
-        public XBindTestSetup(TestSuite tSuite) {
-            super(tSuite);
+        public XBindTestSetup(Test test) {
+            super(test);
         }
 
         /**

Modified: db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/junit/SystemPropertyTestSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/junit/SystemPropertyTestSetup.java?rev=1488121&r1=1488120&r2=1488121&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/junit/SystemPropertyTestSetup.java (original)
+++ db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/junit/SystemPropertyTestSetup.java Fri May 31 07:41:02 2013
@@ -68,6 +68,31 @@ public class SystemPropertyTestSetup ext
 		this.newValues = newValues;
 		this.staticProperties = false;
 	}
+
+    /**
+     * Decorate a test so that it sets a single system property in
+     * {@code setUp()} and resets it in {@code tearDown()}. The engine is
+     * not shut down after the property is set.
+     */
+    public static Test singleProperty(Test test, String property, String value)
+    {
+        return singleProperty(test, property, value, false);
+    }
+
+    /**
+     * Decorate a test so that it sets a single system property in
+     * {@code setUp()} and resets it in {@code tearDown()}. The engine is
+     * shut down after the property is set if {@code staticProperty} is
+     * {@code true}.
+     */
+    public static Test singleProperty(Test test, String property, String value,
+            boolean staticProperty)
+    {
+        Properties properties = new Properties();
+        properties.setProperty(property, value);
+        return new SystemPropertyTestSetup(test, properties, staticProperty);
+    }
+
 	/**
 	 * For each property store the current value and
 	 * replace it with the new value, unless there is no change.