[432978] Support nested at_begin vars
Signed-off-by: Gregory Amerson <gregory.amerson@liferay.com>
diff --git a/tests/org.eclipse.jst.jsp.core.tests/src/org/eclipse/jst/jsp/core/tests/translation/JSPJavaTranslatorCoreTest.java b/tests/org.eclipse.jst.jsp.core.tests/src/org/eclipse/jst/jsp/core/tests/translation/JSPJavaTranslatorCoreTest.java
index 47d3c16..a58d11d 100644
--- a/tests/org.eclipse.jst.jsp.core.tests/src/org/eclipse/jst/jsp/core/tests/translation/JSPJavaTranslatorCoreTest.java
+++ b/tests/org.eclipse.jst.jsp.core.tests/src/org/eclipse/jst/jsp/core/tests/translation/JSPJavaTranslatorCoreTest.java
@@ -755,7 +755,9 @@
waitForBuildAndValidation(project);
IFile file = project.getFile("/WebContent/test.jsp");
+ IFile file2= project.getFile("/WebContent/test2.jsp");
IDOMModel structuredModel = null;
+ IDOMModel structuredModel2 = null;
try {
structuredModel = (IDOMModel) StructuredModelManager.getModelManager().getModelForRead(file);
@@ -769,10 +771,26 @@
// the extra variable should only be declared once in the translated text
assertEquals( 2, translation.split( "java.lang.Integer extra" ).length );
+
+ structuredModel2 = (IDOMModel) StructuredModelManager.getModelManager().getModelForRead(file2);
+
+ ModelHandlerForJSP.ensureTranslationAdapterFactory(structuredModel2);
+
+ JSPTranslationAdapter translationAdapter2 = (JSPTranslationAdapter) structuredModel2.getDocument().getAdapterFor(IJSPTranslation.class);
+
+ final String translation2 = translationAdapter2.getJSPTranslation().getJavaText();
+
+ assertTrue( translation2.indexOf( "extra" ) != -1 );
+
+ // the extra variable should be declared twice because of the nested atbegin tags
+ assertEquals( 3, translation2.split( "java.lang.Integer extra" ).length );
}
finally {
if (structuredModel != null)
structuredModel.releaseFromRead();
+
+ if (structuredModel2 != null)
+ structuredModel2.releaseFromRead();
}
}
}
diff --git a/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/WebContent/test2.jsp b/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/WebContent/test2.jsp
new file mode 100644
index 0000000..268f93d
--- /dev/null
+++ b/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/WebContent/test2.jsp
@@ -0,0 +1,25 @@
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+ pageEncoding="ISO-8859-1"%>
+<%@ taglib uri="http://eclipse.org/test" prefix="test" %>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Insert title here</title>
+</head>
+<body>
+
+<c:choose>
+ <c:when test="true">
+ <test:atbegin>
+ </test:atbegin>
+ </c:when>
+ <c:otherwise>
+ <test:atbegin>
+ </test:atbegin>
+ </c:otherwise>
+</c:choose>
+
+</body>
+</html>
\ No newline at end of file