2222 */
2323package common .jdkcatalog ;
2424
25- import static jaxp .library .JAXPTestUtilities .SRC_DIR ;
26- import static jaxp .library .JAXPTestUtilities .isWindows ;
27-
2825import java .io .StringReader ;
26+ import java .net .URI ;
2927import java .nio .file .Files ;
3028import java .nio .file .Path ;
3129import java .nio .file .Paths ;
3230import java .util .stream .Collectors ;
3331import javax .xml .XMLConstants ;
3432import javax .xml .catalog .Catalog ;
3533import javax .xml .catalog .CatalogFeatures ;
34+ import javax .xml .catalog .CatalogManager ;
3635import javax .xml .parsers .SAXParserFactory ;
3736import javax .xml .transform .sax .SAXSource ;
3837import javax .xml .validation .SchemaFactory ;
3938import javax .xml .validation .Validator ;
40- import jdk . xml . internal . JdkCatalog ;
39+ import jaxp . library . JAXPTestUtilities ;
4140import org .testng .Assert ;
4241import org .testng .Assert .ThrowingRunnable ;
4342import org .testng .annotations .DataProvider ;
5049/*
5150 * @test
5251 * @bug 8344800 8345353 8351969
53- * @modules java.xml/jdk.xml.internal
5452 * @library /javax/xml/jaxp/libs
5553 * @run testng/othervm common.jdkcatalog.JDKCatalogTest
5654 * @summary Verifies the W3C DTDs and XSDs in the JDK built-in catalog.
@@ -62,11 +60,9 @@ public class JDKCatalogTest {
6260 private static final String XSD_LOCATION = "{{SCHEMA_LOCATION}}" ;
6361 private static final String TARGET_NAMESPACE = "{{targetNamespace}}" ;
6462 private static final String ROOT_ELEMENT = "{{rootElement}}" ;
65- private static final Catalog JDKCATALOG ;
66- static {
67- JdkCatalog .init ("continue" );
68- JDKCATALOG = JdkCatalog .catalog ;
69- }
63+ private static final String JDKCATALOG_URL = "jrt:/java.xml/jdk/xml/internal/jdkcatalog/JDKCatalog.xml" ;
64+
65+ private Catalog catalog = CatalogManager .catalog (CatalogFeatures .defaults (), URI .create (JDKCATALOG_URL ));
7066
7167 /*
7268 * DataProvider: DTDs in the JDK built-in Catalog
@@ -139,8 +135,8 @@ public Object[][] getXSD() throws Exception {
139135 */
140136 @ Test (dataProvider = "DTDsInJDKCatalog" )
141137 public void testDTDsInJDKCatalog (String publicId , String systemId ) {
142- String matchingPubId = JDKCATALOG .matchPublic (publicId );
143- String matchingSysId = JDKCATALOG .matchSystem (systemId );
138+ String matchingPubId = catalog .matchPublic (publicId );
139+ String matchingSysId = catalog .matchSystem (systemId );
144140 Assert .assertEquals (matchingPubId , matchingSysId );
145141 }
146142
@@ -184,10 +180,10 @@ public void testExternalDTD(String publicId, String systemId, Class<Throwable> e
184180 public void testXSD (String xmlTemplate , String xsdLocation , String targetNS , String rootElement , String catalog ,
185181 Class <Throwable > expectedThrow )
186182 throws Exception {
187- String xmlSrcPath = SRC_DIR + "/" + xmlTemplate ;
183+ String xmlSrcPath = JAXPTestUtilities . SRC_DIR + "/" + xmlTemplate ;
188184 final String xmlSrcId = getSysId (xmlSrcPath );
189185
190- final String customCatalog = getSysId ((catalog != null ) ? SRC_DIR + "/" + catalog : null );
186+ final String customCatalog = getSysId ((catalog != null ) ? JAXPTestUtilities . SRC_DIR + "/" + catalog : null );
191187
192188 final String xmlString = generateXMLWithXSDRef (xmlSrcPath , xsdLocation ,
193189 targetNS , rootElement );
@@ -245,7 +241,7 @@ public void parseWithResolveStrict(String xml)
245241 */
246242 private String generateXMLWithDTDRef (String publicId , String systemId )
247243 throws Exception {
248- Path path = Paths .get (SRC_DIR + "/dtdtest.xml" );
244+ Path path = Paths .get (JAXPTestUtilities . SRC_DIR + "/dtdtest.xml" );
249245 String xmlString = Files .lines (path ).map (line -> {
250246 line = line .replace (PUBLIC_ID , publicId );
251247 line = line .replace (SYSTEM_ID , systemId );
@@ -287,7 +283,7 @@ private String generateXMLWithXSDRef(String xmlSrcPath, String xsd,
287283 private String getSysId (String path ) {
288284 if (path == null ) return null ;
289285 String xmlSysId = "file://" + path ;
290- if (isWindows ) {
286+ if (JAXPTestUtilities . isWindows ) {
291287 path = path .replace ('\\' , '/' );
292288 xmlSysId = "file:///" + path ;
293289 }
0 commit comments