Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2006-11-21 15:35:08 -0500
committerpelder2006-11-21 15:35:08 -0500
commit0ff861880316a067249750eba5530b799194e002 (patch)
treeb4f902403bd17c5d83037679179c2aa248be2d51 /tests/org.eclipse.jet.tests
parent85e924faca7becbb1ce6bc080e8a4c2784d69587 (diff)
downloadorg.eclipse.jet-0ff861880316a067249750eba5530b799194e002.tar.gz
org.eclipse.jet-0ff861880316a067249750eba5530b799194e002.tar.xz
org.eclipse.jet-0ff861880316a067249750eba5530b799194e002.zip
[163849] Merge in 0.7.x maintenance fixes
Diffstat (limited to 'tests/org.eclipse.jet.tests')
-rw-r--r--tests/org.eclipse.jet.tests/data/ActionsUtil/MANIFEST.MF17
-rw-r--r--tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf16be.xmlbin0 -> 150 bytes
-rw-r--r--tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf16le.xmlbin0 -> 150 bytes
-rw-r--r--tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf8_bom.xml4
-rw-r--r--tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf8_no_bom.xml4
-rw-r--r--tests/org.eclipse.jet.tests/data/attributeParsingErrors.jet6
-rw-r--r--tests/org.eclipse.jet.tests/data/bug147714.jet11
-rw-r--r--tests/org.eclipse.jet.tests/data/taglibs.jet.astdump.expected2
-rw-r--r--tests/org.eclipse.jet.tests/data/textTrimmingTests.jet70
-rw-r--r--tests/org.eclipse.jet.tests/data/unclosedXMLEnd.jet4
-rw-r--r--tests/org.eclipse.jet.tests/data/unclosedXMLStart.jet4
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/AllTests.java1
-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.java212
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJETParser.java15
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TextTrimmingTests.java226
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/AllTests.java3
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/TestBundleJarUtil.java47
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/TestDirectoryBundleProvider.java83
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/java/JavaActionsUtilTests.java70
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/workspace/ActionsUtilTests.java116
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/workspace/AllTests.java17
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/AllTests.java1
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/DescendantOrSelfTests.java58
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/EObjectInspectorTests.java50
25 files changed, 1001 insertions, 21 deletions
diff --git a/tests/org.eclipse.jet.tests/data/ActionsUtil/MANIFEST.MF b/tests/org.eclipse.jet.tests/data/ActionsUtil/MANIFEST.MF
new file mode 100644
index 0000000..ff8d913
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/ActionsUtil/MANIFEST.MF
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.jet.tests;singleton:=true
+Bundle-Version: 0.7.0.qualifier
+Bundle-ClassPath: tests.jar
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.jet,
+ org.junit,
+ org.eclipse.emf.codegen,
+ org.eclipse.core.runtime,
+ org.eclipse.emf.ecore,
+ org.eclipse.emf.ecore.xmi,
+ org.eclipse.xsd,
+ org.eclipse.core.filebuffers,
+ org.eclipse.core.resources
+Bundle-Vendor: %providerName
diff --git a/tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf16be.xml b/tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf16be.xml
new file mode 100644
index 0000000..368bb8c
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf16be.xml
Binary files differ
diff --git a/tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf16le.xml b/tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf16le.xml
new file mode 100644
index 0000000..a167ef1
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf16le.xml
Binary files differ
diff --git a/tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf8_bom.xml b/tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf8_bom.xml
new file mode 100644
index 0000000..59bda64
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf8_bom.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<root>
+ <a attr="b"/>
+</root>
diff --git a/tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf8_no_bom.xml b/tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf8_no_bom.xml
new file mode 100644
index 0000000..e93c6a2
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/ActionsUtil/sample_utf8_no_bom.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<root>
+ <a attr="b"/>
+</root>
diff --git a/tests/org.eclipse.jet.tests/data/attributeParsingErrors.jet b/tests/org.eclipse.jet.tests/data/attributeParsingErrors.jet
new file mode 100644
index 0000000..99bf3cc
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/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/data/bug147714.jet b/tests/org.eclipse.jet.tests/data/bug147714.jet
new file mode 100644
index 0000000..ec12e85
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/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.controlTags" prefix="c" %>
+<%@taglib id="org.eclipse.jet.tests.TestLibrary" prefix="" %>
+
+<%-- line 8: expect error --%><c:get select="$foo">
+<%-- line 9: expect ok --%><c:get select="$foo"/>
+<%-- line 10: expect warning --%><nl>
+<%-- line 11: expect ok --%><nl/>
diff --git a/tests/org.eclipse.jet.tests/data/taglibs.jet.astdump.expected b/tests/org.eclipse.jet.tests/data/taglibs.jet.astdump.expected
index 0c61be6..b73ff74 100644
--- a/tests/org.eclipse.jet.tests/data/taglibs.jet.astdump.expected
+++ b/tests/org.eclipse.jet.tests/data/taglibs.jet.astdump.expected
@@ -1,6 +1,6 @@
<directive name="taglib" line="1" col="1">
- <attribute name="prefix">test</attribute>
<attribute name="id">org.eclipse.jet.tests.TestLibrary</attribute>
+ <attribute name="prefix">test</attribute>
</directive>
<data>
"isAllUpper", "nl", "other", "tokenize", "upper"
diff --git a/tests/org.eclipse.jet.tests/data/textTrimmingTests.jet b/tests/org.eclipse.jet.tests/data/textTrimmingTests.jet
new file mode 100644
index 0000000..1570482
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/textTrimmingTests.jet
@@ -0,0 +1,70 @@
+<%@taglib id="org.eclipse.jet.controlTags" prefix="c"%>
+<%-- This template is used to verify text trimming rules. It is used by TextTrimmingTexts.java --%>
+
+<%-- text stripping around start/end tags that support stripping (e.g. c:iterate) --%>
+test 001
+<c:iterate select="foo" var="bar">
+ some text with four spaces after
+</c:iterate>
+test 001
+
+<%-- text stripping around start/end tags that support stripping (e.g. c:iterate)
+ with leading and trailing whitepace --%>
+test 002
+ <c:iterate select="foo" var="bar">
+ some text with four spaces after
+ </c:iterate>
+test 002
+
+<%-- text stripping around start/end tags that support stripping (e.g. c:iterate)
+ with multi-line tags --%>
+test 003
+ <c:iterate
+ select="foo"
+ var="bar"
+ >
+ some text with four spaces after
+ </c:iterate
+ >
+test 003
+
+<%-- text stripping on directives --%>
+test 004
+ <%@taglib id="org.eclipse.jet.workspaceTags" prefix="ws"%>
+test 004
+
+<%-- text stripping on scriptlet --%>
+test 005
+ <%
+ int x = 3;
+%>
+test 005
+
+<%-- text stripping on declarations --%>
+test 006
+ <%!
+ public int square(int arg) {
+ return arg * arg;
+ }
+%>
+test 006
+
+<%-- text stripping on empytags that supports stripping --%>
+test 007
+ <c:include template="templates/foo.jet"/>
+test 007
+
+<%-- text stripping on empytags that does not support stripping --%>
+test 008
+ <c:get select="templates/foo.jet"/>
+test 008
+
+<%-- text stripping on comments --%>
+test 009
+ <%-- a comment --%>
+test 009
+
+<%-- text stripping an expression --%>
+test 010
+ <%= x %>
+test 010
diff --git a/tests/org.eclipse.jet.tests/data/unclosedXMLEnd.jet b/tests/org.eclipse.jet.tests/data/unclosedXMLEnd.jet
index 188636c..08f095f 100644
--- a/tests/org.eclipse.jet.tests/data/unclosedXMLEnd.jet
+++ b/tests/org.eclipse.jet.tests/data/unclosedXMLEnd.jet
@@ -1,3 +1,3 @@
-<%@jet package="org.eclipse.emf.examples.test" class="Foo" %>
+<%@taglib id="org.eclipse.jet.controlTags" prefix="test" %>
-</test:start
+</test:include
diff --git a/tests/org.eclipse.jet.tests/data/unclosedXMLStart.jet b/tests/org.eclipse.jet.tests/data/unclosedXMLStart.jet
index d3e55e0..31f3ccf 100644
--- a/tests/org.eclipse.jet.tests/data/unclosedXMLStart.jet
+++ b/tests/org.eclipse.jet.tests/data/unclosedXMLStart.jet
@@ -1,3 +1,3 @@
-<%@jet package="org.eclipse.emf.examples.test" class="Foo" %>
+<%@taglib id="org.eclipse.jet.controlTags" prefix="test" %>
-<test:start attr="foo"
+<test:include template="foo"
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/AllTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/AllTests.java
index 4b2fe16..fd2efbb 100644
--- a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/AllTests.java
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/AllTests.java
@@ -14,6 +14,7 @@ public class AllTests {
suite.addTest(org.eclipse.jet.tests.model.load.AllTests.suite());
suite.addTest(org.eclipse.jet.tests.taglib.AllTests.suite());
suite.addTest(org.eclipse.jet.tests.taglib.control.AllTests.suite());
+ suite.addTest(org.eclipse.jet.tests.taglib.workspace.AllTests.suite());
suite.addTest(org.eclipse.jet.tests.taglib.java.AllTests.suite());
suite.addTest(org.eclipse.jet.tests.taglib.format.AllTests.suite());
suite.addTest(org.eclipse.jet.tests.runtime.AllTests.suite());
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 d15dc13..be0b1b5 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
@@ -11,6 +11,7 @@ public class AllTests {
//$JUnit-BEGIN$
suite.addTestSuite(TestJETParser.class);
suite.addTestSuite(TestJET2Parser.class);
+ suite.addTest(TextTrimmingTests.suite());
suite.addTestSuite(LineInfoTests.class);
//$JUnit-END$
return suite;
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 1339b0b..cb59f25 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,8 +6,11 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
+import java.util.ArrayList;
import java.util.Collections;
+import java.util.Comparator;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import junit.framework.TestCase;
@@ -20,11 +23,13 @@ import org.eclipse.jet.compiler.JET2Declaration;
import org.eclipse.jet.compiler.JET2Directive;
import org.eclipse.jet.compiler.JET2Expression;
import org.eclipse.jet.compiler.JET2Scriptlet;
+import org.eclipse.jet.compiler.Problem;
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.TemplateRunner;
+import org.eclipse.jet.internal.parser.ParseProblemSeverity;
import org.eclipse.jet.taglib.TagLibraryReference;
import org.eclipse.jet.tests.FileUtils;
@@ -253,4 +258,211 @@ public class TestJET2Parser extends TestCase {
}
+ public void testXMLStartAsEmpty_bug147714() throws MalformedURLException, FileNotFoundException, IOException {
+ String url = "platform:/plugin/org.eclipse.jet.tests/data/bug147714.jet";
+
+ InputStream is = getFileContentsAsStream(url);
+
+ JET2CompilationUnit cu = new JET2CompilationUnit();
+ cu.parse(is, "UTF-8");
+
+ Problem[] problems = getSortedProblems(cu);
+
+ assertEquals("Number of problems", 2, 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 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());
+
+
+ }
+
+ public void testUnclosedCommnetErrors() throws Exception {
+ String url = "platform:/plugin/org.eclipse.jet.tests/data/unclosedComment.jet";
+
+ InputStream is = getFileContentsAsStream(url);
+
+ JET2CompilationUnit cu = new JET2CompilationUnit();
+ cu.parse(is, "UTF-8");
+
+ Problem[] problems = getSortedProblems(cu);
+
+ assertEquals("Number of problems", 1, problems.length);
+
+
+ // 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());
+
+ }
+
+ public void testUnclosedDeclarationErrors() throws Exception {
+ String url = "platform:/plugin/org.eclipse.jet.tests/data/unclosedDeclaration.jet";
+
+ InputStream is = getFileContentsAsStream(url);
+
+ JET2CompilationUnit cu = new JET2CompilationUnit();
+ cu.parse(is, "UTF-8");
+
+ Problem[] problems = getSortedProblems(cu);
+
+ assertEquals("Number of problems", 1, problems.length);
+
+
+ // 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());
+
+ }
+
+ public void testUnclosedDirectiveErrors() throws Exception {
+ String url = "platform:/plugin/org.eclipse.jet.tests/data/unclosedDirective.jet";
+
+ InputStream is = getFileContentsAsStream(url);
+
+ JET2CompilationUnit cu = new JET2CompilationUnit();
+ cu.parse(is, "UTF-8");
+
+ Problem[] problems = getSortedProblems(cu);
+
+ assertEquals("Number of problems", 1, problems.length);
+
+
+ // 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());
+
+ }
+
+ public void testUnclosedExpressionErrors() throws Exception {
+ String url = "platform:/plugin/org.eclipse.jet.tests/data/unclosedExpression.jet";
+
+ InputStream is = getFileContentsAsStream(url);
+
+ JET2CompilationUnit cu = new JET2CompilationUnit();
+ cu.parse(is, "UTF-8");
+
+ Problem[] problems = getSortedProblems(cu);
+
+ assertEquals("Number of problems", 1, problems.length);
+
+
+ // 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());
+
+ }
+
+ public void testUnclosedScriptletErrors() throws Exception {
+ String url = "platform:/plugin/org.eclipse.jet.tests/data/unclosedScriplet.jet";
+
+ InputStream is = getFileContentsAsStream(url);
+
+ JET2CompilationUnit cu = new JET2CompilationUnit();
+ cu.parse(is, "UTF-8");
+
+ Problem[] problems = getSortedProblems(cu);
+
+ assertEquals("Number of problems", 1, problems.length);
+
+
+ // 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());
+
+ }
+
+ public void testUnclosedXMLEndErrors() throws Exception {
+ String url = "platform:/plugin/org.eclipse.jet.tests/data/unclosedXMLEnd.jet";
+
+ InputStream is = getFileContentsAsStream(url);
+
+ JET2CompilationUnit cu = new JET2CompilationUnit();
+ cu.parse(is, "UTF-8");
+
+ Problem[] problems = getSortedProblems(cu);
+
+ assertEquals("Number of problems", 1, problems.length);
+
+
+ // 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());
+
+ }
+
+ public void testUnclosedXMLStartErrors() throws Exception {
+ String url = "platform:/plugin/org.eclipse.jet.tests/data/unclosedXMLStart.jet";
+
+ InputStream is = getFileContentsAsStream(url);
+
+ JET2CompilationUnit cu = new JET2CompilationUnit();
+ cu.parse(is, "UTF-8");
+
+ Problem[] problems = getSortedProblems(cu);
+
+ assertEquals("Number of problems", 1, problems.length);
+
+
+ // 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());
+
+ }
+
+ /**
+ * @param cu
+ * @return
+ */
+ private Problem[] getSortedProblems(JET2CompilationUnit 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 {
+ String url = "platform:/plugin/org.eclipse.jet.tests/data/attributeParsingErrors.jet";
+
+ InputStream is = getFileContentsAsStream(url);
+
+ JET2CompilationUnit cu = new JET2CompilationUnit();
+ cu.parse(is, "UTF-8");
+
+ Problem[] problems = getSortedProblems(cu);
+
+ 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 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 247fc8b..3ddd6e6 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
@@ -254,6 +254,7 @@ public class TestJETParser extends TestCase {
AllJET2SyntaxListener listener = new AllJET2SyntaxListener(reader);
JETParser.Directive directive = new JETParser.Directive();
directive.getDirectives().add("jet");
+ directive.getDirectives().add("taglib");
JETCoreElement[] coreElements = new JETCoreElement[] {
directive,
@@ -289,12 +290,7 @@ public class TestJETParser extends TestCase {
String urlString = "platform:/plugin/org.eclipse.jet.tests/data/unclosedComment.jet";
String openChars = "<%--";
- try {
- doUnclosedElementTest(urlString, openChars, 0);
- fail();
- } catch(JETException e) {
- // success.
- }
+ doUnclosedElementTest(urlString, openChars, Problem.UnterminatedXMLTag);
}
@@ -303,12 +299,7 @@ public class TestJETParser extends TestCase {
String urlString = "platform:/plugin/org.eclipse.jet.tests/data/unclosedDeclaration.jet";
String openChars = "<%!";
- try {
- doUnclosedElementTest(urlString, openChars, 0);
- fail();
- } catch(JETException e) {
- // success.
- }
+ doUnclosedElementTest(urlString, openChars, Problem.UnterminatedXMLTag);
}
public void testUnclosedDirective() throws Exception {
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
new file mode 100644
index 0000000..361ab43
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TextTrimmingTests.java
@@ -0,0 +1,226 @@
+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 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.internal.parser.LineInfo;
+import org.eclipse.jet.tests.FileUtils;
+
+public class TextTrimmingTests extends TestCase {
+
+ private static JET2CompilationUnit unstrippedCu;
+ private static JET2CompilationUnit strippedCu;
+
+ private static FileInputStream getFileContentsAsStream(String urlString) throws IOException, MalformedURLException, FileNotFoundException {
+ String fileName = FileUtils.resolveURLToLocationString(urlString);
+ FileInputStream inputStream = new FileInputStream(new File(fileName));
+ return inputStream;
+ }
+
+ /**
+ * Wrap this suite in a TestSetup so that we can do one-time setup
+ * @return a wrapped TestSetup wrapped suite.
+ */
+ public static Test suite() {
+ TestSetup setup = new TestSetup(new TestSuite(TextTrimmingTests.class)) {
+ protected void setUp() throws Exception {
+ setUpAllTests();
+ }
+
+ protected void tearDown() throws Exception {
+ tearDownAllTests();
+ }
+ };
+
+ return setup;
+ }
+
+ 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());
+
+ }
+
+ private static void tearDownAllTests() {
+ // nothing to do
+ }
+
+
+ private String[] getLines(TextElement text) {
+ char[] chars = text.getText();
+ LineInfo[] lineInfos = LineInfo.calculateLines(chars);
+ String[] lines = new String[lineInfos.length];
+ for (int i = 0; i < lineInfos.length; i++) {
+ lines[i] = new String(chars, lineInfos[i].getStart(), lineInfos[i].getEnd() - lineInfos[i].getStart()) + lineInfos[i].getDelimiter();
+ }
+ return lines;
+ }
+
+ private String[] getTextLinesInRange(JET2CompilationUnit cu, final String testMarker) {
+ final StringBuffer linesBuffer = new StringBuffer();
+ cu.accept(new DefaultJET2ASTVisitor() {
+ private boolean rangeStarted = false;
+ private boolean rangeEnded = false;
+
+ public void visit(TextElement text) {
+ if(rangeEnded) return;
+
+ String lines[] = getLines(text);
+ int i = 0;
+ for (; i < lines.length && !rangeStarted; i++) {
+ if(lines[i].startsWith(testMarker)) {
+ rangeStarted = true;
+ linesBuffer.append(lines[i]);
+ }
+ }
+
+ for(; i < lines.length && rangeStarted && !rangeEnded; i++) {
+ linesBuffer.append(lines[i]);
+ if(lines[i].startsWith(testMarker)) {
+ rangeEnded = true;
+ }
+ }
+ }
+ });
+ final LineInfo[] lineInfos = LineInfo.calculateLines(linesBuffer.toString().toCharArray());
+ String[] lines = new String[lineInfos.length];
+ for (int i = 0; i < lineInfos.length; i++) {
+ lines[i] = linesBuffer.substring(lineInfos[i].getStart(), lineInfos[i].getEnd());
+ }
+ return lines;
+ }
+
+ public void testStartEndTagStripping() {
+ final String TEST_CASE = "test 001";
+ String[] unstrippedText = getTextLinesInRange(unstrippedCu, TEST_CASE);
+ String[] strippedText = getTextLinesInRange(strippedCu, TEST_CASE);
+
+ assertEquals(5, unstrippedText.length);
+
+ assertEquals(3, strippedText.length);
+ }
+
+ public void testStartEndTagStripping2() {
+ final String TEST_CASE = "test 002";
+ String[] unstrippedText = getTextLinesInRange(unstrippedCu, TEST_CASE);
+ String[] strippedText = getTextLinesInRange(strippedCu, TEST_CASE);
+
+ assertEquals(5, unstrippedText.length);
+
+ assertEquals(3, strippedText.length);
+
+ }
+
+ public void testStartEndTagStripping3() {
+ final String TEST_CASE = "test 003";
+ String[] unstrippedText = getTextLinesInRange(unstrippedCu, TEST_CASE);
+ String[] strippedText = getTextLinesInRange(strippedCu, TEST_CASE);
+
+ assertEquals(5, unstrippedText.length);
+
+ assertEquals(3, strippedText.length);
+
+ }
+
+ public void testDirectiveStripping() {
+ final String TEST_CASE = "test 004";
+ String[] unstrippedText = getTextLinesInRange(unstrippedCu, TEST_CASE);
+ String[] strippedText = getTextLinesInRange(strippedCu, TEST_CASE);
+
+ assertEquals(3, unstrippedText.length);
+
+ assertEquals(2, strippedText.length);
+
+ }
+
+ public void testScriptletStripping() {
+ final String TEST_CASE = "test 005";
+ String[] unstrippedText = getTextLinesInRange(unstrippedCu, TEST_CASE);
+ String[] strippedText = getTextLinesInRange(strippedCu, TEST_CASE);
+
+ assertEquals(3, unstrippedText.length);
+
+ assertEquals(2, strippedText.length);
+
+ }
+
+ public void testDeclarationStripping() {
+ final String TEST_CASE = "test 006";
+ String[] unstrippedText = getTextLinesInRange(unstrippedCu, TEST_CASE);
+ String[] strippedText = getTextLinesInRange(strippedCu, TEST_CASE);
+
+ assertEquals(3, unstrippedText.length);
+
+ assertEquals(2, strippedText.length);
+
+ }
+
+ public void testEmptyTagStripping_supportsRemove() {
+ final String TEST_CASE = "test 007";
+ String[] unstrippedText = getTextLinesInRange(unstrippedCu, TEST_CASE);
+ String[] strippedText = getTextLinesInRange(strippedCu, TEST_CASE);
+
+ assertEquals(3, unstrippedText.length);
+
+ assertEquals(2, strippedText.length);
+
+ }
+
+
+ public void testEmptyTagStripping_noRemove() {
+ final String TEST_CASE = "test 008";
+ String[] unstrippedText = getTextLinesInRange(unstrippedCu, TEST_CASE);
+ String[] strippedText = getTextLinesInRange(strippedCu, TEST_CASE);
+
+ assertEquals(3, unstrippedText.length);
+
+ assertEquals(3, strippedText.length);
+
+ }
+
+ public void testCommentStripping() {
+ final String TEST_CASE = "test 009";
+ String[] unstrippedText = getTextLinesInRange(unstrippedCu, TEST_CASE);
+ String[] strippedText = getTextLinesInRange(strippedCu, TEST_CASE);
+
+ assertEquals(3, unstrippedText.length);
+
+ assertEquals(2, strippedText.length);
+
+ }
+
+ public void testExpressionStripping() {
+ final String TEST_CASE = "test 010";
+ String[] unstrippedText = getTextLinesInRange(unstrippedCu, TEST_CASE);
+ String[] strippedText = getTextLinesInRange(strippedCu, TEST_CASE);
+
+ assertEquals(3, unstrippedText.length);
+
+ assertEquals(3, strippedText.length);
+
+ }
+
+
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/AllTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/AllTests.java
index d2e7fe9..1b5c8a9 100644
--- a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/AllTests.java
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/AllTests.java
@@ -9,8 +9,9 @@ public class AllTests {
TestSuite suite = new TestSuite(
"Test for org.eclipse.jet.tests.runtime");
//$JUnit-BEGIN$
- suite.addTestSuite(TestBundleDescriptions.class);
suite.addTestSuite(TestBundleLoading.class);
+ suite.addTestSuite(TestBundleJarUtil.class);
+ suite.addTestSuite(TestBundleDescriptions.class);
//$JUnit-END$
return suite;
}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/TestBundleJarUtil.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/TestBundleJarUtil.java
new file mode 100644
index 0000000..0eaf172
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/TestBundleJarUtil.java
@@ -0,0 +1,47 @@
+package org.eclipse.jet.tests.runtime;
+
+import org.eclipse.jet.internal.runtime.BundleJarInfo;
+
+import junit.framework.TestCase;
+
+public class TestBundleJarUtil extends TestCase {
+
+ private BundleJarInfo complexBJU;
+ private BundleJarInfo simpleBJU;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ complexBJU = BundleJarInfo.createBundleJarInfo("a.b.c_1.2.3.x_yz_4.5.6.a_b_c.jar");
+ simpleBJU = BundleJarInfo.createBundleJarInfo("a.b.c_1.2.3.jar");
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testGetBundleSymbolicName_complex() {
+ assertEquals("a.b.c_1.2.3.x_yz", complexBJU.getBundleSymbolicName());
+ }
+
+ public void testGetVersion_complex() {
+ assertEquals("4.5.6.a_b_c", complexBJU.getVersion());
+ }
+
+ public void testGetJarName_complex() {
+ assertEquals("a.b.c_1.2.3.x_yz_4.5.6.a_b_c.jar", complexBJU.getJarName());
+ }
+
+ public void testGetBundleSymbolicName_simple() {
+ assertEquals("a.b.c", simpleBJU.getBundleSymbolicName());
+ }
+
+ public void testGetVersion_simple() {
+ assertEquals("1.2.3", simpleBJU.getVersion());
+ }
+
+ public void testGetJarName_simple() {
+ assertEquals("a.b.c_1.2.3.jar", simpleBJU.getJarName());
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/TestDirectoryBundleProvider.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/TestDirectoryBundleProvider.java
new file mode 100644
index 0000000..d532460
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/TestDirectoryBundleProvider.java
@@ -0,0 +1,83 @@
+/**
+ * <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$
+ */
+
+package org.eclipse.jet.tests.runtime;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jet.internal.runtime.DirectoryBundleProvider;
+import org.eclipse.jet.transform.IJETBundleDescriptor;
+
+/**
+ * @author pelder
+ *
+ */
+public class TestDirectoryBundleProvider extends TestCase {
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testGetAllJETBundleIds() throws Exception {
+ // FIXME: Tests are specific to one development environment/machine
+ DirectoryBundleProvider dbp = new DirectoryBundleProvider("c:/temp/plugins");
+
+ final Set ids = dbp.getAllJETBundleIds();
+
+// assertEquals(1, ids.size());
+ assertTrue("contains gp02.generator.pattern", ids.contains("gp02.generator.pattern"));
+ assertFalse("does not contain org.eclipse.jet.doc", ids.contains("org.eclipse.jet.doc"));
+ }
+
+ public void testGetDescriptor() throws Exception {
+ // FIXME: Tests are specific to one development environment/machine
+ DirectoryBundleProvider dbp = new DirectoryBundleProvider("c:/temp/plugins");
+
+ final IJETBundleDescriptor descriptor = dbp.getDescriptor("gp02.generator.pattern");
+ assertNotNull("Descriptor", descriptor);
+ assertEquals("gp02.generator.pattern", descriptor.getId());
+ }
+
+ public void testGetAllJETBundleDescriptors() throws Exception {
+ // FIXME: Tests are specific to one development environment/machine
+ DirectoryBundleProvider dbp = new DirectoryBundleProvider("c:/temp/plugins");
+
+ final Collection col = dbp.getAllJETBundleDescriptors();
+
+ for (Iterator i = col.iterator(); i.hasNext();) {
+ IJETBundleDescriptor descriptor = (IJETBundleDescriptor) i.next();
+ if(descriptor.getId().equals("gp02.generator.pattern")) {
+ return;
+ }
+ }
+ fail("gp02.generator.pattern not found");
+ }
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/java/JavaActionsUtilTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/java/JavaActionsUtilTests.java
new file mode 100644
index 0000000..4304f79
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/java/JavaActionsUtilTests.java
@@ -0,0 +1,70 @@
+/**
+ * <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$
+ */
+
+package org.eclipse.jet.tests.taglib.java;
+
+import junit.framework.TestCase;
+
+/**
+ * @author pelder
+ *
+ */
+public class JavaActionsUtilTests extends TestCase {
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.taglib.java.JavaActionsUtil#getContainerForPackage(org.eclipse.core.runtime.IPath, java.lang.String)}.
+ */
+ public void testGetContainerForPackage() {
+ fail("Not yet implemented");
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.taglib.java.JavaActionsUtil#getImportManager(org.eclipse.jet.JET2Writer)}.
+ */
+ public void testGetImportManager() {
+ fail("Not yet implemented");
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.taglib.java.JavaActionsUtil#findContainingJavaPackageTag(org.eclipse.jet.taglib.CustomTag)}.
+ */
+ public void testFindContainingJavaPackageTag() {
+ fail("Not yet implemented");
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.taglib.java.JavaActionsUtil#getResourceForJavaResource(org.eclipse.core.runtime.IPath, java.lang.String, java.lang.String)}.
+ */
+ public void testGetResourceForJavaResource() {
+ fail("Not yet implemented");
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/workspace/ActionsUtilTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/workspace/ActionsUtilTests.java
new file mode 100644
index 0000000..9203668
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/workspace/ActionsUtilTests.java
@@ -0,0 +1,116 @@
+/**
+ * <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$
+ */
+
+package org.eclipse.jet.tests.taglib.workspace;
+
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jet.taglib.workspace.ActionsUtil;
+
+/**
+ * JUnit tests for {@link ActionsUtil}.
+ *
+ */
+public class ActionsUtilTests extends TestCase {
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.taglib.workspace.ActionsUtil#readTextFile(java.net.URL, java.lang.String)}.
+ * @throws Exception
+ */
+ public void testReadTextFile_Manifest_MF() throws Exception {
+ URL url = new URL("platform:/plugin/org.eclipse.jet.tests/data/ActionsUtil/MANIFEST.MF");
+ final String correctText = ActionsUtil.readTextFile(url, "UTF-8");
+
+ final String rawText = ActionsUtil.readTextFile(url, null);
+
+ assertTrue("raw text", rawText.startsWith("Manifest-Version: 1.0"));
+ assertTrue("correct text", correctText.startsWith("Manifest-Version: 1.0"));
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.taglib.workspace.ActionsUtil#readTextFile(java.net.URL, java.lang.String)}.
+ * @throws Exception
+ */
+ public void testReadTextFile_utf8_no_bom_xml() throws Exception {
+ URL url = new URL("platform:/plugin/org.eclipse.jet.tests/data/ActionsUtil/sample_utf8_no_bom.xml");
+ final String correctText = ActionsUtil.readTextFile(url, "UTF-8");
+
+ final String rawText = ActionsUtil.readTextFile(url, null);
+
+ assertTrue("correct text", correctText.startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
+ assertTrue("raw text", rawText.startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.taglib.workspace.ActionsUtil#readTextFile(java.net.URL, java.lang.String)}.
+ * @throws Exception
+ */
+ public void testReadTextFile_utf8_bom_xml() throws Exception {
+ URL url = new URL("platform:/plugin/org.eclipse.jet.tests/data/ActionsUtil/sample_utf8_bom.xml");
+ final String correctText = ActionsUtil.readTextFile(url, "UTF-8");
+
+ final String rawText = ActionsUtil.readTextFile(url, null);
+
+ assertTrue("correct text", correctText.startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
+ assertTrue("raw text", rawText.startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.taglib.workspace.ActionsUtil#readTextFile(java.net.URL, java.lang.String)}.
+ * @throws Exception
+ */
+ public void testReadTextFile_utf16_le_xml() throws Exception {
+ URL url = new URL("platform:/plugin/org.eclipse.jet.tests/data/ActionsUtil/sample_utf16le.xml");
+ final String correctText = ActionsUtil.readTextFile(url, "UTF-16");
+
+
+ assertTrue("correct text", correctText.startsWith("<?xml version=\"1.0\" encoding=\"UTF-16\"?>"));
+ // XXX: Should verify presence of BOM by reading byte stream directly.
+// final String rawText = ActionsUtil.readTextFile(url, null);
+// assertTrue("raw text", rawText.startsWith("\u00FF\u00FE")); // Little Endian BOM is FF FE
+ }
+
+ /**
+ * Test method for {@link org.eclipse.jet.taglib.workspace.ActionsUtil#readTextFile(java.net.URL, java.lang.String)}.
+ * @throws Exception
+ */
+ public void testReadTextFile_utf16_be_xml() throws Exception {
+ URL url = new URL("platform:/plugin/org.eclipse.jet.tests/data/ActionsUtil/sample_utf16be.xml");
+ final String correctText = ActionsUtil.readTextFile(url, "UTF-16");
+
+ assertTrue("correct text", correctText.startsWith("<?xml version=\"1.0\" encoding=\"UTF-16\"?>"));
+ // XXX: Should verify presence of BOM by reading byte stream directly.
+// final String rawText = ActionsUtil.readTextFile(url, null);
+// assertTrue("raw text", rawText.startsWith("\u00FE\u00FF")); // big endian BOM is FE FF
+ }
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/workspace/AllTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/workspace/AllTests.java
new file mode 100644
index 0000000..1088325
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/workspace/AllTests.java
@@ -0,0 +1,17 @@
+package org.eclipse.jet.tests.taglib.workspace;
+
+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.taglib.workspace");
+ //$JUnit-BEGIN$
+ suite.addTestSuite(ActionsUtilTests.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/AllTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/AllTests.java
index 4d7e201..6d10fc7 100644
--- a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/AllTests.java
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/AllTests.java
@@ -15,6 +15,7 @@ public class AllTests {
suite.addTest(ResourceAttributeInspectorTests.suite());
suite.addTestSuite(SelfStepTests.class);
suite.addTestSuite(ParentStepTests.class);
+ suite.addTestSuite(DescendantOrSelfTests.class);
suite.addTestSuite(LogicalOpTests.class);
suite.addTestSuite(DOMInspectorTests.class);
suite.addTestSuite(ExpandedNameTests.class);
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/DescendantOrSelfTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/DescendantOrSelfTests.java
new file mode 100644
index 0000000..1b725ea
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/DescendantOrSelfTests.java
@@ -0,0 +1,58 @@
+/**
+ * <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$
+ */
+
+package org.eclipse.jet.tests.xpath;
+
+import java.util.Set;
+
+import org.eclipse.jet.internal.xpath.ast.Axis;
+import org.eclipse.jet.internal.xpath.ast.NodeTest;
+import org.eclipse.jet.internal.xpath.ast.Root;
+import org.eclipse.jet.internal.xpath.ast.Step;
+import org.eclipse.jet.xpath.Context;
+import org.eclipse.jet.xpath.inspector.ExpandedName;
+import org.eclipse.jet.xpath.inspector.INodeInspector.NodeKind;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Test the 'descendant-of-self' axis.
+ *
+ */
+public class DescendantOrSelfTests extends AbstractExprTest {
+
+ public void testEvalAsNodeSet_root_slash_slash_b() {
+ Step stepExpr = new Step(
+ new Step(new Root(), Axis.childAxis(),
+ NodeTest.nameTest(NodeKind.ELEMENT, new ExpandedName("root"))),
+ Axis.descendantOrSelf(),
+ NodeTest.nameTest(NodeKind.ELEMENT, new ExpandedName("b")));
+
+ Context context = new Context(document, null);
+
+ Set resultSet = stepExpr.evalAsNodeSet(context);
+
+ assertNotNull(resultSet);
+ assertEquals(2, resultSet.size());
+ Element elementA2 = (Element) rootElement.getElementsByTagName("a").item(1);
+ Node elementB2 = (Element) elementA2.getElementsByTagName("b").item(0);
+
+ assertTrue(resultSet.contains(elementB));
+ assertTrue(resultSet.contains(elementB2));
+
+ }
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/EObjectInspectorTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/EObjectInspectorTests.java
index 227bc57..3c2912e 100644
--- a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/EObjectInspectorTests.java
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/EObjectInspectorTests.java
@@ -474,7 +474,7 @@ public class EObjectInspectorTests extends TestCase {
assertEquals(1, doc.length);
assertTrue("instanceof EMFEAttrAsElementWrapper", doc[0] instanceof EMFEAttrAsElementWrapper);
EMFEAttrAsElementWrapper wrapper = (EMFEAttrAsElementWrapper) doc[0];
- assertEquals("doc for Author.name", wrapper.getSetting().get(true));
+ assertEquals("doc for Author.name", wrapper.getValue());
}
/*
@@ -587,7 +587,7 @@ public class EObjectInspectorTests extends TestCase {
assertEquals(1, namedChildren.length);
for (int i = 0; i < namedChildren.length; i++) {
EMFEAttrAsElementWrapper child = (EMFEAttrAsElementWrapper) namedChildren[i];
- assertEquals("doc for Author.name", child.getSetting().get(true));
+ assertEquals("doc for Author.name", child.getValue());
}
}
@@ -699,6 +699,49 @@ public class EObjectInspectorTests extends TestCase {
assertTrue("cust not in afterList", !afterList.contains(emp));
}
+ public void testRemoveAttribute_emf() {
+ EStructuralFeature nameFeature = emfRoot.eClass().getEStructuralFeature("name");
+ assertTrue("setup: name is not set", emfRoot.eIsSet(nameFeature));
+
+ inspector.removeAttribute(emfRoot, "name");
+
+ assertFalse("name is still set", emfRoot.eIsSet(nameFeature));
+ assertNull(inspector.getNamedAttribute(emfRoot, new ExpandedName("name")));
+ }
+
+ public void testRemoveAttribute_emf_nonexisting() {
+ final String attrName = "notAnAttribute";
+ EStructuralFeature nameFeature = emfRoot.eClass().getEStructuralFeature(attrName);
+ assertNull("setup: " + attrName + " is not set", nameFeature);
+
+ inspector.removeAttribute(emfRoot, attrName);
+
+ // success if we get here without someone throwing an exception
+ }
+
+ public void testRemoveAttribute_xml() {
+ ExpandedName enRootAttr = new ExpandedName("rootAttr");
+ Object originalRootAttr = inspector.getNamedAttribute(xmlRootElement, enRootAttr);
+ assertNotNull("setup: originalRootAttr is null", originalRootAttr);
+
+ inspector.removeAttribute(xmlRootElement, "rootAttr");
+
+ Object rootAttr = inspector.getNamedAttribute(xmlRootElement, enRootAttr);
+ assertNull("rootAttr should be null", rootAttr);
+ }
+
+ public void testRemoveAttribute_xsd() {
+ Object projectElement = xsdRootElement.eContents().get(0);
+
+ Object originalAttribute = inspector.getNamedAttribute(projectElement, new ExpandedName("name"));
+ assertNotNull("setup: originalAttribute is null", originalAttribute);
+
+ inspector.removeAttribute(projectElement, "name");
+
+ Object attribute = inspector.getNamedAttribute(projectElement, new ExpandedName("name"));
+ assertNull("attribute should be null", attribute);
+ }
+
public void testRemoveElement_xml() {
// EStructuralFeature feature = xmlRootElement.getAny().getEStructuralFeature(0);
EStructuralFeature feature = Bug130552Workaround.getEStructuralFeature(xmlRootElement.getAny(), 0);
@@ -787,6 +830,7 @@ public class EObjectInspectorTests extends TestCase {
// assertEquals(elementACopy ,xmlRootElement.getAny().getValue(initialSize));
assertEquals(elementACopy ,Bug130552Workaround.getValue(xmlRootElement.getAny(), initialSize));
assertEquals(0, inspector.getChildren(elementACopy).length);
+ assertEquals(elementA.getAnyAttribute().size(), ((AnyType)elementACopy).getAnyAttribute().size());
}
public void testCopyElement_xsd() throws CopyElementException {
@@ -833,7 +877,7 @@ public class EObjectInspectorTests extends TestCase {
assertEquals(1, doc.length);
assertTrue("instanceof EMFEAttrAsElementWrapper", doc[0] instanceof EMFEAttrAsElementWrapper);
EMFEAttrAsElementWrapper wrapper = (EMFEAttrAsElementWrapper) doc[0];
- assertEquals("Hello Attribute 1", wrapper.getSetting().get(true));
+ assertEquals("Hello Attribute 1", wrapper.getValue());
}
public void testAddTextElement_xml() throws AddElementException {

Back to the top