Merge
authorlana
Thu, 07 Apr 2016 11:03:17 -0700
changeset 36985 453a9cb3ecdf
parent 36983 30735eb1ecaf (current diff)
parent 36984 4d76e25cb8d3 (diff)
child 36986 a9e6c29ad4c7
Merge
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogReader.java	Thu Apr 07 10:07:00 2016 -0700
+++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogReader.java	Thu Apr 07 11:03:17 2016 -0700
@@ -186,7 +186,7 @@
                     }
                     //override property settings with those from the catalog file
                     catalog.setResolve(resolve);
-                    catalog.setPrefer(defer);
+                    catalog.setDeferred(defer);
                     catalogEntry = new CatalogEntry(base, prefer, defer, resolve);
                 } else {
                     catalogEntry = new CatalogEntry(base, prefer);
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java	Thu Apr 07 10:07:00 2016 -0700
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java	Thu Apr 07 11:03:17 2016 -0700
@@ -24,6 +24,7 @@
 
 import java.io.IOException;
 import javax.xml.catalog.Catalog;
+import javax.xml.catalog.CatalogException;
 import javax.xml.catalog.CatalogFeatures;
 import javax.xml.catalog.CatalogFeatures.Feature;
 import javax.xml.catalog.CatalogManager;
@@ -42,11 +43,29 @@
 import org.xml.sax.ext.DefaultHandler2;
 
 /*
- * @bug 8081248, 8144966, 8146606, 8146237, 8151154
+ * @bug 8081248, 8144966, 8146606, 8146237, 8151154, 8150969
  * @summary Tests basic Catalog functions.
  */
 public class CatalogTest {
     /**
+     * @bug 8150969
+     * Verifies that the defer attribute set in the catalog file takes precedence
+     * over other settings, in which case, whether next and delegate Catalogs will
+     * be loaded is determined by the defer attribute.
+     */
+    @Test(dataProvider = "invalidAltCatalogs", expectedExceptions = CatalogException.class)
+    public void testDeferAltCatalogs(String file) {
+        String catalogFile = getClass().getResource(file).getFile();
+        CatalogFeatures features = CatalogFeatures.builder().with(CatalogFeatures.Feature.DEFER, "true").build();
+        /*
+          Since the defer attribute is set to false in the specified catalog file,
+          the parent catalog will try to load the alt catalog, which will fail
+          since it points to an invalid catalog.
+        */
+        Catalog catalog = CatalogManager.catalog(features, catalogFile);
+    }
+
+    /**
      * @bug 8151154
      * Verifies that the CatalogFeatures' builder throws IllegalArgumentException
      * on invalid file inputs.
@@ -214,6 +233,18 @@
     }
 
     /*
+       DataProvider: catalogs that contain invalid next or delegate catalogs.
+                     The defer attribute is set to false.
+     */
+    @DataProvider(name = "invalidAltCatalogs")
+    Object[][] getCatalogs() {
+        return new Object[][]{
+            {"defer_false_2.xml"},
+            {"defer_del_false.xml"}
+        };
+    }
+
+    /*
        DataProvider: for testing the verification of file paths by
                      the CatalogFeatures builder
      */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/bad_cat.xml	Thu Apr 07 11:03:17 2016 -0700
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
+    <public
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/defer_del_false.xml	Thu Apr 07 11:03:17 2016 -0700
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" defer="false">
+    <delegatePublic publicIdStartString="DELEGATE-DEFER" catalog="bad_cat.xml"/>
+    <!--<nextCatalog catalog="file_cat.xml"/>-->
+</catalog>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/defer_false_2.xml	Thu Apr 07 11:03:17 2016 -0700
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" defer="false">
+    <nextCatalog catalog="bad_cat.xml"/>
+    <!--<nextCatalog catalog="file_cat.xml"/>-->
+</catalog>
+