use of org.eclipse.wst.xml.core.internal.contentmodel.util.CMVisitor in project webtools.sourceediting by eclipse.
the class TestCyclicGroupReferences method testCyclicGroupReferences.
/**
* Test CMVisitor for cyclic group references.
*/
public void testCyclicGroupReferences() {
// $NON-NLS-1$
IFile file = getFile("Test.xml");
CMVisitor cmVisitor = new CMVisitor();
IStructuredModel model = null;
try {
IModelManager modelManager = StructuredModelManager.getModelManager();
model = modelManager.getModelForRead(file);
// $NON-NLS-1$
assertNotNull("failure loading model", model);
IDOMModel domModel = (IDOMModel) model;
IDOMDocument document = domModel.getDocument();
// $NON-NLS-1$
assertNotNull("failure getting document", document);
ModelQuery modelQuery = ModelQueryUtil.getModelQuery(model);
// $NON-NLS-1$
assertNotNull("ModelQuery is missing", modelQuery);
IDOMElement documentElement = (IDOMElement) document.getDocumentElement();
// $NON-NLS-1$
assertNotNull("missing document element", documentElement);
CMElementDeclaration cmElementDeclaration = modelQuery.getCMElementDeclaration(documentElement);
assertNotNull("No element declaration for" + documentElement.getNodeName() + " (" + documentElement.getNamespaceURI() + ")", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
cmElementDeclaration);
cmVisitor.visitCMElementDeclaration(cmElementDeclaration);
} catch (Throwable th) {
fail("Test failed :" + th.getClass().getName());
} finally {
if (model != null) {
model.releaseFromRead();
}
}
}
Aggregations