use of org.eclipse.jst.jsp.core.internal.domdocument.DOMModelForJSP in project webtools.sourceediting by eclipse.
the class JSPTranslationTest method testXMLJSPTranslationText.
/**
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=86382
*/
public void testXMLJSPTranslationText() {
IFile f = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("INCLUDES_TESTS/xml-jsp/most-tags-xml-jsp.jsp"));
DOMModelForJSP sModel = (DOMModelForJSP) getStructuredModelForRead(f);
try {
setupAdapterFactory(sModel);
JSPTranslationAdapter adapter = (JSPTranslationAdapter) sModel.getDocument().getAdapterFor(IJSPTranslation.class);
JSPTranslation translation = adapter.getJSPTranslation();
String javaText = translation.getJavaText();
// named as .bin so no line conversion occurs (\n is in use)
InputStream in = getClass().getResourceAsStream("translated_xml_jsp.bin");
String knownTranslationText = loadChars(in);
assertEquals(knownTranslationText, javaText);
} finally {
if (sModel != null)
sModel.releaseFromRead();
}
}
use of org.eclipse.jst.jsp.core.internal.domdocument.DOMModelForJSP in project webtools.sourceediting by eclipse.
the class JSPTranslationTest method testUseBeanNoSpace.
/**
* Makes sure both beans are translated even though they are
* right next to each other with no space.
*
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=103004
*/
public void testUseBeanNoSpace() {
IFile f = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("INCLUDES_TESTS/useBean_tester.jsp"));
DOMModelForJSP sModel = (DOMModelForJSP) getStructuredModelForRead(f);
try {
setupAdapterFactory(sModel);
JSPTranslationAdapter adapter = (JSPTranslationAdapter) sModel.getDocument().getAdapterFor(IJSPTranslation.class);
JSPTranslation translation = adapter.getJSPTranslation();
String javaText = translation.getJavaText();
boolean bean1 = javaText.indexOf("javax.swing.JButton x = null;") != -1;
boolean bean2 = javaText.indexOf("javax.swing.JButton y = null;") != -1;
assertTrue(bean1);
assertTrue(bean2);
} finally {
if (sModel != null)
sModel.releaseFromRead();
}
}
use of org.eclipse.jst.jsp.core.internal.domdocument.DOMModelForJSP in project webtools.sourceediting by eclipse.
the class JSPTranslationTest method testXMLJSPMapping.
public void testXMLJSPMapping() {
IFile f = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("INCLUDES_TESTS/xml-jsp/most-tags-xml-jsp.jsp"));
DOMModelForJSP sModel = (DOMModelForJSP) getStructuredModelForRead(f);
try {
setupAdapterFactory(sModel);
JSPTranslationAdapter adapter = (JSPTranslationAdapter) sModel.getDocument().getAdapterFor(IJSPTranslation.class);
JSPTranslation translation = adapter.getJSPTranslation();
HashMap jsp2java = translation.getJsp2JavaMap();
Object[] jspRanges = jsp2java.keySet().toArray();
Position jspPos = null;
Position javaPos = null;
for (int i = 0; i < jspRanges.length; i++) {
jspPos = (Position) jspRanges[i];
javaPos = (Position) jsp2java.get(jspPos);
// System.out.println("jsp:" + printPos(jspPos) + " >> java:" + printPos(javaPos));
checkPosition(jspPos, javaPos);
}
} finally {
if (sModel != null)
sModel.releaseFromRead();
}
}
use of org.eclipse.jst.jsp.core.internal.domdocument.DOMModelForJSP in project webtools.sourceediting by eclipse.
the class JSPTranslationTest method testXMLJSPCDATAText.
public void testXMLJSPCDATAText() {
IFile f = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("INCLUDES_TESTS/cdata/cdata.jsp"));
DOMModelForJSP sModel = (DOMModelForJSP) getStructuredModelForRead(f);
try {
setupAdapterFactory(sModel);
JSPTranslationAdapter adapter = (JSPTranslationAdapter) sModel.getDocument().getAdapterFor(IJSPTranslation.class);
JSPTranslation translation = adapter.getJSPTranslation();
String transText = translation.getJavaText();
// named as .bin so no line conversion occurs (\n is in use)
InputStream in = getClass().getResourceAsStream("translated_xml_jsp_cdata.bin");
String knownText = loadChars(in);
assertEquals(knownText, transText);
} finally {
if (sModel != null)
sModel.releaseFromRead();
}
}
Aggregations