mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 19:14:38 +02:00
8146237: PREFER from Features API taking precedence over catalog file
Reviewed-by: lancea
This commit is contained in:
parent
ca3da12f5a
commit
ffa5558ae1
3 changed files with 35 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -184,11 +184,14 @@ class CatalogReader extends DefaultHandler implements EntityResolver, URIResolve
|
||||||
if (resolve == null) {
|
if (resolve == null) {
|
||||||
resolve = catalog.getResolve().literal;
|
resolve = catalog.getResolve().literal;
|
||||||
}
|
}
|
||||||
|
//override property settings with those from the catalog file
|
||||||
catalog.setResolve(resolve);
|
catalog.setResolve(resolve);
|
||||||
|
catalog.setPrefer(defer);
|
||||||
catalogEntry = new CatalogEntry(base, prefer, defer, resolve);
|
catalogEntry = new CatalogEntry(base, prefer, defer, resolve);
|
||||||
} else {
|
} else {
|
||||||
catalogEntry = new CatalogEntry(base, prefer);
|
catalogEntry = new CatalogEntry(base, prefer);
|
||||||
}
|
}
|
||||||
|
catalog.setPrefer(prefer);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
inGroup = true;
|
inGroup = true;
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
package catalog;
|
package catalog;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import javax.xml.catalog.Catalog;
|
||||||
import javax.xml.catalog.CatalogFeatures;
|
import javax.xml.catalog.CatalogFeatures;
|
||||||
import javax.xml.catalog.CatalogFeatures.Feature;
|
import javax.xml.catalog.CatalogFeatures.Feature;
|
||||||
import javax.xml.catalog.CatalogManager;
|
import javax.xml.catalog.CatalogManager;
|
||||||
|
@ -41,15 +42,36 @@ import org.xml.sax.XMLReader;
|
||||||
import org.xml.sax.ext.DefaultHandler2;
|
import org.xml.sax.ext.DefaultHandler2;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @bug 8081248, 8144966, 8146606
|
* @bug 8081248, 8144966, 8146606, 8146237
|
||||||
* @summary Tests basic Catalog functions.
|
* @summary Tests basic Catalog functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class CatalogTest {
|
public class CatalogTest {
|
||||||
|
/**
|
||||||
|
* @bug 8146237
|
||||||
|
* PREFER from Features API taking precedence over catalog file
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testJDK8146237() {
|
||||||
|
String catalogFile = getClass().getResource("JDK8146237_catalog.xml").getFile();
|
||||||
|
|
||||||
|
try {
|
||||||
|
CatalogFeatures features = CatalogFeatures.builder().with(CatalogFeatures.Feature.PREFER, "system").build();
|
||||||
|
Catalog catalog = CatalogManager.catalog(features, catalogFile);
|
||||||
|
CatalogResolver catalogResolver = CatalogManager.catalogResolver(catalog);
|
||||||
|
String actualSystemId = catalogResolver.resolveEntity("-//FOO//DTD XML Dummy V0.0//EN", "http://www.oracle.com/alt1sys.dtd").getSystemId();
|
||||||
|
Assert.assertTrue(actualSystemId.contains("dummy.dtd"), "Resulting id should contain dummy.dtd, indicating a match by publicId");
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
Assert.fail(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@bug 8146606
|
@bug 8146606
|
||||||
Verifies that the resulting systemId does not contain duplicate slashes
|
Verifies that the resulting systemId does not contain duplicate slashes
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testRewriteSystem() {
|
public void testRewriteSystem() {
|
||||||
String catalog = getClass().getResource("rewriteCatalog.xml").getFile();
|
String catalog = getClass().getResource("rewriteCatalog.xml").getFile();
|
||||||
|
|
||||||
|
@ -67,6 +89,7 @@ public class CatalogTest {
|
||||||
@bug 8146606
|
@bug 8146606
|
||||||
Verifies that the resulting systemId does not contain duplicate slashes
|
Verifies that the resulting systemId does not contain duplicate slashes
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testRewriteUri() {
|
public void testRewriteUri() {
|
||||||
String catalog = getClass().getResource("rewriteCatalog.xml").getFile();
|
String catalog = getClass().getResource("rewriteCatalog.xml").getFile();
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<catalog prefer="public" xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
|
||||||
|
|
||||||
|
<public publicId="-//FOO//DTD XML Dummy V0.0//EN"
|
||||||
|
uri="dummy.dtd"/>
|
||||||
|
</catalog>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue