# HG changeset patch # User joehw # Date 1460676964 25200 # Node ID 04a4a89d81b9e1239802a14ee906c5b47b695939 # Parent efd79368977b521b492eb74dc97c1cb563c296c1 8152527: Relative rewriteSystem with xml:base at group level failed Reviewed-by: lancea diff -r efd79368977b -r 04a4a89d81b9 jaxp/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java Thu Apr 14 09:33:48 2016 -0700 +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java Thu Apr 14 16:36:04 2016 -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; diff -r efd79368977b -r 04a4a89d81b9 jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java Thu Apr 14 09:33:48 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java Thu Apr 14 16:36:04 2016 -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 diff -r efd79368977b -r 04a4a89d81b9 jaxp/test/javax/xml/jaxp/unittest/catalog/rewriteSystem_id.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/rewriteSystem_id.xml Thu Apr 14 16:36:04 2016 -0700 @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + +