8215330: javax.xml.catalog.CatalogResolverImpl: GroupEntry.matchURI fails to match
Reviewed-by: lancea
This commit is contained in:
parent
0359a76b78
commit
32a556860d
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -372,8 +372,10 @@ class GroupEntry extends BaseEntry {
|
||||
return match;
|
||||
} else if (grpEntry.longestRewriteMatch > longestRewriteMatch) {
|
||||
rewriteMatch = match;
|
||||
longestRewriteMatch = grpEntry.longestRewriteMatch;
|
||||
} else if (grpEntry.longestSuffixMatch > longestSuffixMatch) {
|
||||
suffixMatch = match;
|
||||
longestSuffixMatch = grpEntry.longestSuffixMatch;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
87
test/jaxp/javax/xml/jaxp/unittest/catalog/GroupTest.java
Normal file
87
test/jaxp/javax/xml/jaxp/unittest/catalog/GroupTest.java
Normal file
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package catalog;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.file.Paths;
|
||||
import javax.xml.catalog.CatalogFeatures;
|
||||
import javax.xml.catalog.CatalogManager;
|
||||
import javax.xml.catalog.CatalogResolver;
|
||||
import javax.xml.transform.Source;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Listeners;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8215330
|
||||
* @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||||
* @run testng catalog.GroupTest
|
||||
* @summary Tests catalog with Group entries.
|
||||
*/
|
||||
@Listeners({jaxp.library.FilePolicy.class})
|
||||
public class GroupTest extends CatalogSupportBase {
|
||||
|
||||
String catalogGroup;
|
||||
/*
|
||||
* Initializing fields
|
||||
*/
|
||||
@BeforeClass
|
||||
public void setUpClass() throws Exception {
|
||||
super.setUp();
|
||||
catalogGroup = Paths.get(filepath + "GroupTest.xml").toUri().toASCIIString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests catalog resolution with entries in a group.
|
||||
*
|
||||
* @param catalog the catalog to be used
|
||||
* @param uri an URI to be resolved by the catalog
|
||||
* @param expected the expected result string
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test(dataProvider = "data_group")
|
||||
public void testGroup(String catalog, String uri, String expected) throws Exception {
|
||||
CatalogResolver resolver = CatalogManager.catalogResolver(
|
||||
CatalogFeatures.defaults(), URI.create(catalog));
|
||||
|
||||
Source src = resolver.resolve(uri, null);
|
||||
Assert.assertTrue(src.getSystemId().endsWith(expected), "uriSuffix match");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
DataProvider: for testing catalogs with group entries
|
||||
Data: catalog file, uri, expected result string
|
||||
*/
|
||||
@DataProvider(name = "data_group")
|
||||
public Object[][] getDataDOM() {
|
||||
return new Object[][]{
|
||||
{catalogGroup, "http://openjdk_java_net/xml/catalog/A/CommonFileA1.xml", "LocalFileA1.xml"},
|
||||
{catalogGroup, "http://openjdk_java_net/xml/catalog/B/CommonFileB1.xml", "LocalFileB1.xml"},
|
||||
{catalogGroup, "http://openjdk_java_net/xml/catalog/C/CommonFileC1.xml", "LocalFileC1.xml"},
|
||||
};
|
||||
}
|
||||
}
|
18
test/jaxp/javax/xml/jaxp/unittest/catalog/GroupTest.xml
Normal file
18
test/jaxp/javax/xml/jaxp/unittest/catalog/GroupTest.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"
|
||||
prefer="system" resolve="strict">
|
||||
|
||||
<uriSuffix uriSuffix="/A/CommonFileA1.xml" uri="localMirrorA/LocalFileA1.xml"/>
|
||||
|
||||
<group>
|
||||
<uriSuffix uriSuffix="/B/CommonFileB1.xml" uri="localMirrorB/LocalFileB1.xml"/>
|
||||
<uriSuffix uriSuffix="/B/CommonFileB2.xml" uri="localMirrorB/LocalFileB2.xml"/>
|
||||
</group>
|
||||
|
||||
<group baseURI="localMirrorC">
|
||||
<uriSuffix uriSuffix="/C/CommonFileC1.xml" uri="LocalFileC1.xml"/>
|
||||
<uriSuffix uriSuffix="/C/CommonFileC2.xml" uri="LocalFileC2.xml"/>
|
||||
</group>
|
||||
|
||||
</catalog>
|
||||
|
Loading…
Reference in New Issue
Block a user