Skip to main content
summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorpelder2008-08-28 12:25:28 -0400
committerpelder2008-08-28 12:25:28 -0400
commit1bae69b75b8c505b61e3c5da7cfdb6ec071f3152 (patch)
tree3bfd1ae72bd1acfb9446a0b19e2e46e91a963974 /tests
parentd961087f3ba0911b6181def3e0cb8476b36287f9 (diff)
downloadorg.eclipse.jet-1bae69b75b8c505b61e3c5da7cfdb6ec071f3152.tar.gz
org.eclipse.jet-1bae69b75b8c505b61e3c5da7cfdb6ec071f3152.tar.xz
org.eclipse.jet-1bae69b75b8c505b61e3c5da7cfdb6ec071f3152.zip
[245398,245400,245401] XPath steps matching substitution group head members produce unpredictable results - commit to head
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.jet.tests-feature/feature.xml2
-rw-r--r--tests/org.eclipse.jet.tests/META-INF/MANIFEST.MF2
-rw-r--r--tests/org.eclipse.jet.tests/data/substGroup/ChildrenOnly.xml5
-rw-r--r--tests/org.eclipse.jet.tests/data/substGroup/MixedChildren.xml7
-rw-r--r--tests/org.eclipse.jet.tests/data/substGroup/SpecialChildrenOnly.xml5
-rw-r--r--tests/org.eclipse.jet.tests/data/substGroup/XMLSchemaWithGroups.xsd36
-rw-r--r--tests/org.eclipse.jet.tests/data/substGroup_2.4/ChildrenOnly.xml5
-rw-r--r--tests/org.eclipse.jet.tests/data/substGroup_2.4/MixedChildren.xml7
-rw-r--r--tests/org.eclipse.jet.tests/data/substGroup_2.4/SpecialChildrenOnly.xml5
-rw-r--r--tests/org.eclipse.jet.tests/data/substGroup_2.4/XMLSchemaWithGroups.xsd38
-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/xpath/inspectors/AbstractSubstitutionGroupTests.java128
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/inspectors/AllTests.java18
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/inspectors/EMFXML24SubstitutionGroupTests.java40
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/inspectors/LegacyEMFXMLSubstitutionGroupTests.java28
15 files changed, 325 insertions, 2 deletions
diff --git a/tests/org.eclipse.jet.tests-feature/feature.xml b/tests/org.eclipse.jet.tests-feature/feature.xml
index 787d35f..caa7031 100644
--- a/tests/org.eclipse.jet.tests-feature/feature.xml
+++ b/tests/org.eclipse.jet.tests-feature/feature.xml
@@ -2,7 +2,7 @@
<feature
id="org.eclipse.jet.tests"
label="%featureName"
- version="0.9.0.qualifier"
+ version="0.9.100.qualifier"
provider-name="%providerName">
<description url="http://www.eclipse.org/modeling/m2t">
diff --git a/tests/org.eclipse.jet.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.jet.tests/META-INF/MANIFEST.MF
index 6e54c3d..a41f2cc 100644
--- a/tests/org.eclipse.jet.tests/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.jet.tests/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jet.tests;singleton:=true
-Bundle-Version: 0.9.0.qualifier
+Bundle-Version: 0.9.100.qualifier
Bundle-ClassPath: tests.jar
Bundle-Localization: plugin
Require-Bundle: org.eclipse.jet,
diff --git a/tests/org.eclipse.jet.tests/data/substGroup/ChildrenOnly.xml b/tests/org.eclipse.jet.tests/data/substGroup/ChildrenOnly.xml
new file mode 100644
index 0000000..c806657
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/substGroup/ChildrenOnly.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<tns:topElement xmlns:tns="http://www.example.org/XMLSchemaWithGroups" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.org/XMLSchemaWithGroups XMLSchemaWithGroups.xsd ">
+ <tns:child name="Francis"/>
+ <tns:child name="Jason"/>
+</tns:topElement>
diff --git a/tests/org.eclipse.jet.tests/data/substGroup/MixedChildren.xml b/tests/org.eclipse.jet.tests/data/substGroup/MixedChildren.xml
new file mode 100644
index 0000000..bd715e9
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/substGroup/MixedChildren.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<tns:topElement xmlns:tns="http://www.example.org/XMLSchemaWithGroups" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.org/XMLSchemaWithGroups XMLSchemaWithGroups.xsd ">
+ <tns:child name="James"/>
+ <tns:specialChild name="Harry" specialNeed="Lots of Action"/>
+ <tns:child name="Lilly"/>
+ <tns:specialChild name="Dudley" specialNeed="Lots of Candy"/>
+</tns:topElement>
diff --git a/tests/org.eclipse.jet.tests/data/substGroup/SpecialChildrenOnly.xml b/tests/org.eclipse.jet.tests/data/substGroup/SpecialChildrenOnly.xml
new file mode 100644
index 0000000..36aa2ef
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/substGroup/SpecialChildrenOnly.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<tns:topElement xmlns:tns="http://www.example.org/XMLSchemaWithGroups" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.org/XMLSchemaWithGroups XMLSchemaWithGroups.xsd ">
+ <tns:specialChild name="Jim" specialNeed="Lots of Food"/>
+ <tns:specialChild name="Bob" specialNeed="Lots of TV"/>
+</tns:topElement>
diff --git a/tests/org.eclipse.jet.tests/data/substGroup/XMLSchemaWithGroups.xsd b/tests/org.eclipse.jet.tests/data/substGroup/XMLSchemaWithGroups.xsd
new file mode 100644
index 0000000..77ec9da
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/substGroup/XMLSchemaWithGroups.xsd
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/XMLSchemaWithGroups" xmlns:tns="http://www.example.org/XMLSchemaWithGroups" elementFormDefault="qualified">
+
+ <element name="topElement">
+ <complexType>
+ <sequence>
+ <element ref="tns:child" maxOccurs="unbounded" minOccurs="0"></element>
+ </sequence>
+ </complexType>
+ </element>
+
+
+
+ <element name="child" type="tns:childComplexType">
+ </element>
+
+ <element name="specialChild" type="tns:SpecialChildComplexType" substitutionGroup="tns:child"></element>
+ <complexType name="childComplexType">
+ <sequence>
+ <element name="hobby" maxOccurs="unbounded" minOccurs="0">
+ <complexType>
+ <attribute name="type" type="string" use="required"></attribute>
+ </complexType>
+ </element>
+ </sequence>
+ <attribute use="required" name="name" type="string"></attribute>
+ </complexType>
+
+ <complexType name="SpecialChildComplexType">
+ <complexContent>
+ <extension base="tns:childComplexType">
+ <attribute name="specialNeed" type="string" use="required"></attribute>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema> \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests/data/substGroup_2.4/ChildrenOnly.xml b/tests/org.eclipse.jet.tests/data/substGroup_2.4/ChildrenOnly.xml
new file mode 100644
index 0000000..c806657
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/substGroup_2.4/ChildrenOnly.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<tns:topElement xmlns:tns="http://www.example.org/XMLSchemaWithGroups" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.org/XMLSchemaWithGroups XMLSchemaWithGroups.xsd ">
+ <tns:child name="Francis"/>
+ <tns:child name="Jason"/>
+</tns:topElement>
diff --git a/tests/org.eclipse.jet.tests/data/substGroup_2.4/MixedChildren.xml b/tests/org.eclipse.jet.tests/data/substGroup_2.4/MixedChildren.xml
new file mode 100644
index 0000000..bd715e9
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/substGroup_2.4/MixedChildren.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<tns:topElement xmlns:tns="http://www.example.org/XMLSchemaWithGroups" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.org/XMLSchemaWithGroups XMLSchemaWithGroups.xsd ">
+ <tns:child name="James"/>
+ <tns:specialChild name="Harry" specialNeed="Lots of Action"/>
+ <tns:child name="Lilly"/>
+ <tns:specialChild name="Dudley" specialNeed="Lots of Candy"/>
+</tns:topElement>
diff --git a/tests/org.eclipse.jet.tests/data/substGroup_2.4/SpecialChildrenOnly.xml b/tests/org.eclipse.jet.tests/data/substGroup_2.4/SpecialChildrenOnly.xml
new file mode 100644
index 0000000..36aa2ef
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/substGroup_2.4/SpecialChildrenOnly.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<tns:topElement xmlns:tns="http://www.example.org/XMLSchemaWithGroups" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.org/XMLSchemaWithGroups XMLSchemaWithGroups.xsd ">
+ <tns:specialChild name="Jim" specialNeed="Lots of Food"/>
+ <tns:specialChild name="Bob" specialNeed="Lots of TV"/>
+</tns:topElement>
diff --git a/tests/org.eclipse.jet.tests/data/substGroup_2.4/XMLSchemaWithGroups.xsd b/tests/org.eclipse.jet.tests/data/substGroup_2.4/XMLSchemaWithGroups.xsd
new file mode 100644
index 0000000..b07e459
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/substGroup_2.4/XMLSchemaWithGroups.xsd
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/XMLSchemaWithGroups" xmlns:tns="http://www.example.org/XMLSchemaWithGroups" elementFormDefault="qualified"
+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
+ ecore:ignoreSubstitutionGroups="true">
+
+ <element name="topElement">
+ <complexType>
+ <sequence>
+ <element ref="tns:child" maxOccurs="unbounded" minOccurs="0"></element>
+ </sequence>
+ </complexType>
+ </element>
+
+
+
+ <element name="child" type="tns:childComplexType">
+ </element>
+
+ <element name="specialChild" type="tns:SpecialChildComplexType" substitutionGroup="tns:child"></element>
+ <complexType name="childComplexType">
+ <sequence>
+ <element name="hobby" maxOccurs="unbounded" minOccurs="0">
+ <complexType>
+ <attribute name="type" type="string" use="required"></attribute>
+ </complexType>
+ </element>
+ </sequence>
+ <attribute use="required" name="name" type="string"></attribute>
+ </complexType>
+
+ <complexType name="SpecialChildComplexType">
+ <complexContent>
+ <extension base="tns:childComplexType">
+ <attribute name="specialNeed" type="string" use="required"></attribute>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema> \ No newline at end of file
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 6445e93..c1fd966 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
@@ -10,6 +10,7 @@ public class AllTests {
TestSuite suite = new TestSuite("Test for org.eclipse.jet.tests");
suite.addTest(org.eclipse.jet.tests.compiler.AllTests.suite());
suite.addTest(org.eclipse.jet.tests.xpath.AllTests.suite());
+ suite.addTest(org.eclipse.jet.tests.xpath.inspectors.AllTests.suite());
suite.addTest(org.eclipse.jet.tests.xpath.functions.extras.AllTests.suite());
suite.addTest(org.eclipse.jet.tests.model.load.AllTests.suite());
suite.addTest(org.eclipse.jet.tests.taglib.AllTests.suite());
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/inspectors/AbstractSubstitutionGroupTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/inspectors/AbstractSubstitutionGroupTests.java
new file mode 100644
index 0000000..9427616
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/inspectors/AbstractSubstitutionGroupTests.java
@@ -0,0 +1,128 @@
+package org.eclipse.jet.tests.xpath.inspectors;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collection;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jet.runtime.model.IModelLoader;
+import org.eclipse.jet.xpath.XPath;
+import org.eclipse.jet.xpath.XPathException;
+import org.eclipse.jet.xpath.XPathExpression;
+import org.eclipse.jet.xpath.XPathFactory;
+import org.eclipse.jet.xpath.XPathUtil;
+
+public abstract class AbstractSubstitutionGroupTests extends TestCase {
+
+ private final XPath xpathEngine = XPathFactory.newInstance().newXPath(null);
+
+ public AbstractSubstitutionGroupTests() {
+ super();
+ }
+
+ protected abstract URL getPluginURL() throws MalformedURLException;
+
+ protected abstract String getTestDataFolder();
+
+ protected abstract IModelLoader getModelLoader();
+
+ public AbstractSubstitutionGroupTests(String name) {
+ super(name);
+ }
+
+ public void testHeadElementOnly() throws XPathException, IOException {
+ final Object documentRoot = loadEMFXML("ChildrenOnly.xml");
+
+ final String xpath = "/topElement/child";
+
+ final XPathExpression compiledXPath = xpathEngine.compile(xpath);
+
+ Collection result = compiledXPath.evaluateAsNodeSet(documentRoot);
+
+ assertEquals("result.size()", 2, result.size());
+ Object[] resultArray = result.toArray();
+
+ assertEquals("result[0]/@name", "Francis", getXPath(resultArray[0], "@name"));
+ assertEquals("result[1]/@name", "Jason", getXPath(resultArray[1], "@name"));
+ }
+
+ public void testMixedChildren_child() throws XPathException, IOException {
+ final Object documentRoot = loadEMFXML("MixedChildren.xml");
+
+ final String xpath = "/topElement/child";
+
+ final XPathExpression compiledXPath = xpathEngine.compile(xpath);
+
+ Collection result = compiledXPath.evaluateAsNodeSet(documentRoot);
+
+ assertEquals("result.size()", 2, result.size());
+ Object[] resultArray = result.toArray();
+
+ assertEquals("result[0]/@name", "James", getXPath(resultArray[0], "@name"));
+ assertEquals("result[1]/@name", "Lilly", getXPath(resultArray[1], "@name"));
+ }
+
+ public void testMixedChildren_specialChild() throws XPathException,
+ IOException {
+ final Object documentRoot = loadEMFXML("MixedChildren.xml");
+
+ final String xpath = "/topElement/specialChild";
+
+ final XPathExpression compiledXPath = xpathEngine.compile(xpath);
+
+ Collection result = compiledXPath.evaluateAsNodeSet(documentRoot);
+
+ assertEquals("result.size()", 2, result.size());
+ Object[] resultArray = result.toArray();
+
+ assertEquals("result[0]/@name", "Harry", getXPath(resultArray[0], "@name"));
+ assertEquals("result[1]/@name", "Dudley", getXPath(resultArray[1], "@name"));
+ }
+
+ public void testMixedChildren_schema_element_child() throws XPathException,
+ IOException {
+ final Object documentRoot = loadEMFXML("MixedChildren.xml");
+
+ final String xpath = "/topElement/_schema-element_child";
+
+ final XPathExpression compiledXPath = xpathEngine.compile(xpath);
+
+ Collection result = compiledXPath.evaluateAsNodeSet(documentRoot);
+
+ assertEquals("result.size()", 4, result.size());
+ Object[] resultArray = result.toArray();
+
+ assertEquals("result[0]/@name", "James", getXPath(resultArray[0], "@name"));
+ assertEquals("result[1]/@name", "Harry", getXPath(resultArray[1], "@name"));
+ assertEquals("result[0]/@name", "Lilly", getXPath(resultArray[2], "@name"));
+ assertEquals("result[1]/@name", "Dudley", getXPath(resultArray[3], "@name"));
+ }
+
+ public void testSpecialChildrenOnly() throws XPathException, IOException {
+ final Object documentRoot = loadEMFXML("SpecialChildrenOnly.xml");
+
+ final String xpath = "/topElement/child";
+
+ final XPathExpression compiledXPath = xpathEngine.compile(xpath);
+
+ Collection result = compiledXPath.evaluateAsNodeSet(documentRoot);
+
+ assertEquals("result.size()", 0, result.size());
+ }
+
+ private String getXPath(Object contextObject, String expression) throws XPathException {
+ final XPathExpression compiledExpression = xpathEngine.compile(expression);
+ return XPathUtil.xpathString(compiledExpression.evaluate(contextObject));
+ }
+
+ private Object loadEMFXML(String pluginRelativePath) throws IOException {
+ final IModelLoader loader = getModelLoader();
+ final URL baseURL = getPluginURL();
+ final URL resourceURL = new URL(baseURL, getTestDataFolder() + pluginRelativePath);
+ return loader.load(resourceURL);
+
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/inspectors/AllTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/inspectors/AllTests.java
new file mode 100644
index 0000000..7cb6e9c
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/inspectors/AllTests.java
@@ -0,0 +1,18 @@
+package org.eclipse.jet.tests.xpath.inspectors;
+
+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.xpath.inspectors");
+ //$JUnit-BEGIN$
+ suite.addTestSuite(EMFXML24SubstitutionGroupTests.class);
+ suite.addTestSuite(LegacyEMFXMLSubstitutionGroupTests.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/inspectors/EMFXML24SubstitutionGroupTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/inspectors/EMFXML24SubstitutionGroupTests.java
new file mode 100644
index 0000000..48c5ddb
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/inspectors/EMFXML24SubstitutionGroupTests.java
@@ -0,0 +1,40 @@
+/**
+ *
+ */
+package org.eclipse.jet.tests.xpath.inspectors;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.jet.internal.runtime.model.EMFXMLModelLoader;
+import org.eclipse.jet.runtime.model.IModelLoader;
+
+/**
+ * Perform substitution group tests using EMF 2.4 style schemas
+ *
+ */
+public class EMFXML24SubstitutionGroupTests extends
+ AbstractSubstitutionGroupTests {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jet.tests.xpath.inspectors.AbstractSubstitutionGroupTests#getModelLoader()
+ */
+ protected IModelLoader getModelLoader() {
+ return new EMFXMLModelLoader();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jet.tests.xpath.inspectors.AbstractSubstitutionGroupTests#getPluginURL()
+ */
+ protected URL getPluginURL() throws MalformedURLException {
+ return new URL("platform:/plugin/org.eclipse.jet.tests/");
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jet.tests.xpath.inspectors.AbstractSubstitutionGroupTests#getTestDataFolder()
+ */
+ protected String getTestDataFolder() {
+ return "data/substGroup_2.4/";
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/inspectors/LegacyEMFXMLSubstitutionGroupTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/inspectors/LegacyEMFXMLSubstitutionGroupTests.java
new file mode 100644
index 0000000..ec289fe
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/inspectors/LegacyEMFXMLSubstitutionGroupTests.java
@@ -0,0 +1,28 @@
+package org.eclipse.jet.tests.xpath.inspectors;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+
+import org.eclipse.jet.internal.runtime.model.EMFXMLModelLoader;
+import org.eclipse.jet.runtime.model.IModelLoader;
+
+/**
+ * Perform substitution group tests using legacy (pre EMF 2.4) substitution groups
+ *
+ */
+public class LegacyEMFXMLSubstitutionGroupTests extends AbstractSubstitutionGroupTests {
+
+ protected IModelLoader getModelLoader() {
+ return new EMFXMLModelLoader();
+ }
+
+ protected String getTestDataFolder() {
+ return "data/substGroup/";
+ }
+
+ protected URL getPluginURL() throws MalformedURLException {
+ return new URL("platform:/plugin/org.eclipse.jet.tests/");
+ }
+
+}

Back to the top