summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGregory Amerson2014-04-23 21:30:23 (EDT)
committerNick Sandonato2014-04-23 21:33:52 (EDT)
commitee8a05048e8071981a4a968434200a03b85d3b05 (patch)
tree23a39a8564ad3cbcf867374a96ba3c3ae89c9966
parent503d39a39c0ac412b82418cdd7312f91f2f04a04 (diff)
downloadwebtools.sourceediting.tests-ee8a05048e8071981a4a968434200a03b85d3b05.zip
webtools.sourceediting.tests-ee8a05048e8071981a4a968434200a03b85d3b05.tar.gz
webtools.sourceediting.tests-ee8a05048e8071981a4a968434200a03b85d3b05.tar.bz2
[432978] JSPTranslator can generate incorrect source for JSPs that use particular taglibs multiple times in one JSP file
Signed-off-by: Gregory Amerson <gregory.amerson@liferay.com>
-rw-r--r--tests/org.eclipse.jst.jsp.core.tests/src/org/eclipse/jst/jsp/core/tests/translation/JSPJavaTranslatorCoreTest.java35
-rw-r--r--tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.classpath8
-rw-r--r--tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.project25
-rw-r--r--tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.settings/.jsdtscope12
-rw-r--r--tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.settings/org.eclipse.wst.common.component8
-rw-r--r--tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.settings/org.eclipse.wst.common.project.facet.core.xml9
-rw-r--r--tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.settings/org.eclipse.wst.jsdt.ui.superType.container1
-rw-r--r--tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.settings/org.eclipse.wst.jsdt.ui.superType.name1
-rw-r--r--tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/WebContent/META-INF/MANIFEST.MF3
-rw-r--r--tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/WebContent/WEB-INF/test.tld18
-rw-r--r--tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/WebContent/WEB-INF/web.xml12
-rw-r--r--tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/WebContent/test.jsp19
-rw-r--r--tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/src/test/AtBeginTag.java26
-rw-r--r--tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/src/test/AtBeginTei.java18
15 files changed, 202 insertions, 0 deletions
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 21677e8..e638805 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
@@ -743,4 +743,39 @@ public class JSPJavaTranslatorCoreTest extends TestCase {
structuredModel.releaseFromRead();
}
}
+
+ public void test_432978() throws Exception {
+ String testName = "bug_432978";
+ // Create new project
+ IProject project = BundleResourceUtil.createJavaWebProject(testName);
+ assertTrue(project.exists());
+ BundleResourceUtil.copyBundleEntriesIntoWorkspace("/testfiles/" + testName, "/" + testName);
+
+ IFile file = project.getFile("/WebContent/test.jsp");
+ JSPTranslator translator = new JSPTranslator();
+ IDOMModel structuredModel = null;
+ try {
+ structuredModel = (IDOMModel) StructuredModelManager.getModelManager().getModelForRead(file);
+ translator.reset(structuredModel.getDocument(), new NullProgressMonitor());
+ translator.translate();
+
+ final String translation = translator.getTranslation().toString();
+ assertTrue( translation.contains( "extra" ) );
+
+ // the extra variable should only be declared once in the translated text
+ assertEquals( 2, translation.split( "java.lang.Integer extra" ).length );
+ }
+ finally {
+ if (structuredModel != null)
+ structuredModel.releaseFromRead();
+ }
+// waitForBuildAndValidation(project);
+// ValidationFramework.getDefault().validate(new IProject[]{project}, true, true, new NullProgressMonitor());
+// waitForBuildAndValidation(project);
+//
+// IFile main = project.getFile("/WebContent/test.jsp");
+// assertTrue("test file does not exist", main.isAccessible());
+// IMarker[] markers = main.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ZERO);
+// assertEquals("number of markers not 1", 1, markers.length );
+ }
}
diff --git a/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.classpath b/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.classpath
new file mode 100644
index 0000000..5fb681c
--- /dev/null
+++ b/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry exported="true" kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
+ <classpathentry combineaccessrules="false" kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.project b/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.project
new file mode 100644
index 0000000..9d5a88e
--- /dev/null
+++ b/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.project
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>bug_432978</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ </natures>
+</projectDescription>
diff --git a/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.settings/.jsdtscope b/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.settings/.jsdtscope
new file mode 100644
index 0000000..3a28de0
--- /dev/null
+++ b/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.settings/.jsdtscope
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="WebContent"/>
+ <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
+ <attributes>
+ <attribute name="hide" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
+ <classpathentry kind="output" path=""/>
+</classpath>
diff --git a/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.settings/org.eclipse.jdt.core.prefs b/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..c537b63
--- /dev/null
+++ b/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.settings/org.eclipse.wst.common.component b/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.settings/org.eclipse.wst.common.component
new file mode 100644
index 0000000..1d8078d
--- /dev/null
+++ b/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.settings/org.eclipse.wst.common.component
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
+ <wb-module deploy-name="testAT_BEGIN">
+ <wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/>
+ <wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
+ <property name="context-root" value="testAT_BEGIN"/>
+ <property name="java-output-path" value="/testAT_BEGIN/build/classes"/>
+ </wb-module>
+</project-modules>
diff --git a/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.settings/org.eclipse.wst.common.project.facet.core.xml b/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 0000000..0d3d10e
--- /dev/null
+++ b/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <fixed facet="jst.web"/>
+ <fixed facet="java"/>
+ <fixed facet="wst.jsdt.web"/>
+ <installed facet="java" version="1.6"/>
+ <installed facet="jst.web" version="3.0"/>
+ <installed facet="wst.jsdt.web" version="1.0"/>
+</faceted-project>
diff --git a/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.settings/org.eclipse.wst.jsdt.ui.superType.container b/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.settings/org.eclipse.wst.jsdt.ui.superType.container
new file mode 100644
index 0000000..3bd5d0a
--- /dev/null
+++ b/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.settings/org.eclipse.wst.jsdt.ui.superType.container
@@ -0,0 +1 @@
+org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file
diff --git a/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.settings/org.eclipse.wst.jsdt.ui.superType.name b/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.settings/org.eclipse.wst.jsdt.ui.superType.name
new file mode 100644
index 0000000..05bd71b
--- /dev/null
+++ b/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/.settings/org.eclipse.wst.jsdt.ui.superType.name
@@ -0,0 +1 @@
+Window \ No newline at end of file
diff --git a/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/WebContent/META-INF/MANIFEST.MF b/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/WebContent/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..254272e
--- /dev/null
+++ b/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/WebContent/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
diff --git a/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/WebContent/WEB-INF/test.tld b/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/WebContent/WEB-INF/test.tld
new file mode 100644
index 0000000..f16d6f3
--- /dev/null
+++ b/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/WebContent/WEB-INF/test.tld
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<taglib xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
+ version="2.0">
+
+ <description>Test library</description>
+ <display-name>Test Library</display-name>
+ <tlib-version>1.0</tlib-version>
+ <short-name>test</short-name>
+ <uri>http://eclipse.org/test</uri>
+
+ <tag>
+ <name>atbegin</name>
+ <tag-class>test.AtBeginTag</tag-class>
+ <tei-class>test.AtBeginTei</tei-class>
+ <body-content>JSP</body-content>
+ </tag>
+</taglib> \ No newline at end of file
diff --git a/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/WebContent/WEB-INF/web.xml b/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/WebContent/WEB-INF/web.xml
new file mode 100644
index 0000000..5aa6dca
--- /dev/null
+++ b/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/WebContent/WEB-INF/web.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+ <display-name>testIterationTags</display-name>
+ <welcome-file-list>
+ <welcome-file>index.html</welcome-file>
+ <welcome-file>index.htm</welcome-file>
+ <welcome-file>index.jsp</welcome-file>
+ <welcome-file>default.html</welcome-file>
+ <welcome-file>default.htm</welcome-file>
+ <welcome-file>default.jsp</welcome-file>
+ </welcome-file-list>
+</web-app>
diff --git a/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/WebContent/test.jsp b/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/WebContent/test.jsp
new file mode 100644
index 0000000..c20db43
--- /dev/null
+++ b/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/WebContent/test.jsp
@@ -0,0 +1,19 @@
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+ pageEncoding="ISO-8859-1"%>
+<%@ taglib uri="http://eclipse.org/test" prefix="test" %>
+<!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>
+
+<test:atbegin>
+</test:atbegin>
+<test:atbegin>
+</test:atbegin>
+
+
+</body>
+</html> \ No newline at end of file
diff --git a/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/src/test/AtBeginTag.java b/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/src/test/AtBeginTag.java
new file mode 100644
index 0000000..fdc2494
--- /dev/null
+++ b/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/src/test/AtBeginTag.java
@@ -0,0 +1,26 @@
+package test;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.BodyTagSupport;
+
+
+public class AtBeginTag extends BodyTagSupport
+{
+ private int extra;
+
+ public int getExtra() {
+ return extra;
+ }
+
+
+ public void setExtra( int extra ) {
+ this.extra = extra;
+ }
+
+ @Override
+ public int doStartTag() throws JspException
+ {
+ pageContext.setAttribute("extra", 10);
+ return EVAL_BODY_INCLUDE;
+ }
+}
diff --git a/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/src/test/AtBeginTei.java b/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/src/test/AtBeginTei.java
new file mode 100644
index 0000000..aea8daa
--- /dev/null
+++ b/tests/org.eclipse.jst.jsp.core.tests/testfiles/bug_432978/src/test/AtBeginTei.java
@@ -0,0 +1,18 @@
+package test;
+
+import javax.servlet.jsp.tagext.TagData;
+import javax.servlet.jsp.tagext.TagExtraInfo;
+import javax.servlet.jsp.tagext.VariableInfo;
+
+
+public class AtBeginTei extends TagExtraInfo
+{
+ @Override
+ public VariableInfo[] getVariableInfo( TagData data )
+ {
+ return new VariableInfo[] {
+ new VariableInfo(
+ "extra", Integer.class.getName(), true, VariableInfo.AT_BEGIN)
+ };
+ }
+} \ No newline at end of file