use of org.eclipse.jst.jsp.core.internal.document.PageDirectiveAdapter in project webtools.sourceediting by eclipse.
the class TestModelHandlers method testDirtyStateForMisspelledEmbeddedCharset.
public void testDirtyStateForMisspelledEmbeddedCharset() throws Exception {
String projectName = "TestModelHandlers." + getName();
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
if (!project.isAccessible()) {
project = BundleResourceUtil.createSimpleProject(projectName, null, null);
}
IFile testFile = project.getFile("charaset.jsp");
String contents = "<%@ page language=\"java\" contentType=\"text/xml; charaset=UTF-8\" pageEncoding=\"UTF-8\"%>\n" + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<Contents>\n" + "<Error state=\"fatal\" code=\"\">\n" + "</Error>\n" + "</Contents>";
if (!testFile.exists()) {
testFile.create(new ByteArrayInputStream(contents.getBytes("utf8")), IResource.FORCE, null);
} else {
testFile.setContents(new ByteArrayInputStream(contents.getBytes("utf8")), IResource.FORCE, null);
}
IStructuredModel model = null;
try {
model = StructuredModelManager.getModelManager().getModelForRead(testFile);
Document doc = ((IDOMModel) model).getDocument();
PageDirectiveAdapter pageDirectiveAdapter = (PageDirectiveAdapter) ((INodeNotifier) doc).getAdapterFor(PageDirectiveAdapter.class);
EmbeddedTypeHandler embeddedHandler = pageDirectiveAdapter.getEmbeddedType();
assertFalse("newly opened model was dirty, embedded handler changed? current family:" + embeddedHandler.getFamilyId(), model.isDirty());
} finally {
if (model != null)
model.releaseFromRead();
}
project.delete(true, null);
}
Aggregations