--- old/src/java.xml/share/classes/javax/xml/catalog/CatalogFeatures.java 2016-04-27 15:43:30.968446369 -0700 +++ new/src/java.xml/share/classes/javax/xml/catalog/CatalogFeatures.java 2016-04-27 15:43:30.892442583 -0700 @@ -444,13 +444,15 @@ } } else if (index == Feature.FILES.ordinal()) { try { - if (Util.verifyAndGetURI(value, null) == null) { - CatalogMessages.reportIAE(new Object[]{value, Feature.FILES.name()}, null); + String[] catalogFile = value.split(";[ ]*"); + for (String temp : catalogFile) { + if (Util.verifyAndGetURI(temp, null) == null) { + CatalogMessages.reportIAE(new Object[]{value, Feature.FILES.name()}, null); + } } }catch (MalformedURLException | URISyntaxException | IllegalArgumentException ex) { CatalogMessages.reportIAE(new Object[]{value, Feature.FILES.name()}, ex); } - } if (states[index] == null || state.compareTo(states[index]) >= 0) { values[index] = value; --- old/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java 2016-04-27 15:43:31.248460324 -0700 +++ new/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java 2016-04-27 15:43:31.172456536 -0700 @@ -23,6 +23,7 @@ package catalog; import java.io.IOException; +import java.nio.file.Paths; import javax.xml.catalog.Catalog; import javax.xml.catalog.CatalogException; import javax.xml.catalog.CatalogFeatures; @@ -34,6 +35,7 @@ import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.testng.Assert; +import org.testng.annotations.BeforeClass; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import org.xml.sax.Attributes; @@ -44,10 +46,49 @@ import org.xml.sax.ext.DefaultHandler2; /* - * @bug 8081248, 8144966, 8146606, 8146237, 8151154, 8150969, 8151162, 8152527 + * @bug 8081248, 8144966, 8146606, 8146237, 8151154, 8150969, 8151162, 8152527, 8154220 * @summary Tests basic Catalog functions. */ public class CatalogTest { + static final String KEY_FILES = "javax.xml.catalog.files"; + + public String filepath; + + /* + * Initializing fields + */ + @BeforeClass + public void setUpClass() throws Exception { + String file1 = getClass().getResource("first_cat.xml").getFile(); + if (System.getProperty("os.name").contains("Windows")) { + filepath = file1.substring(1, file1.lastIndexOf("/") + 1); + } else { + filepath = file1.substring(0, file1.lastIndexOf("/") + 1); + } + } + + /* + * @bug 8154220 + * Verifies that the file input is validated properly. Valid input includes + * multiple file paths separated by semicolon. + */ + @Test(dataProvider = "hierarchyOfCatFilesData") + public void hierarchyOfCatFiles2(String systemId, String expectedUri) { + String file1 = getClass().getResource("first_cat.xml").getFile(); + String file2 = getClass().getResource("second_cat.xml").getFile(); + String files = file1 + ";" + file2; + + try { + System.setProperty(KEY_FILES, files); + CatalogResolver catalogResolver = CatalogManager.catalogResolver(CatalogFeatures.defaults()); + String sysId = catalogResolver.resolveEntity(null, systemId).getSystemId(); + Assert.assertEquals(sysId, Paths.get(filepath + expectedUri).toUri().toString().replace("///", "/"), "System ID match not right"); + } finally { + System.clearProperty(KEY_FILES); + } + + } + /* * @bug 8152527 * This test is the same as the JDK test ResolveEntityTests:testMatch1. @@ -289,6 +330,19 @@ } /* + DataProvider: used to verify hierarchical catalogs. Refer to JCK test + hierarchyOfCatFiles2. + */ + @DataProvider(name = "hierarchyOfCatFilesData") + Object[][] getHierarchyOfCatFilesData() { + return new Object[][]{ + {"http://www.oracle.com/sequence.dtd", "first.dtd"}, + {"http://www.oracle.com/sequence_next.dtd", "next.dtd"}, + {"http://www.oracle.com/sequence_second.dtd", "second.dtd"} + }; + } + + /* DataProvider: used to verify CatalogResolver's resolveEntity function. Data columns: catalog, prefer, systemId, publicId, expectedUri, expectedFile, msg @@ -300,6 +354,7 @@ {"rewriteSystem_id.xml", "system", "http://www.sys00test.com/rewrite.dtd", "PUB-404", expected, expected, "Relative rewriteSystem with xml:base at group level failed"}, }; } + static String id = "http://openjdk.java.net/xml/catalog/dtd/system.dtd"; /* DataProvider: used to verify how prefer settings affect the result of the --- /dev/null 2016-04-26 09:24:45.888145998 -0700 +++ new/test/javax/xml/jaxp/unittest/catalog/first_cat.xml 2016-04-27 15:43:31.452470491 -0700 @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file --- /dev/null 2016-04-26 09:24:45.888145998 -0700 +++ new/test/javax/xml/jaxp/unittest/catalog/next_cat.xml 2016-04-27 15:43:31.700482852 -0700 @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file --- /dev/null 2016-04-26 09:24:45.888145998 -0700 +++ new/test/javax/xml/jaxp/unittest/catalog/second_cat.xml 2016-04-27 15:43:31.944495013 -0700 @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file