use of org.eclipse.wst.xml.core.internal.document.DOMModelImpl in project webtools.sourceediting by eclipse.
the class DOMImplementationTests method testCreateDocumentIllegalNamespace.
public void testCreateDocumentIllegalNamespace() {
final DOMModelImpl model = (DOMModelImpl) StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML);
try {
model.createDocument(null, "foo:bar", null);
} catch (DOMException e) {
assertEquals("Did not receive the correct DOMException", DOMException.NAMESPACE_ERR, e.code);
return;
}
fail("No exceptions for illegal input");
}
use of org.eclipse.wst.xml.core.internal.document.DOMModelImpl in project webtools.sourceediting by eclipse.
the class DOMImplementationTests method testCreateDocumentNoDocumentType.
public void testCreateDocumentNoDocumentType() {
final DOMModelImpl model = (DOMModelImpl) StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML);
final Document document = model.createDocument("http://eclipse.org", "foo:bar", null);
final Node node = document.getFirstChild();
assertNotNull("Document should not be empty", node);
assertEquals("Element qualified name is not equal", "foo:bar", node.getNodeName());
assertEquals("Element namespace URI is not equal", "http://eclipse.org", node.getNamespaceURI());
}
use of org.eclipse.wst.xml.core.internal.document.DOMModelImpl in project webtools.sourceediting by eclipse.
the class DOMImplementationTests method testCreateDocumentNamespaceWithNoQualifiedName.
public void testCreateDocumentNamespaceWithNoQualifiedName() {
final DOMModelImpl model = (DOMModelImpl) StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML);
try {
model.createDocument("http://eclipse.org", null, null);
} catch (DOMException e) {
assertEquals("Did not receive the correct DOMException", DOMException.NAMESPACE_ERR, e.code);
return;
}
fail("No exceptions for illegal input");
}
use of org.eclipse.wst.xml.core.internal.document.DOMModelImpl in project webtools.sourceediting by eclipse.
the class DOMImplementationTests method testCreateDocumentEmpty.
public void testCreateDocumentEmpty() {
final DOMModelImpl model = (DOMModelImpl) StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForXML.ContentTypeID_XML);
final Document document = model.createDocument(null, null, null);
assertNull("The document should be empty", document.getFirstChild());
}
use of org.eclipse.wst.xml.core.internal.document.DOMModelImpl in project webtools.sourceediting by eclipse.
the class StructuredDocumentToDOMUnitTests method testNodeDeletion4.
/**
* Unit test -- test insert followed by delete at beginning of string.
*/
void testNodeDeletion4() {
String initialString = getTestString4();
// print out what we always can
System.out.println();
System.out.println("----------------");
System.out.println("Test Node Insert and Delete");
String outString = StringUtils.escape(initialString);
System.out.println("Initial String: " + outString);
// always start with fresh model
IStructuredDocument f = null;
IModelManager mm = StructuredModelManager.getModelManager();
try {
f = mm.createStructuredDocumentFor("dummy.xml", (InputStream) null, null);
} catch (IOException e) {
// do nothing, since dummy
}
//
// we'll listen to structuredDocument events to print out diagnostics
f.addDocumentChangedListener(this);
//
IDOMModel tree = new DOMModelImpl();
f.addDocumentChangingListener((IStructuredDocumentListener) tree);
// set text to structuredDocument (which updates tree)
f.setText(null, initialString);
// dump initial structuredDocument
Debug.dump(f);
// dump initial dom
DebugDocument.dump(tree.getDocument());
//
//
f.replaceText(null, 0, 0, "a");
System.out.println(" ==== Results after insert");
// display resulting text
System.out.println("resultString (from structuredDocument): ");
System.out.println(StringUtils.escape(f.getText()));
//
//
// dump post change structuredDocument
Debug.dump(f);
// dump post change DOM
DebugDocument.dump(tree.getDocument());
//
f.replaceText(null, 0, 1, "");
System.out.println(" ==== Results after delete");
// display resulting text
System.out.println("resultString (from structuredDocument): ");
System.out.println(StringUtils.escape(f.getText()));
//
//
// dump post change structuredDocument
Debug.dump(f);
// dump post change DOM
DebugDocument.dump(tree.getDocument());
//
}
Aggregations