summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2007-04-04 10:55:56 (EDT)
committerpelder2007-04-04 10:55:56 (EDT)
commit94732f3ff6590dd893f5a896ad34b804e012b928 (patch)
treed34136049943a67dedf2b6ec0451a7b00ed6c75d
parent269ac5b36386165367d80aa4d9a8c338d00a8d17 (diff)
downloadorg.eclipse.jet-94732f3ff6590dd893f5a896ad34b804e012b928.zip
org.eclipse.jet-94732f3ff6590dd893f5a896ad34b804e012b928.tar.gz
org.eclipse.jet-94732f3ff6590dd893f5a896ad34b804e012b928.tar.bz2
[180962,131208] JUnits for org.eclipse.jet.core
-rw-r--r--tests/org.eclipse.jet.tests.core/.classpath7
-rw-r--r--tests/org.eclipse.jet.tests.core/.cvsignore1
-rw-r--r--tests/org.eclipse.jet.tests.core/.project28
-rw-r--r--tests/org.eclipse.jet.tests.core/.settings/org.eclipse.jdt.core.prefs12
-rw-r--r--tests/org.eclipse.jet.tests.core/.settings/org.eclipse.jdt.ui.prefs4
-rw-r--r--tests/org.eclipse.jet.tests.core/META-INF/MANIFEST.MF13
-rw-r--r--tests/org.eclipse.jet.tests.core/about.html28
-rw-r--r--tests/org.eclipse.jet.tests.core/build.properties6
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/ast/attributeParsingErrors.jet6
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/ast/bug147714.jet11
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/ast/taglibs.jet10
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/ast/taglibs.jet.JETASTParser.astdump.expected41
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/ast/unclosedComment.jet3
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/ast/unclosedDeclaration.jet3
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/ast/unclosedDirective.jet1
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/ast/unclosedExpression.jet3
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/ast/unclosedScriplet.jet3
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/ast/unclosedXMLEnd.jet3
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/ast/unclosedXMLStart.jet3
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/legacy/alljet2.jet34
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/legacy/alljet2.jet.expected93
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/legacy/unclosedComment.jet3
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/legacy/unclosedDeclaration.jet3
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/legacy/unclosedDirective.jet1
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/legacy/unclosedExpression.jet3
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/legacy/unclosedScriplet.jet3
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/legacy/unclosedXMLEnd.jet3
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/legacy/unclosedXMLStart.jet3
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/legacy/xmlEndWithAttributes.jet3
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/legacy/xmlStartWithoutEnd.jet8
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/lineinfo.jet10
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/lineinfo.jet.expected.txt10
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/v1/alt1/include2.jetinc3
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/v1/alt2/include2.jetinc4
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/v1/base/alternative.include.javajet36
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/v1/base/alternative.include.javajet.astdump.expected74
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/v1/base/complex.include.javajet4
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/v1/base/complex.include.javajet.astdump.expected49
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/v1/base/include1.jetinc3
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/v1/base/include2.jetinc3
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/v1/base/simple.include.javajet4
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/v1/base/simple.include.javajet.astdump.expected19
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/v1/base/simple.include.javajet.chararray.astdump.expected11
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/v1/base/simple.javajet9
-rw-r--r--tests/org.eclipse.jet.tests.core/data/parser/v1/base/simple.javajet.astdump.expected16
-rw-r--r--tests/org.eclipse.jet.tests.core/data/templates/base1/nested/test3.txt1
-rw-r--r--tests/org.eclipse.jet.tests.core/data/templates/base1/nested/test4.txt1
-rw-r--r--tests/org.eclipse.jet.tests.core/data/templates/base1/test1.txt1
-rw-r--r--tests/org.eclipse.jet.tests.core/data/templates/base1/test2.txt1
-rw-r--r--tests/org.eclipse.jet.tests.core/data/templates/base2/nested/test5.txt1
-rw-r--r--tests/org.eclipse.jet.tests.core/data/templates/base2/test1.txt1
-rw-r--r--tests/org.eclipse.jet.tests.core/data/templates/base2/test2.txt1
-rw-r--r--tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/core/AllTests.java19
-rw-r--r--tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/core/AllToolsSuites.java60
-rw-r--r--tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/core/FileUtils.java78
-rw-r--r--tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/core/TestNewLineUtil.java49
-rw-r--r--tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/parser/jasper/AllTests.java17
-rw-r--r--tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/parser/jasper/TestJETParser.java373
-rw-r--r--tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/AllTests.java23
-rw-r--r--tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/IncludeDependenciesTest.java136
-rw-r--r--tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/LineInfoTests.java67
-rw-r--r--tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/TestIncludeAlternativesTracker.java213
-rw-r--r--tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/TestInputManager.java177
-rw-r--r--tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/TestInputManagerBuilder.java95
-rw-r--r--tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/TestTemplateInput.java51
-rw-r--r--tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/TestUniqueNameGenerator.java131
-rw-r--r--tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/parser/ASTDumper.java184
-rw-r--r--tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/parser/AllTests.java18
-rw-r--r--tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/parser/TestInternalJET1Parser.java153
-rw-r--r--tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/parser/TestJETASTParser.java560
70 files changed, 3009 insertions, 0 deletions
diff --git a/tests/org.eclipse.jet.tests.core/.classpath b/tests/org.eclipse.jet.tests.core/.classpath
new file mode 100644
index 0000000..751c8f2
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/tests/org.eclipse.jet.tests.core/.cvsignore b/tests/org.eclipse.jet.tests.core/.cvsignore
new file mode 100644
index 0000000..ba077a4
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/.cvsignore
@@ -0,0 +1 @@
+bin
diff --git a/tests/org.eclipse.jet.tests.core/.project b/tests/org.eclipse.jet.tests.core/.project
new file mode 100644
index 0000000..ea64630
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.jet.tests.core</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>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/tests/org.eclipse.jet.tests.core/.settings/org.eclipse.jdt.core.prefs b/tests/org.eclipse.jet.tests.core/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..16c4e97
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+#Tue Apr 03 15:15:39 EDT 2007
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.source=1.4
diff --git a/tests/org.eclipse.jet.tests.core/.settings/org.eclipse.jdt.ui.prefs b/tests/org.eclipse.jet.tests.core/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 0000000..a758fcc
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,4 @@
+#Tue Apr 03 15:15:39 EDT 2007
+eclipse.preferences.version=1
+internal.default.compliance=user
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\r\n * @return the ${bare_field_name}\r\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\r\n * @param ${param} the ${bare_field_name} to set\r\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*\r\n * Copyright (c) ${year} IBM Corporation and others.\r\n * All rights reserved. This program and the accompanying materials\r\n * are made available under the terms of the Eclipse Public License v1.0\r\n * which accompanies this distribution, and is available at\r\n * http\://www.eclipse.org/legal/epl-v10.html\r\n * \r\n * Contributors\:\r\n * IBM Corporation - initial API and implementation\r\n */</template><template autoinsert\="true" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * @author ${user}\r\n *\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\r\n * \r\n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\r\n * ${see_to_overridden}\r\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\r\n * ${tags}\r\n * ${see_to_target}\r\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\r\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\r\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\r\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
diff --git a/tests/org.eclipse.jet.tests.core/META-INF/MANIFEST.MF b/tests/org.eclipse.jet.tests.core/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..3874c4c
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/META-INF/MANIFEST.MF
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: JET Tools Unit Tests Plug-in
+Bundle-SymbolicName: org.eclipse.jet.tests.core
+Bundle-Version: 1.0.0
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.jet.core,
+ org.eclipse.core.filebuffers,
+ org.eclipse.core.resources,
+ org.eclipse.core.runtime,
+ org.eclipse.text,
+ org.junit
+Bundle-RequiredExecutionEnvironment: J2SE-1.4
diff --git a/tests/org.eclipse.jet.tests.core/about.html b/tests/org.eclipse.jet.tests.core/about.html
new file mode 100644
index 0000000..12a49f1
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>May 2, 2006</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html>
diff --git a/tests/org.eclipse.jet.tests.core/build.properties b/tests/org.eclipse.jet.tests.core/build.properties
new file mode 100644
index 0000000..da79d93
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/build.properties
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ data/,\
+ about.html
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/ast/attributeParsingErrors.jet b/tests/org.eclipse.jet.tests.core/data/parser/ast/attributeParsingErrors.jet
new file mode 100644
index 0000000..99bf3cc
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/ast/attributeParsingErrors.jet
@@ -0,0 +1,6 @@
+<%@taglib prefix="c" id="org.eclipse.jet.controlTags"%>
+
+<%-- The following line is missing a double quote (") on the 'var' attribute --%>
+<c:iterate select="foo" var="bar>
+ some text parameterized by bar: <c:get select="$bar"/>
+</c:iterate> \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/ast/bug147714.jet b/tests/org.eclipse.jet.tests.core/data/parser/ast/bug147714.jet
new file mode 100644
index 0000000..5a8e497
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/ast/bug147714.jet
@@ -0,0 +1,11 @@
+<%-- Bug 147714 requests the JET compiler to treat <tag ...> as <tag .../> if tag is an emptyTag.
+This is for compatibility with DPTK: http://www.alphaworks.ibm.com/tech/dptk.
+Since DPTK does not use namespace prefixes, the fix only applies to tags with not prefix.
+--%>
+<%@taglib id="org.eclipse.jet.tests.TestLibrary2" prefix="c" %>
+<%@taglib id="org.eclipse.jet.tests.TestLibrary" prefix="" %>
+
+<%-- line 8: expect error --%><c:nl>
+<%-- line 9: expect ok --%><c:nl/>
+<%-- line 10: expect warning --%><nl>
+<%-- line 11: expect ok --%><nl/>
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/ast/taglibs.jet b/tests/org.eclipse.jet.tests.core/data/parser/ast/taglibs.jet
new file mode 100644
index 0000000..2bc9dfc
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/ast/taglibs.jet
@@ -0,0 +1,10 @@
+<%@taglib id="org.eclipse.jet.tests.TestLibrary" prefix="test" %>
+"isAllUpper", "nl", "other", "tokenize", "upper"
+
+<test:tokenize string="a,b,c,d,e,f,g" sep="," var="token">
+<test:other>some text</test:other>
+<test:isAllUpper var="token">
+</test:isAllUpper>
+<test:upper>foo</test:upper><test:nl/>
+<test:other/>
+</test:tokenize> \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/ast/taglibs.jet.JETASTParser.astdump.expected b/tests/org.eclipse.jet.tests.core/data/parser/ast/taglibs.jet.JETASTParser.astdump.expected
new file mode 100644
index 0000000..b99d6d3
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/ast/taglibs.jet.JETASTParser.astdump.expected
@@ -0,0 +1,41 @@
+<directive name="taglib" line="1" col="1">
+ <attribute name="id">org.eclipse.jet.tests.TestLibrary</attribute>
+ <attribute name="prefix">test</attribute>
+</directive>
+<data>"isAllUpper", "nl", "other", "tokenize", "upper"
+
+</data>
+<tag name="test:tokenize" line="4" col="1">
+ <attribute name="sep">,</attribute>
+ <attribute name="var">token</attribute>
+ <attribute name="string">a,b,c,d,e,f,g</attribute>
+ <content>
+ <data></data>
+ <tag name="test:other" line="5" col="1">
+ <content>
+ <data>some text</data>
+ </content>
+ </tag>
+ <data>
+</data>
+ <tag name="test:isAllUpper" line="6" col="1">
+ <attribute name="var">token</attribute>
+ <content>
+ <data></data>
+ </content>
+ </tag>
+ <data></data>
+ <tag name="test:upper" line="8" col="1">
+ <content>
+ <data>foo</data>
+ </content>
+ </tag>
+ <tag name="test:nl" line="8" col="29">
+ </tag>
+ <data>
+</data>
+ <tag name="test:other" line="9" col="1">
+ </tag>
+ <data></data>
+ </content>
+</tag>
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/ast/unclosedComment.jet b/tests/org.eclipse.jet.tests.core/data/parser/ast/unclosedComment.jet
new file mode 100644
index 0000000..ba01d6f
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/ast/unclosedComment.jet
@@ -0,0 +1,3 @@
+<%@jet package="org.eclipse.emf.examples.test" class="Foo" %>
+
+<%-- String x = "Hello World!"; -%>
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/ast/unclosedDeclaration.jet b/tests/org.eclipse.jet.tests.core/data/parser/ast/unclosedDeclaration.jet
new file mode 100644
index 0000000..a12518f
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/ast/unclosedDeclaration.jet
@@ -0,0 +1,3 @@
+<%@jet package="org.eclipse.emf.examples.test" class="Foo" %>
+
+<%! public void foo() {} >
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/ast/unclosedDirective.jet b/tests/org.eclipse.jet.tests.core/data/parser/ast/unclosedDirective.jet
new file mode 100644
index 0000000..c822dec
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/ast/unclosedDirective.jet
@@ -0,0 +1 @@
+<%@jet package="org.eclipse.emf.examples.test" class="Foo" \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/ast/unclosedExpression.jet b/tests/org.eclipse.jet.tests.core/data/parser/ast/unclosedExpression.jet
new file mode 100644
index 0000000..b67abe9
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/ast/unclosedExpression.jet
@@ -0,0 +1,3 @@
+<%@jet package="org.eclipse.emf.examples.test" class="Foo" %>
+
+<%= "Hello World!" >
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/ast/unclosedScriplet.jet b/tests/org.eclipse.jet.tests.core/data/parser/ast/unclosedScriplet.jet
new file mode 100644
index 0000000..dd654a9
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/ast/unclosedScriplet.jet
@@ -0,0 +1,3 @@
+<%@jet package="org.eclipse.emf.examples.test" class="Foo" %>
+
+<% String x = "Hello World!"; >
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/ast/unclosedXMLEnd.jet b/tests/org.eclipse.jet.tests.core/data/parser/ast/unclosedXMLEnd.jet
new file mode 100644
index 0000000..08f095f
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/ast/unclosedXMLEnd.jet
@@ -0,0 +1,3 @@
+<%@taglib id="org.eclipse.jet.controlTags" prefix="test" %>
+
+</test:include
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/ast/unclosedXMLStart.jet b/tests/org.eclipse.jet.tests.core/data/parser/ast/unclosedXMLStart.jet
new file mode 100644
index 0000000..31f3ccf
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/ast/unclosedXMLStart.jet
@@ -0,0 +1,3 @@
+<%@taglib id="org.eclipse.jet.controlTags" prefix="test" %>
+
+<test:include template="foo"
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/legacy/alljet2.jet b/tests/org.eclipse.jet.tests.core/data/parser/legacy/alljet2.jet
new file mode 100644
index 0000000..241c44d
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/legacy/alljet2.jet
@@ -0,0 +1,34 @@
+<%@jet class="Foo" package="org.eclipse.emf.examples"%>
+Some top level text.
+<%= "An expression" %>
+<%!
+int foo() {
+ return 3;
+}
+%>
+<%
+if(foo() > 0) {
+ foo();
+}
+%>
+<%-- a comment --%>
+<test:container one="test one" two='test two'>
+ <test:empty/>
+ <test:container>
+ some text <nontest:text attributes="foo"/>
+ </test:container>
+</test:container>
+<%-- tags containing Java --%>
+<test:container>
+ <%= foo(); %>
+ <% if(foo() > 0) { %>
+ some text
+ <% } %>
+</test:container>
+<%-- Java container tags --%>
+<% if(foo() > 0) { %>
+ some text
+ <test:empty/>
+ <test:container>
+ </test:container>
+<% } %>
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/legacy/alljet2.jet.expected b/tests/org.eclipse.jet.tests.core/data/parser/legacy/alljet2.jet.expected
new file mode 100644
index 0000000..43b65a2
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/legacy/alljet2.jet.expected
@@ -0,0 +1,93 @@
+<directive name="jet" start="(1,1)" stop="(1,56)">
+ <attribute name="class">Foo</attribute>
+ <attribute name="package">org.eclipse.emf.examples</attribute>
+</directive>
+<data>
+Some top level text.
+</data>
+<expression start="(3,4)" stop="(3,21)"> "An expression" </expression>
+<data>
+</data>
+<declaration start="(4,4)" stop="(8,1)">
+int foo() {
+ return 3;
+}
+</declaration>
+<data>
+</data>
+<scriptlet start="(9,3)" stop="(13,1)">
+if(foo() > 0) {
+ foo();
+}
+</scriptlet>
+<data>
+</data>
+<comment start="(14,5)" stop="(14,16)"> a comment </comment>
+<data>
+</data>
+<tag name="test:container" start="(15,1)" stop="(15,47)">
+ <attribute name="one">test one</attribute>
+ <attribute name="two">test two</attribute>
+ <content>
+ <data>
+ </data>
+ <tag name="test:empty" start="(16,5)" stop="(16,18)">
+ </tag>
+ <data>
+ </data>
+ <tag name="test:container" start="(17,5)" stop="(17,21)">
+ <content>
+ <data>
+ some text <nontest:text attributes="foo"/>
+ </data>
+ </content>
+ </tag>
+ <data>
+</data>
+ </content>
+</tag>
+<data>
+</data>
+<comment start="(21,5)" stop="(21,27)"> tags containing Java </comment>
+<data>
+</data>
+<tag name="test:container" start="(22,1)" stop="(22,17)">
+ <content>
+ <data>
+ </data>
+ <expression start="(23,8)" stop="(23,16)"> foo(); </expression>
+ <data>
+ </data>
+ <scriptlet start="(24,7)" stop="(24,24)"> if(foo() > 0) { </scriptlet>
+ <data>
+ some text
+ </data>
+ <scriptlet start="(26,7)" stop="(26,10)"> } </scriptlet>
+ <data>
+</data>
+ </content>
+</tag>
+<data>
+</data>
+<comment start="(28,5)" stop="(28,26)"> Java container tags </comment>
+<data>
+</data>
+<scriptlet start="(29,3)" stop="(29,20)"> if(foo() > 0) { </scriptlet>
+<data>
+ some text
+ </data>
+<tag name="test:empty" start="(31,9)" stop="(31,22)">
+</tag>
+<data>
+ </data>
+<tag name="test:container" start="(32,9)" stop="(32,25)">
+ <content>
+ <data>
+ </data>
+ </content>
+</tag>
+<data>
+</data>
+<scriptlet start="(34,3)" stop="(34,6)"> } </scriptlet>
+<data>
+</data>
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/legacy/unclosedComment.jet b/tests/org.eclipse.jet.tests.core/data/parser/legacy/unclosedComment.jet
new file mode 100644
index 0000000..ba01d6f
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/legacy/unclosedComment.jet
@@ -0,0 +1,3 @@
+<%@jet package="org.eclipse.emf.examples.test" class="Foo" %>
+
+<%-- String x = "Hello World!"; -%>
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/legacy/unclosedDeclaration.jet b/tests/org.eclipse.jet.tests.core/data/parser/legacy/unclosedDeclaration.jet
new file mode 100644
index 0000000..a12518f
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/legacy/unclosedDeclaration.jet
@@ -0,0 +1,3 @@
+<%@jet package="org.eclipse.emf.examples.test" class="Foo" %>
+
+<%! public void foo() {} >
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/legacy/unclosedDirective.jet b/tests/org.eclipse.jet.tests.core/data/parser/legacy/unclosedDirective.jet
new file mode 100644
index 0000000..c822dec
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/legacy/unclosedDirective.jet
@@ -0,0 +1 @@
+<%@jet package="org.eclipse.emf.examples.test" class="Foo" \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/legacy/unclosedExpression.jet b/tests/org.eclipse.jet.tests.core/data/parser/legacy/unclosedExpression.jet
new file mode 100644
index 0000000..b67abe9
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/legacy/unclosedExpression.jet
@@ -0,0 +1,3 @@
+<%@jet package="org.eclipse.emf.examples.test" class="Foo" %>
+
+<%= "Hello World!" >
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/legacy/unclosedScriplet.jet b/tests/org.eclipse.jet.tests.core/data/parser/legacy/unclosedScriplet.jet
new file mode 100644
index 0000000..dd654a9
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/legacy/unclosedScriplet.jet
@@ -0,0 +1,3 @@
+<%@jet package="org.eclipse.emf.examples.test" class="Foo" %>
+
+<% String x = "Hello World!"; >
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/legacy/unclosedXMLEnd.jet b/tests/org.eclipse.jet.tests.core/data/parser/legacy/unclosedXMLEnd.jet
new file mode 100644
index 0000000..08f095f
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/legacy/unclosedXMLEnd.jet
@@ -0,0 +1,3 @@
+<%@taglib id="org.eclipse.jet.controlTags" prefix="test" %>
+
+</test:include
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/legacy/unclosedXMLStart.jet b/tests/org.eclipse.jet.tests.core/data/parser/legacy/unclosedXMLStart.jet
new file mode 100644
index 0000000..31f3ccf
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/legacy/unclosedXMLStart.jet
@@ -0,0 +1,3 @@
+<%@taglib id="org.eclipse.jet.controlTags" prefix="test" %>
+
+<test:include template="foo"
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/legacy/xmlEndWithAttributes.jet b/tests/org.eclipse.jet.tests.core/data/parser/legacy/xmlEndWithAttributes.jet
new file mode 100644
index 0000000..a614208
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/legacy/xmlEndWithAttributes.jet
@@ -0,0 +1,3 @@
+<%@jet package="org.eclipse.emf.examples.test" class="Foo" %>
+
+</test:start attr="value">
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/legacy/xmlStartWithoutEnd.jet b/tests/org.eclipse.jet.tests.core/data/parser/legacy/xmlStartWithoutEnd.jet
new file mode 100644
index 0000000..54760f5
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/legacy/xmlStartWithoutEnd.jet
@@ -0,0 +1,8 @@
+<%@jet package="org.eclipse.emf.examples.test" class="Foo" %>
+
+<test:start attr="value">
+
+<test:start2 attr="two">
+
+</test:start>
+</test:start2> \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/lineinfo.jet b/tests/org.eclipse.jet.tests.core/data/parser/lineinfo.jet
new file mode 100644
index 0000000..2bc9dfc
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/lineinfo.jet
@@ -0,0 +1,10 @@
+<%@taglib id="org.eclipse.jet.tests.TestLibrary" prefix="test" %>
+"isAllUpper", "nl", "other", "tokenize", "upper"
+
+<test:tokenize string="a,b,c,d,e,f,g" sep="," var="token">
+<test:other>some text</test:other>
+<test:isAllUpper var="token">
+</test:isAllUpper>
+<test:upper>foo</test:upper><test:nl/>
+<test:other/>
+</test:tokenize> \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/lineinfo.jet.expected.txt b/tests/org.eclipse.jet.tests.core/data/parser/lineinfo.jet.expected.txt
new file mode 100644
index 0000000..4fecfd7
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/lineinfo.jet.expected.txt
@@ -0,0 +1,10 @@
+1:69:<%@taglib id="org.eclipse.jet.tests.TestLibrary" prefix="test" %>
+2:48:"isAllUpper", "nl", "other", "tokenize", "upper"
+3:0:
+4:58:<test:tokenize string="a,b,c,d,e,f,g" sep="," var="token">
+5:34:<test:other>some text</test:other>
+6:29:<test:isAllUpper var="token">
+7:18:</test:isAllUpper>
+8:38:<test:upper>foo</test:upper><test:nl/>
+9:13:<test:other/>
+10:16:</test:tokenize>
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/v1/alt1/include2.jetinc b/tests/org.eclipse.jet.tests.core/data/parser/v1/alt1/include2.jetinc
new file mode 100644
index 0000000..1435b71
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/v1/alt1/include2.jetinc
@@ -0,0 +1,3 @@
+This is content from include2.jetinc in alt1.
+<%@ include file="include2.jetinc" %>
+Done
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/v1/alt2/include2.jetinc b/tests/org.eclipse.jet.tests.core/data/parser/v1/alt2/include2.jetinc
new file mode 100644
index 0000000..75d8420
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/v1/alt2/include2.jetinc
@@ -0,0 +1,4 @@
+This is content from include2.jetinc in alt2.
+7 + 8 = <%= 7 + 8 %>
+<%@include file="include1.jetinc"%>
+Done
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/v1/base/alternative.include.javajet b/tests/org.eclipse.jet.tests.core/data/parser/v1/base/alternative.include.javajet
new file mode 100644
index 0000000..264a6bf
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/v1/base/alternative.include.javajet
@@ -0,0 +1,36 @@
+<%@jet class="Simple" package="org.eclipse.jet.tests.tools.tempates" %>
+--- before failing include with alternative >>>
+<%@include file="include1.fail.jetinc" fail="alternative"%>
+<%@start%>
+ Alternative text to include1.fail.jetinc
+ 2 + 4 = <%= 2 + 4 %>
+ <%@include file="include1.jetinc" fail="alternative"%>
+ <%@start%>
+ Fail alternative for include1.jetinc within fail alternative of include1.fail.jetinc
+ <%@end%>
+ <%@include file="include2.fail.jetinc" fail="alternative"%>
+ <%@start%>
+ Fail alternative for include2.fail.jetinc within fail alternative of include1.fail.jetinc
+ <%@end%>
+<%@end%>
+<<< after include ---
+
+--- before successful include with alternative >>>
+<%@include file="include1.jetinc" fail="alternative"%>
+<%@start%>
+ Alternative text to include1.jetinc - should not be processed
+ 7 + 3 = <%= 7 + 3 %>
+ <%@include file="include2.jetinc" fail="alternative"%>
+ <%@start%>
+ Fail alternative for include2.jetinc within fail alternative of include1.jetinc
+ <%@end%>
+ <%@include file="include2.fail.jetinc" fail="alternative"%>
+ <%@start%>
+ Fail alternative for include2.fail.jetinc within fail alternative of include1.jetinc
+ <%@end%>
+<%@end%>
+<<< after include ---
+
+--- before failing include with alternative >>>
+<%@include file="include1.fail.jetinc" fail="silent"%>
+<<< after include ---
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/v1/base/alternative.include.javajet.astdump.expected b/tests/org.eclipse.jet.tests.core/data/parser/v1/base/alternative.include.javajet.astdump.expected
new file mode 100644
index 0000000..f0eef0e
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/v1/base/alternative.include.javajet.astdump.expected
@@ -0,0 +1,74 @@
+<directive name="jet" line="1" col="1">
+ <attribute name="class">Simple</attribute>
+ <attribute name="package">org.eclipse.jet.tests.tools.tempates</attribute>
+</directive>
+<data>--- before failing include with alternative >>>
+</data>
+<directive name="include" line="3" col="1">
+ <attribute name="file">include1.fail.jetinc</attribute>
+ <attribute name="fail">alternative</attribute>
+</directive>
+<data></data>
+<directive name="start" line="4" col="1">
+</directive>
+<data> Alternative text to include1.fail.jetinc
+ 2 + 4 = </data>
+<expression line="6" col="14"> 2 + 4 </expression>
+<data>
+ </data>
+<directive name="include" line="7" col="3">
+ <attribute name="file">include1.jetinc</attribute>
+ <attribute name="fail">alternative</attribute>
+</directive>
+<included templatePath="include1.jetinc" baseLocation="platform:/plugin/org.eclipse.jet.tests.core/data/parser/v1/base/">
+ <data>This is content from include1.jetinc in base.
+3 + 5 = </data>
+ <expression line="2" col="12"> 3 + 5 </expression>
+ <data>
+Done
+</data>
+</included>
+<data> </data>
+<data>
+</data>
+<directive name="include" line="11" col="3">
+ <attribute name="file">include2.fail.jetinc</attribute>
+ <attribute name="fail">alternative</attribute>
+</directive>
+<data></data>
+<directive name="start" line="12" col="3">
+</directive>
+<data> Fail alternative for include2.fail.jetinc within fail alternative of include1.fail.jetinc
+</data>
+<directive name="end" line="14" col="3">
+</directive>
+<data></data>
+<directive name="end" line="15" col="1">
+</directive>
+<data><<< after include ---
+
+--- before successful include with alternative >>>
+</data>
+<directive name="include" line="19" col="1">
+ <attribute name="file">include1.jetinc</attribute>
+ <attribute name="fail">alternative</attribute>
+</directive>
+<included templatePath="include1.jetinc" baseLocation="platform:/plugin/org.eclipse.jet.tests.core/data/parser/v1/base/">
+ <data>This is content from include1.jetinc in base.
+3 + 5 = </data>
+ <expression line="2" col="12"> 3 + 5 </expression>
+ <data>
+Done
+</data>
+</included>
+<data>
+<<< after include ---
+
+--- before failing include with alternative >>>
+</data>
+<directive name="include" line="35" col="1">
+ <attribute name="file">include1.fail.jetinc</attribute>
+ <attribute name="fail">silent</attribute>
+</directive>
+<data><<< after include ---
+</data>
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/v1/base/complex.include.javajet b/tests/org.eclipse.jet.tests.core/data/parser/v1/base/complex.include.javajet
new file mode 100644
index 0000000..2a9764f
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/v1/base/complex.include.javajet
@@ -0,0 +1,4 @@
+<%@jet class="Simple" package="org.eclipse.jet.tests.tools.tempates" %>
+--- before include >>>
+<%@include file="include2.jetinc"%>
+<<< after include ---
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/v1/base/complex.include.javajet.astdump.expected b/tests/org.eclipse.jet.tests.core/data/parser/v1/base/complex.include.javajet.astdump.expected
new file mode 100644
index 0000000..88b4247
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/v1/base/complex.include.javajet.astdump.expected
@@ -0,0 +1,49 @@
+<directive name="jet" line="1" col="1">
+ <attribute name="class">Simple</attribute>
+ <attribute name="package">org.eclipse.jet.tests.tools.tempates</attribute>
+</directive>
+<data>--- before include >>>
+</data>
+<directive name="include" line="3" col="1">
+ <attribute name="file">include2.jetinc</attribute>
+</directive>
+<included templatePath="include2.jetinc" baseLocation="platform:/plugin/org.eclipse.jet.tests.core/data/parser/v1/base/">
+ <data>This is content from include2.jetinc in base.
+</data>
+ <directive name="include" line="2" col="1">
+ <attribute name="file">include2.jetinc</attribute>
+ </directive>
+ <included templatePath="include2.jetinc" baseLocation="platform:/plugin/org.eclipse.jet.tests.core/data/parser/v1/alt1/">
+ <data>This is content from include2.jetinc in alt1.
+</data>
+ <directive name="include" line="2" col="1">
+ <attribute name="file">include2.jetinc</attribute>
+ </directive>
+ <included templatePath="include2.jetinc" baseLocation="platform:/plugin/org.eclipse.jet.tests.core/data/parser/v1/alt2/">
+ <data>This is content from include2.jetinc in alt2.
+7 + 8 = </data>
+ <expression line="2" col="12"> 7 + 8 </expression>
+ <data>
+</data>
+ <directive name="include" line="3" col="1">
+ <attribute name="file">include1.jetinc</attribute>
+ </directive>
+ <included templatePath="include1.jetinc" baseLocation="platform:/plugin/org.eclipse.jet.tests.core/data/parser/v1/base/">
+ <data>This is content from include1.jetinc in base.
+3 + 5 = </data>
+ <expression line="2" col="12"> 3 + 5 </expression>
+ <data>
+Done
+</data>
+ </included>
+ <data>Done
+</data>
+ </included>
+ <data>Done
+</data>
+ </included>
+ <data>Done
+</data>
+</included>
+<data><<< after include ---
+</data>
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/v1/base/include1.jetinc b/tests/org.eclipse.jet.tests.core/data/parser/v1/base/include1.jetinc
new file mode 100644
index 0000000..ef24377
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/v1/base/include1.jetinc
@@ -0,0 +1,3 @@
+This is content from include1.jetinc in base.
+3 + 5 = <%= 3 + 5 %>
+Done
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/v1/base/include2.jetinc b/tests/org.eclipse.jet.tests.core/data/parser/v1/base/include2.jetinc
new file mode 100644
index 0000000..230b451
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/v1/base/include2.jetinc
@@ -0,0 +1,3 @@
+This is content from include2.jetinc in base.
+<%@ include file="include2.jetinc" %>
+Done
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/v1/base/simple.include.javajet b/tests/org.eclipse.jet.tests.core/data/parser/v1/base/simple.include.javajet
new file mode 100644
index 0000000..80803f6
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/v1/base/simple.include.javajet
@@ -0,0 +1,4 @@
+<%@jet class="Simple" package="org.eclipse.jet.tests.tools.tempates" %>
+--- before include >>>
+<%@include file="include1.jetinc"%>
+<<< after include ---
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/v1/base/simple.include.javajet.astdump.expected b/tests/org.eclipse.jet.tests.core/data/parser/v1/base/simple.include.javajet.astdump.expected
new file mode 100644
index 0000000..6051345
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/v1/base/simple.include.javajet.astdump.expected
@@ -0,0 +1,19 @@
+<directive name="jet" line="1" col="1">
+ <attribute name="class">Simple</attribute>
+ <attribute name="package">org.eclipse.jet.tests.tools.tempates</attribute>
+</directive>
+<data>--- before include >>>
+</data>
+<directive name="include" line="3" col="1">
+ <attribute name="file">include1.jetinc</attribute>
+</directive>
+<included templatePath="include1.jetinc" baseLocation="platform:/plugin/org.eclipse.jet.tests.core/data/parser/v1/base/">
+ <data>This is content from include1.jetinc in base.
+3 + 5 = </data>
+ <expression line="2" col="12"> 3 + 5 </expression>
+ <data>
+Done
+</data>
+</included>
+<data><<< after include ---
+</data>
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/v1/base/simple.include.javajet.chararray.astdump.expected b/tests/org.eclipse.jet.tests.core/data/parser/v1/base/simple.include.javajet.chararray.astdump.expected
new file mode 100644
index 0000000..ff45607
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/v1/base/simple.include.javajet.chararray.astdump.expected
@@ -0,0 +1,11 @@
+<directive name="jet" line="1" col="1">
+ <attribute name="class">Simple</attribute>
+ <attribute name="package">org.eclipse.jet.tests.tools.tempates</attribute>
+</directive>
+<data>--- before include >>>
+</data>
+<directive name="include" line="3" col="1">
+ <attribute name="file">include1.jetinc</attribute>
+</directive>
+<data><<< after include ---
+</data>
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/v1/base/simple.javajet b/tests/org.eclipse.jet.tests.core/data/parser/v1/base/simple.javajet
new file mode 100644
index 0000000..b910599
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/v1/base/simple.javajet
@@ -0,0 +1,9 @@
+<%@jet class="Simple" package="org.eclipse.jet.tests.tools.tempates" %>
+--- before scriptlet >>>
+<%
+// This is a scriptlet
+String value = "World";
+%>
+<<< after scriptlet ---
+
+Hello <%= value %>!
diff --git a/tests/org.eclipse.jet.tests.core/data/parser/v1/base/simple.javajet.astdump.expected b/tests/org.eclipse.jet.tests.core/data/parser/v1/base/simple.javajet.astdump.expected
new file mode 100644
index 0000000..4af00e5
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/parser/v1/base/simple.javajet.astdump.expected
@@ -0,0 +1,16 @@
+<directive name="jet" line="1" col="1">
+ <attribute name="class">Simple</attribute>
+ <attribute name="package">org.eclipse.jet.tests.tools.tempates</attribute>
+</directive>
+<data>--- before scriptlet >>>
+</data>
+<scriptlet line="3" col="3">
+// This is a scriptlet
+String value = "World";
+</scriptlet>
+<data><<< after scriptlet ---
+
+Hello </data>
+<expression line="9" col="10"> value </expression>
+<data>!
+</data>
diff --git a/tests/org.eclipse.jet.tests.core/data/templates/base1/nested/test3.txt b/tests/org.eclipse.jet.tests.core/data/templates/base1/nested/test3.txt
new file mode 100644
index 0000000..04fabc7
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/templates/base1/nested/test3.txt
@@ -0,0 +1 @@
+This is nested/test3.txt in data/templates/base1. \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests.core/data/templates/base1/nested/test4.txt b/tests/org.eclipse.jet.tests.core/data/templates/base1/nested/test4.txt
new file mode 100644
index 0000000..e6f09cd
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/templates/base1/nested/test4.txt
@@ -0,0 +1 @@
+This is nested/test4.txt in data/templates/base1. \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests.core/data/templates/base1/test1.txt b/tests/org.eclipse.jet.tests.core/data/templates/base1/test1.txt
new file mode 100644
index 0000000..be088ae
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/templates/base1/test1.txt
@@ -0,0 +1 @@
+This is test1.txt in data/templates/base1. \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests.core/data/templates/base1/test2.txt b/tests/org.eclipse.jet.tests.core/data/templates/base1/test2.txt
new file mode 100644
index 0000000..ebbc1b4
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/templates/base1/test2.txt
@@ -0,0 +1 @@
+This is test2.txt in data/templates/base1. \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests.core/data/templates/base2/nested/test5.txt b/tests/org.eclipse.jet.tests.core/data/templates/base2/nested/test5.txt
new file mode 100644
index 0000000..62f7a19
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/templates/base2/nested/test5.txt
@@ -0,0 +1 @@
+This is nested/test5.txt in data/templates/base2. \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests.core/data/templates/base2/test1.txt b/tests/org.eclipse.jet.tests.core/data/templates/base2/test1.txt
new file mode 100644
index 0000000..9a38f46
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/templates/base2/test1.txt
@@ -0,0 +1 @@
+This is test1.txt in data/templates/base2. \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests.core/data/templates/base2/test2.txt b/tests/org.eclipse.jet.tests.core/data/templates/base2/test2.txt
new file mode 100644
index 0000000..c36abf0
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/data/templates/base2/test2.txt
@@ -0,0 +1 @@
+This is test2.txt in data/templates/base2. \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/core/AllTests.java b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/core/AllTests.java
new file mode 100644
index 0000000..9af446f
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/core/AllTests.java
@@ -0,0 +1,19 @@
+package org.eclipse.jet.tests.core;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("Test for org.eclipse.jet.tests.tools"); //$NON-NLS-1$
+ suite.addTest(org.eclipse.jet.tests.parser.jasper.AllTests.suite());
+ suite.addTest(org.eclipse.jet.tests.tools.compiler.AllTests.suite());
+ suite.addTest(org.eclipse.jet.tests.tools.parser.AllTests.suite());
+ //$JUnit-BEGIN$
+ suite.addTestSuite(TestNewLineUtil.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/core/AllToolsSuites.java b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/core/AllToolsSuites.java
new file mode 100644
index 0000000..ce4c6fa
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/core/AllToolsSuites.java
@@ -0,0 +1,60 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *
+ * </copyright>
+ *
+ * $Id: AllToolsSuites.java,v 1.1 2007/04/04 14:55:55 pelder Exp $
+ */
+
+package org.eclipse.jet.tests.core;
+
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllToolsSuites extends TestSuite
+{
+ private static Test[] suites = new Test []{
+ org.eclipse.jet.tests.core.AllTests.suite(),
+ };
+
+ public static Test suite()
+ {
+ return new AllToolsSuites("JET Build JUnit Test Suite"); //$NON-NLS-1$
+ }
+
+ public AllToolsSuites()
+ {
+ super();
+ populateSuite();
+ }
+
+ public AllToolsSuites(Class theClass)
+ {
+ super(theClass);
+ populateSuite();
+ }
+
+ public AllToolsSuites(String name)
+ {
+ super(name);
+ populateSuite();
+ }
+
+ protected void populateSuite()
+ {
+ for (int i = 0; i < suites.length; i++)
+ {
+ addTest(suites[i]);
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/core/FileUtils.java b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/core/FileUtils.java
new file mode 100644
index 0000000..8aafa2d
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/core/FileUtils.java
@@ -0,0 +1,78 @@
+package org.eclipse.jet.tests.core;
+
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.core.filebuffers.ITextFileBuffer;
+import org.eclipse.core.filebuffers.ITextFileBufferManager;
+import org.eclipse.core.filebuffers.manipulation.ConvertLineDelimitersOperation;
+import org.eclipse.core.filebuffers.manipulation.FileBufferOperationRunner;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jet.internal.core.NewLineUtil;
+
+/**
+ * File utilities for Unit tests getting expected results from the JUnit project.
+ *
+ */
+public class FileUtils {
+
+ /**
+ *
+ *
+ */
+ private FileUtils() {
+ // prevent instantiation.
+ }
+
+ /**
+ * Resolve a URL to a location string (file system absolute path).
+ * @param urlString a URL string, possibly using the platform:/ format.
+ * @return an absolute file system path corresponding to <code>urlString</code>
+ * @throws IOException if an IO error occurs
+ * @throws MalformedURLException if urlString is an invalid URL
+ */
+ public static String resolveURLToLocationString(String urlString) throws IOException, MalformedURLException {
+ String fileName = Platform.resolve(new URL(urlString)).getFile();
+ return fileName;
+ }
+
+ /**
+ * Return the file contents as a string. This method also converts the file's line
+ * separator to the current system's line separator if <code>convertNewLines</code> is <code>true</code>.
+ * @param urlString a URL string, possibly using the platform:/ format.
+ * @param convertNewLines Convert the file line separators to the system line separator.
+ * @return the file contents
+ * @throws IOException if an IO error occurs
+ * @throws MalformedURLException if urlString is an invalid URL
+ * @throws CoreException if an error occurs reading the file.
+ */
+ public static String getFileContents(String urlString, boolean convertNewLines) throws MalformedURLException, IOException, CoreException {
+
+ final ITextFileBufferManager textBufferMgr = FileBuffers.getTextFileBufferManager();
+ String fileName = resolveURLToLocationString(urlString);
+
+ final IPath path = new Path(fileName);
+ textBufferMgr.connect(path, new NullProgressMonitor());
+ final ITextFileBuffer textFileBuffer = textBufferMgr.getTextFileBuffer(path);
+
+ if(convertNewLines) {
+ new FileBufferOperationRunner(textBufferMgr, null)
+ .execute(
+ new IPath[] { path },
+ new ConvertLineDelimitersOperation(System.getProperty("line.separator")), //$NON-NLS-1$
+ new NullProgressMonitor());
+ }
+
+ final String result = textFileBuffer.getDocument().get();
+ textBufferMgr.disconnect(path, new NullProgressMonitor());
+ return result;
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/core/TestNewLineUtil.java b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/core/TestNewLineUtil.java
new file mode 100644
index 0000000..4530281
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/core/TestNewLineUtil.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ */
+package org.eclipse.jet.tests.core;
+
+import org.eclipse.jet.internal.core.NewLineUtil;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for ReplaceLineTerminatorOperation
+ *
+ */
+public class TestNewLineUtil extends TestCase {
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testSetLineTerminator() {
+ final String mixedText = "Line1\nLine2\r\nLine3\n\rLine4\r\n"; //$NON-NLS-1$
+ final String result = NewLineUtil.setLineTerminator(mixedText, "\n"); //$NON-NLS-1$
+
+ final String expected = "Line1\nLine2\nLine3\n\nLine4\n"; //$NON-NLS-1$
+ assertEquals(expected,result);
+ }
+
+ public void testGetLineTerminator() {
+ final String windowsText = "Line1\r\nLine2\r\nLine3\n\rLine4\r\n"; //$NON-NLS-1$
+ assertEquals("\r\n", NewLineUtil.getLineTerminator(windowsText)); //$NON-NLS-1$
+
+ final String linuxText = "Line1\nLine2\r\nLine3\n\rLine4\r\n"; //$NON-NLS-1$
+ assertEquals("\n", NewLineUtil.getLineTerminator(linuxText)); //$NON-NLS-1$
+
+ final String macosText = "Line1\rLine2\r\nLine3\n\rLine4\r\n"; //$NON-NLS-1$
+ assertEquals("\r", NewLineUtil.getLineTerminator(macosText)); //$NON-NLS-1$
+
+ }
+}
diff --git a/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/parser/jasper/AllTests.java b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/parser/jasper/AllTests.java
new file mode 100644
index 0000000..b67c829
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/parser/jasper/AllTests.java
@@ -0,0 +1,17 @@
+package org.eclipse.jet.tests.parser.jasper;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(
+ "Test for org.eclipse.jet.tests.parser.legacy"); //$NON-NLS-1$
+ //$JUnit-BEGIN$
+ suite.addTestSuite(TestJETParser.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/parser/jasper/TestJETParser.java b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/parser/jasper/TestJETParser.java
new file mode 100644
index 0000000..7f7bce7
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/parser/jasper/TestJETParser.java
@@ -0,0 +1,373 @@
+package org.eclipse.jet.tests.parser.jasper;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jet.core.parser.IProblem;
+import org.eclipse.jet.core.parser.ProblemSeverity;
+import org.eclipse.jet.internal.core.NewLineUtil;
+import org.eclipse.jet.internal.core.parser.jasper.CommentElementDelegate;
+import org.eclipse.jet.internal.core.parser.jasper.DeclarationElementDelegate;
+import org.eclipse.jet.internal.core.parser.jasper.JETCoreElement;
+import org.eclipse.jet.internal.core.parser.jasper.JETException;
+import org.eclipse.jet.internal.core.parser.jasper.JETMark;
+import org.eclipse.jet.internal.core.parser.jasper.JETParseEventListener2;
+import org.eclipse.jet.internal.core.parser.jasper.JETParser;
+import org.eclipse.jet.internal.core.parser.jasper.JETReader;
+import org.eclipse.jet.internal.core.parser.jasper.XMLElementDelegate;
+import org.eclipse.jet.tests.core.FileUtils;
+
+public class TestJETParser extends TestCase {
+
+ private static final String PLUGIN_ID = "org.eclipse.jet.tests.core"; //$NON-NLS-1$
+ private static final String BASE_PLUGIN_URL = "platform:/plugin/" + PLUGIN_ID + "/data/parser/legacy/"; //$NON-NLS-1$ //$NON-NLS-2$
+
+
+ private static class SavedProblem {
+
+ private final ProblemSeverity severity;
+ private final int problemId;
+ private final String message;
+ private final Object[] msgArgs;
+ private final int start;
+ private final int end;
+ private final int line;
+
+ public SavedProblem(ProblemSeverity severity, int problemId, String message, Object[] msgArgs, int start, int end, int line) {
+ this.severity = severity;
+ this.problemId = problemId;
+ this.message = message;
+ this.msgArgs = msgArgs;
+ this.start = start;
+ this.end = end;
+ this.line = line;
+ }
+
+ /**
+ * @return Returns the end.
+ */
+ public final int getEnd() {
+ return end;
+ }
+
+ /**
+ * @return Returns the line.
+ */
+ public final int getLine() {
+ return line;
+ }
+
+ /**
+ * @return Returns the message.
+ */
+ public final String getMessage() {
+ return message;
+ }
+
+ /**
+ * @return Returns the msgArgs.
+ */
+ public final Object[] getMsgArgs() {
+ return msgArgs;
+ }
+
+ /**
+ * @return Returns the problemId.
+ */
+ public final int getProblemId() {
+ return problemId;
+ }
+
+ /**
+ * @return Returns the severity.
+ */
+ public final ProblemSeverity getSeverity() {
+ return severity;
+ }
+
+ /**
+ * @return Returns the start.
+ */
+ public final int getStart() {
+ return start;
+ }
+
+ }
+
+ private static class AllJET2SyntaxListener implements JETParseEventListener2 {
+
+ private final StringBuffer buffer = new StringBuffer();
+ private int indent = 0;
+ private final String NL = System.getProperty("line.separator"); //$NON-NLS-1$
+ private final JETReader reader;
+ private final List problems = new ArrayList();
+
+
+ public AllJET2SyntaxListener(JETReader reader) {
+ this.reader = reader;
+ }
+
+ public void beginPageProcessing() throws JETException {
+// doIndent();
+// buffer.append("<jet2>").append(NL); //$NON-NLS-1$
+// indent++;
+ }
+
+ private void doIndent() {
+ for(int i = 0; i < indent; i++) {
+ buffer.append(" "); //$NON-NLS-1$
+ }
+ }
+
+ public void endPageProcessing() throws JETException {
+// doIndent();
+// buffer.append("</jet2>").append(NL); //$NON-NLS-1$
+ }
+
+ public String getLog() {
+ return NewLineUtil.setLineTerminator(buffer, NL);
+ }
+
+ public void handleCharData(char[] chars) throws JETException {
+ doIndent();
+ buffer.append("<data>").append(chars).append("</data>").append(NL); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void handleComment(JETMark start, JETMark stop) {
+ doIndent();
+ buffer.append("<comment start=\"" + start.toShortString() + "\" stop=\"" + stop.toShortString() + "\">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ buffer.append(reader.getChars(start,stop));
+ buffer.append("</comment>").append(NL); //$NON-NLS-1$
+
+ }
+
+ public void handleDeclaration(JETMark start, JETMark stop) {
+ doIndent();
+ buffer.append("<declaration start=\"" + start.toShortString() + "\" stop=\"" + stop.toShortString() + "\">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ buffer.append(reader.getChars(start,stop));
+ buffer.append("</declaration>").append(NL); //$NON-NLS-1$
+
+ }
+
+ public void handleDirective(String directive, JETMark start,
+ JETMark stop, Map attributes) throws JETException {
+ doIndent();
+ buffer.append("<directive name=\"" + directive + "\" start=\"" + start.toShortString() + "\" stop=\"" + stop.toShortString() + "\">").append(NL); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ indent++;
+ for (Iterator i = attributes.entrySet().iterator(); i.hasNext();) {
+ Map.Entry entry = (Map.Entry) i.next();
+ doIndent();
+ buffer.append("<attribute name=\"" + entry.getKey() + "\">"); //$NON-NLS-1$ //$NON-NLS-2$
+ buffer.append(entry.getValue()).append("</attribute>").append(NL); //$NON-NLS-1$
+
+ }
+ indent--;
+ doIndent();
+ buffer.append("</directive>").append(NL); //$NON-NLS-1$
+ }
+
+ public void handleExpression(JETMark start, JETMark stop, Map attributes)
+ throws JETException {
+ doIndent();
+ buffer.append("<expression start=\"" + start.toShortString() + "\" stop=\"" + stop.toShortString() + "\">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ buffer.append(reader.getChars(start,stop));
+ buffer.append("</expression>").append(NL); //$NON-NLS-1$
+ }
+
+ public void handleScriptlet(JETMark start, JETMark stop, Map attributes)
+ throws JETException {
+ doIndent();
+ buffer.append("<scriptlet start=\"" + start.toShortString() + "\" stop=\"" + stop.toShortString() + "\">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ buffer.append(reader.getChars(start,stop));
+ buffer.append("</scriptlet>").append(NL); //$NON-NLS-1$
+ }
+
+ public void handleXMLEmptyTag(String tagName, JETMark start, JETMark stop, Map attributeMap) {
+ doIndent();
+ buffer.append("<tag name=\"" + tagName + "\" start=\"" + start.toShortString() + "\" stop=\"" + stop.toShortString() + "\">").append(NL); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ indent++;
+ for (Iterator i = attributeMap.entrySet().iterator(); i.hasNext();) {
+ Map.Entry entry = (Map.Entry) i.next();
+ doIndent();
+ buffer.append("<attribute name=\"" + entry.getKey() + "\">" + entry.getValue() + "</attribute>").append(NL); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ indent--;
+ doIndent();
+ buffer.append("</tag>").append(NL); //$NON-NLS-1$
+ }
+
+ public void handleXMLEndTag(String tagName, JETMark start, JETMark stop) {
+ indent--;
+ doIndent();
+ buffer.append("</content>").append(NL); //$NON-NLS-1$
+ indent--;
+ doIndent();
+ buffer.append("</tag>").append(NL); //$NON-NLS-1$
+ }
+
+ public void handleXMLStartTag(String tagName, JETMark start, JETMark stop, Map attributeMap) {
+ doIndent();
+ buffer.append("<tag name=\"" + tagName + "\" start=\"" + start.toShortString() + "\" stop=\"" + stop.toShortString() + "\">").append(NL); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ indent++;
+ for (Iterator i = attributeMap.entrySet().iterator(); i.hasNext();) {
+ Map.Entry entry = (Map.Entry) i.next();
+ doIndent();
+ buffer.append("<attribute name=\"" + entry.getKey() + "\">" + entry.getValue() + "</attribute>").append(NL); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ doIndent();
+ buffer.append("<content>").append(NL); //$NON-NLS-1$
+ indent++;
+ }
+
+ public boolean isKnownTag(String tagName) {
+ return tagName.startsWith("test:"); //$NON-NLS-1$
+ }
+
+ /**
+ * @return Returns the problems.
+ */
+ public final List getProblems() {
+ return problems;
+ }
+
+ public void recordProblem(ProblemSeverity severity, int problemId, String message, Object[] msgArgs, int start, int end, int line, int colOffset) {
+ problems.add(new SavedProblem(severity, problemId, message, msgArgs, start, end, line));
+
+ }
+
+ public boolean isKnownInvalidTagName(String tagName) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+ }
+
+ private AllJET2SyntaxListener doJET2Parse(String urlString) throws IOException, MalformedURLException, FileNotFoundException, JETException {
+ String fileName = FileUtils.resolveURLToLocationString(urlString);
+
+ FileInputStream inputStream = new FileInputStream(new File(fileName));
+ JETReader reader = new JETReader(urlString, inputStream, "UTF8"); //$NON-NLS-1$
+ AllJET2SyntaxListener listener = new AllJET2SyntaxListener(reader);
+ JETParser.Directive directive = new JETParser.Directive();
+ directive.getDirectives().add("jet"); //$NON-NLS-1$
+ directive.getDirectives().add("taglib"); //$NON-NLS-1$
+
+ JETCoreElement[] coreElements = new JETCoreElement[] {
+ directive,
+ new JETParser.Expression(),
+ new CommentElementDelegate(),
+ new DeclarationElementDelegate(),
+ new JETParser.Scriptlet(),
+ new XMLElementDelegate(),
+ };
+ JETParser parser = new JETParser(reader, listener, coreElements);
+
+ parser.parse();
+ return listener;
+ }
+
+ private void doUnclosedElementTest(String urlString, String openChars, int expectedProblemId) throws IOException, MalformedURLException, FileNotFoundException, JETException {
+ final AllJET2SyntaxListener listener = doJET2Parse(urlString);
+ final List problems = listener.getProblems();
+ assertEquals(1, problems.size());
+ SavedProblem problem = (SavedProblem) problems.get(0);
+ assertEquals(ProblemSeverity.ERROR, problem.getSeverity());
+ assertEquals(expectedProblemId, problem.getProblemId());
+ }
+
+ public void testAllJET2Syntax() throws Exception {
+ String urlString = BASE_PLUGIN_URL + "alljet2.jet"; //$NON-NLS-1$
+ AllJET2SyntaxListener listener = doJET2Parse(urlString);
+
+ assertEquals(FileUtils.getFileContents(urlString + ".expected", true), listener.getLog()); //$NON-NLS-1$
+ }
+
+ public void testUnclosedComment() throws Exception {
+ String urlString = BASE_PLUGIN_URL + "unclosedComment.jet"; //$NON-NLS-1$
+ String openChars = "<%--"; //$NON-NLS-1$
+
+ doUnclosedElementTest(urlString, openChars, IProblem.UnterminatedXMLTag);
+
+
+ }
+
+ public void testUnclosedDeclaration() throws Exception {
+ String urlString = BASE_PLUGIN_URL + "unclosedDeclaration.jet"; //$NON-NLS-1$
+ String openChars = "<%!"; //$NON-NLS-1$
+
+ doUnclosedElementTest(urlString, openChars, IProblem.UnterminatedXMLTag);
+ }
+
+ public void testUnclosedDirective() throws Exception {
+ String urlString = BASE_PLUGIN_URL + "unclosedDirective.jet"; //$NON-NLS-1$
+ String openChars = "<%@"; //$NON-NLS-1$
+
+ try {
+ doUnclosedElementTest(urlString, openChars, 0);
+ fail();
+ } catch(JETException e) {
+ // success.
+ }
+ }
+
+ public void testUnclosedExpression() throws Exception {
+ String urlString = BASE_PLUGIN_URL + "unclosedExpression.jet"; //$NON-NLS-1$
+ String openChars = "<%="; //$NON-NLS-1$
+
+ try {
+ doUnclosedElementTest(urlString, openChars, 0);
+ fail();
+ } catch(JETException e) {
+ // success.
+ }
+ }
+
+ public void testUnclosedScriptlet() throws Exception {
+ String urlString = BASE_PLUGIN_URL + "unclosedScriplet.jet"; //$NON-NLS-1$
+ String openChars = "<%"; //$NON-NLS-1$
+
+ try {
+ doUnclosedElementTest(urlString, openChars, 0);
+ fail();
+ } catch(JETException e) {
+ // success.
+ }
+ }
+
+ public void testUnclosedXMLStart() throws Exception {
+ String urlString = BASE_PLUGIN_URL + "unclosedXMLStart.jet"; //$NON-NLS-1$
+ String openChars = "<"; //$NON-NLS-1$
+
+ doUnclosedElementTest(urlString, openChars, IProblem.UnterminatedXMLTag);
+ }
+
+ public void testUnclosedXMLEnd() throws Exception {
+ String urlString = BASE_PLUGIN_URL + "unclosedXMLEnd.jet"; //$NON-NLS-1$
+ String openChars = "</"; //$NON-NLS-1$
+
+ doUnclosedElementTest(urlString, openChars, IProblem.UnterminatedXMLTag);
+ }
+
+ public void testXMLEndWithAttributes() throws Exception {
+ String urlString = BASE_PLUGIN_URL + "xmlEndWithAttributes.jet"; //$NON-NLS-1$
+ String openChars = "</"; //$NON-NLS-1$
+
+ doUnclosedElementTest(urlString, openChars, IProblem.UnterminatedXMLTag);
+ }
+
+ // this error is not detected by the parser, but by post parse processing.
+// public void testXMLStartWithoutEnd() throws Exception {
+// String urlString = BASE_PLUGIN_URL + "xmlStartWithoutEnd.jet";
+// String openChars = "<test:start>";
+//
+// doUnclosedElementTest(urlString, openChars, Problem.MissingXmlEndTag);
+// }
+}
diff --git a/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/AllTests.java b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/AllTests.java
new file mode 100644
index 0000000..737a035
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/AllTests.java
@@ -0,0 +1,23 @@
+package org.eclipse.jet.tests.tools.compiler;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(
+ "Test for org.eclipse.jet.tests.tools.compiler"); //$NON-NLS-1$
+ //$JUnit-BEGIN$
+ suite.addTestSuite(TestIncludeAlternativesTracker.class);
+ suite.addTestSuite(TestTemplateInput.class);
+ suite.addTestSuite(LineInfoTests.class);
+ suite.addTestSuite(IncludeDependenciesTest.class);
+ suite.addTestSuite(TestUniqueNameGenerator.class);
+ suite.addTestSuite(TestInputManager.class);
+ suite.addTestSuite(TestInputManagerBuilder.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/IncludeDependenciesTest.java b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/IncludeDependenciesTest.java
new file mode 100644
index 0000000..bd8bbd4
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/IncludeDependenciesTest.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ */
+package org.eclipse.jet.tests.tools.compiler;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jet.internal.core.compiler.IncludeDependencies;
+
+/**
+ * @author pelder
+ *
+ */
+public class IncludeDependenciesTest extends TestCase {
+
+
+ private static final String TEMPLATE_A = "templates/A.jet"; //$NON-NLS-1$
+ private static final String TEMPLATE_B = "templates/B.jet"; //$NON-NLS-1$
+ private static final String INCLUDE_X = "X.jetinc"; //$NON-NLS-1$
+ private static final String INLCUDE_Y = "Y.jetinc"; //$NON-NLS-1$
+ private static final String INCLUDE_Z = "Z.jetinc"; //$NON-NLS-1$
+ private static final String INCLUDE_W = "W.jetinc"; //$NON-NLS-1$
+ private IncludeDependencies includeDependencies;
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ includeDependencies = new IncludeDependencies();
+ includeDependencies.addDependencies(TEMPLATE_A, new String[] {INCLUDE_X, INLCUDE_Y});
+ includeDependencies.addDependencies(TEMPLATE_B, new String[] {INCLUDE_X, INCLUDE_Z});
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.internal.core.compiler.IncludeDependencies#addDependencies(java.lang.String, java.lang.String[])}.
+ */
+ public void testAddDependencies() {
+ includeDependencies.addDependencies(TEMPLATE_A, new String[] {INCLUDE_W});
+
+ final String[] xAffectedTemplates = includeDependencies.getAffectedTemplates(INCLUDE_X);
+ assertEqualSets("xAffectedTemplates", new String[]{TEMPLATE_A, TEMPLATE_B}, xAffectedTemplates); //$NON-NLS-1$
+
+ final String[] yAffectedTemplates = includeDependencies.getAffectedTemplates(INLCUDE_Y);
+ assertEqualSets("yAffectedTemplates", new String[]{TEMPLATE_A, }, yAffectedTemplates); //$NON-NLS-1$
+
+ final String[] zAffectedTemplates = includeDependencies.getAffectedTemplates(INCLUDE_Z);
+ assertEqualSets("zAffectedTemplates", new String[]{TEMPLATE_B}, zAffectedTemplates); //$NON-NLS-1$
+
+ final String[] wAffectedTemplates = includeDependencies.getAffectedTemplates(INCLUDE_W);
+ assertEqualSets("wAffectedTemplates", new String[]{TEMPLATE_A}, wAffectedTemplates); //$NON-NLS-1$
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.internal.core.compiler.IncludeDependencies#removeDependencies(java.lang.String)}.
+ */
+ public void testRemoveDependencies() {
+ includeDependencies.removeDependencies(TEMPLATE_A);
+
+ final String[] xAffectedTemplates = includeDependencies.getAffectedTemplates(INCLUDE_X);
+ assertEqualSets("xAffectedTemplates", new String[]{TEMPLATE_B}, xAffectedTemplates); //$NON-NLS-1$
+
+ final String[] yAffectedTemplates = includeDependencies.getAffectedTemplates(INLCUDE_Y);
+ assertEqualSets("yAffectedTemplates", new String[]{}, yAffectedTemplates); //$NON-NLS-1$
+
+ final String[] zAffectedTemplates = includeDependencies.getAffectedTemplates(INCLUDE_Z);
+ assertEqualSets("zAffectedTemplates", new String[]{TEMPLATE_B}, zAffectedTemplates); //$NON-NLS-1$
+
+ final String[] wAffectedTemplates = includeDependencies.getAffectedTemplates(INCLUDE_W);
+ assertEqualSets("wAffectedTemplates", new String[]{}, wAffectedTemplates); //$NON-NLS-1$
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.internal.core.compiler.IncludeDependencies#getAffectedTemplates(java.lang.String)}.
+ */
+ public void testGetAffectedTemplates() {
+ final String[] xAffectedTemplates = includeDependencies.getAffectedTemplates(INCLUDE_X);
+ assertEqualSets("xAffectedTemplates", new String[]{TEMPLATE_A, TEMPLATE_B}, xAffectedTemplates); //$NON-NLS-1$
+
+ final String[] yAffectedTemplates = includeDependencies.getAffectedTemplates(INLCUDE_Y);
+ assertEqualSets("yAffectedTemplates", new String[]{TEMPLATE_A, }, yAffectedTemplates); //$NON-NLS-1$
+
+ final String[] zAffectedTemplates = includeDependencies.getAffectedTemplates(INCLUDE_Z);
+ assertEqualSets("zAffectedTemplates", new String[]{TEMPLATE_B}, zAffectedTemplates); //$NON-NLS-1$
+
+ final String[] wAffectedTemplates = includeDependencies.getAffectedTemplates(INCLUDE_W);
+ assertEqualSets("wAffectedTemplates", new String[]{}, wAffectedTemplates); //$NON-NLS-1$
+ }
+
+ public void testSerialization() throws Exception {
+ final ByteArrayOutputStream byteOutput = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(byteOutput);
+
+ oos.writeObject(includeDependencies);
+
+ oos.close();
+
+ ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(byteOutput.toByteArray()));
+ includeDependencies = (IncludeDependencies) ois.readObject();
+
+ ois.close();
+
+ testGetAffectedTemplates();
+
+ testRemoveDependencies();
+
+ }
+ /**
+ * @param message
+ * @param expected
+ * @param actual
+ */
+ private void assertEqualSets(final String message, final String[] expected, final String[] actual) {
+ assertNotNull(message + " not null"); //$NON-NLS-1$
+ final Set affectedSet = new HashSet(Arrays.asList(actual));
+ assertEquals(message + " size", expected.length, affectedSet.size()); //$NON-NLS-1$
+ for (int i = 0; i < expected.length; i++) {
+ assertTrue(message + " contains " + expected[i], affectedSet.contains(expected[i])); //$NON-NLS-1$
+ }
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/LineInfoTests.java b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/LineInfoTests.java
new file mode 100644
index 0000000..9855ae0
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/LineInfoTests.java
@@ -0,0 +1,67 @@
+package org.eclipse.jet.tests.tools.compiler;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jet.internal.core.parser.LineInfo;
+import org.eclipse.jet.tests.core.FileUtils;
+
+public class LineInfoTests extends TestCase {
+
+ private static final String TESTDATA_URI = "platform:/plugin/org.eclipse.jet.tests.core/data/parser/lineinfo.jet"; //$NON-NLS-1$
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.parser.LineInfo.calculateLines(char[])'
+ */
+ public void testCalculateLines() throws Exception {
+ String urlString = TESTDATA_URI;
+ final String fileContents = FileUtils.getFileContents(urlString, false);
+
+ final LineInfo[] lineInfo = LineInfo.calculateLines(fileContents.toCharArray());
+ final String NL = System.getProperty("line.separator"); //$NON-NLS-1$
+
+ StringBuffer result = new StringBuffer();
+ for (int i = 0; i < lineInfo.length; i++) {
+ result.append(i + 1).append(":").append(lineInfo[i].getEnd() - lineInfo[i].getStart()).append(':') //$NON-NLS-1$
+ .append(fileContents.substring(lineInfo[i].getStart(), lineInfo[i].getEnd())).append(NL);
+ }
+
+ final String expectedContents = FileUtils.getFileContents(urlString + ".expected.txt", true); //$NON-NLS-1$
+ assertEquals(expectedContents, result.toString());
+
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.parser.LineInfo.getLineInfo(LineInfo[], int)'
+ */
+ public void testGetLineInfo() throws Exception {
+ String urlString = TESTDATA_URI;
+ final String fileContents = FileUtils.getFileContents(urlString, false);
+
+ final LineInfo[] lineInfo = LineInfo.calculateLines(fileContents.toCharArray());
+
+ try {
+ LineInfo.getLineInfo(lineInfo, -1);
+ fail();
+ } catch(IllegalArgumentException e) {
+ // success
+ }
+
+
+ final LineInfo startInfo = LineInfo.getLineInfo(lineInfo, 0);
+ assertEquals(lineInfo[0], startInfo);
+ assertEquals(0, startInfo.getStart());
+
+ final LineInfo liInNL = LineInfo.getLineInfo(lineInfo, lineInfo[0].getEnd());
+ assertEquals(lineInfo[0], liInNL);
+
+ final int lastcharOffset = lineInfo[lineInfo.length - 1].getEnd() - 1;
+ final LineInfo endInfo = LineInfo.getLineInfo(lineInfo, lastcharOffset);
+ assertEquals(lineInfo[lineInfo.length - 1], endInfo);
+
+ final int strOffset = fileContents.indexOf("a,b,c,d,e,f,g"); // this is on line 4, col 24 //$NON-NLS-1$
+ final LineInfo strLineInfo = LineInfo.getLineInfo(lineInfo, strOffset);
+ assertEquals(lineInfo[3], strLineInfo);
+ assertTrue("in [start, end)", strLineInfo.getStart() <= strOffset && strOffset < strLineInfo.getEnd()); //$NON-NLS-1$
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/TestIncludeAlternativesTracker.java b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/TestIncludeAlternativesTracker.java
new file mode 100644
index 0000000..e0877cb
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/TestIncludeAlternativesTracker.java
@@ -0,0 +1,213 @@
+package org.eclipse.jet.tests.tools.compiler;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jet.internal.core.parser.IncludeAlternativesTracker;
+
+public class TestIncludeAlternativesTracker extends TestCase {
+
+ public void testFailedInclude() {
+ final String includeMarker = "include"; //$NON-NLS-1$
+ final String startMarker = "start"; //$NON-NLS-1$
+ final String endMarker = "end"; //$NON-NLS-1$
+ IncludeAlternativesTracker tracker = new IncludeAlternativesTracker();
+
+ assertTrue(tracker.isCompileEnabled());
+
+ tracker.addIncludeWithAlternative(includeMarker, true);
+
+ assertTrue(tracker.isCompileEnabled());
+
+ tracker.startAlternative(startMarker);
+
+ assertTrue(tracker.isCompileEnabled());
+
+ tracker.endAlternative(endMarker);
+
+ assertTrue(tracker.isCompileEnabled());
+ }
+
+ public void testSuccessfulInclude() {
+ final String includeMarker = "include"; //$NON-NLS-1$
+ final String startMarker = "start"; //$NON-NLS-1$
+ final String endMarker = "end"; //$NON-NLS-1$
+ IncludeAlternativesTracker tracker = new IncludeAlternativesTracker();
+
+ assertTrue(tracker.isCompileEnabled());
+
+ tracker.addIncludeWithAlternative(includeMarker, false);
+
+ assertTrue(tracker.isCompileEnabled());
+
+ tracker.startAlternative(startMarker);
+
+ assertFalse(tracker.isCompileEnabled());
+
+ tracker.endAlternative(endMarker);
+
+ assertTrue(tracker.isCompileEnabled());
+ }
+
+ public void testFailedIncludeWithNestedInclude() {
+ final String includeMarker = "include"; //$NON-NLS-1$
+ final String startMarker = "start"; //$NON-NLS-1$
+ final String endMarker = "end"; //$NON-NLS-1$
+ final String includeChildFoundMarker = "includeChildFound"; //$NON-NLS-1$
+ final String startChildFoundMarker = "startChildFound"; //$NON-NLS-1$
+ final String endChildFoundMarker = "endChildFound"; //$NON-NLS-1$
+ final String includeChildNotFoundMarker = "includeChildNotFound"; //$NON-NLS-1$
+ final String startChildNotFoundMarker = "startChildNotFound"; //$NON-NLS-1$
+ final String endChildNotFoundMarker = "endChildNotFound"; //$NON-NLS-1$
+ IncludeAlternativesTracker tracker = new IncludeAlternativesTracker();
+
+ assertTrue(tracker.isCompileEnabled());
+
+ // <%@include fail="alternative" file="NotFound" %>
+ tracker.addIncludeWithAlternative(includeMarker, true);
+
+ assertTrue(tracker.isCompileEnabled());
+
+ // <%@ start %> for NotFound
+ tracker.startAlternative(startMarker);
+
+ assertTrue(tracker.isCompileEnabled());
+ {
+ // <%@include fail="alternative" file="ChildFound" %>
+ tracker.addIncludeWithAlternative(includeChildFoundMarker, false);
+ assertTrue(tracker.isCompileEnabled());
+
+ // <%@ start %> for ChildFound
+ tracker.startAlternative(startChildFoundMarker);
+ assertFalse(tracker.isCompileEnabled());
+
+ // <%@ end %> for ChildFound
+ tracker.endAlternative(endChildFoundMarker);
+ assertTrue(tracker.isCompileEnabled());
+ }
+ {
+ // <%@include fail="alternative" file="ChildNotFound" %>
+ tracker.addIncludeWithAlternative(includeChildNotFoundMarker, true);
+ assertTrue(tracker.isCompileEnabled());
+
+ // <%@ start %> for ChildNotFound
+ tracker.startAlternative(startChildNotFoundMarker);
+ assertTrue(tracker.isCompileEnabled());
+
+ // <%@ end %> for ChildNotFound
+ tracker.endAlternative(endChildNotFoundMarker);
+ assertTrue(tracker.isCompileEnabled());
+ }
+ // <%@ end %> for NotFound
+ tracker.endAlternative(endMarker);
+
+ assertTrue(tracker.isCompileEnabled());
+ }
+
+ public void testSuccessIncludeWithNestedInclude() {
+ final String includeMarker = "include"; //$NON-NLS-1$
+ final String startMarker = "start"; //$NON-NLS-1$
+ final String endMarker = "end"; //$NON-NLS-1$
+ final String includeChildFoundMarker = "includeChildFound"; //$NON-NLS-1$
+ final String startChildFoundMarker = "startChildFound"; //$NON-NLS-1$
+ final String endChildFoundMarker = "endChildFound"; //$NON-NLS-1$
+ final String includeChildNotFoundMarker = "includeChildNotFound"; //$NON-NLS-1$
+ final String startChildNotFoundMarker = "startChildNotFound"; //$NON-NLS-1$
+ final String endChildNotFoundMarker = "endChildNotFound"; //$NON-NLS-1$
+ IncludeAlternativesTracker tracker = new IncludeAlternativesTracker();
+
+ assertTrue(tracker.isCompileEnabled());
+
+ // <%@include fail="alternative" file="Found" %>
+ tracker.addIncludeWithAlternative(includeMarker, false);
+
+ assertTrue(tracker.isCompileEnabled());
+
+ // <%@ start %> for Found
+ tracker.startAlternative(startMarker);
+
+ assertFalse(tracker.isCompileEnabled());
+ {
+ // <%@include fail="alternative" file="ChildFound" %>
+ tracker.addIncludeWithAlternative(includeChildFoundMarker, false);
+ assertFalse(tracker.isCompileEnabled());
+
+ // <%@ start %> for ChildFound
+ tracker.startAlternative(startChildFoundMarker);
+ assertFalse(tracker.isCompileEnabled());
+
+ // <%@ end %> for ChildFound
+ tracker.endAlternative(endChildFoundMarker);
+ assertFalse(tracker.isCompileEnabled());
+ }
+ {
+ // <%@include fail="alternative" file="ChildNotFound" %>
+ tracker.addIncludeWithAlternative(includeChildNotFoundMarker, false);
+ assertFalse(tracker.isCompileEnabled());
+
+ // <%@ start %> for ChildNotFound
+ tracker.startAlternative(startChildNotFoundMarker);
+ assertFalse(tracker.isCompileEnabled());
+
+ // <%@ end %> for ChildNotFound
+ tracker.endAlternative(endChildNotFoundMarker);
+ assertFalse(tracker.isCompileEnabled());
+ }
+ // <%@ end %> for Found
+ tracker.endAlternative(endMarker);
+
+ assertTrue(tracker.isCompileEnabled());
+ }
+
+ public void testMissingEnd() {
+ final String includeMarker = "include"; //$NON-NLS-1$
+ final String startMarker = "start"; //$NON-NLS-1$
+ IncludeAlternativesTracker tracker = new IncludeAlternativesTracker();
+
+ assertTrue(tracker.isCompileEnabled());
+
+ tracker.addIncludeWithAlternative(includeMarker, true);
+
+ tracker.startAlternative(startMarker);
+
+ final int count[] = {0};
+
+ tracker.validateStackIsEmpty(new IncludeAlternativesTracker.ValidationProblemReporter() {
+
+ public void reportMissingEnd(Object startDirective) {
+ assertEquals(startDirective, startDirective);
+ count[0]++;
+ }
+
+ public void reportMissingStart(Object includeDirective) {
+ fail();
+
+ }});
+
+ assertEquals(1, count[0]);
+ }
+
+ public void testMissingStart() {
+ final String includeMarker = "include"; //$NON-NLS-1$
+ IncludeAlternativesTracker tracker = new IncludeAlternativesTracker();
+
+ assertTrue(tracker.isCompileEnabled());
+
+ tracker.addIncludeWithAlternative(includeMarker, true);
+
+ final int count[] = {0};
+
+ tracker.validateStackIsEmpty(new IncludeAlternativesTracker.ValidationProblemReporter() {
+
+ public void reportMissingEnd(Object startDirective) {
+ fail();
+ }
+
+ public void reportMissingStart(Object includeDirective) {
+ assertEquals(includeMarker, includeDirective);
+ count[0]++;
+
+ }});
+
+ assertEquals(1, count[0]);
+ }
+}
diff --git a/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/TestInputManager.java b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/TestInputManager.java
new file mode 100644
index 0000000..752b718
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/TestInputManager.java
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ */
+package org.eclipse.jet.tests.tools.compiler;
+
+import java.net.URI;
+import java.util.Stack;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jet.core.parser.DefaultTemplateResolver;
+import org.eclipse.jet.core.parser.ITemplateInput;
+import org.eclipse.jet.core.parser.ITemplateResolver;
+import org.eclipse.jet.core.parser.RecursiveIncludeException;
+
+/**
+ * Tests for {@link DefaultTemplateResolver}.
+ */
+public class TestInputManager extends TestCase {
+
+ private static final String LOCATION1_URL = "platform:/plugin/org.eclipse.jet.tests.core/data/templates/base1/"; //$NON-NLS-1$
+ private static final String LOCATION2_URL = "platform:/plugin/org.eclipse.jet.tests.core/data/templates/base2/"; //$NON-NLS-1$
+ private URI location1;
+ private URI location2;
+ private ITemplateResolver im;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ location1 = new URI(LOCATION1_URL);
+ location2 = new URI(LOCATION2_URL);
+ DefaultTemplateResolver.Builder builder = new DefaultTemplateResolver.Builder(new URI[] {location1, location2});
+
+ im = builder.build();
+ }
+
+ /**
+ * Test method for {@link DefaultTemplateResolver#getInput(String)}.
+ *
+ */
+ public void testGetInput() {
+ final String templatePath = "test1.txt"; //$NON-NLS-1$
+ final ITemplateInput input = im.getInput(templatePath);
+
+ assertEquals(templatePath, input.getTemplatePath());
+ assertEquals(location1, input.getBaseLocation());
+ }
+
+ /**
+ * Test method for {@link DefaultTemplateResolver#getIncludedInput(String, ITemplateInput[])}.
+ *
+ */
+ public void testGetIncludedInput() throws RecursiveIncludeException {
+ final String templatePath = "test1.txt"; //$NON-NLS-1$
+
+ final String[] includePaths = {
+ "test1.txt", //$NON-NLS-1$
+ "test2.txt", //$NON-NLS-1$
+ "test2.txt", //$NON-NLS-1$
+ };
+ final URI[] expectedBaseURLs = {
+ location2,
+ location1,
+ location2,
+ };
+ final Stack inputStack = new Stack();
+
+ inputStack.push(im.getInput(templatePath));
+
+ for (int i = 0; i < expectedBaseURLs.length; i++) {
+ final ITemplateInput[] currentStack = (ITemplateInput[])inputStack.toArray(new ITemplateInput[inputStack.size()]);
+ final ITemplateInput includedInput = im.getIncludedInput(includePaths[i], currentStack);
+
+ assertEquals("index " + i, includePaths[i], includedInput.getTemplatePath()); //$NON-NLS-1$
+ assertEquals("index " + i, expectedBaseURLs[i], includedInput.getBaseLocation()); //$NON-NLS-1$
+
+ inputStack.push(includedInput);
+ }
+ }
+
+ /**
+ * Test method for {@link DefaultTemplateResolver#getIncludedInput(String, ITemplateInput[])} to verify recursion detection.
+ *
+ */
+ public void testGetIncludedInput_recursion() {
+ final String templatePath = "test1.txt"; //$NON-NLS-1$
+
+ final String[] includePaths = {
+ "test2.txt", //$NON-NLS-1$
+ "test1.txt", //$NON-NLS-1$
+ };
+ final URI[] expectedActiveBaseLocations = {
+ location1,
+ location1,
+ };
+ final String[] expectedActiveTemplatePaths = {
+ "test1.txt", //$NON-NLS-1$
+ "test2.txt", //$NON-NLS-1$
+ };
+ final Stack inputStack = new Stack();
+
+ inputStack.push(im.getInput(templatePath));
+
+ try {
+ for (int i = 0; i < includePaths.length; i++) {
+ final ITemplateInput[] currentStack = (ITemplateInput[])inputStack.toArray(new ITemplateInput[inputStack.size()]);
+ final ITemplateInput includedInput = im.getIncludedInput(includePaths[i], currentStack);
+
+ inputStack.push(includedInput);
+ }
+
+ fail("Expected RecursiveIncludeException"); //$NON-NLS-1$
+ } catch(RecursiveIncludeException e) {
+ assertEquals(includePaths[includePaths.length - 1], e.getTemplatePath());
+ assertEquals(location1, e.getBaseLocation());
+ final String[] activeTemplatePaths = e.getActiveTemplatePaths();
+ assertEquals(2, activeTemplatePaths.length);
+ for (int i = 0; i < activeTemplatePaths.length; i++) {
+ assertEquals(expectedActiveTemplatePaths[i], activeTemplatePaths[i]);
+ }
+ final URI[] activeBaseLocations = e.getActiveBaseLocations();
+ assertEquals(2, activeBaseLocations.length);
+ for (int i = 0; i < activeBaseLocations.length; i++) {
+ assertEquals(expectedActiveBaseLocations[i], activeBaseLocations[i]);
+ }
+ }
+
+
+ }
+
+ public void testGetIncludedInput_relativePaths() throws RecursiveIncludeException {
+ final String templatePath = "test1.txt"; //$NON-NLS-1$
+
+ final String[] includePaths = {
+ "nested/test3.txt", //$NON-NLS-1$
+ "test4.txt", //$NON-NLS-1$
+ "test5.txt", //$NON-NLS-1$
+ "../test2.txt", //$NON-NLS-1$
+ };
+ final URI[] expectedBaseURLs = {
+ location1,
+ location1,
+ location2,
+ location1,
+ };
+ final String[] expectedTemplatePaths = {
+ "nested/test3.txt", //$NON-NLS-1$
+ "nested/test4.txt", //$NON-NLS-1$
+ "nested/test5.txt", //$NON-NLS-1$
+ "test2.txt", //$NON-NLS-1$
+ };
+
+ final Stack inputStack = new Stack();
+
+ inputStack.push(im.getInput(templatePath));
+
+ for (int i = 0; i < expectedBaseURLs.length; i++) {
+ final ITemplateInput[] currentStack = (ITemplateInput[])inputStack.toArray(new ITemplateInput[inputStack.size()]);
+ final ITemplateInput includedInput = im.getIncludedInput(includePaths[i], currentStack);
+ assertNotNull("index " + i, includedInput); //$NON-NLS-1$
+ assertEquals("index " + i, expectedTemplatePaths[i], includedInput.getTemplatePath()); //$NON-NLS-1$
+ assertEquals("index " + i, expectedBaseURLs[i], includedInput.getBaseLocation()); //$NON-NLS-1$
+
+ inputStack.push(includedInput);
+ }
+
+ }
+
+
+
+}
diff --git a/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/TestInputManagerBuilder.java b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/TestInputManagerBuilder.java
new file mode 100644
index 0000000..d259fc4
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/TestInputManagerBuilder.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ */package org.eclipse.jet.tests.tools.compiler;
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jet.core.parser.DefaultTemplateResolver;
+import org.eclipse.jet.core.parser.ITemplateResolver;
+
+/**
+ * JUnits for {@link DefaultTemplateResolver.Builder}.
+ *
+ */
+public class TestInputManagerBuilder extends TestCase {
+
+ private static final String LOCATION1_URL = "platform:/plugin/org.eclipse.jet.tests.core/data/templates/base2/"; //$NON-NLS-1$
+ private static final String LOCATION2_URL = "platform:/plugin/org.eclipse.jet.tests.core/data/templates/base1/"; //$NON-NLS-1$
+
+ /**
+ * Test method for {@link org.eclipse.jet.core.parser.DefaultTemplateResolver.Builder#Builder(java.net.URI[])}.
+ * @throws MalformedURLException
+ * @throws URISyntaxException
+ */
+ public void testBuilderURLArray() throws MalformedURLException, URISyntaxException {
+ final URI location1 = new URI(LOCATION2_URL);
+ final URI location2 = new URI(LOCATION1_URL);
+ DefaultTemplateResolver.Builder builder = new DefaultTemplateResolver.Builder(new URI[] {location1, location2});
+
+ final ITemplateResolver im = builder.build();
+
+ URI[] baseLocations = im.getBaseLocations();
+
+ assertNotNull("baseLocations", baseLocations); //$NON-NLS-1$
+ assertEquals(2, baseLocations.length);
+ assertEquals(location1, baseLocations[0]);
+ assertEquals(location2, baseLocations[1]);
+ }
+
+ /**
+ * Test method for {@link DefaultTemplateResolver.Builder#Builder(URI[])} with a null array
+ */
+ public void testBuilderURLArray_null() {
+ URI[] nullArray = null;
+
+ try {
+ new DefaultTemplateResolver.Builder(nullArray);
+ fail("Expected NullPointerException"); //$NON-NLS-1$
+ } catch(NullPointerException e) {
+ // success
+ }
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.core.parser.DefaultTemplateResolver.Builder#Builder(java.net.URI)}.
+ * @throws URISyntaxException
+ */
+ public void testBuilderURL() throws URISyntaxException {
+ final URI location1 = new URI(LOCATION2_URL);
+ DefaultTemplateResolver.Builder builder = new DefaultTemplateResolver.Builder(location1);
+
+ final ITemplateResolver im = builder.build();
+
+ URI[] baseLocations = im.getBaseLocations();
+
+ assertNotNull("baseLocations", baseLocations); //$NON-NLS-1$
+ assertEquals(1, baseLocations.length);
+ assertEquals(location1, baseLocations[0]);
+ }
+
+ /**
+ * Test method for {@link DefaultTemplateResolver.Builder#Builder(URI)} with a null argument.
+ *
+ */
+ public void testBuilderURL_null() {
+ final URI nullURL = null;
+ try {
+ new DefaultTemplateResolver.Builder(nullURL);
+ fail("Expected NullPointerException"); //$NON-NLS-1$
+ } catch(NullPointerException e) {
+ // success
+ }
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/TestTemplateInput.java b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/TestTemplateInput.java
new file mode 100644
index 0000000..0ad8c5c
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/TestTemplateInput.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ */
+package org.eclipse.jet.tests.tools.compiler;
+
+import java.net.URI;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jet.internal.core.parser.DefaultTemplateInput;
+
+/**
+ * @author pelder
+ *
+ */
+public class TestTemplateInput extends TestCase {
+
+ private static final String TEMPLATE_PATH = "test1.txt"; //$NON-NLS-1$
+ private static final String LOCATION1_URI = "platform:/plugin/org.eclipse.jet.tests.core/data/templates/base1/"; //$NON-NLS-1$
+ private URI location1;
+ private DefaultTemplateInput templateInput;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ location1 = new URI(LOCATION1_URI);
+ templateInput = new DefaultTemplateInput(location1, TEMPLATE_PATH, "UTF-8"); //$NON-NLS-1$
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.internal.core.parser.DefaultTemplateInput#getBaseLocation()}.
+ */
+ public void testGetBaseLocation() {
+ assertEquals(location1, templateInput.getBaseLocation());
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.internal.core.parser.DefaultTemplateInput#getTemplatePath()}.
+ */
+ public void testGetTemplatePath() {
+ assertEquals(TEMPLATE_PATH, templateInput.getTemplatePath());
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/TestUniqueNameGenerator.java b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/TestUniqueNameGenerator.java
new file mode 100644
index 0000000..72e73ab
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/compiler/TestUniqueNameGenerator.java
@@ -0,0 +1,131 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *
+ * </copyright>
+ *
+ * $Id: TestUniqueNameGenerator.java,v 1.1 2007/04/04 14:55:55 pelder Exp $
+ */
+package org.eclipse.jet.tests.tools.compiler;
+
+import java.util.Collections;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jet.core.parser.ast.JETAST;
+import org.eclipse.jet.core.parser.ast.JETCompilationUnit;
+import org.eclipse.jet.internal.core.compiler.DuplicateGeneratedClassException;
+import org.eclipse.jet.internal.core.compiler.UniqueNameGenerator;
+
+/**
+ * Unit tests for {@link UniqueNameGenerator}.
+ *
+ */
+public class TestUniqueNameGenerator extends TestCase {
+
+ private static final String DEFAULT_PACKAGE = "org.eclipse.jet.compiled"; //$NON-NLS-1$
+
+ /**
+ * Test method for {@link org.eclipse.jet.internal.core.compiler.UniqueNameGenerator#ensureJavaOutputSet(java.lang.String, JETCompilationUnit)}.
+ * @throws DuplicateGeneratedClassException
+ */
+ public void testEnsureJavaOutputSet_noconflicts() throws DuplicateGeneratedClassException {
+ Map pathToFQN = Collections.EMPTY_MAP;
+ Map fqnToPath = Collections.EMPTY_MAP;
+ UniqueNameGenerator util = new UniqueNameGenerator(pathToFQN, fqnToPath, DEFAULT_PACKAGE);
+
+ JETCompilationUnit cu = new JETAST().newJETCompilationUnit();
+
+ util.ensureJavaOutputSet("templates/bob.jet", cu); //$NON-NLS-1$
+
+ assertEquals(DEFAULT_PACKAGE, cu.getOutputJavaPackage());
+ assertEquals("_jet_bob", cu.getOutputJavaClassName()); //$NON-NLS-1$
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.internal.core.compiler.UniqueNameGenerator#ensureJavaOutputSet(java.lang.String, JETCompilationUnit)}.
+ * @throws DuplicateGeneratedClassException
+ */
+ public void testEnsureJavaOutputSet_nameConflict() throws DuplicateGeneratedClassException {
+ final String templatePath = "templates/bob.jet"; //$NON-NLS-1$
+ final String otherTemplatePath = "templates/other/bob.jet"; //$NON-NLS-1$
+ UniqueNameGenerator util = new UniqueNameGenerator(Collections.EMPTY_MAP, Collections.EMPTY_MAP, DEFAULT_PACKAGE);
+
+ JETCompilationUnit cu1 = new JETAST().newJETCompilationUnit();
+ JETCompilationUnit cu2 = new JETAST().newJETCompilationUnit();
+
+ util.ensureJavaOutputSet(templatePath, cu1);
+
+ assertEquals(DEFAULT_PACKAGE, cu1.getOutputJavaPackage());
+ assertEquals("_jet_bob", cu1.getOutputJavaClassName()); //$NON-NLS-1$
+
+ util.ensureJavaOutputSet(otherTemplatePath, cu2);
+
+ assertEquals(DEFAULT_PACKAGE, cu2.getOutputJavaPackage());
+ assertEquals("_jet_bob_0", cu2.getOutputJavaClassName()); //$NON-NLS-1$
+
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.internal.core.compiler.UniqueNameGenerator#ensureJavaOutputSet(java.lang.String, JETCompilationUnit)}.
+ * @throws DuplicateGeneratedClassException
+ */
+ public void testEnsureJavaOutputSet_sameName() throws DuplicateGeneratedClassException {
+ final String templatePath = "templates/bob.jet"; //$NON-NLS-1$
+ UniqueNameGenerator util = new UniqueNameGenerator(Collections.EMPTY_MAP, Collections.EMPTY_MAP, DEFAULT_PACKAGE);
+
+ JETCompilationUnit cu1 = new JETAST().newJETCompilationUnit();
+ JETCompilationUnit cu2 = new JETAST().newJETCompilationUnit();
+
+ util.ensureJavaOutputSet(templatePath, cu1);
+
+ assertEquals(DEFAULT_PACKAGE, cu1.getOutputJavaPackage());
+ assertEquals("_jet_bob", cu1.getOutputJavaClassName()); //$NON-NLS-1$
+
+ util.ensureJavaOutputSet(templatePath, cu2);
+
+ assertEquals(DEFAULT_PACKAGE, cu2.getOutputJavaPackage());
+ assertEquals("_jet_bob", cu2.getOutputJavaClassName()); //$NON-NLS-1$
+
+ }
+
+ public void testEnsureJavaOutputSet_duplicate() {
+ final String templatePath = "templates/bob.jet"; //$NON-NLS-1$
+ final String otherTemplatePath = "templates/jim.jet"; //$NON-NLS-1$
+
+ JETCompilationUnit cu1 = new JETAST().newJETCompilationUnit();
+ cu1.setOutputJavaPackage("a.b.c"); //$NON-NLS-1$
+ cu1.setOutputJavaClassName("Common"); //$NON-NLS-1$
+
+ UniqueNameGenerator util = new UniqueNameGenerator(Collections.EMPTY_MAP, Collections.EMPTY_MAP, DEFAULT_PACKAGE);
+ try {
+ util.ensureJavaOutputSet(otherTemplatePath, cu1);
+ } catch (DuplicateGeneratedClassException e) {
+ fail(e.toString());
+ }
+
+ JETCompilationUnit cu2 = new JETAST().newJETCompilationUnit();
+ cu2.setOutputJavaPackage("a.b.c"); //$NON-NLS-1$
+ cu2.setOutputJavaClassName("Common"); //$NON-NLS-1$
+
+ try {
+ util.ensureJavaOutputSet(templatePath, cu2);
+ fail("Expected DuplicateGeneratedClassException"); //$NON-NLS-1$
+ } catch (DuplicateGeneratedClassException e) {
+ assertEquals("templatePath", templatePath, e.getTemplatePath()); //$NON-NLS-1$
+ assertEquals("otherTemplatePath", otherTemplatePath, e.getOtherTemplatePath()); //$NON-NLS-1$
+ assertEquals("fqn", "a.b.c.Common", e.getFullyQualifiedJavaClassName()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/parser/ASTDumper.java b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/parser/ASTDumper.java
new file mode 100644
index 0000000..3e11679
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/parser/ASTDumper.java
@@ -0,0 +1,184 @@
+package org.eclipse.jet.tests.tools.parser;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.jet.core.parser.ast.Comment;
+import org.eclipse.jet.core.parser.ast.IncludedContent;
+import org.eclipse.jet.core.parser.ast.JETASTVisitor;
+import org.eclipse.jet.core.parser.ast.JETDirective;
+import org.eclipse.jet.core.parser.ast.JavaDeclaration;
+import org.eclipse.jet.core.parser.ast.JavaExpression;
+import org.eclipse.jet.core.parser.ast.JavaScriptlet;
+import org.eclipse.jet.core.parser.ast.TextElement;
+import org.eclipse.jet.core.parser.ast.XMLBodyElement;
+import org.eclipse.jet.core.parser.ast.XMLBodyElementEnd;
+import org.eclipse.jet.core.parser.ast.XMLEmptyElement;
+import org.eclipse.jet.internal.core.NewLineUtil;
+
+/**
+ * AST Dumper for verification
+ *
+ */
+public class ASTDumper extends JETASTVisitor {
+
+ private final StringBuffer buffer = new StringBuffer();
+ private int indent = 0;
+ private final String NL = System.getProperty("line.separator"); //$NON-NLS-1$
+
+ private void doIndent() {
+ for(int i = 0; i < indent; i++) {
+ buffer.append(" "); //$NON-NLS-1$
+ }
+ }
+
+ public String getLog() {
+ return NewLineUtil.setLineTerminator(buffer, NL);
+ }
+
+
+ /**
+ *
+ */
+ public ASTDumper() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jet.compiler.JET2ASTVisitor#visit(org.eclipse.jet.compiler.JET2Declaration)
+ */
+ public boolean visit(JavaDeclaration declaration) {
+ doIndent();
+ buffer.append("<declaration line=\"" + declaration.getLine() + "\" col=\"" + declaration.getColumn() + "\">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ buffer.append(declaration.getJavaContent());
+ buffer.append("</declaration>").append(NL); //$NON-NLS-1$
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jet.compiler.JET2ASTVisitor#visit(org.eclipse.jet.compiler.JET2Directive)
+ */
+ public boolean visit(JETDirective directive) {
+ doIndent();
+ buffer.append("<directive name=\"" + directive.getName() + "\" line=\"" + directive.getLine() + "\" col=\"" + directive.getColumn() + "\">").append(NL); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ indent++;
+ for (Iterator i = directive.getAttributes().entrySet().iterator(); i.hasNext();) {
+ Map.Entry entry = (Map.Entry) i.next();
+ doIndent();
+ buffer.append("<attribute name=\"" + entry.getKey() + "\">"); //$NON-NLS-1$ //$NON-NLS-2$
+ buffer.append(entry.getValue()).append("</attribute>").append(NL); //$NON-NLS-1$
+
+ }
+ indent--;
+ doIndent();
+ buffer.append("</directive>").append(NL); //$NON-NLS-1$
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jet.compiler.JET2ASTVisitor#visit(org.eclipse.jet.compiler.JET2Expression)
+ */
+ public boolean visit(JavaExpression expression) {
+ doIndent();
+ buffer.append("<expression line=\"" + expression.getLine() + "\" col=\"" + expression.getColumn() + "\">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ buffer.append(expression.getJavaContent());
+ buffer.append("</expression>").append(NL); //$NON-NLS-1$
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jet.compiler.JET2ASTVisitor#visit(org.eclipse.jet.compiler.JET2Scriptlet)
+ */
+ public boolean visit(JavaScriptlet scriptlet) {
+ doIndent();
+ buffer.append("<scriptlet line=\"" + scriptlet.getLine() + "\" col=\"" + scriptlet.getColumn() + "\">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ buffer.append(scriptlet.getJavaContent());
+ buffer.append("</scriptlet>").append(NL); //$NON-NLS-1$
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jet.compiler.JET2ASTVisitor#visit(org.eclipse.jet.compiler.TextElement)
+ */
+ public boolean visit(TextElement text) {
+ doIndent();
+ buffer.append("<data>").append(text.getText()).append("</data>").append(NL); //$NON-NLS-1$ //$NON-NLS-2$
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jet.compiler.JET2ASTVisitor#visit(org.eclipse.jet.compiler.XMLEmptyElement)
+ */
+ public boolean visit(XMLEmptyElement xmlEmptyElement) {
+ doIndent();
+ buffer.append("<tag name=\"" + xmlEmptyElement.getName() + "\" line=\"" + xmlEmptyElement.getLine() + "\" col=\"" + xmlEmptyElement.getColumn() + "\">").append(NL); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ indent++;
+ for (Iterator i = xmlEmptyElement.getAttributes().entrySet().iterator(); i.hasNext();) {
+ Map.Entry entry = (Map.Entry) i.next();
+ doIndent();
+ buffer.append("<attribute name=\"" + entry.getKey() + "\">" + entry.getValue() + "</attribute>").append(NL); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ indent--;
+ doIndent();
+ buffer.append("</tag>").append(NL); //$NON-NLS-1$
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jet.compiler.JET2ASTVisitor#visit(org.eclipse.jet.compiler.XMLBodyElement)
+ */
+ public boolean visit(XMLBodyElement xmlBodyElement) {
+ doIndent();
+ buffer.append("<tag name=\"" + xmlBodyElement.getName() + "\" line=\"" + xmlBodyElement.getLine() + "\" col=\"" + xmlBodyElement.getColumn() + "\">").append(NL); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ indent++;
+ for (Iterator i = xmlBodyElement.getAttributes().entrySet().iterator(); i.hasNext();) {
+ Map.Entry entry = (Map.Entry) i.next();
+ doIndent();
+ buffer.append("<attribute name=\"" + entry.getKey() + "\">" + entry.getValue() + "</attribute>").append(NL); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ doIndent();
+ buffer.append("<content>").append(NL); //$NON-NLS-1$
+ indent++;
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jet.compiler.JET2ASTVisitor#endVisit(org.eclipse.jet.compiler.XMLBodyElement)
+ */
+ public void endVisit(XMLBodyElement xmlBodyElement) {
+ indent--;
+ doIndent();
+ buffer.append("</content>").append(NL); //$NON-NLS-1$
+ indent--;
+ doIndent();
+ buffer.append("</tag>").append(NL); //$NON-NLS-1$
+ }
+
+ public boolean visit(Comment comment) {
+ doIndent();
+ buffer.append("<comment line=\"" + comment.getLine() + "\" col=\"" + comment.getColumn() + "\">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ buffer.append(comment.getCommentText());
+ buffer.append("</comment>").append(NL); //$NON-NLS-1$
+ return true;
+ }
+
+ public boolean visit(XMLBodyElementEnd xmlBodyElementEnd) {
+ // do nothing
+ return true;
+
+ }
+
+ public boolean visit(IncludedContent content) {
+ doIndent();
+ buffer.append("<included templatePath=\"" + content.getTemplatePath() + "\" baseLocation=\"" + content.getBaseLocationURI() + "\">").append(NL); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ indent++;
+ return true;
+ }
+
+ public void endVisit(IncludedContent content) {
+ indent--;
+ doIndent();
+ buffer.append("</included>").append(NL); //$NON-NLS-1$
+
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/parser/AllTests.java b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/parser/AllTests.java
new file mode 100644
index 0000000..9b4a36c
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/parser/AllTests.java
@@ -0,0 +1,18 @@
+package org.eclipse.jet.tests.tools.parser;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(
+ "Test for org.eclipse.jet.tests.tools.parser"); //$NON-NLS-1$
+ //$JUnit-BEGIN$
+ suite.addTestSuite(TestJETASTParser.class);
+ suite.addTestSuite(TestInternalJET1Parser.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/parser/TestInternalJET1Parser.java b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/parser/TestInternalJET1Parser.java
new file mode 100644
index 0000000..9f55330
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/parser/TestInternalJET1Parser.java
@@ -0,0 +1,153 @@
+package org.eclipse.jet.tests.tools.parser;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jet.core.parser.DefaultTemplateResolver;
+import org.eclipse.jet.core.parser.IJETParser;
+import org.eclipse.jet.core.parser.IProblem;
+import org.eclipse.jet.core.parser.ITemplateResolver;
+import org.eclipse.jet.core.parser.ProblemSeverity;
+import org.eclipse.jet.core.parser.ast.JETCompilationUnit;
+import org.eclipse.jet.core.parser.ast.Problem;
+import org.eclipse.jet.internal.core.parser.InternalJET1Parser;
+import org.eclipse.jet.tests.core.FileUtils;
+
+public class TestInternalJET1Parser extends TestCase {
+
+ private URI baseLocation;
+ private URI altBaseLocation1;
+ private URI altBaseLocation2
+ ;
+ private IJETParser parser;
+ protected void setUp() throws Exception {
+ super.setUp();
+ baseLocation = new URI("platform:/plugin/org.eclipse.jet.tests.core/data/parser/v1/base/"); //$NON-NLS-1$
+ altBaseLocation1 = new URI("platform:/plugin/org.eclipse.jet.tests.core/data/parser/v1/alt1/"); //$NON-NLS-1$
+ altBaseLocation2 = new URI("platform:/plugin/org.eclipse.jet.tests.core/data/parser/v1/alt2/"); //$NON-NLS-1$
+ ITemplateResolver templateResolver = new DefaultTemplateResolver.Builder(new URI[] {
+ baseLocation,
+ altBaseLocation1,
+ altBaseLocation2,
+ }).build();
+ parser = new InternalJET1Parser(templateResolver);
+ }
+
+ /**
+ * @param templatePath
+ * @param resultsSuffix
+ * @return
+ * @throws MalformedURLException
+ * @throws IOException
+ * @throws CoreException
+ */
+ private String getResultsContents(final String templatePath, final String resultsSuffix) throws MalformedURLException, IOException, CoreException {
+ return FileUtils.getFileContents(baseLocation.resolve(templatePath + resultsSuffix).toString(), true);
+ }
+
+ public void testInternalJET1Parser() {
+
+ }
+
+ public void testParseString() throws Exception {
+ final String templatePath = "simple.javajet"; //$NON-NLS-1$
+ final JETCompilationUnit cu = (JETCompilationUnit) parser.parse(templatePath);
+
+ assertTrue("cu not null", cu != null); //$NON-NLS-1$
+
+ assertFalse("no cu errors or warnings", cu.hasErrors() || cu.hasWarnings()); //$NON-NLS-1$
+
+ final ASTDumper astDumper = new ASTDumper();
+ cu.accept(astDumper);
+
+ assertEquals(getResultsContents(templatePath, ".astdump.expected"), astDumper.getLog()); //$NON-NLS-1$
+ }
+
+ public void testParseString_simpleInclude() throws Exception {
+ final String templatePath = "simple.include.javajet"; //$NON-NLS-1$
+ final JETCompilationUnit cu = (JETCompilationUnit) parser.parse(templatePath);
+
+ assertTrue("cu not null", cu != null); //$NON-NLS-1$
+
+ assertFalse("no cu errors or warnings", cu.hasErrors() || cu.hasWarnings()); //$NON-NLS-1$
+
+ final ASTDumper astDumper = new ASTDumper();
+ cu.accept(astDumper);
+
+ assertEquals(getResultsContents(templatePath, ".astdump.expected"), astDumper.getLog()); //$NON-NLS-1$
+ }
+
+ public void testParseString_complexInclude() throws Exception {
+ final String templatePath = "complex.include.javajet"; //$NON-NLS-1$
+ final JETCompilationUnit cu = (JETCompilationUnit) parser.parse(templatePath);
+
+ assertTrue("cu not null", cu != null); //$NON-NLS-1$
+
+ assertFalse("no cu errors or warnings", cu.hasErrors() || cu.hasWarnings()); //$NON-NLS-1$
+
+ final ASTDumper astDumper = new ASTDumper();
+ cu.accept(astDumper);
+
+ assertEquals(getResultsContents(templatePath, ".astdump.expected"), astDumper.getLog()); //$NON-NLS-1$
+ }
+
+ public void testParseCharArray() throws Exception {
+ final String templatePath = "simple.javajet"; //$NON-NLS-1$
+ final String templateSource = getResultsContents(templatePath, ""); //$NON-NLS-1$
+
+ final JETCompilationUnit cu = (JETCompilationUnit) parser.parse(templateSource.toCharArray());
+
+ assertTrue("cu not null", cu != null); //$NON-NLS-1$
+
+ assertFalse("no cu errors or warnings", cu.hasErrors() || cu.hasWarnings()); //$NON-NLS-1$
+
+ final ASTDumper astDumper = new ASTDumper();
+ cu.accept(astDumper);
+
+ assertEquals(getResultsContents(templatePath, ".astdump.expected"), astDumper.getLog()); //$NON-NLS-1$
+ }
+
+ public void testParseCharArray_simpleInclude() throws Exception {
+ final String templatePath = "simple.include.javajet"; //$NON-NLS-1$
+ final String templateSource = getResultsContents(templatePath, ""); //$NON-NLS-1$
+
+ final JETCompilationUnit cu = (JETCompilationUnit) parser.parse(templateSource.toCharArray());
+
+ assertTrue("cu not null", cu != null); //$NON-NLS-1$
+
+ assertTrue("cu errors, but no warnings", cu.hasErrors() && !cu.hasWarnings()); //$NON-NLS-1$
+
+ final List problems = cu.getProblems();
+
+ assertEquals(1, problems.size());
+
+ Problem problem = (Problem) problems.get(0);
+ assertEquals(ProblemSeverity.ERROR, problem.getProblemSeverity());
+ assertEquals(IProblem.MissingFile, problem.getId());
+ assertEquals("include1.jetinc", problem.getMessageArgs()[0]); //$NON-NLS-1$
+
+ final ASTDumper astDumper = new ASTDumper();
+ cu.accept(astDumper);
+
+ assertEquals(getResultsContents(templatePath, ".chararray.astdump.expected"), astDumper.getLog()); //$NON-NLS-1$
+ }
+
+ public void testParseString_includeWithAlternatives() throws Exception {
+ final String templatePath = "alternative.include.javajet"; //$NON-NLS-1$
+ final JETCompilationUnit cu = (JETCompilationUnit) parser.parse(templatePath);
+
+ assertTrue("cu not null", cu != null); //$NON-NLS-1$
+
+ assertFalse("no cu errors or warnings", cu.hasErrors() || cu.hasWarnings()); //$NON-NLS-1$
+
+ final ASTDumper astDumper = new ASTDumper();
+ cu.accept(astDumper);
+
+ assertEquals(getResultsContents(templatePath, ".astdump.expected"), astDumper.getLog()); //$NON-NLS-1$
+ }
+}
diff --git a/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/parser/TestJETASTParser.java b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/parser/TestJETASTParser.java
new file mode 100644
index 0000000..d893fcf
--- /dev/null
+++ b/tests/org.eclipse.jet.tests.core/src/org/eclipse/jet/tests/tools/parser/TestJETASTParser.java
@@ -0,0 +1,560 @@
+package org.eclipse.jet.tests.tools.parser;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jet.core.parser.DefaultTemplateResolver;
+import org.eclipse.jet.core.parser.IProblem;
+import org.eclipse.jet.core.parser.ITagLibraryResolver;
+import org.eclipse.jet.core.parser.ProblemSeverity;
+import org.eclipse.jet.core.parser.ast.JETAST;
+import org.eclipse.jet.core.parser.ast.JETASTParser;
+import org.eclipse.jet.core.parser.ast.JETCompilationUnit;
+import org.eclipse.jet.core.parser.ast.Problem;
+import org.eclipse.jet.taglib.CustomTagKind;
+import org.eclipse.jet.taglib.TagAttributeDefinition;
+import org.eclipse.jet.taglib.TagDefinition;
+import org.eclipse.jet.taglib.TagLibrary;
+import org.eclipse.jet.taglib.TagLibraryReference;
+import org.eclipse.jet.tests.core.FileUtils;
+
+public class TestJETASTParser extends TestCase {
+
+ public static final class TestTagAttributeDefinition implements TagAttributeDefinition {
+
+ public static final class Builder {
+ private final String name;
+ private final String type;
+ private boolean required;
+
+ public Builder(String name, String type) {
+ this.name = name;
+ this.type = type;
+ }
+
+ public Builder required(boolean required) {
+ this.required = required;
+ return this;
+ }
+
+ public TestTagAttributeDefinition build() {
+ return new TestTagAttributeDefinition(this);
+ }
+ }
+
+ private final String name;
+ private final String type;
+ private final String description;
+ private final boolean required;
+
+ private TestTagAttributeDefinition(Builder builder) {
+ name = builder.name;
+ description = "Description of " + name; //$NON-NLS-1$
+ type = builder.type;
+ required = builder.required;
+
+
+ }
+ public String getDescription() {
+ return description;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public boolean isDeprecated() {
+ return false;
+ }
+
+ public boolean isRequired() {
+ return required;
+ }
+
+ }
+ public static final class TestTagDefinition implements TagDefinition {
+
+ public static final class Builder {
+
+ private final TagLibrary tagLib;
+ private final String name;
+ private final CustomTagKind kind;
+ private boolean contentAllowed;
+ private boolean emptyAllowed;
+ private boolean removeWhenContainingLineIsEmpty;
+ private boolean requiresNewWriter;
+ private final List tags = new ArrayList();
+
+ public Builder(TagLibrary tagLib, String name, CustomTagKind kind) {
+ this.tagLib = tagLib;
+ this.name = name;
+ this.kind = kind;
+ }
+
+ public Builder contentAllowed(boolean contentAllowed) {
+ this.contentAllowed = contentAllowed;
+ return this;
+ }
+
+ public Builder emptyAllowed(boolean emptyAllowed) {
+ this.emptyAllowed = emptyAllowed;
+ return this;
+ }
+
+ public Builder removeWhenContainingLineIsEmpty(boolean removeWhenContainingLineIsEmpty) {
+ this.removeWhenContainingLineIsEmpty = removeWhenContainingLineIsEmpty;
+ return this;
+ }
+
+ public Builder requiresNewWriter(boolean requiresNewWriter) {
+ this.requiresNewWriter = requiresNewWriter;
+ return this;
+ }
+
+ public Builder attribute(TagAttributeDefinition attribute) {
+ tags.add(attribute);
+ return this;
+ }
+
+ public TagDefinition build() {
+ return new TestTagDefinition(this);
+ }
+ }
+ private final TagLibrary tagLib;
+ private final String name;
+ private final CustomTagKind kind;
+ private final String description;
+ private final boolean contentAllowed;
+ private final boolean emptyAllowed;
+ private final boolean removeWhenContainingLineIsEmpty;
+ private final boolean requiresNewWriter;
+ private final List attributes;
+
+ public TestTagDefinition(Builder builder) {
+ tagLib = builder.tagLib;
+ name = builder.name;
+ kind = builder.kind;
+ description = "Description for " + builder.name; //$NON-NLS-1$
+ contentAllowed = builder.contentAllowed;
+ emptyAllowed = builder.emptyAllowed;
+ removeWhenContainingLineIsEmpty = builder.removeWhenContainingLineIsEmpty;
+ requiresNewWriter = builder.requiresNewWriter;
+
+ attributes = builder.tags;
+ }
+ public TagAttributeDefinition getAttributeDefinition(String name) {
+ for (Iterator i = attributes.iterator(); i.hasNext();) {
+ TagAttributeDefinition attribute = (TagAttributeDefinition) i.next();
+ if(name.equals(attribute.getName())) {
+ return attribute;
+ }
+ }
+ return null;
+ }
+
+ public List getAttributeDefinitions() {
+ // TODO Auto-generated method stub
+ return attributes;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public CustomTagKind getKind() {
+ return kind;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public TagLibrary getTagLibrary() {
+ return tagLib;
+ }
+
+ public boolean isContentAllowed() {
+ return contentAllowed;
+ }
+
+ public boolean isDeprecated() {
+ return false;
+ }
+
+ public boolean isEmptyTagAllowed() {
+ return emptyAllowed;
+ }
+
+ public boolean removeWhenContainingLineIsEmpty() {
+ return removeWhenContainingLineIsEmpty;
+ }
+
+ public boolean requiresNewWriter() {
+ return requiresNewWriter;
+ }
+
+ }
+ public static final class TestTagLibrary implements TagLibrary {
+
+ private static final TagLibrary instance = new TestTagLibrary();
+
+ public static TagLibrary getInstance() {
+ return instance;
+ }
+
+ private static final Map tagsByName = new HashMap(5);
+ static {
+ tagsByName.put("tokenize", //$NON-NLS-1$
+ new TestTagDefinition.Builder(instance, "tokenize", CustomTagKind.ITERATING) //$NON-NLS-1$
+ .contentAllowed(true)
+ .removeWhenContainingLineIsEmpty(true)
+ .attribute(new TestTagAttributeDefinition.Builder("string", "String").required(true).build()) //$NON-NLS-1$ //$NON-NLS-2$
+ .attribute(new TestTagAttributeDefinition.Builder("sep", "String").required(true).build()) //$NON-NLS-1$ //$NON-NLS-2$
+ .attribute(new TestTagAttributeDefinition.Builder("var", "String").required(true).build()) //$NON-NLS-1$ //$NON-NLS-2$
+ .build());
+ tagsByName.put("upper", //$NON-NLS-1$
+ new TestTagDefinition.Builder(instance, "upper", CustomTagKind.FUNCTION) //$NON-NLS-1$
+ .contentAllowed(true)
+ .build());
+ tagsByName.put("isAllUpper", //$NON-NLS-1$
+ new TestTagDefinition.Builder(instance, "isAllUpper", CustomTagKind.CONDITIONAL) //$NON-NLS-1$
+ .contentAllowed(true)
+ .removeWhenContainingLineIsEmpty(true)
+ .attribute(new TestTagAttributeDefinition.Builder("var", "String").required(true).build()) //$NON-NLS-1$ //$NON-NLS-2$
+ .build());
+ tagsByName.put("nl", //$NON-NLS-1$
+ new TestTagDefinition.Builder(instance, "nl", CustomTagKind.EMPTY) //$NON-NLS-1$
+ .contentAllowed(false)
+ .emptyAllowed(true)
+ .build());
+ tagsByName.put("other", //$NON-NLS-1$
+ new TestTagDefinition.Builder(instance, "other", CustomTagKind.EMPTY) //$NON-NLS-1$
+ .contentAllowed(true)
+ .emptyAllowed(true)
+ .removeWhenContainingLineIsEmpty(true)
+ .build());
+ }
+
+ public String getDefaultPrefix() {
+ return "test"; //$NON-NLS-1$
+ }
+
+ public String getDescription() {
+ return "test description"; //$NON-NLS-1$
+ }
+
+ public String getLibraryId() {
+ return "org.eclipse.jet.tests.TestLibrary"; //$NON-NLS-1$
+ }
+
+ public String getLibraryName() {
+ return "Test Library"; //$NON-NLS-1$
+ }
+
+ public TagDefinition getTagDefinition(String name) {
+ return (TagDefinition) tagsByName.get(name);
+ }
+
+ public String[] getTagNames() {
+ return (String[]) tagsByName.keySet().toArray(new String[0]);
+ }
+
+ public boolean hasTag(String tagNCName) {
+ return tagsByName.containsKey(tagNCName);
+ }
+
+ public boolean isDeprecated() {
+ return false;
+ }
+
+ }
+ private static final class TagLibResolver implements ITagLibraryResolver {
+
+ public TagLibrary getLibrary(String tagLibraryID) {
+ return TestTagLibrary.getInstance();
+ }
+
+ }
+ private URI baseLocation;
+ protected void setUp() throws Exception {
+ super.setUp();
+ baseLocation = new URI("platform:/plugin/org.eclipse.jet.tests.core/data/parser/ast/"); //$NON-NLS-1$
+
+ }
+ /*
+ * Test method for 'org.eclipse.jet.compiler.JET2Parser.compile(String, InputStream, String)'
+ */
+ public void testCompile() throws Exception {
+ final String templatePath = "taglibs.jet"; //$NON-NLS-1$
+
+ JETCompilationUnit cu = (JETCompilationUnit) new JETASTParser.Builder(JETAST.JET_SPEC_V2)
+ .templateResolver(new DefaultTemplateResolver.Builder(baseLocation).build())
+ .tagLibraryResolver(new TagLibResolver())
+ .build()
+ .parse(templatePath);
+
+ ASTDumper astDumper = new ASTDumper();
+ cu.accept(astDumper);
+
+ assertEquals(getResultsContents(templatePath, ".JETASTParser.astdump.expected"), astDumper.getLog()); //$NON-NLS-1$
+
+ }
+ /**
+ * @param templatePath
+ * @param resultsSuffix
+ * @return
+ * @throws MalformedURLException
+ * @throws IOException
+ * @throws CoreException
+ */
+ private String getResultsContents(final String templatePath, final String resultsSuffix) throws MalformedURLException, IOException, CoreException {
+ return FileUtils.getFileContents(baseLocation.resolve(templatePath + resultsSuffix).toString(), true);
+ }
+
+ public void testCompilationUnit_getTagLibraryReferences() throws Exception {
+ final String templatePath = "taglibs.jet"; //$NON-NLS-1$
+
+ JETCompilationUnit cu = (JETCompilationUnit) new JETASTParser.Builder(JETAST.JET_SPEC_V2)
+ .templateResolver(new DefaultTemplateResolver.Builder(baseLocation).build())
+ .tagLibraryResolver(new TagLibResolver())
+ .build()
+ .parse(templatePath);
+
+ final TagLibraryReference[] tlRefs = cu.getTagLibraryReferences();
+ assertNotNull(tlRefs);
+ assertEquals(1, tlRefs.length);
+ assertEquals("test", tlRefs[0].getPrefix()); //$NON-NLS-1$
+ assertEquals("org.eclipse.jet.tests.TestLibrary", tlRefs[0].getTagLibraryId()); //$NON-NLS-1$
+ }
+
+ public void testXMLStartAsEmpty_bug147714() throws MalformedURLException, FileNotFoundException, IOException {
+ final String templatePath = "bug147714.jet"; //$NON-NLS-1$
+
+ JETCompilationUnit cu = (JETCompilationUnit) new JETASTParser.Builder(JETAST.JET_SPEC_V2)
+ .templateResolver(new DefaultTemplateResolver.Builder(baseLocation).build())
+ .tagLibraryResolver(new TagLibResolver())
+ .build()
+ .parse(templatePath);
+
+ Problem[] problems = getSortedProblems(cu);
+
+ assertEquals("Number of problems", 3, problems.length); //$NON-NLS-1$
+
+
+ // This assertions correspond to comments in bug147714.jet
+ assertEquals("Problem 1 line number", 8, problems[0].getLineNumber()); //$NON-NLS-1$
+ assertEquals("Problem 1 severity", ProblemSeverity.ERROR, problems[0].getProblemSeverity()); //$NON-NLS-1$
+ assertEquals("Problem 1 id", IProblem.MissingXmlEndTag, problems[0].getId()); //$NON-NLS-1$
+
+ assertEquals("Problem 2 line number", 8, problems[1].getLineNumber()); //$NON-NLS-1$
+ assertEquals("Problem 2 severity", ProblemSeverity.ERROR, problems[1].getProblemSeverity()); //$NON-NLS-1$
+ assertEquals("Problem 2 id", IProblem.TagCannotHaveContent, problems[1].getId()); //$NON-NLS-1$
+
+ assertEquals("Problem 3 line number", 10, problems[2].getLineNumber()); //$NON-NLS-1$
+ assertEquals("Problem 3 severity", ProblemSeverity.WARNING, problems[2].getProblemSeverity()); //$NON-NLS-1$
+ assertEquals("Problem 3 id", IProblem.TagInterpretedAsEmptyTag, problems[2].getId()); //$NON-NLS-1$
+
+
+ }
+
+ public void testUnclosedCommnetErrors() throws Exception {
+ final String templatePath = "unclosedComment.jet"; //$NON-NLS-1$
+
+ JETCompilationUnit cu = (JETCompilationUnit) new JETASTParser.Builder(JETAST.JET_SPEC_V2)
+ .templateResolver(new DefaultTemplateResolver.Builder(baseLocation).build())
+ .build()
+ .parse(templatePath);
+
+ Problem[] problems = getSortedProblems(cu);
+
+ assertEquals("Number of problems", 1, problems.length); //$NON-NLS-1$
+
+
+ // This assertions correspond to comments in bug147714.jet
+ assertEquals("Problem 1 line number", 3, problems[0].getLineNumber()); //$NON-NLS-1$
+ assertEquals("Problem 1 severity", ProblemSeverity.ERROR, problems[0].getProblemSeverity()); //$NON-NLS-1$
+ assertEquals("Problem 1 id", IProblem.UnterminatedXMLTag, problems[0].getId()); //$NON-NLS-1$
+
+ }
+
+ public void testUnclosedDeclarationErrors() throws Exception {
+ final String templatePath = "unclosedDeclaration.jet"; //$NON-NLS-1$
+
+ JETCompilationUnit cu = (JETCompilationUnit) new JETASTParser.Builder(JETAST.JET_SPEC_V2)
+ .templateResolver(new DefaultTemplateResolver.Builder(baseLocation).build())
+ .build()
+ .parse(templatePath);
+
+ Problem[] problems = getSortedProblems(cu);
+
+ assertEquals("Number of problems", 1, problems.length); //$NON-NLS-1$
+
+ // This assertions correspond to comments in bug147714.jet
+ assertEquals("Problem 1 line number", 3, problems[0].getLineNumber()); //$NON-NLS-1$
+ assertEquals("Problem 1 severity", ProblemSeverity.ERROR, problems[0] //$NON-NLS-1$
+ .getProblemSeverity());
+ assertEquals("Problem 1 id", IProblem.UnterminatedXMLTag, problems[0] //$NON-NLS-1$
+ .getId());
+
+ }
+
+ public void testUnclosedDirectiveErrors() throws Exception {
+ final String templatePath = "unclosedDirective.jet"; //$NON-NLS-1$
+
+ JETCompilationUnit cu = (JETCompilationUnit) new JETASTParser.Builder(JETAST.JET_SPEC_V2)
+ .templateResolver(new DefaultTemplateResolver.Builder(baseLocation).build())
+ .build()
+ .parse(templatePath);
+
+ Problem[] problems = getSortedProblems(cu);
+
+ assertEquals("Number of problems", 1, problems.length); //$NON-NLS-1$
+
+
+ // This assertions correspond to comments in bug147714.jet
+ assertEquals("Problem 1 line number", 1, problems[0].getLineNumber()); //$NON-NLS-1$
+ assertEquals("Problem 1 severity", ProblemSeverity.ERROR, problems[0].getProblemSeverity()); //$NON-NLS-1$
+ assertEquals("Problem 1 id", IProblem.JETException, problems[0].getId()); //$NON-NLS-1$
+
+ }
+
+ public void testUnclosedExpressionErrors() throws Exception {
+ final String templatePath = "unclosedExpression.jet"; //$NON-NLS-1$
+
+ JETCompilationUnit cu = (JETCompilationUnit) new JETASTParser.Builder(JETAST.JET_SPEC_V2)
+ .templateResolver(new DefaultTemplateResolver.Builder(baseLocation).build())
+ .build()
+ .parse(templatePath);
+
+ Problem[] problems = getSortedProblems(cu);
+
+ assertEquals("Number of problems", 1, problems.length); //$NON-NLS-1$
+
+
+ // This assertions correspond to comments in bug147714.jet
+ assertEquals("Problem 1 line number", 3, problems[0].getLineNumber()); //$NON-NLS-1$
+ assertEquals("Problem 1 severity", ProblemSeverity.ERROR, problems[0].getProblemSeverity()); //$NON-NLS-1$
+ assertEquals("Problem 1 id", IProblem.JETException, problems[0].getId()); //$NON-NLS-1$
+
+ }
+
+ public void testUnclosedScriptletErrors() throws Exception {
+ final String templatePath = "unclosedScriplet.jet"; //$NON-NLS-1$
+
+ JETCompilationUnit cu = (JETCompilationUnit) new JETASTParser.Builder(JETAST.JET_SPEC_V2)
+ .templateResolver(new DefaultTemplateResolver.Builder(baseLocation).build())
+ .build()
+ .parse(templatePath);
+
+ Problem[] problems = getSortedProblems(cu);
+
+ assertEquals("Number of problems", 1, problems.length); //$NON-NLS-1$
+
+
+ // This assertions correspond to comments in bug147714.jet
+ assertEquals("Problem 1 line number", 3, problems[0].getLineNumber()); //$NON-NLS-1$
+ assertEquals("Problem 1 severity", ProblemSeverity.ERROR, problems[0].getProblemSeverity()); //$NON-NLS-1$
+ assertEquals("Problem 1 id", IProblem.JETException, problems[0].getId()); //$NON-NLS-1$
+
+ }
+
+ public void testUnclosedXMLEndErrors() throws Exception {
+ final String templatePath = "unclosedXMLEnd.jet"; //$NON-NLS-1$
+
+ JETCompilationUnit cu = (JETCompilationUnit) new JETASTParser.Builder(JETAST.JET_SPEC_V2)
+ .templateResolver(new DefaultTemplateResolver.Builder(baseLocation).build())
+ .tagLibraryResolver(new TagLibResolver())
+ .build()
+ .parse(templatePath);
+
+ Problem[] problems = getSortedProblems(cu);
+
+ assertEquals("Number of problems", 1, problems.length); //$NON-NLS-1$
+
+
+ // This assertions correspond to comments in bug147714.jet
+ assertEquals("Problem 1 line number", 3, problems[0].getLineNumber()); //$NON-NLS-1$
+ assertEquals("Problem 1 severity", ProblemSeverity.ERROR, problems[0].getProblemSeverity()); //$NON-NLS-1$
+ assertEquals("Problem 1 id", IProblem.UnterminatedXMLTag, problems[0].getId()); //$NON-NLS-1$
+
+ }
+
+ public void testUnclosedXMLStartErrors() throws Exception {
+ final String templatePath = "unclosedXMLStart.jet"; //$NON-NLS-1$
+
+ JETCompilationUnit cu = (JETCompilationUnit) new JETASTParser.Builder(JETAST.JET_SPEC_V2)
+ .templateResolver(new DefaultTemplateResolver.Builder(baseLocation).build())
+ .tagLibraryResolver(new TagLibResolver())
+ .build()
+ .parse(templatePath);
+
+ Problem[] problems = getSortedProblems(cu);
+
+ assertEquals("Number of problems", 1, problems.length); //$NON-NLS-1$
+
+
+ // This assertions correspond to comments in bug147714.jet
+ assertEquals("Problem 1 line number", 3, problems[0].getLineNumber()); //$NON-NLS-1$
+ assertEquals("Problem 1 severity", ProblemSeverity.ERROR, problems[0].getProblemSeverity()); //$NON-NLS-1$
+ assertEquals("Problem 1 id", IProblem.UnterminatedXMLTag, problems[0].getId()); //$NON-NLS-1$
+
+ }
+
+ /**
+ * @param cu
+ * @return
+ */
+ private Problem[] getSortedProblems(JETCompilationUnit cu) {
+ List problems = new ArrayList(cu.getProblems());
+ // problems are not guaranteed to be in line order (should they)
+ Collections.sort(problems, new Comparator() {
+
+ public int compare(Object arg0, Object arg1) {
+ Problem p0 = (Problem) arg0;
+ Problem p1 = (Problem) arg1;
+ int lineCompare = p0.getLineNumber() - p1.getLineNumber();
+ if(lineCompare == 0) {
+ return p0.getColOffset() - p1.getColOffset();
+ } else {
+ return lineCompare;
+ }
+ }});
+
+ Problem[] problem = (Problem[]) problems.toArray(new Problem[problems.size()]);
+ return problem;
+ }
+
+ public void testAttributeParsingErrors() throws Exception {
+ final String templatePath = "attributeParsingErrors.jet"; //$NON-NLS-1$
+
+ JETCompilationUnit cu = (JETCompilationUnit) new JETASTParser.Builder(JETAST.JET_SPEC_V2)
+ .templateResolver(new DefaultTemplateResolver.Builder(baseLocation).build())
+ .tagLibraryResolver(new TagLibResolver())
+ .build()
+ .parse(templatePath);
+
+ Problem[] problems = getSortedProblems(cu);
+
+ assertTrue("At least one problem", problems.length > 0); //$NON-NLS-1$
+
+ assertEquals("Problem 1 severity", ProblemSeverity.ERROR, problems[0].getProblemSeverity()); //$NON-NLS-1$
+ assertEquals("Problem 1 id", IProblem.JETException, problems[0].getId()); //$NON-NLS-1$
+ assertEquals("Problem 1 line number", 4, problems[0].getLineNumber()); //$NON-NLS-1$
+ }
+}