CreateDocumentpublic final class CreateDocument extends DOMTestCase The "createDocument(namespaceURI,qualifiedName,doctype)" method for a
DOMImplementation should raise NAMESPACE_ERR DOMException if parameter
qualifiedName is malformed.
Retrieve the DOMImplementation on the XMLNS Document. Invoke method
createDocument(namespaceURI,qualifiedName,doctype) on the retrieved
DOMImplementation with namespaceURI being the literal string
"http://www.ecommerce.org/", qualifiedName as "prefix::local", and doctype as
null. 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 | testCreateDocument1()Runs the test case.
String namespaceURI = "http://www.ecommerce.org/";
String malformedName = "prefix::local";
Document doc;
DocumentType docType = null;
DOMImplementation domImpl;
doc = (Document) load("staffNS", builder);
domImpl = doc.getImplementation();
boolean success = false;
try {
domImpl.createDocument(namespaceURI, malformedName, docType);
} catch (DOMException ex) {
success = (ex.code == DOMException.NAMESPACE_ERR);
}
assertTrue("throw_NAMESPACE_ERR", success);
| public void | testCreateDocument2()
String namespaceURI = null;
String qualifiedName = "k:local";
Document doc;
DocumentType docType = null;
DOMImplementation domImpl;
doc = (Document) load("staffNS", builder);
domImpl = doc.getImplementation();
boolean success = false;
try {
domImpl.createDocument(namespaceURI, qualifiedName, docType);
} catch (DOMException ex) {
success = (ex.code == DOMException.NAMESPACE_ERR);
}
assertTrue("throw_NAMESPACE_ERR", success);
| public void | testCreateDocument5()
String namespaceURI = "http://www.ecommerce.org/schema";
String qualifiedName;
Document doc;
DocumentType docType = null;
DOMImplementation domImpl;
List<String> illegalQNames = new ArrayList<String>();
illegalQNames.add("namespaceURI:{");
illegalQNames.add("namespaceURI:}");
illegalQNames.add("namespaceURI:~");
illegalQNames.add("namespaceURI:'");
illegalQNames.add("namespaceURI:!");
illegalQNames.add("namespaceURI:@");
illegalQNames.add("namespaceURI:#");
illegalQNames.add("namespaceURI:$");
illegalQNames.add("namespaceURI:%");
illegalQNames.add("namespaceURI:^");
illegalQNames.add("namespaceURI:&");
illegalQNames.add("namespaceURI:*");
illegalQNames.add("namespaceURI:(");
illegalQNames.add("namespaceURI:)");
illegalQNames.add("namespaceURI:+");
illegalQNames.add("namespaceURI:=");
illegalQNames.add("namespaceURI:[");
illegalQNames.add("namespaceURI:]");
illegalQNames.add("namespaceURI:\\");
illegalQNames.add("namespaceURI:/");
illegalQNames.add("namespaceURI:;");
illegalQNames.add("namespaceURI:`");
illegalQNames.add("namespaceURI:<");
illegalQNames.add("namespaceURI:>");
illegalQNames.add("namespaceURI:,");
illegalQNames.add("namespaceURI:a ");
illegalQNames.add("namespaceURI:\"");
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.createDocument(namespaceURI, qualifiedName, docType);
} catch (DOMException ex) {
success = (ex.code == DOMException.INVALID_CHARACTER_ERR);
}
assertTrue("throw_INVALID_CHARACTER_ERR", success);
}
| public void | testCreateDocument6()
String namespaceURI = "http://ecommerce.org/schema";
String qualifiedName = "xml:local";
Document doc;
DocumentType docType = null;
DOMImplementation domImpl;
doc = (Document) load("staffNS", builder);
domImpl = doc.getImplementation();
boolean success = false;
try {
domImpl.createDocument(namespaceURI, qualifiedName, docType);
} catch (DOMException ex) {
success = (ex.code == DOMException.NAMESPACE_ERR);
}
assertTrue("throw_NAMESPACE_ERR", success);
| public void | testCreateDocument7()
String namespaceURI = "http://www.ecommerce.org/schema";
String qualifiedName = "y:x";
Document doc;
DocumentType docType = null;
DOMImplementation domImpl;
Document aNewDoc;
String nodeName;
String nodeValue;
doc = (Document) load("staffNS", builder);
domImpl = doc.getImplementation();
aNewDoc = domImpl.createDocument(namespaceURI, qualifiedName, docType);
nodeName = aNewDoc.getNodeName();
nodeValue = aNewDoc.getNodeValue();
assertEquals("nodeName", "#document", nodeName);
assertNull("nodeValue", nodeValue);
| public void | testCreateDocument8()
String namespaceURI = "http://www.example.org/schema";
DocumentType docType = null;
DOMImplementation domImpl;
domImpl = builder.getDOMImplementation();
boolean success = false;
try {
domImpl.createDocument(namespaceURI, "", docType);
} catch (DOMException ex) {
success = (ex.code == DOMException.NAMESPACE_ERR);
}
assertTrue("throw_NAMESPACE_ERR", success);
|
|