test/javax/xml/jaxp/unittest/catalog/CatalogTest.java
Print this page
@@ -40,16 +40,36 @@
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.ext.DefaultHandler2;
/*
- * @bug 8081248
+ * @bug 8081248, 8144966
* @summary Tests basic Catalog functions.
*/
public class CatalogTest {
/*
+ @bug 8144966
+ Verifies that passing null as CatalogFeatures will result in a NPE.
+ */
+ @Test(expectedExceptions = NullPointerException.class)
+ public void testFeatureNull() {
+ CatalogResolver resolver = CatalogManager.catalogResolver(null, "");
+
+ }
+
+ /*
+ @bug 8144966
+ Verifies that passing null as the path will result in a NPE.
+ */
+ @Test(expectedExceptions = NullPointerException.class)
+ public void testPathNull() {
+ String path = null;
+ CatalogResolver resolver = CatalogManager.catalogResolver(CatalogFeatures.defaults(), path);
+ }
+
+ /*
Tests basic catalog feature by using a CatalogResolver instance to
resolve a DTD reference to a locally specified DTD file. If the resolution
is successful, the Handler shall return the value of the entity reference
that matches the expected value.
*/
@@ -59,11 +79,11 @@
if (catalogFile != null) {
catalog = getClass().getResource(catalogFile).getFile();
}
String url = getClass().getResource(xml).getFile();
try {
- CatalogResolver cr = CatalogManager.catalogResolver(null, catalog);
+ CatalogResolver cr = CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalog);
XMLReader reader = saxParser.getXMLReader();
reader.setEntityResolver(cr);
MyHandler handler = new MyHandler(saxParser);
reader.setContentHandler(handler);
reader.parse(url);
@@ -82,11 +102,11 @@
public void testInvalidCatalog() {
String catalog = getClass().getResource("catalog_invalid.xml").getFile();
String test = "testInvalidCatalog";
try {
- CatalogResolver resolver = CatalogManager.catalogResolver(null, catalog);
+ CatalogResolver resolver = CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalog);
String actualSystemId = resolver.resolveEntity(null, "http://remote/xml/dtd/sys/alice/docAlice.dtd").getSystemId();
} catch (Exception e) {
String msg = e.getMessage();
if (msg != null) {
if (msg.contains("No match found for publicId")) {