CreateDocumentTypepublic final class CreateDocumentType extends DOMTestCase The "createDocumentType(qualifiedName,publicId,systemId)" method for a
DOMImplementation should raise NAMESPACE_ERR DOMException if qualifiedName is
malformed.
Retrieve the DOMImplementation on the XMLNS Document. Invoke method
createDocumentType(qualifiedName,publicId,systemId) on the retrieved
DOMImplementation with qualifiedName being the literal string
"prefix::local", publicId as "STAFF", and systemId as "staff". Method should
raise NAMESPACE_ERR DOMException. |
Fields Summary |
---|
DOMDocumentBuilderFactory | factory | DocumentBuilder | builder |
Methods Summary |
---|
protected void | setUp()
super.setUp();
try {
factory = new DOMDocumentBuilderFactory(DOMDocumentBuilderFactory
.getConfiguration1());
builder = factory.getBuilder();
} catch (Exception e) {
fail("Unexpected exception" + e.getMessage());
}
| protected void | tearDown()
factory = null;
builder = null;
super.tearDown();
| public void | testCreateDocumentType1()Runs the test case.
String publicId = "STAFF";
String systemId = "staff.xml";
String malformedName = "prefix::local";
Document doc;
DOMImplementation domImpl;
doc = (Document) load("staffNS", builder);
domImpl = doc.getImplementation();
{
boolean success = false;
try {
domImpl.createDocumentType(malformedName, publicId, systemId);
} catch (DOMException ex) {
success = (ex.code == DOMException.NAMESPACE_ERR);
}
assertTrue("throw_NAMESPACE_ERR", success);
}
| public void | testCreateDocumentType2()
String publicId = "http://www.localhost.com/";
String systemId = "myDoc.dtd";
String qualifiedName;
Document doc;
DOMImplementation domImpl;
List<String> illegalQNames = new ArrayList<String>();
illegalQNames.add("edi:{");
illegalQNames.add("edi:}");
illegalQNames.add("edi:~");
illegalQNames.add("edi:'");
illegalQNames.add("edi:!");
illegalQNames.add("edi:@");
illegalQNames.add("edi:#");
illegalQNames.add("edi:$");
illegalQNames.add("edi:%");
illegalQNames.add("edi:^");
illegalQNames.add("edi:&");
illegalQNames.add("edi:*");
illegalQNames.add("edi:(");
illegalQNames.add("edi:)");
illegalQNames.add("edi:+");
illegalQNames.add("edi:=");
illegalQNames.add("edi:[");
illegalQNames.add("edi:]");
illegalQNames.add("edi:\\");
illegalQNames.add("edi:/");
illegalQNames.add("edi:;");
illegalQNames.add("edi:`");
illegalQNames.add("edi:<");
illegalQNames.add("edi:>");
illegalQNames.add("edi:,");
illegalQNames.add("edi:a ");
illegalQNames.add("edi:\"");
doc = (Document) load("staffNS", builder);
for (int indexN1009A = 0; indexN1009A < illegalQNames.size(); indexN1009A++) {
qualifiedName = (String) illegalQNames.get(indexN1009A);
domImpl = doc.getImplementation();
{
boolean success = false;
try {
domImpl.createDocumentType(qualifiedName, publicId,
systemId);
} catch (DOMException ex) {
success = (ex.code == DOMException.INVALID_CHARACTER_ERR);
}
assertTrue("throw_INVALID_CHARACTER_ERR", success);
}
}
| public void | testCreateDocumentType3()
String qualifiedName = "prefix:myDoc";
String publicId = "http://www.localhost.com";
String systemId = "myDoc.dtd";
Document doc;
DOMImplementation domImpl;
DocumentType newType = null;
String nodeName;
String nodeValue;
doc = (Document) load("staffNS", builder);
domImpl = doc.getImplementation();
newType = domImpl.createDocumentType(qualifiedName, publicId, systemId);
nodeName = newType.getNodeName();
assertEquals("nodeName", "prefix:myDoc", nodeName);
nodeValue = newType.getNodeValue();
assertNull("nodeValue", nodeValue);
| public void | testCreateDocumentType4()
String publicId = "http://www.example.com/";
String systemId = "myDoc.dtd";
DOMImplementation domImpl;
domImpl = builder.getDOMImplementation();
{
boolean success = false;
try {
domImpl.createDocumentType("", publicId, systemId);
} catch (DOMException ex) {
success = (ex.code == DOMException.NAMESPACE_ERR);
}
assertTrue("throw_NAMESPACE_ERR", success);
}
|
|