db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abr...@apache.org
Subject svn commit: r478336 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: functionTests/suites/XMLSuite.java functionTests/tests/lang/XMLBindingTest.java functionTests/tests/lang/_Suite.java junit/SecurityManagerSetup.java
Date Wed, 22 Nov 2006 21:47:24 GMT
Author: abrown
Date: Wed Nov 22 13:47:23 2006
New Revision: 478336

URL: http://svn.apache.org/viewvc?view=rev&rev=478336
Log:
DERBY-1758 (partial):

  1. Updates XMLBindingTest to ignore the Windows line-ending character
     ("\r") when counting characters as part of serialization.

  2. Updates XMLBindingTest to run with NO security manager for now.
     This works toward the "progress not perfection" goal of incremental
     development.  Once the questions surrounding the security policy for
     JAXP have been answered the test can be updated to run with the security
     manager.

  3. Creates a new JUnit suite, suites/XMLSuite.java, to run all of the
     XML JUnit tests, and enables that suite to run as part of
     lang/_Suite.java, which in turn means it is executed as part
     suites.All.

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/XMLSuite.java
  (with props)
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/XMLBindingTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/XMLSuite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/XMLSuite.java?view=auto&rev=478336
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/XMLSuite.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/XMLSuite.java
Wed Nov 22 13:47:23 2006
@@ -0,0 +1,54 @@
+/*
+ *
+ * Derby - Class org.apache.derbyTesting.functionTests.suites.XMLSuite
+ *
+ * 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.suites;
+
+import org.apache.derbyTesting.junit.BaseTestCase;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Run all of the XML JUnit tests as a single suite.
+ */
+public final class XMLSuite extends BaseTestCase {
+
+    /**
+     * Use suite method instead.
+     */
+    private XMLSuite(String name)
+    {
+        super(name);
+    }
+
+    /**
+     * Return the suite that runs the XML tests.
+     */
+    public static Test suite()
+    {
+        TestSuite suite = new TestSuite("XML Suite");
+        
+        // Add all JUnit tests for XML.
+        suite.addTest(org.apache.derbyTesting.functionTests.tests.lang.XMLTypeAndOpsTest.suite());
+        suite.addTest(org.apache.derbyTesting.functionTests.tests.lang.XMLBindingTest.suite());
+        suite.addTest(org.apache.derbyTesting.functionTests.tests.lang.XMLMissingClassesTest.suite());
+        
+        return suite;
+    }
+}

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

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/XMLBindingTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/XMLBindingTest.java?view=diff&rev=478336&r1=478335&r2=478336
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/XMLBindingTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/XMLBindingTest.java
Wed Nov 22 13:47:23 2006
@@ -30,6 +30,7 @@
 import java.sql.Types;
 
 import junit.framework.Test;
+import junit.extensions.TestSetup;
 import junit.framework.TestSuite;
 
 import org.apache.derbyTesting.junit.JDBC;
@@ -37,6 +38,7 @@
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
 import org.apache.derbyTesting.junit.BaseJDBCTestSetup;
 import org.apache.derbyTesting.junit.BaseTestCase;
+import org.apache.derbyTesting.junit.SecurityManagerSetup;
 import org.apache.derbyTesting.junit.SupportFilesSetup;
 import org.apache.derbyTesting.junit.TestConfiguration;
 
@@ -82,15 +84,25 @@
             suite.addTest(
                 TestConfiguration.defaultSuite(XMLBindingTest.class, false));
 
-            XBindTestSetup wrapper = new XBindTestSetup(suite);
+            TestSetup wrapper = new XBindTestSetup(suite);
 
             /* XML parser needs to read "personal.dtd" for schema-based
              * insertion, so copy it to user directory.
              */
-            return new SupportFilesSetup(wrapper,
+            wrapper = new SupportFilesSetup(wrapper,
                 new String [] {
                     "functionTests/tests/lang/xmlTestFiles/personal.dtd"
                 });
+
+            /* RESOLVE: In order to run XMLBindingTest as part of a
+             * suite we currently have to disable the security manager
+             * to allow the JAXP parser to read DTD files.  Once we
+             * figure out how to give JAXP the correct permissions
+             * in the derby_tests policy file, we can then remove the
+             * "noSecurityManager()" decoration. See comments in
+             * DERBY-1758 for details.
+             */
+            return SecurityManagerSetup.noSecurityManager(wrapper);
         }
 
         return suite;
@@ -138,7 +150,7 @@
         // into xTable.t1 as part of XBindTestSetup setup.  A "0"
         // means empty string; a "-1" means we inserted a null.
         int [] expectedCharCounts =
-            new int [] { 40869, 40375, 1199, 1187, 1218, 954, 22, -1, -1 };
+            new int [] { 39441, 37925, 1161, 1155, 1180, 922, 22, -1, -1 };
 
         int rowCount = 0;
         ResultSet rs = createStatement().executeQuery(
@@ -152,7 +164,17 @@
             // Count the number of characters we read back.
             if (!rs.wasNull())
             {
-                for (charCount = 0; xResult.read() != -1; charCount++);
+                int ch = xResult.read();
+                for (charCount = 0; ch != -1; ch = xResult.read())
+                {
+                    /* Xalan serialization produces platform-specific line-
+                     * endings (DERBY-2106), which can throw off the character
+                     * count on Windows.  So if we see the Windows '\r' char
+                     * we do not count it.
+                     */
+                    if ((char)ch != '\r')
+                        charCount++;
+                }
                 xResult.close();
             }
             else

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java?view=diff&rev=478336&r1=478335&r2=478336
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
Wed Nov 22 13:47:23 2006
@@ -21,6 +21,7 @@
 */
 package org.apache.derbyTesting.functionTests.tests.lang;
 
+import org.apache.derbyTesting.functionTests.suites.XMLSuite;
 import org.apache.derbyTesting.functionTests.tests.nist.NistScripts;
 import org.apache.derbyTesting.junit.BaseTestCase;
 import org.apache.derbyTesting.junit.JDBC;
@@ -69,9 +70,11 @@
         suite.addTest(SQLAuthorizationPropTest.suite());
         suite.addTest(TimeHandlingTest.suite());
         suite.addTest(VTITest.suite());
-        suite.addTest(XMLTypeAndOpsTest.suite());
-        suite.addTest(XMLMissingClassesTest.suite());
-        
+
+        // Add the XML tests, which exist as a separate suite
+        // so that users can "run all XML tests" easily.
+        suite.addTest(XMLSuite.suite());
+         
         // Add the NIST suite in from the nist package since
         // it is a SQL language related test.
         suite.addTest(NistScripts.suite());

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java?view=diff&rev=478336&r1=478335&r2=478336
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java
Wed Nov 22 13:47:23 2006
@@ -83,6 +83,17 @@
 		return new SecurityManagerSetup(test, "<NONE>");
 	}
 	
+    /**
+     * Same as noSecurityManager() above but takes a TestSetup
+     * instead of a BaseTestCase.
+     */
+    public static Test noSecurityManager(TestSetup tSetup)
+    {
+		if (externalSecurityManagerInstalled)
+			return new TestSuite();
+		return new SecurityManagerSetup(tSetup, "<NONE>");
+    }
+
 	/**
 	 * Install a SecurityManager with the default test policy
 	 * file:



Mime
View raw message