Skip to main content
summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorpelder2006-03-16 10:18:40 -0500
committerpelder2006-03-16 10:18:40 -0500
commit0d883910a16b7cb69561d7b18bf30f3cc686d5eb (patch)
tree990f2737416ff0d03c7a2d39346ac3b8b6d798fe /tests
parent8708c10a73accc0cea9592fc541831660c66c960 (diff)
downloadorg.eclipse.jet-0d883910a16b7cb69561d7b18bf30f3cc686d5eb.tar.gz
org.eclipse.jet-0d883910a16b7cb69561d7b18bf30f3cc686d5eb.tar.xz
org.eclipse.jet-0d883910a16b7cb69561d7b18bf30f3cc686d5eb.zip
[132167] Add, implement and consume new INodeInspector method 'testExpandedName'.
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/AllTests.java34
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/EObjectInspectorTests.java48
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/SelfStepTests.java117
3 files changed, 182 insertions, 17 deletions
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 de9fbff..1dbb92a 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
@@ -6,33 +6,33 @@ import junit.framework.TestSuite;
public class AllTests {
public static Test suite() {
- TestSuite suite = new TestSuite(
- "Test for org.eclipse.jet.tests.xpath");
+ TestSuite suite = new TestSuite("Test for org.eclipse.jet.tests.xpath");
//$JUnit-BEGIN$
- suite.addTestSuite(StringFunctionTests.class);
suite.addTestSuite(AttributeStepTests.class);
- suite.addTestSuite(RelOpTests.class);
- suite.addTestSuite(BooleanFunctionTests.class);
- suite.addTestSuite(BuiltinStringFunctionsTests.class);
+ suite.addTestSuite(XPathOverDOMTests.class);
+ suite.addTestSuite(StringFunctionTests.class);
+ suite.addTestSuite(ResourceInspectorTests.class);
suite.addTestSuite(XPathOverEmfXmlXsdTests.class);
- suite.addTestSuite(EStructuralFeatureSettingTests.class);
+ suite.addTestSuite(BooleanFunctionTests.class);
+ suite.addTestSuite(RelOpTests.class);
suite.addTestSuite(XPathParserTests.class);
- suite.addTestSuite(ChildStepTests.class);
- suite.addTestSuite(XPathInspectorManagerTests.class);
+ suite.addTestSuite(ExpandedNameTests.class);
+ suite.addTestSuite(XPathTokenScannerTests.class);
suite.addTestSuite(NumberFunctionTests.class);
+ suite.addTestSuite(NumberBinaryOpTests.class);
+ suite.addTestSuite(SelfStepTests.class);
+ suite.addTestSuite(BuiltinStringFunctionsTests.class);
+ suite.addTestSuite(XPathInspectorManagerTests.class);
+ suite.addTestSuite(EObjectInspectorTests.class);
suite.addTestSuite(DOMInspectorTests.class);
- suite.addTestSuite(XPathOverDOMTests.class);
suite.addTestSuite(LogicalOpTests.class);
- suite.addTestSuite(ParentStepTests.class);
- suite.addTestSuite(XPathTokenScannerTests.class);
- suite.addTestSuite(ExpandedNameTests.class);
- suite.addTestSuite(EObjectInspectorTests.class);
suite.addTestSuite(XPathOverEcoreTests.class);
- suite.addTestSuite(VariableTests.class);
+ suite.addTestSuite(EStructuralFeatureSettingTests.class);
+ suite.addTestSuite(ChildStepTests.class);
+ suite.addTestSuite(ParentStepTests.class);
suite.addTestSuite(RootTests.class);
- suite.addTestSuite(ResourceInspectorTests.class);
- suite.addTestSuite(NumberBinaryOpTests.class);
suite.addTestSuite(XPathParserDefects.class);
+ suite.addTestSuite(VariableTests.class);
//$JUnit-END$
return suite;
}
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 f462be8..227bc57 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
@@ -851,4 +851,52 @@ public class EObjectInspectorTests extends TestCase {
assertEquals(1, namedChildren.length);
assertEquals("Hello Bob!", inspector.stringValueOf(namedChildren[0]));
}
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.expandedNameOf(Object)'
+ */
+ public void testTestExpandedName_emf() {
+ ExpandedName enEmfRootContents = new ExpandedName("contents");
+ assertTrue("root contents", inspector.testExpandedName(emfRoot, enEmfRootContents));
+ ExpandedName enEmfRootEmployee = new ExpandedName("Employee");
+ assertTrue("root Employee", inspector.testExpandedName(emfRoot, enEmfRootEmployee));
+
+ Object employee = ((Employee)emfRoot).getCustomers().get(0);
+ ExpandedName enCustomers = new ExpandedName("customers");
+ assertTrue("employee/customers", inspector.testExpandedName(employee, enCustomers));
+ ExpandedName enCustomer = new ExpandedName("Customer");
+ assertTrue("employee /Customer", inspector.testExpandedName(employee, enCustomer));
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.expandedNameOf(Object)'
+ */
+ public void testTestExpandedName_xml() {
+ ExpandedName enRoot = new ExpandedName("root");
+ assertTrue("root /root", inspector.testExpandedName(xmlRootElement, enRoot));
+
+ ExpandedName enAny = new ExpandedName("Any");
+ assertFalse("root /Any", inspector.testExpandedName(xmlRootElement, enAny));
+
+// final Object value = xmlRootElement.getAny().getValue(0);
+ final Object elementA = Bug130552Workaround.getValue(xmlRootElement.getAny(), 0);
+
+
+ ExpandedName enA = new ExpandedName("a");
+ assertTrue("a /a", inspector.testExpandedName(elementA, enA));
+
+ assertFalse("a /Any", inspector.testExpandedName(elementA, enAny));
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.expandedNameOf(Object)'
+ */
+ public void testTestExpandedName_xsd() {
+ ExpandedName enRoot = new ExpandedName("http://www.example.org/beans", "root");
+ assertTrue("root /root", inspector.testExpandedName(xsdRootElement, enRoot));
+
+ final Object elementProject = xsdRootElement.eContents().get(0);
+ ExpandedName enProject = new ExpandedName("project");
+ assertTrue("project /project", inspector.testExpandedName(elementProject, enProject));
+ }
}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/SelfStepTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/SelfStepTests.java
new file mode 100644
index 0000000..951bca9
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/SelfStepTests.java
@@ -0,0 +1,117 @@
+package org.eclipse.jet.tests.xpath;
+
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.Resource.Factory;
+import org.eclipse.jet.internal.xpath.ast.Axis;
+import org.eclipse.jet.internal.xpath.ast.ContextNode;
+import org.eclipse.jet.internal.xpath.ast.NodeTest;
+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;
+
+public class SelfStepTests extends TestCase {
+
+ protected Resource emfResource;
+ protected EObject emfRoot;
+ protected EObject emfCustomer;
+
+ protected void emfSetUp() throws Exception {
+
+ URI fileURI = URI.createURI("platform:/plugin/org.eclipse.jet.tests/data/sample.dataaccess");
+ Factory factory = Resource.Factory.Registry.INSTANCE.getFactory(fileURI);
+
+ emfResource = factory.createResource(fileURI);
+ emfResource.load(null);
+
+ emfRoot = (EObject) emfResource.getContents().get(0);
+
+ emfCustomer = (EObject) emfRoot.eContents().get(0);
+
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ emfSetUp();
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.ast.Step.evalAsNodeSet(Context)'
+ */
+ public void testEvalAsNodeSet_root_element_contents() {
+ Step stepExpr = new Step(new ContextNode(),
+ Axis.selfAxis(),
+ NodeTest.nameTest(NodeKind.ELEMENT, new ExpandedName("contents")));
+
+ Context context = new Context(emfRoot, null);
+
+ Set resultSet = stepExpr.evalAsNodeSet(context);
+
+ assertNotNull(resultSet);
+ assertEquals(1, resultSet.size());
+ assertTrue(resultSet.contains(emfRoot));
+
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.ast.Step.evalAsNodeSet(Context)'
+ */
+ public void testEvalAsNodeSet_root_element_Employee() {
+ Step stepExpr = new Step(new ContextNode(),
+ Axis.selfAxis(),
+ NodeTest.nameTest(NodeKind.ELEMENT, new ExpandedName("Employee")));
+
+ Context context = new Context(emfRoot, null);
+
+ Set resultSet = stepExpr.evalAsNodeSet(context);
+
+ assertNotNull(resultSet);
+ assertEquals(1, resultSet.size());
+ assertTrue(resultSet.contains(emfRoot));
+
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.ast.Step.evalAsNodeSet(Context)'
+ */
+ public void testEvalAsNodeSet_customer_element_customers() {
+ Step stepExpr = new Step(new ContextNode(),
+ Axis.selfAxis(),
+ NodeTest.nameTest(NodeKind.ELEMENT, new ExpandedName("customers")));
+
+ Context context = new Context(emfCustomer, null);
+
+ Set resultSet = stepExpr.evalAsNodeSet(context);
+
+ assertNotNull(resultSet);
+ assertEquals(1, resultSet.size());
+ assertTrue(resultSet.contains(emfCustomer));
+
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.ast.Step.evalAsNodeSet(Context)'
+ */
+ public void testEvalAsNodeSet_customer_element_Customer() {
+ Step stepExpr = new Step(new ContextNode(),
+ Axis.selfAxis(),
+ NodeTest.nameTest(NodeKind.ELEMENT, new ExpandedName("Customer")));
+
+ Context context = new Context(emfCustomer, null);
+
+ Set resultSet = stepExpr.evalAsNodeSet(context);
+
+ assertNotNull(resultSet);
+ assertEquals(1, resultSet.size());
+ assertTrue(resultSet.contains(emfCustomer));
+
+ }
+
+}

Back to the top