Skip to main content
summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorpelder2006-05-31 16:55:32 -0400
committerpelder2006-05-31 16:55:32 -0400
commit512c254e765c7e6ea93263898d473b4a82b53e7e (patch)
treedd4198068771236663003dda3fbcdc33d23d4997 /tests
parent8e43a38b22587e6d50d320e51976c3f66a1be0ac (diff)
downloadorg.eclipse.jet-512c254e765c7e6ea93263898d473b4a82b53e7e.tar.gz
org.eclipse.jet-512c254e765c7e6ea93263898d473b4a82b53e7e.tar.xz
org.eclipse.jet-512c254e765c7e6ea93263898d473b4a82b53e7e.zip
[144779] Switch to JET2 for template engine used by compiler.
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.jet.tests/data/taglibs.jet.expected.java176
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJET2Parser.java8
2 files changed, 104 insertions, 80 deletions
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 b8c161b..388b5fd 100644
--- a/tests/org.eclipse.jet.tests/data/taglibs.jet.expected.java
+++ b/tests/org.eclipse.jet.tests/data/taglibs.jet.expected.java
@@ -7,88 +7,112 @@ 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 static final String _jetns_test = "org.eclipse.jet.tests.TestLibrary";//$NON-NLS-1$
-
-
-
-
public X() {
super();
}
- public void generate(JET2Context context, JET2Writer out) {
-
- final TagInfo _jettd_test_tokenize_4_1 = new TagInfo( "test:tokenize", 4, 1, new String[] {"sep", "var", "string", }, new String[] {",", "token", "a,b,c,d,e,f,g", });
-final TagInfo _jettd_test_other_5_1 = new TagInfo( "test:other", 5, 1, new String[] {}, new String[] {});
-final TagInfo _jettd_test_isAllUpper_6_1 = new TagInfo( "test:isAllUpper", 6, 1, new String[] {"var", }, new String[] {"token", });
-final TagInfo _jettd_test_upper_8_1 = new TagInfo( "test:upper", 8, 1, new String[] {}, new String[] {});
-final TagInfo _jettd_test_nl_8_29 = new TagInfo( "test:nl", 8, 29, new String[] {}, new String[] {});
-final TagInfo _jettd_test_other_9_1 = new TagInfo( "test:other", 9, 1, new String[] {}, new String[] {});
-
-
- out.write("\r\n\"isAllUpper\", \"nl\", \"other\", \"tokenize\", \"upper\"\r\n\r\n");
- RuntimeTagElement _jettag_test_tokenize_4_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "tokenize", "test:tokenize", _jettd_test_tokenize_4_1);
- _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");
- RuntimeTagElement _jettag_test_other_5_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "other", "test:other", _jettd_test_other_5_1);
- _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");
- _jettag_test_other_5_1.handleBodyContent(out);
- }
- _jettag_test_other_5_1.doEnd();
-out.write("\r\n");
- RuntimeTagElement _jettag_test_isAllUpper_6_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "isAllUpper", "test:isAllUpper", _jettd_test_isAllUpper_6_1);
- _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()) {
-
-out.write("\r\n");
- _jettag_test_isAllUpper_6_1.handleBodyContent(out);
- }
- _jettag_test_isAllUpper_6_1.doEnd();
-out.write("\r\n");
- RuntimeTagElement _jettag_test_upper_8_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "upper", "test:upper", _jettd_test_upper_8_1);
- _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");
- _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);
- _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");
- RuntimeTagElement _jettag_test_other_9_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "other", "test:other", _jettd_test_other_9_1);
- _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();
-out.write("\r\n");
- _jettag_test_tokenize_4_1.handleBodyContent(out);
- }
- _jettag_test_tokenize_4_1.doEnd();
+ 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( "\r\n\"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);
+ _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);
+ _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);
+ _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()) {
+ 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);
+ _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);
+ _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);
+ _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();
+ out.write( "\r\n" ); //$NON-NLS-1$
+ _jettag_test_tokenize_4_1.handleBodyContent(out);
+ }
+ _jettag_test_tokenize_4_1.doEnd();
}
}
- \ No newline at end of file
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 79f3ad8..1339b0b 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
@@ -6,6 +6,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
+import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
@@ -23,7 +24,7 @@ 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.internal.compiler.templates.JET2JavaGenerator;
+import org.eclipse.jet.internal.compiler.TemplateRunner;
import org.eclipse.jet.taglib.TagLibraryReference;
import org.eclipse.jet.tests.FileUtils;
@@ -243,11 +244,10 @@ public class TestJET2Parser extends TestCase {
JET2CompilationUnit cu = new JET2CompilationUnit();
cu.parse(is, "UTF-8");
- JET2JavaGenerator writer = new JET2JavaGenerator();
-
cu.setOutputJavaPackage(JET2Compiler.DEFAULT_COMPILED_TEMPLATE_PACKAGE);
cu.setOutputJavaClassName("X");
- String result = writer.generate(cu);
+
+ String result = new TemplateRunner().generate("templates/jet2java.jet", Collections.singletonMap("cu", cu));
assertEquals(FileUtils.getFileContents(urlString + ".expected.java", true), result);

Back to the top