You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2013/10/12 22:53:01 UTC
svn commit: r1531593 - in
/webservices/axiom/trunk/systests/eclipse-tests/src/it/project:
META-INF/MANIFEST.MF src/PsychoPathTest.java src/test.xml
Author: veithen
Date: Sat Oct 12 20:53:01 2013
New Revision: 1531593
URL: http://svn.apache.org/r1531593
Log:
AXIOM-367: Added some test cases for PsychoPath. One test case works, the other doesn't (because Node#compareDocumentPosition is not implemented).
Added:
webservices/axiom/trunk/systests/eclipse-tests/src/it/project/src/PsychoPathTest.java (with props)
webservices/axiom/trunk/systests/eclipse-tests/src/it/project/src/test.xml (with props)
Modified:
webservices/axiom/trunk/systests/eclipse-tests/src/it/project/META-INF/MANIFEST.MF
Modified: webservices/axiom/trunk/systests/eclipse-tests/src/it/project/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/systests/eclipse-tests/src/it/project/META-INF/MANIFEST.MF?rev=1531593&r1=1531592&r2=1531593&view=diff
==============================================================================
--- webservices/axiom/trunk/systests/eclipse-tests/src/it/project/META-INF/MANIFEST.MF (original)
+++ webservices/axiom/trunk/systests/eclipse-tests/src/it/project/META-INF/MANIFEST.MF Sat Oct 12 20:53:01 2013
@@ -4,5 +4,8 @@ Bundle-SymbolicName: eclipse-tests-proje
Bundle-Version: 0.0.0
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.apache.axiom.om,
- org.apache.axiom.om.dom
+ org.apache.axiom.om.dom,
+ org.eclipse.wst.xml.xpath2.api,
+ org.eclipse.wst.xml.xpath2.processor,
+ org.eclipse.wst.xml.xpath2.processor.util
Require-Bundle: org.junit;bundle-version="[4.0.0,5.0.0)"
Added: webservices/axiom/trunk/systests/eclipse-tests/src/it/project/src/PsychoPathTest.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/systests/eclipse-tests/src/it/project/src/PsychoPathTest.java?rev=1531593&view=auto
==============================================================================
--- webservices/axiom/trunk/systests/eclipse-tests/src/it/project/src/PsychoPathTest.java (added)
+++ webservices/axiom/trunk/systests/eclipse-tests/src/it/project/src/PsychoPathTest.java Sat Oct 12 20:53:01 2013
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import static org.junit.Assert.assertEquals;
+
+import java.io.InputStream;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.eclipse.wst.xml.xpath2.api.ResultSequence;
+import org.eclipse.wst.xml.xpath2.api.XPath2Expression;
+import org.eclipse.wst.xml.xpath2.processor.Engine;
+import org.eclipse.wst.xml.xpath2.processor.util.DynamicContextBuilder;
+import org.eclipse.wst.xml.xpath2.processor.util.StaticContextBuilder;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.w3c.dom.Document;
+
+/**
+ * Tests that Axiom's DOM implementation is interoperable with the PsychoPath XPath 2.0 processor.
+ */
+// Note: This test is placed here because PsychoPath is not available from Maven central, but only
+// from the Eclipse P2 repositories.
+public class PsychoPathTest {
+ private static ResultSequence evaluate(String xpath) throws Exception {
+ InputStream is = PsychoPathTest.class.getResourceAsStream("test.xml");
+ try {
+ OMFactory factory = OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM).getOMFactory();
+ Document doc = (Document)OMXMLBuilderFactory.createOMBuilder(factory, is).getDocument();
+ StaticContextBuilder scb = new StaticContextBuilder();
+ XPath2Expression expr = new Engine().parseExpression(xpath, scb);
+ return expr.evaluate(new DynamicContextBuilder(scb), new Object[] { doc });
+ } finally {
+ is.close();
+ }
+ }
+
+ @Test
+ public void testSingleNodeResult() throws Exception {
+ ResultSequence rs = evaluate("/Persons/Person[1]/Name");
+ assertEquals(1, rs.size());
+ assertEquals("Albert Einstein", rs.item(0).getStringValue());
+ }
+
+ @Ignore // TODO: doesn't work yet because Node#compareDocumentPosition is not implemented
+ @Test
+ public void testNodeSetResult() throws Exception {
+ ResultSequence rs = evaluate("/Persons/Person[BirthYear='1664']/Name");
+ assertEquals(2, rs.size());
+ assertEquals("Jean Meslier", rs.item(0).getStringValue());
+ assertEquals("Andreas Schlter", rs.item(1).getStringValue());
+ }
+}
Propchange: webservices/axiom/trunk/systests/eclipse-tests/src/it/project/src/PsychoPathTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/axiom/trunk/systests/eclipse-tests/src/it/project/src/test.xml
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/systests/eclipse-tests/src/it/project/src/test.xml?rev=1531593&view=auto
==============================================================================
--- webservices/axiom/trunk/systests/eclipse-tests/src/it/project/src/test.xml (added)
+++ webservices/axiom/trunk/systests/eclipse-tests/src/it/project/src/test.xml Sat Oct 12 20:53:01 2013
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<Persons>
+ <Person>
+ <Name>Albert Einstein</Name>
+ <BirthYear>1879</BirthYear>
+ </Person>
+ <Person>
+ <Name>Jean Meslier</Name>
+ <BirthYear>1664</BirthYear>
+ </Person>
+ <Person>
+ <Name>Andreas Schlüter</Name>
+ <BirthYear>1664</BirthYear>
+ </Person>
+</Persons>
Propchange: webservices/axiom/trunk/systests/eclipse-tests/src/it/project/src/test.xml
------------------------------------------------------------------------------
svn:eol-style = native