jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java
changeset 36984 4d76e25cb8d3
parent 36700 3afcaff239f5
child 37382 c7d898d8da12
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java	Wed Jul 05 21:31:37 2017 +0200
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java	Wed Apr 06 14:31:38 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
      */