--- old/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java 2016-04-13 13:26:50.800470456 -0700 +++ new/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java 2016-04-13 13:26:50.640462501 -0700 @@ -249,8 +249,10 @@ //use it if there is a match of the system type return match; } else if (grpEntry.longestRewriteMatch > longestRewriteMatch) { + longestRewriteMatch = grpEntry.longestRewriteMatch; rewriteMatch = match; } else if (grpEntry.longestSuffixMatch > longestSuffixMatch) { + longestSuffixMatch = grpEntry.longestSuffixMatch; suffixMatch = match; } break; --- old/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java 2016-04-13 13:26:52.552557561 -0700 +++ new/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java 2016-04-13 13:26:52.448552390 -0700 @@ -38,16 +38,34 @@ import org.testng.annotations.Test; import org.xml.sax.Attributes; import org.xml.sax.ErrorHandler; +import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import org.xml.sax.ext.DefaultHandler2; /* - * @bug 8081248, 8144966, 8146606, 8146237, 8151154, 8150969, 8151162 + * @bug 8081248, 8144966, 8146606, 8146237, 8151154, 8150969, 8151162, 8152527 * @summary Tests basic Catalog functions. */ public class CatalogTest { /* + * @bug 8152527 + * This test is the same as the JDK test ResolveEntityTests:testMatch1. + * Verifies that the CatalogResolver resolves a publicId and/or systemId as + * expected. + */ + @Test(dataProvider = "resolveEntity") + public void testMatch1(String cfile, String prefer, String sysId, String pubId, String expectedUri, String expectedFile, String msg) { + String catalogFile = getClass().getResource(cfile).getFile(); + CatalogFeatures features = CatalogFeatures.builder().with(CatalogFeatures.Feature.PREFER, prefer).build(); + CatalogResolver catalogResolver = CatalogManager.catalogResolver(features, catalogFile); + InputSource is = catalogResolver.resolveEntity(pubId, sysId); + Assert.assertNotNull(is, msg); + String expected = (expectedUri == null) ? expectedFile : expectedUri; + Assert.assertEquals(expected, is.getSystemId(), msg); + } + + /* * @bug 8151162 * Verifies that the Catalog matches specified publicId or systemId and returns * results as expected. @@ -270,6 +288,18 @@ } } + /* + DataProvider: used to verify CatalogResolver's resolveEntity function. + Data columns: + catalog, prefer, systemId, publicId, expectedUri, expectedFile, msg + */ + @DataProvider(name = "resolveEntity") + Object[][] getDataForMatchingBothIds() { + String expected = "http://www.groupxmlbase.com/dtds/rewrite.dtd"; + return new Object[][]{ + {"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-01-15 19:44:37.354334997 -0800 +++ new/test/javax/xml/jaxp/unittest/catalog/rewriteSystem_id.xml 2016-04-13 13:26:52.832571482 -0700 @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + +