Skip to main content
summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorpelder2007-04-04 10:59:40 -0400
committerpelder2007-04-04 10:59:40 -0400
commit115966a43c9f71738ba2e952e0f42ce2051cd24f (patch)
tree03b461c5daf4d26221a24e26796adfe791674fba /tests
parent94732f3ff6590dd893f5a896ad34b804e012b928 (diff)
downloadorg.eclipse.jet-115966a43c9f71738ba2e952e0f42ce2051cd24f.tar.gz
org.eclipse.jet-115966a43c9f71738ba2e952e0f42ce2051cd24f.tar.xz
org.eclipse.jet-115966a43c9f71738ba2e952e0f42ce2051cd24f.zip
[180962,131208] add JET1 compilation, move some elements to org.eclipse.jet.core
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.jet.tests-feature/feature.xml7
-rw-r--r--tests/org.eclipse.jet.tests/.classpath2
-rw-r--r--tests/org.eclipse.jet.tests/.settings/org.eclipse.jdt.core.prefs12
-rw-r--r--tests/org.eclipse.jet.tests/.settings/org.eclipse.jdt.ui.prefs3
-rw-r--r--tests/org.eclipse.jet.tests/META-INF/MANIFEST.MF1
-rw-r--r--tests/org.eclipse.jet.tests/data/simplifiedCompiler/changedTemplates/simple.v2.input.jet11
-rw-r--r--tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.input.jet10
-rw-r--r--tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.input.jet.expected.java125
-rw-r--r--tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.input2.jet10
-rw-r--r--tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.loader.expected.java80
-rw-r--r--tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.pat1
-rw-r--r--tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.pat21
-rw-r--r--tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.pat31
-rw-r--r--tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.pat41
-rw-r--r--tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.usePredefTagLibs.jet3
-rw-r--r--tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.usePredefTagLibs.jet.nopredefs.expected.java23
-rw-r--r--tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.usePredefTagLibs.jet.predefs.expected.java43
-rw-r--r--tests/org.eclipse.jet.tests/data/taglibs.jet.JETASTParser.astdump.expected41
-rw-r--r--tests/org.eclipse.jet.tests/data/taglibs.jet.JETASTParser.expected.java114
-rw-r--r--tests/org.eclipse.jet.tests/data/taglibs.jet.expected.java6
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/AllTests.java1
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJET2Parser.java66
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJETParser.java49
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestSimplifiedCompiler.java428
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TextTrimmingTests.java111
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/control/LoadTagTests.java6
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/format/FormatNowTagTests.java6
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/format/UuidTagTests.java10
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/java/TestImportsLocationTag.java13
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/ResourceInspectorTests.java4
30 files changed, 1057 insertions, 132 deletions
diff --git a/tests/org.eclipse.jet.tests-feature/feature.xml b/tests/org.eclipse.jet.tests-feature/feature.xml
index 39775c2..69d7c27 100644
--- a/tests/org.eclipse.jet.tests-feature/feature.xml
+++ b/tests/org.eclipse.jet.tests-feature/feature.xml
@@ -55,4 +55,11 @@ http://www.eclipse.org/legal/epl-v10.html
version="0.0.0"
fragment="true"/>
+ <plugin
+ id="org.eclipse.jet.tests.core"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
</feature>
diff --git a/tests/org.eclipse.jet.tests/.classpath b/tests/org.eclipse.jet.tests/.classpath
index 751c8f2..ce73933 100644
--- a/tests/org.eclipse.jet.tests/.classpath
+++ b/tests/org.eclipse.jet.tests/.classpath
@@ -1,7 +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.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/tests/org.eclipse.jet.tests/.settings/org.eclipse.jdt.core.prefs b/tests/org.eclipse.jet.tests/.settings/org.eclipse.jdt.core.prefs
index f32ef68..96cf3d5 100644
--- a/tests/org.eclipse.jet.tests/.settings/org.eclipse.jdt.core.prefs
+++ b/tests/org.eclipse.jet.tests/.settings/org.eclipse.jdt.core.prefs
@@ -1,12 +1,21 @@
-#Thu Feb 02 16:59:31 EST 2006
+#Tue Apr 03 15:27:11 EDT 2007
eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+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.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
org.eclipse.jdt.core.compiler.problem.deprecation=warning
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
@@ -47,3 +56,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=di
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.3
diff --git a/tests/org.eclipse.jet.tests/.settings/org.eclipse.jdt.ui.prefs b/tests/org.eclipse.jet.tests/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 0000000..f992ce5
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,3 @@
+#Tue Apr 03 14:56:39 EDT 2007
+eclipse.preferences.version=1
+internal.default.compliance=user
diff --git a/tests/org.eclipse.jet.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.jet.tests/META-INF/MANIFEST.MF
index 5570f00..bd84436 100644
--- a/tests/org.eclipse.jet.tests/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.jet.tests/META-INF/MANIFEST.MF
@@ -15,3 +15,4 @@ Require-Bundle: org.eclipse.jet,
org.eclipse.core.filebuffers,
org.eclipse.core.resources
Bundle-Vendor: %providerName
+Bundle-RequiredExecutionEnvironment: J2SE-1.4
diff --git a/tests/org.eclipse.jet.tests/data/simplifiedCompiler/changedTemplates/simple.v2.input.jet b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/changedTemplates/simple.v2.input.jet
new file mode 100644
index 0000000..3681ee5
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/changedTemplates/simple.v2.input.jet
@@ -0,0 +1,11 @@
+<%@jet class="ChangedInput"%>
+<%@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/data/simplifiedCompiler/templates/simple.v2.input.jet b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.input.jet
new file mode 100644
index 0000000..2bc9dfc
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.input.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/data/simplifiedCompiler/templates/simple.v2.input.jet.expected.java b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.input.jet.expected.java
new file mode 100644
index 0000000..92b9eeb
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.input.jet.expected.java
@@ -0,0 +1,125 @@
+package org.eclipse.jet.compiled;
+
+import org.eclipse.jet.JET2Context;
+import org.eclipse.jet.JET2Template;
+import org.eclipse.jet.JET2Writer;
+import org.eclipse.jet.taglib.RuntimeTagElement;
+import org.eclipse.jet.taglib.TagInfo;
+
+public class _jet_simplev2input implements JET2Template {
+ private static final String _jetns_test = "org.eclipse.jet.tests.TestLibrary"; //$NON-NLS-1$
+
+ public _jet_simplev2input() {
+ super();
+ }
+
+ private static final String NL = System.getProperties().getProperty("line.separator");
+
+ private static final class _TEXT {
+ private static final String TEXT_1 = "\"isAllUpper\", \"nl\", \"other\", \"tokenize\", \"upper\"" + NL + NL; //$NON-NLS-1$
+ private static final String TEXT_2 = "some text"; //$NON-NLS-1$
+ private static final String TEXT_3 = NL;
+ private static final String TEXT_4 = "foo"; //$NON-NLS-1$
+ private static final String TEXT_5 = NL;
+ }
+
+ private static final class _TAGS {
+ private static final TagInfo test_tokenize_4_1 = new TagInfo("test:tokenize", //$NON-NLS-1$
+ 4, 1,
+ new String[] {
+ "sep", //$NON-NLS-1$
+ "var", //$NON-NLS-1$
+ "string", //$NON-NLS-1$
+ },
+ new String[] {
+ ",", //$NON-NLS-1$
+ "token", //$NON-NLS-1$
+ "a,b,c,d,e,f,g", //$NON-NLS-1$
+ } );
+ private static final TagInfo test_other_5_1 = new TagInfo("test:other", //$NON-NLS-1$
+ 5, 1,
+ new String[] {
+ },
+ new String[] {
+ } );
+ private static final TagInfo test_isAllUpper_6_1 = new TagInfo("test:isAllUpper", //$NON-NLS-1$
+ 6, 1,
+ new String[] {
+ "var", //$NON-NLS-1$
+ },
+ new String[] {
+ "token", //$NON-NLS-1$
+ } );
+ private static final TagInfo test_upper_8_1 = new TagInfo("test:upper", //$NON-NLS-1$
+ 8, 1,
+ new String[] {
+ },
+ new String[] {
+ } );
+ private static final TagInfo test_nl_8_29 = new TagInfo("test:nl", //$NON-NLS-1$
+ 8, 29,
+ new String[] {
+ },
+ new String[] {
+ } );
+ private static final TagInfo test_other_9_1 = new TagInfo("test:other", //$NON-NLS-1$
+ 9, 1,
+ new String[] {
+ },
+ new String[] {
+ } );
+ }
+
+ public void generate(final JET2Context context, JET2Writer out) {
+ out.write(_TEXT.TEXT_1);
+ RuntimeTagElement _jettag_test_tokenize_4_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "tokenize", "test:tokenize", _TAGS.test_tokenize_4_1); //$NON-NLS-1$ //$NON-NLS-2$
+ _jettag_test_tokenize_4_1.setRuntimeParent(null);
+ _jettag_test_tokenize_4_1.setTagInfo(_TAGS.test_tokenize_4_1);
+ _jettag_test_tokenize_4_1.doStart(context, out);
+ while (_jettag_test_tokenize_4_1.okToProcessBody()) {
+ RuntimeTagElement _jettag_test_other_5_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "other", "test:other", _TAGS.test_other_5_1); //$NON-NLS-1$ //$NON-NLS-2$
+ _jettag_test_other_5_1.setRuntimeParent(_jettag_test_tokenize_4_1);
+ _jettag_test_other_5_1.setTagInfo(_TAGS.test_other_5_1);
+ _jettag_test_other_5_1.doStart(context, out);
+ while (_jettag_test_other_5_1.okToProcessBody()) {
+ out.write(_TEXT.TEXT_2);
+ _jettag_test_other_5_1.handleBodyContent(out);
+ }
+ _jettag_test_other_5_1.doEnd();
+ out.write(_TEXT.TEXT_3);
+ RuntimeTagElement _jettag_test_isAllUpper_6_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "isAllUpper", "test:isAllUpper", _TAGS.test_isAllUpper_6_1); //$NON-NLS-1$ //$NON-NLS-2$
+ _jettag_test_isAllUpper_6_1.setRuntimeParent(_jettag_test_tokenize_4_1);
+ _jettag_test_isAllUpper_6_1.setTagInfo(_TAGS.test_isAllUpper_6_1);
+ _jettag_test_isAllUpper_6_1.doStart(context, out);
+ while (_jettag_test_isAllUpper_6_1.okToProcessBody()) {
+ _jettag_test_isAllUpper_6_1.handleBodyContent(out);
+ }
+ _jettag_test_isAllUpper_6_1.doEnd();
+ RuntimeTagElement _jettag_test_upper_8_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "upper", "test:upper", _TAGS.test_upper_8_1); //$NON-NLS-1$ //$NON-NLS-2$
+ _jettag_test_upper_8_1.setRuntimeParent(_jettag_test_tokenize_4_1);
+ _jettag_test_upper_8_1.setTagInfo(_TAGS.test_upper_8_1);
+ _jettag_test_upper_8_1.doStart(context, out);
+ JET2Writer _jettag_test_upper_8_1_saved_out = out;
+ while (_jettag_test_upper_8_1.okToProcessBody()) {
+ out = out.newNestedContentWriter();
+ out.write(_TEXT.TEXT_4);
+ _jettag_test_upper_8_1.handleBodyContent(out);
+ }
+ out = _jettag_test_upper_8_1_saved_out;
+ _jettag_test_upper_8_1.doEnd();
+ RuntimeTagElement _jettag_test_nl_8_29 = context.getTagFactory().createRuntimeTag(_jetns_test, "nl", "test:nl", _TAGS.test_nl_8_29); //$NON-NLS-1$ //$NON-NLS-2$
+ _jettag_test_nl_8_29.setRuntimeParent(_jettag_test_tokenize_4_1);
+ _jettag_test_nl_8_29.setTagInfo(_TAGS.test_nl_8_29);
+ _jettag_test_nl_8_29.doStart(context, out);
+ _jettag_test_nl_8_29.doEnd();
+ out.write(_TEXT.TEXT_5);
+ RuntimeTagElement _jettag_test_other_9_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "other", "test:other", _TAGS.test_other_9_1); //$NON-NLS-1$ //$NON-NLS-2$
+ _jettag_test_other_9_1.setRuntimeParent(_jettag_test_tokenize_4_1);
+ _jettag_test_other_9_1.setTagInfo(_TAGS.test_other_9_1);
+ _jettag_test_other_9_1.doStart(context, out);
+ _jettag_test_other_9_1.doEnd();
+ _jettag_test_tokenize_4_1.handleBodyContent(out);
+ }
+ _jettag_test_tokenize_4_1.doEnd();
+ }
+}
diff --git a/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.input2.jet b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.input2.jet
new file mode 100644
index 0000000..2bc9dfc
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.input2.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/data/simplifiedCompiler/templates/simple.v2.loader.expected.java b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.loader.expected.java
new file mode 100644
index 0000000..c73aeff
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.loader.expected.java
@@ -0,0 +1,80 @@
+package org.eclipse.jet.compiled;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jet.JET2TemplateLoader;
+import org.eclipse.jet.JET2TemplateLoaderExtension;
+import org.eclipse.jet.JET2Template;
+
+public class TemplateLoaderClass implements JET2TemplateLoader, JET2TemplateLoaderExtension {
+
+ private static final class TemplateFactoryMethod {
+
+ private final String templatePath;
+ private final String templateClass;
+
+ public TemplateFactoryMethod(String templatePath, String templateClass) {
+ this.templatePath = templatePath;
+ this.templateClass = templateClass;
+
+ }
+
+ public String getTemplateClass() {
+ return templateClass;
+ }
+
+ public String getTemplatePath() {
+ return templatePath;
+ }
+
+ public JET2Template newTemplate() {
+ JET2Template template = null;
+ try {
+ template = (JET2Template) Class.forName(templateClass).newInstance();
+ } catch (InstantiationException e) {
+ } catch (IllegalAccessException e) {
+ } catch (ClassNotFoundException e) {
+ }
+ return template;
+ }
+
+
+ }
+
+ private Map pathToFactoryMap = null;
+
+ private JET2TemplateLoader delegate = null;
+
+ public TemplateLoaderClass() {
+ super();
+ }
+
+ public JET2Template getTemplate(String templatePath) {
+ if(pathToFactoryMap == null) {
+ initPathToFactoryMap();
+ }
+ TemplateFactoryMethod factory = (TemplateFactoryMethod)pathToFactoryMap.get(templatePath);
+ return factory == null ? delegate == null ? null : delegate.getTemplate(templatePath) : factory.newTemplate();
+ }
+
+ private void addTemplate(String templatePath, String templateClass) {
+ pathToFactoryMap.put(templatePath, //$NON-NLS-1$
+ new TemplateFactoryMethod(templatePath, templateClass));
+ }
+
+ private void initPathToFactoryMap() {
+ pathToFactoryMap = new HashMap(2);
+ addTemplate("simple.v2.input.jet", "org.eclipse.jet.compiled._jet_simplev2input" ); //$NON-NLS-1$ //$NON-NLS-2$
+ addTemplate("simple.v2.input2.jet", "org.eclipse.jet.compiled._jet_simplev2input2" ); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void setDelegateLoader(JET2TemplateLoader loader) {
+ this.delegate = loader;
+ }
+
+ public JET2TemplateLoader getDelegateLoader() {
+ return delegate;
+ }
+}
+
diff --git a/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.pat b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.pat
new file mode 100644
index 0000000..23c0af8
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.pat
@@ -0,0 +1 @@
+simple.v2.pat
diff --git a/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.pat2 b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.pat2
new file mode 100644
index 0000000..0ff28f8
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.pat2
@@ -0,0 +1 @@
+simple.v2.pat2
diff --git a/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.pat3 b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.pat3
new file mode 100644
index 0000000..8ecde48
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.pat3
@@ -0,0 +1 @@
+simple.v2.pat3
diff --git a/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.pat4 b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.pat4
new file mode 100644
index 0000000..768f2a8
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.pat4
@@ -0,0 +1 @@
+simple.v2.pat4
diff --git a/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.usePredefTagLibs.jet b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.usePredefTagLibs.jet
new file mode 100644
index 0000000..e77b527
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.usePredefTagLibs.jet
@@ -0,0 +1,3 @@
+This template uses a predefined tag library:
+
+<c:get select="$useMe/@attr"/>
diff --git a/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.usePredefTagLibs.jet.nopredefs.expected.java b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.usePredefTagLibs.jet.nopredefs.expected.java
new file mode 100644
index 0000000..578bafa
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.usePredefTagLibs.jet.nopredefs.expected.java
@@ -0,0 +1,23 @@
+package org.eclipse.jet.compiled;
+
+import org.eclipse.jet.JET2Context;
+import org.eclipse.jet.JET2Template;
+import org.eclipse.jet.JET2Writer;
+
+public class _jet_simplev2usePredefTagLibs implements JET2Template {
+
+ public _jet_simplev2usePredefTagLibs() {
+ super();
+ }
+
+ private static final String NL = System.getProperties().getProperty("line.separator");
+
+ private static final class _TEXT {
+ private static final String TEXT_1 = "This template uses a predefined tag library:" + NL + NL + "<c:get select=\"$useMe/@attr\"/>" + NL; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+
+ public void generate(final JET2Context context, JET2Writer out) {
+ out.write(_TEXT.TEXT_1);
+ }
+}
diff --git a/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.usePredefTagLibs.jet.predefs.expected.java b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.usePredefTagLibs.jet.predefs.expected.java
new file mode 100644
index 0000000..2eeaaed
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.usePredefTagLibs.jet.predefs.expected.java
@@ -0,0 +1,43 @@
+package org.eclipse.jet.compiled;
+
+import org.eclipse.jet.JET2Context;
+import org.eclipse.jet.JET2Template;
+import org.eclipse.jet.JET2Writer;
+import org.eclipse.jet.taglib.RuntimeTagElement;
+import org.eclipse.jet.taglib.TagInfo;
+
+public class _jet_simplev2usePredefTagLibs implements JET2Template {
+ private static final String _jetns_c = "org.eclipse.jet.controlTags"; //$NON-NLS-1$
+
+ public _jet_simplev2usePredefTagLibs() {
+ super();
+ }
+
+ private static final String NL = System.getProperties().getProperty("line.separator");
+
+ private static final class _TEXT {
+ private static final String TEXT_1 = "This template uses a predefined tag library:" + NL + NL; //$NON-NLS-1$
+ private static final String TEXT_2 = NL;
+ }
+
+ private static final class _TAGS {
+ private static final TagInfo c_get_3_1 = new TagInfo("c:get", //$NON-NLS-1$
+ 3, 1,
+ new String[] {
+ "select", //$NON-NLS-1$
+ },
+ new String[] {
+ "$useMe/@attr", //$NON-NLS-1$
+ } );
+ }
+
+ public void generate(final JET2Context context, JET2Writer out) {
+ out.write(_TEXT.TEXT_1);
+ RuntimeTagElement _jettag_c_get_3_1 = context.getTagFactory().createRuntimeTag(_jetns_c, "get", "c:get", _TAGS.c_get_3_1); //$NON-NLS-1$ //$NON-NLS-2$
+ _jettag_c_get_3_1.setRuntimeParent(null);
+ _jettag_c_get_3_1.setTagInfo(_TAGS.c_get_3_1);
+ _jettag_c_get_3_1.doStart(context, out);
+ _jettag_c_get_3_1.doEnd();
+ out.write(_TEXT.TEXT_2);
+ }
+}
diff --git a/tests/org.eclipse.jet.tests/data/taglibs.jet.JETASTParser.astdump.expected b/tests/org.eclipse.jet.tests/data/taglibs.jet.JETASTParser.astdump.expected
new file mode 100644
index 0000000..b99d6d3
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/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/data/taglibs.jet.JETASTParser.expected.java b/tests/org.eclipse.jet.tests/data/taglibs.jet.JETASTParser.expected.java
new file mode 100644
index 0000000..7e4b77e
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/taglibs.jet.JETASTParser.expected.java
@@ -0,0 +1,114 @@
+package org.eclipse.jet.compiled;
+
+import org.eclipse.jet.JET2Context;
+import org.eclipse.jet.JET2Template;
+import org.eclipse.jet.JET2Writer;
+import org.eclipse.jet.taglib.RuntimeTagElement;
+import org.eclipse.jet.taglib.TagInfo;
+
+public class X implements JET2Template {
+ public static final String _jetns_test = "org.eclipse.jet.tests.TestLibrary"; //$NON-NLS-1$
+
+ public X() {
+ super();
+ }
+
+ public void generate(final JET2Context context, JET2Writer out) {
+ final TagInfo _jettd_test_tokenize_4_1 = new TagInfo("test:tokenize", //$NON-NLS-1$
+ 4, 1,
+ new String[] {
+ "sep", //$NON-NLS-1$
+ "var", //$NON-NLS-1$
+ "string", //$NON-NLS-1$
+ },
+ new String[] {
+ ",", //$NON-NLS-1$
+ "token", //$NON-NLS-1$
+ "a,b,c,d,e,f,g", //$NON-NLS-1$
+ } );
+ final TagInfo _jettd_test_other_5_1 = new TagInfo("test:other", //$NON-NLS-1$
+ 5, 1,
+ new String[] {
+ },
+ new String[] {
+ } );
+ final TagInfo _jettd_test_isAllUpper_6_1 = new TagInfo("test:isAllUpper", //$NON-NLS-1$
+ 6, 1,
+ new String[] {
+ "var", //$NON-NLS-1$
+ },
+ new String[] {
+ "token", //$NON-NLS-1$
+ } );
+ final TagInfo _jettd_test_upper_8_1 = new TagInfo("test:upper", //$NON-NLS-1$
+ 8, 1,
+ new String[] {
+ },
+ new String[] {
+ } );
+ final TagInfo _jettd_test_nl_8_29 = new TagInfo("test:nl", //$NON-NLS-1$
+ 8, 29,
+ new String[] {
+ },
+ new String[] {
+ } );
+ final TagInfo _jettd_test_other_9_1 = new TagInfo("test:other", //$NON-NLS-1$
+ 9, 1,
+ new String[] {
+ },
+ new String[] {
+ } );
+ out.write( "\"isAllUpper\", \"nl\", \"other\", \"tokenize\", \"upper\"\r\n\r\n" ); //$NON-NLS-1$
+ RuntimeTagElement _jettag_test_tokenize_4_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "tokenize", "test:tokenize", _jettd_test_tokenize_4_1); //$NON-NLS-1$ //$NON-NLS-2$
+ _jettag_test_tokenize_4_1.setRuntimeParent(null);
+ _jettag_test_tokenize_4_1.setTagInfo(_jettd_test_tokenize_4_1);
+ _jettag_test_tokenize_4_1.doStart(context, out);
+ while (_jettag_test_tokenize_4_1.okToProcessBody()) {
+ RuntimeTagElement _jettag_test_other_5_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "other", "test:other", _jettd_test_other_5_1); //$NON-NLS-1$ //$NON-NLS-2$
+ _jettag_test_other_5_1.setRuntimeParent(_jettag_test_tokenize_4_1);
+ _jettag_test_other_5_1.setTagInfo(_jettd_test_other_5_1);
+ _jettag_test_other_5_1.doStart(context, out);
+ while (_jettag_test_other_5_1.okToProcessBody()) {
+ out.write( "some text" ); //$NON-NLS-1$
+ _jettag_test_other_5_1.handleBodyContent(out);
+ }
+ _jettag_test_other_5_1.doEnd();
+ out.write( "\r\n" ); //$NON-NLS-1$
+ RuntimeTagElement _jettag_test_isAllUpper_6_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "isAllUpper", "test:isAllUpper", _jettd_test_isAllUpper_6_1); //$NON-NLS-1$ //$NON-NLS-2$
+ _jettag_test_isAllUpper_6_1.setRuntimeParent(_jettag_test_tokenize_4_1);
+ _jettag_test_isAllUpper_6_1.setTagInfo(_jettd_test_isAllUpper_6_1);
+ _jettag_test_isAllUpper_6_1.doStart(context, out);
+ while (_jettag_test_isAllUpper_6_1.okToProcessBody()) {
+ _jettag_test_isAllUpper_6_1.handleBodyContent(out);
+ }
+ _jettag_test_isAllUpper_6_1.doEnd();
+ RuntimeTagElement _jettag_test_upper_8_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "upper", "test:upper", _jettd_test_upper_8_1); //$NON-NLS-1$ //$NON-NLS-2$
+ _jettag_test_upper_8_1.setRuntimeParent(_jettag_test_tokenize_4_1);
+ _jettag_test_upper_8_1.setTagInfo(_jettd_test_upper_8_1);
+ _jettag_test_upper_8_1.doStart(context, out);
+ JET2Writer _jettag_test_upper_8_1_saved_out = out;
+ while (_jettag_test_upper_8_1.okToProcessBody()) {
+ out = out.newNestedContentWriter();
+ out.write( "foo" ); //$NON-NLS-1$
+ _jettag_test_upper_8_1.handleBodyContent(out);
+ }
+ out = _jettag_test_upper_8_1_saved_out;
+ _jettag_test_upper_8_1.doEnd();
+ RuntimeTagElement _jettag_test_nl_8_29 = context.getTagFactory().createRuntimeTag(_jetns_test, "nl", "test:nl", _jettd_test_nl_8_29); //$NON-NLS-1$ //$NON-NLS-2$
+ _jettag_test_nl_8_29.setRuntimeParent(_jettag_test_tokenize_4_1);
+ _jettag_test_nl_8_29.setTagInfo(_jettd_test_nl_8_29);
+ _jettag_test_nl_8_29.doStart(context, out);
+ _jettag_test_nl_8_29.doEnd();
+ out.write( "\r\n" ); //$NON-NLS-1$
+ RuntimeTagElement _jettag_test_other_9_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "other", "test:other", _jettd_test_other_9_1); //$NON-NLS-1$ //$NON-NLS-2$
+ _jettag_test_other_9_1.setRuntimeParent(_jettag_test_tokenize_4_1);
+ _jettag_test_other_9_1.setTagInfo(_jettd_test_other_9_1);
+ _jettag_test_other_9_1.doStart(context, out);
+ _jettag_test_other_9_1.doEnd();
+ _jettag_test_tokenize_4_1.handleBodyContent(out);
+ }
+ _jettag_test_tokenize_4_1.doEnd();
+
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests/data/taglibs.jet.expected.java b/tests/org.eclipse.jet.tests/data/taglibs.jet.expected.java
index 2611bf7..7e4b77e 100644
--- a/tests/org.eclipse.jet.tests/data/taglibs.jet.expected.java
+++ b/tests/org.eclipse.jet.tests/data/taglibs.jet.expected.java
@@ -58,13 +58,12 @@ public class X implements JET2Template {
},
new String[] {
} );
- out.write( "\r\n\"isAllUpper\", \"nl\", \"other\", \"tokenize\", \"upper\"\r\n\r\n" ); //$NON-NLS-1$
+ out.write( "\"isAllUpper\", \"nl\", \"other\", \"tokenize\", \"upper\"\r\n\r\n" ); //$NON-NLS-1$
RuntimeTagElement _jettag_test_tokenize_4_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "tokenize", "test:tokenize", _jettd_test_tokenize_4_1); //$NON-NLS-1$ //$NON-NLS-2$
_jettag_test_tokenize_4_1.setRuntimeParent(null);
_jettag_test_tokenize_4_1.setTagInfo(_jettd_test_tokenize_4_1);
_jettag_test_tokenize_4_1.doStart(context, out);
while (_jettag_test_tokenize_4_1.okToProcessBody()) {
- out.write( "\r\n" ); //$NON-NLS-1$
RuntimeTagElement _jettag_test_other_5_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "other", "test:other", _jettd_test_other_5_1); //$NON-NLS-1$ //$NON-NLS-2$
_jettag_test_other_5_1.setRuntimeParent(_jettag_test_tokenize_4_1);
_jettag_test_other_5_1.setTagInfo(_jettd_test_other_5_1);
@@ -80,11 +79,9 @@ public class X implements JET2Template {
_jettag_test_isAllUpper_6_1.setTagInfo(_jettd_test_isAllUpper_6_1);
_jettag_test_isAllUpper_6_1.doStart(context, out);
while (_jettag_test_isAllUpper_6_1.okToProcessBody()) {
- out.write( "\r\n" ); //$NON-NLS-1$
_jettag_test_isAllUpper_6_1.handleBodyContent(out);
}
_jettag_test_isAllUpper_6_1.doEnd();
- out.write( "\r\n" ); //$NON-NLS-1$
RuntimeTagElement _jettag_test_upper_8_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "upper", "test:upper", _jettd_test_upper_8_1); //$NON-NLS-1$ //$NON-NLS-2$
_jettag_test_upper_8_1.setRuntimeParent(_jettag_test_tokenize_4_1);
_jettag_test_upper_8_1.setTagInfo(_jettd_test_upper_8_1);
@@ -108,7 +105,6 @@ public class X implements JET2Template {
_jettag_test_other_9_1.setTagInfo(_jettd_test_other_9_1);
_jettag_test_other_9_1.doStart(context, out);
_jettag_test_other_9_1.doEnd();
- out.write( "\r\n" ); //$NON-NLS-1$
_jettag_test_tokenize_4_1.handleBodyContent(out);
}
_jettag_test_tokenize_4_1.doEnd();
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/AllTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/AllTests.java
index be0b1b5..cb7b1d0 100644
--- a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/AllTests.java
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/AllTests.java
@@ -10,6 +10,7 @@ public class AllTests {
"Test for org.eclipse.jet.tests.compiler");
//$JUnit-BEGIN$
suite.addTestSuite(TestJETParser.class);
+ suite.addTestSuite(TestSimplifiedCompiler.class);
suite.addTestSuite(TestJET2Parser.class);
suite.addTest(TextTrimmingTests.suite());
suite.addTestSuite(LineInfoTests.class);
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJET2Parser.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJET2Parser.java
index cb59f25..5d2c819 100644
--- a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJET2Parser.java
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJET2Parser.java
@@ -18,7 +18,6 @@ import junit.framework.TestCase;
import org.eclipse.jet.compiler.Comment;
import org.eclipse.jet.compiler.JET2ASTVisitor;
import org.eclipse.jet.compiler.JET2CompilationUnit;
-import org.eclipse.jet.compiler.JET2Compiler;
import org.eclipse.jet.compiler.JET2Declaration;
import org.eclipse.jet.compiler.JET2Directive;
import org.eclipse.jet.compiler.JET2Expression;
@@ -28,8 +27,11 @@ import org.eclipse.jet.compiler.TextElement;
import org.eclipse.jet.compiler.XMLBodyElement;
import org.eclipse.jet.compiler.XMLBodyElementEnd;
import org.eclipse.jet.compiler.XMLEmptyElement;
+import org.eclipse.jet.core.compiler.JETCompilerOptions;
+import org.eclipse.jet.core.parser.IProblem;
+import org.eclipse.jet.core.parser.ProblemSeverity;
import org.eclipse.jet.internal.compiler.TemplateRunner;
-import org.eclipse.jet.internal.parser.ParseProblemSeverity;
+import org.eclipse.jet.internal.core.NewLineUtil;
import org.eclipse.jet.taglib.TagLibraryReference;
import org.eclipse.jet.tests.FileUtils;
@@ -52,7 +54,7 @@ public class TestJET2Parser extends TestCase {
}
public String getLog() {
- return buffer.toString();
+ return NewLineUtil.setLineTerminator(buffer, NL);
}
@@ -133,7 +135,7 @@ public class TestJET2Parser extends TestCase {
*/
public void visit(TextElement text) {
doIndent();
- buffer.append("<data>").append(text.getText()).append("</data>").append(NL);
+ buffer.append("<data>").append(text.getRawText()).append("</data>").append(NL);
}
/* (non-Javadoc)
@@ -196,6 +198,10 @@ public class TestJET2Parser extends TestCase {
}
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ }
private FileInputStream getFileContentsAsStream(String urlString) throws IOException, MalformedURLException, FileNotFoundException {
String fileName = FileUtils.resolveURLToLocationString(urlString);
FileInputStream inputStream = new FileInputStream(new File(fileName));
@@ -249,10 +255,10 @@ public class TestJET2Parser extends TestCase {
JET2CompilationUnit cu = new JET2CompilationUnit();
cu.parse(is, "UTF-8");
- cu.setOutputJavaPackage(JET2Compiler.DEFAULT_COMPILED_TEMPLATE_PACKAGE);
+ cu.setOutputJavaPackage(JETCompilerOptions.DEFAULT_COMPILED_TEMPLATE_PACKAGE);
cu.setOutputJavaClassName("X");
- String result = new TemplateRunner().generate("templates/jet2java.jet", Collections.singletonMap("cu", cu));
+ String result = new TemplateRunner().generate("templates/jet2java.jet", Collections.singletonMap("cu", cu.getDelegateCU()));
assertEquals(FileUtils.getFileContents(urlString + ".expected.java", true), result);
@@ -268,17 +274,21 @@ public class TestJET2Parser extends TestCase {
Problem[] problems = getSortedProblems(cu);
- assertEquals("Number of problems", 2, problems.length);
+ assertEquals("Number of problems", 3, problems.length);
// This assertions correspond to comments in bug147714.jet
assertEquals("Problem 1 line number", 8, problems[0].getLineNumber());
- assertEquals("Problem 1 severity", ParseProblemSeverity.ERROR, problems[0].getSeverity());
- assertEquals("Problem 1 id", Problem.MissingXmlEndTag, problems[0].getId());
+ assertEquals("Problem 1 severity", ProblemSeverity.ERROR, problems[0].getProblemSeverity());
+ assertEquals("Problem 1 id", IProblem.MissingXmlEndTag, problems[0].getId());
- assertEquals("Problem 2 line number", 10, problems[1].getLineNumber());
- assertEquals("Problem 2 severity", ParseProblemSeverity.WARNING, problems[1].getSeverity());
- assertEquals("Problem 2 id", Problem.TagInterpretedAsEmptyTag, problems[1].getId());
+ assertEquals("Problem 2 line number", 8, problems[1].getLineNumber());
+ assertEquals("Problem 2 severity", ProblemSeverity.ERROR, problems[1].getProblemSeverity());
+ assertEquals("Problem 2 id", IProblem.TagCannotHaveContent, problems[1].getId());
+
+ assertEquals("Problem 2 line number", 10, problems[2].getLineNumber());
+ assertEquals("Problem 2 severity", ProblemSeverity.WARNING, problems[2].getProblemSeverity());
+ assertEquals("Problem 2 id", IProblem.TagInterpretedAsEmptyTag, problems[2].getId());
}
@@ -298,8 +308,8 @@ public class TestJET2Parser extends TestCase {
// This assertions correspond to comments in bug147714.jet
assertEquals("Problem 1 line number", 3, problems[0].getLineNumber());
- assertEquals("Problem 1 severity", ParseProblemSeverity.ERROR, problems[0].getSeverity());
- assertEquals("Problem 1 id", Problem.UnterminatedXMLTag, problems[0].getId());
+ assertEquals("Problem 1 severity", ProblemSeverity.ERROR, problems[0].getProblemSeverity());
+ assertEquals("Problem 1 id", IProblem.UnterminatedXMLTag, problems[0].getId());
}
@@ -318,8 +328,8 @@ public class TestJET2Parser extends TestCase {
// This assertions correspond to comments in bug147714.jet
assertEquals("Problem 1 line number", 3, problems[0].getLineNumber());
- assertEquals("Problem 1 severity", ParseProblemSeverity.ERROR, problems[0].getSeverity());
- assertEquals("Problem 1 id", Problem.UnterminatedXMLTag, problems[0].getId());
+ assertEquals("Problem 1 severity", ProblemSeverity.ERROR, problems[0].getProblemSeverity());
+ assertEquals("Problem 1 id", IProblem.UnterminatedXMLTag, problems[0].getId());
}
@@ -338,8 +348,8 @@ public class TestJET2Parser extends TestCase {
// This assertions correspond to comments in bug147714.jet
assertEquals("Problem 1 line number", 1, problems[0].getLineNumber());
- assertEquals("Problem 1 severity", ParseProblemSeverity.ERROR, problems[0].getSeverity());
- assertEquals("Problem 1 id", Problem.JETException, problems[0].getId());
+ assertEquals("Problem 1 severity", ProblemSeverity.ERROR, problems[0].getProblemSeverity());
+ assertEquals("Problem 1 id", IProblem.JETException, problems[0].getId());
}
@@ -358,8 +368,8 @@ public class TestJET2Parser extends TestCase {
// This assertions correspond to comments in bug147714.jet
assertEquals("Problem 1 line number", 3, problems[0].getLineNumber());
- assertEquals("Problem 1 severity", ParseProblemSeverity.ERROR, problems[0].getSeverity());
- assertEquals("Problem 1 id", Problem.JETException, problems[0].getId());
+ assertEquals("Problem 1 severity", ProblemSeverity.ERROR, problems[0].getProblemSeverity());
+ assertEquals("Problem 1 id", IProblem.JETException, problems[0].getId());
}
@@ -378,8 +388,8 @@ public class TestJET2Parser extends TestCase {
// This assertions correspond to comments in bug147714.jet
assertEquals("Problem 1 line number", 3, problems[0].getLineNumber());
- assertEquals("Problem 1 severity", ParseProblemSeverity.ERROR, problems[0].getSeverity());
- assertEquals("Problem 1 id", Problem.JETException, problems[0].getId());
+ assertEquals("Problem 1 severity", ProblemSeverity.ERROR, problems[0].getProblemSeverity());
+ assertEquals("Problem 1 id", IProblem.JETException, problems[0].getId());
}
@@ -398,8 +408,8 @@ public class TestJET2Parser extends TestCase {
// This assertions correspond to comments in bug147714.jet
assertEquals("Problem 1 line number", 3, problems[0].getLineNumber());
- assertEquals("Problem 1 severity", ParseProblemSeverity.ERROR, problems[0].getSeverity());
- assertEquals("Problem 1 id", Problem.UnterminatedXMLTag, problems[0].getId());
+ assertEquals("Problem 1 severity", ProblemSeverity.ERROR, problems[0].getProblemSeverity());
+ assertEquals("Problem 1 id", IProblem.UnterminatedXMLTag, problems[0].getId());
}
@@ -418,8 +428,8 @@ public class TestJET2Parser extends TestCase {
// This assertions correspond to comments in bug147714.jet
assertEquals("Problem 1 line number", 3, problems[0].getLineNumber());
- assertEquals("Problem 1 severity", ParseProblemSeverity.ERROR, problems[0].getSeverity());
- assertEquals("Problem 1 id", Problem.UnterminatedXMLTag, problems[0].getId());
+ assertEquals("Problem 1 severity", ProblemSeverity.ERROR, problems[0].getProblemSeverity());
+ assertEquals("Problem 1 id", IProblem.UnterminatedXMLTag, problems[0].getId());
}
@@ -459,8 +469,8 @@ public class TestJET2Parser extends TestCase {
assertTrue("At least one problem", problems.length > 0);
- assertEquals("Problem 1 severity", ParseProblemSeverity.ERROR, problems[0].getSeverity());
- assertEquals("Problem 1 id", Problem.JETException, problems[0].getId());
+ assertEquals("Problem 1 severity", ProblemSeverity.ERROR, problems[0].getProblemSeverity());
+ assertEquals("Problem 1 id", IProblem.JETException, problems[0].getId());
assertEquals("Problem 1 line number", 4, problems[0].getLineNumber());
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJETParser.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJETParser.java
index 3ddd6e6..a680374 100644
--- a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJETParser.java
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJETParser.java
@@ -12,17 +12,18 @@ import java.util.Map;
import junit.framework.TestCase;
-import org.eclipse.emf.codegen.jet.JETException;
-import org.eclipse.jet.compiler.Problem;
-import org.eclipse.jet.internal.compiler.CommentElementDelegate;
-import org.eclipse.jet.internal.compiler.DeclarationElementDelegate;
-import org.eclipse.jet.internal.compiler.XMLElementDelegate;
-import org.eclipse.jet.internal.parser.JETCoreElement;
-import org.eclipse.jet.internal.parser.JETMark;
-import org.eclipse.jet.internal.parser.JETParseEventListener2;
-import org.eclipse.jet.internal.parser.JETParser;
-import org.eclipse.jet.internal.parser.JETReader;
-import org.eclipse.jet.internal.parser.ParseProblemSeverity;
+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.FileUtils;
public class TestJETParser extends TestCase {
@@ -30,7 +31,7 @@ public class TestJETParser extends TestCase {
private static class SavedProblem {
- private final ParseProblemSeverity severity;
+ private final ProblemSeverity severity;
private final int problemId;
private final String message;
private final Object[] msgArgs;
@@ -38,7 +39,7 @@ public class TestJETParser extends TestCase {
private final int end;
private final int line;
- public SavedProblem(ParseProblemSeverity severity, int problemId, String message, Object[] msgArgs, int start, int end, 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;
@@ -86,7 +87,7 @@ public class TestJETParser extends TestCase {
/**
* @return Returns the severity.
*/
- public final ParseProblemSeverity getSeverity() {
+ public final ProblemSeverity getSeverity() {
return severity;
}
@@ -125,12 +126,12 @@ public class TestJETParser extends TestCase {
}
public void endPageProcessing() throws JETException {
- doIndent();
- buffer.append("</jet2>").append(NL);
+// doIndent();
+// buffer.append("</jet2>").append(NL);
}
public String getLog() {
- return buffer.toString();
+ return NewLineUtil.setLineTerminator(buffer, NL);
}
public void handleCharData(char[] chars) throws JETException {
@@ -235,7 +236,7 @@ public class TestJETParser extends TestCase {
return problems;
}
- public void recordProblem(ParseProblemSeverity severity, int problemId, String message, Object[] msgArgs, int start, int end, int line, int colOffset) {
+ 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));
}
@@ -275,7 +276,7 @@ public class TestJETParser extends TestCase {
final List problems = listener.getProblems();
assertEquals(1, problems.size());
SavedProblem problem = (SavedProblem) problems.get(0);
- assertEquals(ParseProblemSeverity.ERROR, problem.getSeverity());
+ assertEquals(ProblemSeverity.ERROR, problem.getSeverity());
assertEquals(expectedProblemId, problem.getProblemId());
}
@@ -290,7 +291,7 @@ public class TestJETParser extends TestCase {
String urlString = "platform:/plugin/org.eclipse.jet.tests/data/unclosedComment.jet";
String openChars = "<%--";
- doUnclosedElementTest(urlString, openChars, Problem.UnterminatedXMLTag);
+ doUnclosedElementTest(urlString, openChars, IProblem.UnterminatedXMLTag);
}
@@ -299,7 +300,7 @@ public class TestJETParser extends TestCase {
String urlString = "platform:/plugin/org.eclipse.jet.tests/data/unclosedDeclaration.jet";
String openChars = "<%!";
- doUnclosedElementTest(urlString, openChars, Problem.UnterminatedXMLTag);
+ doUnclosedElementTest(urlString, openChars, IProblem.UnterminatedXMLTag);
}
public void testUnclosedDirective() throws Exception {
@@ -342,21 +343,21 @@ public class TestJETParser extends TestCase {
String urlString = "platform:/plugin/org.eclipse.jet.tests/data/unclosedXMLStart.jet";
String openChars = "<";
- doUnclosedElementTest(urlString, openChars, Problem.UnterminatedXMLTag);
+ doUnclosedElementTest(urlString, openChars, IProblem.UnterminatedXMLTag);
}
public void testUnclosedXMLEnd() throws Exception {
String urlString = "platform:/plugin/org.eclipse.jet.tests/data/unclosedXMLEnd.jet";
String openChars = "</";
- doUnclosedElementTest(urlString, openChars, Problem.UnterminatedXMLTag);
+ doUnclosedElementTest(urlString, openChars, IProblem.UnterminatedXMLTag);
}
public void testXMLEndWithAttributes() throws Exception {
String urlString = "platform:/plugin/org.eclipse.jet.tests/data/xmlEndWithAttributes.jet";
String openChars = "</";
- doUnclosedElementTest(urlString, openChars, Problem.UnterminatedXMLTag);
+ doUnclosedElementTest(urlString, openChars, IProblem.UnterminatedXMLTag);
}
// this error is not detected by the parser, but by post parse processing.
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestSimplifiedCompiler.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestSimplifiedCompiler.java
new file mode 100644
index 0000000..dca5dec
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestSimplifiedCompiler.java
@@ -0,0 +1,428 @@
+/**
+ *
+ */
+package org.eclipse.jet.tests.compiler;
+
+import java.io.Serializable;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jet.core.compiler.JETCompilerOptions;
+import org.eclipse.jet.core.parser.ITagLibraryResolver;
+import org.eclipse.jet.core.parser.ast.JETAST;
+import org.eclipse.jet.internal.compiler.SimplifiedCompiler;
+import org.eclipse.jet.internal.core.compiler.ICompilerOutput;
+import org.eclipse.jet.internal.core.compiler.IJETCompiler;
+import org.eclipse.jet.internal.core.compiler.IJETCompiler.CompileResult;
+import org.eclipse.jet.taglib.TagLibrary;
+import org.eclipse.jet.taglib.TagLibraryManager;
+import org.eclipse.jet.tests.FileUtils;
+
+/**
+ * Test {@link SimplifiedCompiler}
+ *
+ */
+public class TestSimplifiedCompiler extends TestCase {
+
+ private URI baseLocation;
+ private URI changedBaseLocation;
+ private CompilerOutput compilerOutput;
+
+ private static final class CompilerOutput implements ICompilerOutput {
+
+ private String code;
+ private String encoding;
+ private String outputFilePath;
+ private String removeOutputFilePath;
+
+ public String getCode() {
+ return code;
+ }
+
+ public String getEncoding() {
+ return encoding;
+ }
+
+ public void removeOutput(String outputFilePath) {
+ removeOutputFilePath = outputFilePath;
+ }
+
+ public void writeOutput(String outputFilePath, String contents, String encoding) {
+ this.outputFilePath = outputFilePath;
+ this.code = contents;
+ this.encoding = encoding;
+
+ }
+
+ public String getOutputFilePath() {
+ return outputFilePath;
+ }
+
+ public String getRemoveOutputFilePath() {
+ return removeOutputFilePath;
+ }
+
+ public void recordProblems(String templatePath, List problems) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void preCompile(String templatePath) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ private static final class TagLibraryResolver implements ITagLibraryResolver {
+
+ public TagLibrary getLibrary(String tagLibraryID) {
+ return TagLibraryManager.getInstance().getTagLibrary(tagLibraryID);
+ }
+
+ }
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ baseLocation = new URI("platform:/plugin/org.eclipse.jet.tests/data/simplifiedCompiler/templates/");
+ changedBaseLocation = new URI("platform:/plugin/org.eclipse.jet.tests/data/simplifiedCompiler/changedTemplates/");
+ compilerOutput = new CompilerOutput();
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.internal.compiler.SimplifiedCompiler#compile(java.lang.String)}.
+ * @throws Exception
+ */
+ public void testCompile() throws Exception {
+ IJETCompiler compiler = new SimplifiedCompiler.Builder(JETAST.JET_SPEC_V2, baseLocation, compilerOutput)
+ .tagLibraryResolver(new TagLibraryResolver())
+ .build();
+
+ final String templatePath = "simple.v2.input.jet";
+ final CompileResult result = compiler.compile(templatePath);
+
+ assertEquals(CompileResult.OK, result);
+
+ final String expectedJavaCode = FileUtils.getFileContents(baseLocation.resolve(templatePath + ".expected.java").toString(), true);
+
+ assertEquals(expectedJavaCode, compilerOutput.getCode());
+ assertEquals("UTF-8", compilerOutput.getEncoding());
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.internal.compiler.SimplifiedCompiler#compile(java.lang.String)} in the
+ * case where a template path with unknown extension is passed.
+ */
+ public void testCompile_unknownExtension() {
+ // default compiler knows only the JET extension
+ IJETCompiler compiler = new SimplifiedCompiler.Builder(JETAST.JET_SPEC_V2, baseLocation, compilerOutput)
+ .build();
+
+ final String templatePath = "template.with.unknown.extension";
+
+ final CompileResult result = compiler.compile(templatePath);
+
+ assertEquals(CompileResult.IGNORED, result);
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.internal.compiler.SimplifiedCompiler#compile(java.lang.String)} in the
+ * case where tag libraries are predefined.
+ * @throws Exception
+ */
+ public void testCompile_predefinedTagLibraries() throws Exception {
+ Map predefinedTagLibraries = new HashMap();
+ predefinedTagLibraries.put("c", "org.eclipse.jet.controlTags");
+ predefinedTagLibraries.put("f", "org.eclipse.jet.formatTags");
+ // test a number of extensions, including those with leading/trailing blanks
+ IJETCompiler compiler = new SimplifiedCompiler.Builder(JETAST.JET_SPEC_V2, baseLocation, compilerOutput)
+ .predefinedTagLibraries(predefinedTagLibraries)
+ .tagLibraryResolver(new TagLibraryResolver())
+ .build();
+
+ final String templatePath = "simple.v2.usePredefTagLibs.jet";
+ final CompileResult result = compiler.compile(templatePath);
+
+ assertEquals(CompileResult.OK, result);
+
+ final String expectedJavaCode = FileUtils.getFileContents(baseLocation.resolve(templatePath + ".predefs.expected.java").toString(), true);
+
+ assertEquals(expectedJavaCode, compilerOutput.getCode());
+ assertEquals("UTF-8", compilerOutput.getEncoding());
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.internal.compiler.SimplifiedCompiler#compile(java.lang.String)} in the
+ * case where no tag libraries are predefined.
+ * @throws Exception
+ */
+ public void testCompile_noPredefinedTagLibraries() throws Exception {
+ IJETCompiler compiler = new SimplifiedCompiler.Builder(JETAST.JET_SPEC_V2, baseLocation, compilerOutput)
+ .build();
+
+ final String templatePath = "simple.v2.usePredefTagLibs.jet";
+ final CompileResult result = compiler.compile(templatePath);
+
+ assertEquals(CompileResult.OK, result);
+
+ final String expectedJavaCode = FileUtils.getFileContents(baseLocation.resolve(templatePath + ".nopredefs.expected.java").toString(), true);
+
+ assertEquals(expectedJavaCode, compilerOutput.getCode());
+ assertEquals("UTF-8", compilerOutput.getEncoding());
+
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.internal.compiler.SimplifiedCompiler#compile(java.lang.String)} in the
+ * case more than one template extension is defined
+ */
+ public void testCompile_multipleExtensions() {
+ Map options = new HashMap(JETCompilerOptions.getDefaultCompilerOptions());
+ // test a number of extensions, including those with leading/trailing blanks
+ options.put(JETCompilerOptions.OPTION_TEMPLATE_EXT, "pat, pat2 ,pat3,pat4");
+ // default compiler knows only the JET extension
+ IJETCompiler compiler = new SimplifiedCompiler.Builder(JETAST.JET_SPEC_V2, baseLocation, compilerOutput)
+ .options(options)
+ .build();
+
+ Object cu;
+ cu = compiler.compile("simple.v2.pat");
+ assertNotNull("simple.v2.pat", cu);
+ compiler.compile("simple.v2.pat2");
+ assertNotNull("simple.v2.pat2", cu);
+ compiler.compile("simple.v2.pat3");
+ assertNotNull("simple.v2.pat3", cu);
+ compiler.compile("simple.v2.pat4");
+ assertNotNull("simple.v2.pat4", cu);
+
+ }
+ /**
+ * Test method for {@link org.eclipse.jet.internal.compiler.SimplifiedCompiler#finish()}.
+ * @throws Exception
+ */
+ public void testFinish() throws Exception {
+ IJETCompiler compiler = new SimplifiedCompiler.Builder(JETAST.JET_SPEC_V2, baseLocation, compilerOutput)
+ .templateLoaderFQN("org.eclipse.jet.compiled.TemplateLoaderClass")
+ .build();
+
+ final String templatePath1 = "simple.v2.input.jet";
+ compiler.compile(templatePath1);
+ final String templatePath2 = "simple.v2.input2.jet";
+ compiler.compile(templatePath2);
+
+ compiler.finish();
+ assertEquals("org/eclipse/jet/compiled/TemplateLoaderClass.java", compilerOutput.getOutputFilePath());
+ final String expectedJavaCode = FileUtils.getFileContents(baseLocation.resolve("simple.v2.loader.expected.java").toString(), true);
+ assertEquals("code", expectedJavaCode, compilerOutput.getCode());
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.internal.compiler.SimplifiedCompiler#compile(java.lang.String)} in the
+ * case where an output class is changed in successive compiles of a template
+ */
+ public void testCompile_withOuputClassNameChange() {
+ IJETCompiler compiler = new SimplifiedCompiler.Builder(
+ JETAST.JET_SPEC_V2, baseLocation, compilerOutput)
+ .build();
+
+ final String templatePath = "simple.v2.input.jet";
+ compiler.compile(templatePath);
+
+ final String outputFilePath = compilerOutput.getOutputFilePath();
+
+ assertNull(compilerOutput.getRemoveOutputFilePath());
+
+ Serializable memento = compiler.getMemento();
+
+ compiler = new SimplifiedCompiler.Builder(
+ JETAST.JET_SPEC_V2, changedBaseLocation, compilerOutput)
+ .savedState(memento)
+ .build();
+ compiler.compile(templatePath);
+
+ assertEquals(outputFilePath, compilerOutput.getRemoveOutputFilePath());
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.internal.compiler.SimplifiedCompiler#clean()}
+ */
+ public void testClean() {
+ IJETCompiler compiler = new SimplifiedCompiler.Builder(JETAST.JET_SPEC_V2, baseLocation, compilerOutput)
+ .templateLoaderFQN("org.eclipse.jet.compiled.TemplateLoaderClass")
+ .build();
+
+ final String templatePath1 = "simple.v2.input.jet";
+ compiler.compile(templatePath1);
+ final String templatePath2 = "simple.v2.input2.jet";
+ compiler.compile(templatePath2);
+
+ compiler.finish();
+
+ Serializable memento = compiler.getMemento();
+
+ final Set removedFiles = new HashSet();
+ IJETCompiler compiler2 = new SimplifiedCompiler.Builder(JETAST.JET_SPEC_V2, baseLocation,
+ new ICompilerOutput() {
+
+ public void removeOutput(String outputFilePath) {
+ removedFiles.add(outputFilePath);
+ }
+
+ public void writeOutput(String outputFilePath, String contents, String encoding) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void recordProblems(String templatePath, List problems) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void preCompile(String templatePath) {
+ // TODO Auto-generated method stub
+
+ }})
+ .templateLoaderFQN("org.eclipse.jet.compiled.TemplateLoaderClass")
+ .savedState(memento)
+ .build();
+
+ compiler2.clean();
+
+ String expectedOutputPaths[] = new String[] {
+ "org/eclipse/jet/compiled/_jet_simplev2input.java",
+ "org/eclipse/jet/compiled/_jet_simplev2input2.java",
+ "org/eclipse/jet/compiled/TemplateLoaderClass.java",
+ };
+
+ assertEquals(expectedOutputPaths.length, removedFiles.size());
+ for (int i = 0; i < expectedOutputPaths.length; i++) {
+ assertTrue("removedFiles contains " + expectedOutputPaths[i], removedFiles.contains(expectedOutputPaths[i]));
+ }
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.internal.compiler.SimplifiedCompiler#remove()}
+ */
+ public void testRemove() {
+ // this is essentially the testCompiler_withOutputNameChange test, but
+ // we run remove instead of the second compile
+ IJETCompiler compiler = new SimplifiedCompiler.Builder(
+ JETAST.JET_SPEC_V2, baseLocation, compilerOutput)
+ .build();
+
+ final String templatePath = "simple.v2.input.jet";
+ compiler.compile(templatePath);
+
+ final String outputFilePath = compilerOutput.getOutputFilePath();
+
+ assertNull(compilerOutput.getRemoveOutputFilePath());
+
+ Serializable memento = compiler.getMemento();
+
+ compiler = new SimplifiedCompiler.Builder(
+ JETAST.JET_SPEC_V2, baseLocation, compilerOutput)
+ .savedState(memento)
+ .build();
+ compiler.removeTemplate(templatePath);
+
+ assertEquals(outputFilePath, compilerOutput.getRemoveOutputFilePath());
+
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.internal.compiler.SimplifiedCompiler#getTagLibaryDependencies()}
+ */
+ public void testGetTagLibaryDependencies_none() {
+ IJETCompiler compiler = new SimplifiedCompiler.Builder(JETAST.JET_SPEC_V2, baseLocation, compilerOutput)
+ .build();
+
+ final String templatePath = "simple.v2.usePredefTagLibs.jet";
+ final CompileResult result = compiler.compile(templatePath);
+
+ assertEquals(CompileResult.OK, result);
+
+ final String[] dependencies = compiler.getTagLibaryDependencies();
+ assertEquals(0, dependencies.length);
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.internal.compiler.SimplifiedCompiler#getTagLibaryDependencies()}
+ */
+ public void testGetTagLibaryDependencies_one() {
+ IJETCompiler compiler = new SimplifiedCompiler.Builder(JETAST.JET_SPEC_V2, baseLocation, compilerOutput)
+ .build();
+
+ final String templatePath = "simple.v2.input.jet";
+ final CompileResult result = compiler.compile(templatePath);
+
+ assertEquals(CompileResult.OK, result);
+
+ final String[] dependencies = compiler.getTagLibaryDependencies();
+ assertEquals(1, dependencies.length);
+ assertEquals("org.eclipse.jet.tests.TestLibrary", dependencies[0]);
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.internal.compiler.SimplifiedCompiler#getTagLibaryDependencies()}
+ */
+ public void testGetTagLibaryDependencies_many() {
+ Map predefinedTagLibraries = new HashMap();
+ predefinedTagLibraries.put("c", "org.eclipse.jet.controlTags");
+ predefinedTagLibraries.put("f", "org.eclipse.jet.formatTags");
+ // test a number of extensions, including those with leading/trailing blanks
+ IJETCompiler compiler = new SimplifiedCompiler.Builder(JETAST.JET_SPEC_V2, baseLocation, compilerOutput)
+ .predefinedTagLibraries(predefinedTagLibraries)
+ .build();
+
+ final String templatePath = "simple.v2.input.jet";
+ final CompileResult result = compiler.compile(templatePath);
+ assertEquals(CompileResult.OK, result);
+
+ final String[] dependencies = compiler.getTagLibaryDependencies();
+ final Set depSet = new HashSet(Arrays.asList(dependencies));
+ assertEquals(3, depSet.size());
+ assertTrue("org.eclipse.jet.controlTags", depSet.contains("org.eclipse.jet.controlTags"));
+ assertTrue("org.eclipse.jet.formatTags", depSet.contains("org.eclipse.jet.formatTags"));
+ assertTrue("org.eclipse.jet.tests.TestLibrary", depSet.contains("org.eclipse.jet.tests.TestLibrary"));
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.internal.compiler.SimplifiedCompiler#getTagLibaryDependencies()}
+ */
+ public void testGetTagLibaryDependencies_afterStateSave() {
+ Map predefinedTagLibraries = new HashMap();
+ predefinedTagLibraries.put("c", "org.eclipse.jet.controlTags");
+ predefinedTagLibraries.put("f", "org.eclipse.jet.formatTags");
+ // test a number of extensions, including those with leading/trailing blanks
+ IJETCompiler compiler = new SimplifiedCompiler.Builder(JETAST.JET_SPEC_V2, baseLocation, compilerOutput)
+ .predefinedTagLibraries(predefinedTagLibraries)
+ .build();
+
+ final String templatePath = "simple.v2.input.jet";
+ final CompileResult result = compiler.compile(templatePath);
+ assertEquals(CompileResult.OK, result);
+
+ final Serializable memento = compiler.getMemento();
+
+ IJETCompiler compiler2 = new SimplifiedCompiler.Builder(JETAST.JET_SPEC_V2, baseLocation, compilerOutput)
+ .predefinedTagLibraries(predefinedTagLibraries)
+ .savedState(memento)
+ .build();
+
+
+ final String[] dependencies = compiler2.getTagLibaryDependencies();
+ final Set depSet = new HashSet(Arrays.asList(dependencies));
+ assertEquals(3, depSet.size());
+ assertTrue("org.eclipse.jet.controlTags", depSet.contains("org.eclipse.jet.controlTags"));
+ assertTrue("org.eclipse.jet.formatTags", depSet.contains("org.eclipse.jet.formatTags"));
+ assertTrue("org.eclipse.jet.tests.TestLibrary", depSet.contains("org.eclipse.jet.tests.TestLibrary"));
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TextTrimmingTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TextTrimmingTests.java
index 361ab43..f6e6b44 100644
--- a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TextTrimmingTests.java
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TextTrimmingTests.java
@@ -1,34 +1,33 @@
package org.eclipse.jet.tests.compiler;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.MalformedURLException;
+import java.net.URI;
import junit.extensions.TestSetup;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-import org.eclipse.jet.compiler.DefaultJET2ASTVisitor;
-import org.eclipse.jet.compiler.JET2CompilationUnit;
-import org.eclipse.jet.compiler.TextElement;
-import org.eclipse.jet.internal.compiler.TextTrimmingVisitor;
+import org.eclipse.jet.core.parser.DefaultTemplateResolver;
+import org.eclipse.jet.core.parser.ITagLibraryResolver;
+import org.eclipse.jet.core.parser.ast.JETAST;
+import org.eclipse.jet.core.parser.ast.JETASTParser;
+import org.eclipse.jet.core.parser.ast.JETASTVisitor;
+import org.eclipse.jet.core.parser.ast.JETCompilationUnit;
+import org.eclipse.jet.core.parser.ast.TextElement;
import org.eclipse.jet.internal.parser.LineInfo;
-import org.eclipse.jet.tests.FileUtils;
+import org.eclipse.jet.taglib.TagLibrary;
+import org.eclipse.jet.taglib.TagLibraryManager;
public class TextTrimmingTests extends TestCase {
- private static JET2CompilationUnit unstrippedCu;
- private static JET2CompilationUnit strippedCu;
+ private final static class TagLibraryResolver implements ITagLibraryResolver {
- private static FileInputStream getFileContentsAsStream(String urlString) throws IOException, MalformedURLException, FileNotFoundException {
- String fileName = FileUtils.resolveURLToLocationString(urlString);
- FileInputStream inputStream = new FileInputStream(new File(fileName));
- return inputStream;
- }
-
+ public TagLibrary getLibrary(String tagLibraryID) {
+ return TagLibraryManager.getInstance().getTagLibrary(tagLibraryID);
+ }
+
+ }
+ private static JETCompilationUnit cu;
/**
* Wrap this suite in a TestSetup so that we can do one-time setup
* @return a wrapped TestSetup wrapped suite.
@@ -48,17 +47,16 @@ public class TextTrimmingTests extends TestCase {
}
private static void setUpAllTests() throws Exception {
- FileInputStream stream = getFileContentsAsStream("platform:/plugin/org.eclipse.jet.tests/data/textTrimmingTests.jet");
-
- unstrippedCu = new JET2CompilationUnit();
- unstrippedCu.parse(stream, "UTF-8");
-
- stream = getFileContentsAsStream("platform:/plugin/org.eclipse.jet.tests/data/textTrimmingTests.jet");
- strippedCu = new JET2CompilationUnit();
- strippedCu.parse(stream, "UTF-8");
- strippedCu.accept(new TextTrimmingVisitor());
-
- assertFalse("Errors in test template", unstrippedCu.hasErrors());
+ final URI baseLocation = new URI("platform:/plugin/org.eclipse.jet.tests/data/");
+ final String templatePath = "textTrimmingTests.jet";
+
+ cu = (JETCompilationUnit) new JETASTParser.Builder(JETAST.JET_SPEC_V2)
+ .templateResolver(new DefaultTemplateResolver.Builder(baseLocation).build())
+ .tagLibraryResolver(new TagLibraryResolver())
+ .build()
+ .parse(templatePath);
+
+ assertFalse("Errors in test template", cu.hasErrors());
}
@@ -67,8 +65,8 @@ public class TextTrimmingTests extends TestCase {
}
- private String[] getLines(TextElement text) {
- char[] chars = text.getText();
+ private String[] getLines(TextElement text, boolean strip) {
+ char[] chars = strip ? text.getText() : text.getRawText();
LineInfo[] lineInfos = LineInfo.calculateLines(chars);
String[] lines = new String[lineInfos.length];
for (int i = 0; i < lineInfos.length; i++) {
@@ -77,16 +75,16 @@ public class TextTrimmingTests extends TestCase {
return lines;
}
- private String[] getTextLinesInRange(JET2CompilationUnit cu, final String testMarker) {
+ private String[] getTextLinesInRange(JETCompilationUnit cu, final String testMarker, final boolean strip) {
final StringBuffer linesBuffer = new StringBuffer();
- cu.accept(new DefaultJET2ASTVisitor() {
+ cu.accept(new JETASTVisitor() {
private boolean rangeStarted = false;
private boolean rangeEnded = false;
- public void visit(TextElement text) {
- if(rangeEnded) return;
+ public boolean visit(TextElement text) {
+ if(rangeEnded) return true;
- String lines[] = getLines(text);
+ String lines[] = getLines(text, strip);
int i = 0;
for (; i < lines.length && !rangeStarted; i++) {
if(lines[i].startsWith(testMarker)) {
@@ -101,6 +99,7 @@ public class TextTrimmingTests extends TestCase {
rangeEnded = true;
}
}
+ return true;
}
});
final LineInfo[] lineInfos = LineInfo.calculateLines(linesBuffer.toString().toCharArray());
@@ -113,8 +112,8 @@ public class TextTrimmingTests extends TestCase {
public void testStartEndTagStripping() {
final String TEST_CASE = "test 001";
- String[] unstrippedText = getTextLinesInRange(unstrippedCu, TEST_CASE);
- String[] strippedText = getTextLinesInRange(strippedCu, TEST_CASE);
+ String[] unstrippedText = getTextLinesInRange(cu, TEST_CASE, false);
+ String[] strippedText = getTextLinesInRange(cu, TEST_CASE, true);
assertEquals(5, unstrippedText.length);
@@ -123,8 +122,8 @@ public class TextTrimmingTests extends TestCase {
public void testStartEndTagStripping2() {
final String TEST_CASE = "test 002";
- String[] unstrippedText = getTextLinesInRange(unstrippedCu, TEST_CASE);
- String[] strippedText = getTextLinesInRange(strippedCu, TEST_CASE);
+ String[] unstrippedText = getTextLinesInRange(cu, TEST_CASE, false);
+ String[] strippedText = getTextLinesInRange(cu, TEST_CASE, true);
assertEquals(5, unstrippedText.length);
@@ -134,8 +133,8 @@ public class TextTrimmingTests extends TestCase {
public void testStartEndTagStripping3() {
final String TEST_CASE = "test 003";
- String[] unstrippedText = getTextLinesInRange(unstrippedCu, TEST_CASE);
- String[] strippedText = getTextLinesInRange(strippedCu, TEST_CASE);
+ String[] unstrippedText = getTextLinesInRange(cu, TEST_CASE, false);
+ String[] strippedText = getTextLinesInRange(cu, TEST_CASE, true);
assertEquals(5, unstrippedText.length);
@@ -145,8 +144,8 @@ public class TextTrimmingTests extends TestCase {
public void testDirectiveStripping() {
final String TEST_CASE = "test 004";
- String[] unstrippedText = getTextLinesInRange(unstrippedCu, TEST_CASE);
- String[] strippedText = getTextLinesInRange(strippedCu, TEST_CASE);
+ String[] unstrippedText = getTextLinesInRange(cu, TEST_CASE, false);
+ String[] strippedText = getTextLinesInRange(cu, TEST_CASE, true);
assertEquals(3, unstrippedText.length);
@@ -156,8 +155,8 @@ public class TextTrimmingTests extends TestCase {
public void testScriptletStripping() {
final String TEST_CASE = "test 005";
- String[] unstrippedText = getTextLinesInRange(unstrippedCu, TEST_CASE);
- String[] strippedText = getTextLinesInRange(strippedCu, TEST_CASE);
+ String[] unstrippedText = getTextLinesInRange(cu, TEST_CASE, false);
+ String[] strippedText = getTextLinesInRange(cu, TEST_CASE, true);
assertEquals(3, unstrippedText.length);
@@ -167,8 +166,8 @@ public class TextTrimmingTests extends TestCase {
public void testDeclarationStripping() {
final String TEST_CASE = "test 006";
- String[] unstrippedText = getTextLinesInRange(unstrippedCu, TEST_CASE);
- String[] strippedText = getTextLinesInRange(strippedCu, TEST_CASE);
+ String[] unstrippedText = getTextLinesInRange(cu, TEST_CASE, false);
+ String[] strippedText = getTextLinesInRange(cu, TEST_CASE, true);
assertEquals(3, unstrippedText.length);
@@ -178,8 +177,8 @@ public class TextTrimmingTests extends TestCase {
public void testEmptyTagStripping_supportsRemove() {
final String TEST_CASE = "test 007";
- String[] unstrippedText = getTextLinesInRange(unstrippedCu, TEST_CASE);
- String[] strippedText = getTextLinesInRange(strippedCu, TEST_CASE);
+ String[] unstrippedText = getTextLinesInRange(cu, TEST_CASE, false);
+ String[] strippedText = getTextLinesInRange(cu, TEST_CASE, true);
assertEquals(3, unstrippedText.length);
@@ -190,8 +189,8 @@ public class TextTrimmingTests extends TestCase {
public void testEmptyTagStripping_noRemove() {
final String TEST_CASE = "test 008";
- String[] unstrippedText = getTextLinesInRange(unstrippedCu, TEST_CASE);
- String[] strippedText = getTextLinesInRange(strippedCu, TEST_CASE);
+ String[] unstrippedText = getTextLinesInRange(cu, TEST_CASE, false);
+ String[] strippedText = getTextLinesInRange(cu, TEST_CASE, true);
assertEquals(3, unstrippedText.length);
@@ -201,8 +200,8 @@ public class TextTrimmingTests extends TestCase {
public void testCommentStripping() {
final String TEST_CASE = "test 009";
- String[] unstrippedText = getTextLinesInRange(unstrippedCu, TEST_CASE);
- String[] strippedText = getTextLinesInRange(strippedCu, TEST_CASE);
+ String[] unstrippedText = getTextLinesInRange(cu, TEST_CASE, false);
+ String[] strippedText = getTextLinesInRange(cu, TEST_CASE, true);
assertEquals(3, unstrippedText.length);
@@ -212,8 +211,8 @@ public class TextTrimmingTests extends TestCase {
public void testExpressionStripping() {
final String TEST_CASE = "test 010";
- String[] unstrippedText = getTextLinesInRange(unstrippedCu, TEST_CASE);
- String[] strippedText = getTextLinesInRange(strippedCu, TEST_CASE);
+ String[] unstrippedText = getTextLinesInRange(cu, TEST_CASE, false);
+ String[] strippedText = getTextLinesInRange(cu, TEST_CASE, true);
assertEquals(3, unstrippedText.length);
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/control/LoadTagTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/control/LoadTagTests.java
index b38c31e..fe941f8 100644
--- a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/control/LoadTagTests.java
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/control/LoadTagTests.java
@@ -4,9 +4,9 @@ import junit.framework.TestCase;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jet.BodyContentWriter;
+import org.eclipse.jet.BufferedJET2Writer;
import org.eclipse.jet.JET2Context;
import org.eclipse.jet.JET2Platform;
-import org.eclipse.jet.JET2Writer;
import org.eclipse.jet.XPathContextExtender;
import org.eclipse.jet.internal.taglib.control.LoadTag;
import org.eclipse.jet.taglib.JET2TagException;
@@ -36,11 +36,11 @@ public class LoadTagTests extends TestCase {
tag.setContext(context);
tag.setParent(null);
- JET2Writer out = new BodyContentWriter();
+ BufferedJET2Writer out = new BodyContentWriter();
tag.doAction(td, context, out);
- assertEquals("", out.getDocument().get());
+ assertEquals("", out.getContent());
final Object loadedDocument = XPathContextExtender.getInstance(context).resolveVariable("root");
assertNotNull("loaded document", loadedDocument);
}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/format/FormatNowTagTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/format/FormatNowTagTests.java
index fb58193..1bee89d 100644
--- a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/format/FormatNowTagTests.java
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/format/FormatNowTagTests.java
@@ -5,15 +5,15 @@ import java.util.Calendar;
import junit.framework.TestCase;
import org.eclipse.jet.BodyContentWriter;
+import org.eclipse.jet.BufferedJET2Writer;
import org.eclipse.jet.JET2Context;
-import org.eclipse.jet.JET2Writer;
import org.eclipse.jet.internal.taglib.format.FormatNowTag;
import org.eclipse.jet.taglib.JET2TagException;
import org.eclipse.jet.taglib.TagInfo;
public class FormatNowTagTests extends TestCase {
- private JET2Writer out;
+ private BufferedJET2Writer out;
private FormatNowTag tag;
private TagInfo tagInfo;
private JET2Context context;
@@ -47,7 +47,7 @@ public class FormatNowTagTests extends TestCase {
final Calendar now = Calendar.getInstance();
tag.doAction(tagInfo, context, out);
- String formatted = out.getDocument().get();
+ String formatted = out.getContent();
final String[] parts = formatted.split("\\.");
assertNotNull(parts);
assertEquals(5, parts.length);
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/format/UuidTagTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/format/UuidTagTests.java
index 3426081..5c6b7de 100644
--- a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/format/UuidTagTests.java
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/format/UuidTagTests.java
@@ -3,15 +3,15 @@ package org.eclipse.jet.tests.taglib.format;
import junit.framework.TestCase;
import org.eclipse.jet.BodyContentWriter;
+import org.eclipse.jet.BufferedJET2Writer;
import org.eclipse.jet.JET2Context;
-import org.eclipse.jet.JET2Writer;
import org.eclipse.jet.internal.taglib.format.UuidTag;
import org.eclipse.jet.taglib.JET2TagException;
import org.eclipse.jet.taglib.TagInfo;
public class UuidTagTests extends TestCase {
- private JET2Writer out;
+ private BufferedJET2Writer out;
private UuidTag tag;
private TagInfo tagInfo;
private JET2Context context;
@@ -38,14 +38,14 @@ public class UuidTagTests extends TestCase {
public void testDoAction() throws JET2TagException {
tag.doAction(tagInfo, context, out);
- String uuid1 = out.getDocument().get();
+ String uuid1 = out.getContent();
assertNotNull(uuid1);
assertEquals(23, uuid1.length()); // all UUIDs returned by this tag are 23 chars
- out.getDocument().set("");
+ out.setContent("");
tag.doAction(tagInfo, context, out);
- String uuid2 = out.getDocument().get();
+ String uuid2 = out.getContent();
assertNotNull(uuid2);
assertEquals(23, uuid2.length()); // all UUIDs returned by this tag are 23 chars
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/java/TestImportsLocationTag.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/java/TestImportsLocationTag.java
index 4730a7b..88dd382 100644
--- a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/java/TestImportsLocationTag.java
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/java/TestImportsLocationTag.java
@@ -4,6 +4,7 @@ import junit.framework.TestCase;
import org.eclipse.emf.codegen.util.ImportManager;
import org.eclipse.jet.BodyContentWriter;
+import org.eclipse.jet.BufferedJET2Writer;
import org.eclipse.jet.JET2Context;
import org.eclipse.jet.JET2Writer;
import org.eclipse.jet.internal.taglib.java.ImportsLocationTag;
@@ -11,6 +12,7 @@ import org.eclipse.jet.taglib.JET2TagException;
import org.eclipse.jet.taglib.TagInfo;
import org.eclipse.jet.taglib.java.JavaActionsUtil;
import org.eclipse.jface.text.BadPositionCategoryException;
+import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.Position;
public class TestImportsLocationTag extends TestCase {
@@ -20,7 +22,7 @@ public class TestImportsLocationTag extends TestCase {
*/
public void testDoAction() throws JET2TagException, BadPositionCategoryException {
JET2Context context = new JET2Context(null);
- JET2Writer writer = new BodyContentWriter();
+ BufferedJET2Writer writer = new BodyContentWriter();
TagInfo td = new TagInfo("java:importsLocation", 1, 1,
new String[] {"package"},
@@ -54,7 +56,7 @@ public class TestImportsLocationTag extends TestCase {
*/
public void testDoAction_multipleTimes() throws JET2TagException, BadPositionCategoryException {
JET2Context context = new JET2Context(null);
- JET2Writer writer = new BodyContentWriter();
+ BufferedJET2Writer writer = new BodyContentWriter();
TagInfo td = new TagInfo("java:importsLocation", 1, 1,
new String[] {"package"},
@@ -84,8 +86,9 @@ public class TestImportsLocationTag extends TestCase {
* @param writer
* @throws BadPositionCategoryException
*/
- private ImportManager verifyImportManagerInstalled(JET2Writer writer) throws BadPositionCategoryException {
- final Position[] positions = writer.getDocument().getPositions(ImportsLocationTag.IMPORTS_POSITION_CATEGORY);
+ private ImportManager verifyImportManagerInstalled(BufferedJET2Writer writer) throws BadPositionCategoryException {
+ final IDocument document = (IDocument) writer.getAdapter(IDocument.class);
+ final Position[] positions = document.getPositions(ImportsLocationTag.IMPORTS_POSITION_CATEGORY);
assertTrue("positions.length == 1", positions.length == 1);
assertTrue("positions[0] instanceof ImportsLocationTag.ImportsPosition", positions[0] instanceof ImportsLocationTag.ImportsPosition);
@@ -98,7 +101,7 @@ public class TestImportsLocationTag extends TestCase {
public void testJavaImportsUtil() throws JET2TagException, BadPositionCategoryException {
// setup an imports tag...
JET2Context context = new JET2Context(null);
- JET2Writer writer = new BodyContentWriter();
+ BufferedJET2Writer writer = new BodyContentWriter();
TagInfo td = new TagInfo("java:importsLocation", 1, 1,
new String[] {"package"},
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/ResourceInspectorTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/ResourceInspectorTests.java
index d11b62a..72a2b14 100644
--- a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/ResourceInspectorTests.java
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/ResourceInspectorTests.java
@@ -36,6 +36,7 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jet.JET2Platform;
import org.eclipse.jet.internal.xpath.inspectors.IWrappedAttribute;
@@ -61,9 +62,10 @@ public class ResourceInspectorTests extends TestCase {
public static Test suite() {
TestSetup setup = new TestSetup(new TestSuite(ResourceInspectorTests.class)) {
protected void setUp() throws Exception {
- JET2Platform.runTransformOnString("org.eclipse.jet.transforms.newproject",
+ final IStatus status = JET2Platform.runTransformOnString("org.eclipse.jet.transforms.newproject",
"<newProjectModel><project name=\"" + TEST_PROJECT_NAME + "\"/></newProjectModel>",
new NullProgressMonitor());
+ assertTrue("setup Transform executed successfully", status.isOK());
}
protected void tearDown() throws Exception {

Back to the top