19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 package catalog; 25 26 import static jaxp.library.JAXPTestUtilities.setSystemProperty; 27 28 import static catalog.CatalogTestUtils.FEATURE_FILES; 29 import static catalog.CatalogTestUtils.catalogResolver; 30 import static catalog.CatalogTestUtils.catalogUriResolver; 31 import static catalog.CatalogTestUtils.getCatalogPath; 32 import static catalog.ResolutionChecker.checkSysIdResolution; 33 import static catalog.ResolutionChecker.checkUriResolution; 34 import static javax.xml.catalog.CatalogFeatures.builder; 35 import static javax.xml.catalog.CatalogFeatures.Feature.FILES; 36 37 import javax.xml.catalog.CatalogFeatures; 38 import javax.xml.catalog.CatalogResolver; 39 import javax.xml.catalog.CatalogUriResolver; 40 41 import org.testng.annotations.Listeners; 42 import org.testng.annotations.Test; 43 44 /* 45 * @test 46 * @bug 8077931 47 * @library /javax/xml/jaxp/libs 48 * @run testng/othervm -DrunSecMngr=true catalog.SpecifyCatalogTest 49 * @run testng/othervm catalog.SpecifyCatalogTest 50 * @summary This case tests how to specify the catalog files. 51 */ 52 @Listeners({jaxp.library.FilePolicy.class}) 53 public class SpecifyCatalogTest { 54 55 private static final String ID_URI = "http://remote/dtd/uri/doc.dtd"; 56 private static final String ID_SYS = "http://remote/dtd/sys/doc.dtd"; 57 58 private static final CatalogFeatures FILES_FEATURE = createFeature( 59 "specifyCatalog-feature.xml"); 60 61 /* 62 * CatalogResolver specifies catalog via feature javax.xml.catalog.files. 63 */ 64 @Test 65 public void specifyCatalogOnEntityResolver() { 66 checkSysIdResolution(catalogResolver(FILES_FEATURE, (String[]) null), 67 ID_SYS, "http://local/base/dtd/docFeatureSys.dtd"); 68 } 69 70 /* 71 * CatalogUriResolver specifies catalog via feature javax.xml.catalog.files. 72 */ 73 @Test 74 public void specifyCatalogOnUriResolver() { 75 checkUriResolution(catalogUriResolver(FILES_FEATURE, (String[]) null), 76 ID_URI, "http://local/base/dtd/docFeatureURI.dtd"); 77 } 78 79 /* 80 * Resolver specifies catalog via system property javax.xml.catalog.files. 81 */ 82 @Test 83 public void specifyCatalogViaSysProps() { 84 setSystemProperty(FEATURE_FILES, 85 getCatalogPath("specifyCatalog-sysProps.xml")); 86 87 checkResolutionOnEntityResolver(catalogResolver((String[]) null), 88 "http://local/base/dtd/docSysPropsSys.dtd"); 89 checkResolutionOnEntityResolver( 90 catalogResolver(FILES_FEATURE, "specifyCatalog-api.xml"), 91 "http://local/base/dtd/docAPISys.dtd"); 92 93 checkResolutionOnUriResolver(catalogUriResolver((String[]) null), 94 "http://local/base/dtd/docSysPropsURI.dtd"); 95 checkResolutionOnUriResolver( 96 catalogUriResolver(FILES_FEATURE, "specifyCatalog-api.xml"), 97 "http://local/base/dtd/docAPIURI.dtd"); 98 } 99 100 private void checkResolutionOnEntityResolver(CatalogResolver resolver, 101 String matchedUri) { 102 checkSysIdResolution(resolver, ID_SYS, matchedUri); 103 } 104 105 private void checkResolutionOnUriResolver(CatalogUriResolver resolver, 106 String matchedUri) { 107 checkUriResolution(resolver, ID_URI, matchedUri); 108 } 109 110 private static CatalogFeatures createFeature(String catalogName) { 111 return builder().with(FILES, getCatalogPath(catalogName)).build(); 112 } 113 } 114 | 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 package catalog; 25 26 import static jaxp.library.JAXPTestUtilities.setSystemProperty; 27 28 import static catalog.CatalogTestUtils.FEATURE_FILES; 29 import static catalog.CatalogTestUtils.catalogResolver; 30 import static catalog.CatalogTestUtils.catalogUriResolver; 31 import static catalog.CatalogTestUtils.getCatalogPath; 32 import static catalog.ResolutionChecker.checkSysIdResolution; 33 import static catalog.ResolutionChecker.checkUriResolution; 34 import static javax.xml.catalog.CatalogFeatures.builder; 35 import static javax.xml.catalog.CatalogFeatures.Feature.FILES; 36 37 import javax.xml.catalog.CatalogFeatures; 38 import javax.xml.catalog.CatalogResolver; 39 40 import org.testng.annotations.Listeners; 41 import org.testng.annotations.Test; 42 43 /* 44 * @test 45 * @bug 8077931 46 * @library /javax/xml/jaxp/libs 47 * @run testng/othervm -DrunSecMngr=true catalog.SpecifyCatalogTest 48 * @run testng/othervm catalog.SpecifyCatalogTest 49 * @summary This case tests how to specify the catalog files. 50 */ 51 @Listeners({jaxp.library.FilePolicy.class}) 52 public class SpecifyCatalogTest { 53 54 private static final String ID_URI = "http://remote/dtd/uri/doc.dtd"; 55 private static final String ID_SYS = "http://remote/dtd/sys/doc.dtd"; 56 57 private static final CatalogFeatures FILES_FEATURE = createFeature( 58 "specifyCatalog-feature.xml"); 59 60 /* 61 * CatalogResolver specifies catalog via feature javax.xml.catalog.files. 62 */ 63 @Test 64 public void specifyCatalogOnEntityResolver() { 65 checkSysIdResolution(catalogResolver(FILES_FEATURE, (String[]) null), 66 ID_SYS, "http://local/base/dtd/docFeatureSys.dtd"); 67 } 68 69 /* 70 * CatalogResolver specifies catalog via feature javax.xml.catalog.files. 71 */ 72 @Test 73 public void specifyCatalogOnUriResolver() { 74 checkUriResolution(catalogUriResolver(FILES_FEATURE, (String[]) null), 75 ID_URI, "http://local/base/dtd/docFeatureURI.dtd"); 76 } 77 78 /* 79 * Resolver specifies catalog via system property javax.xml.catalog.files. 80 */ 81 @Test 82 public void specifyCatalogViaSysProps() { 83 setSystemProperty(FEATURE_FILES, 84 getCatalogPath("specifyCatalog-sysProps.xml")); 85 86 checkResolutionOnEntityResolver(catalogResolver((String[]) null), 87 "http://local/base/dtd/docSysPropsSys.dtd"); 88 checkResolutionOnEntityResolver( 89 catalogResolver(FILES_FEATURE, "specifyCatalog-api.xml"), 90 "http://local/base/dtd/docAPISys.dtd"); 91 92 checkResolutionOnUriResolver(catalogUriResolver((String[]) null), 93 "http://local/base/dtd/docSysPropsURI.dtd"); 94 checkResolutionOnUriResolver( 95 catalogUriResolver(FILES_FEATURE, "specifyCatalog-api.xml"), 96 "http://local/base/dtd/docAPIURI.dtd"); 97 } 98 99 private void checkResolutionOnEntityResolver(CatalogResolver resolver, 100 String matchedUri) { 101 checkSysIdResolution(resolver, ID_SYS, matchedUri); 102 } 103 104 private void checkResolutionOnUriResolver(CatalogResolver resolver, 105 String matchedUri) { 106 checkUriResolution(resolver, ID_URI, matchedUri); 107 } 108 109 private static CatalogFeatures createFeature(String catalogName) { 110 return builder().with(FILES, getCatalogPath(catalogName)).build(); 111 } 112 } |