mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 19:14:38 +02:00
8152527: Relative rewriteSystem with xml:base at group level failed
Reviewed-by: lancea
This commit is contained in:
parent
274668112d
commit
7cd550290a
3 changed files with 58 additions and 1 deletions
|
@ -249,8 +249,10 @@ class GroupEntry extends BaseEntry {
|
|||
//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;
|
||||
|
|
|
@ -38,15 +38,33 @@ import org.testng.annotations.DataProvider;
|
|||
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
|
||||
|
@ -270,6 +288,18 @@ public class CatalogTest {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
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
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" xml:base="http://local/base/dtd/">
|
||||
<rewriteSystem systemIdStartString="http://remote/dtd/alice/" rewritePrefix="http://local/dtd/alice/rs/" />
|
||||
|
||||
<rewriteSystem systemIdStartString="http://remote/dtd/bob/" rewritePrefix="bob/rs/" />
|
||||
|
||||
<rewriteSystem systemIdStartString="http://remote/dtd/carl/" rewritePrefix="carl/rs/"
|
||||
xml:base="http://local/carlBase/dtd/" />
|
||||
|
||||
<rewriteSystem systemIdStartString="http://remote/dtd/david/" rewritePrefix="david1/rs/" />
|
||||
<rewriteSystem systemIdStartString="http://remote/dtd/david/" rewritePrefix="david2/rs/" />
|
||||
|
||||
<rewriteSystem systemIdStartString="http://remote/dtd/" rewritePrefix="ella/" />
|
||||
<rewriteSystem systemIdStartString="http://remote/dtd/ella/" rewritePrefix="ella/rs/" />
|
||||
|
||||
<rewriteSystem systemIdStartString="http://remote.com/"
|
||||
rewritePrefix="file:///share/doctypes/dtd/fail/"/>
|
||||
<rewriteSystem systemIdStartString="http://remote.com/dtd"
|
||||
rewritePrefix="file:///share/docbook/docbook/pass"/>
|
||||
|
||||
<group xml:base="http://www.groupxmlbase.com/">
|
||||
<rewriteSystem systemIdStartString="http://www.sys00test.com" rewritePrefix="dtds"/>
|
||||
</group>
|
||||
</catalog>
|
Loading…
Add table
Add a link
Reference in a new issue