Author: antelder
Date: Sun Oct 28 05:58:36 2007
New Revision: 589346
URL: http://svn.apache.org/viewvc?rev=589346&view=rev
Log:
Add a test for using Rhino 1.6R7 with the Axiom E4X impl
Added:
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/ (with props)
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/.classpath
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/.project
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/.settings/
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/.settings/org.eclipse.jdt.core.prefs
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/pom.xml (with props)
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/main/
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/main/java/
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/main/resources/
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/java/
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/java/org/
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/java/org/apache/
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/java/org/apache/bsf/
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/java/org/apache/bsf/testing/
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/java/org/apache/bsf/testing/e4x/
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/java/org/apache/bsf/testing/e4x/HelloTestCase.java
(with props)
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/java/org/mozilla/
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/java/org/mozilla/javascript/
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/java/org/mozilla/javascript/ContextHelper.java
(with props)
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/resources/
Propchange: jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Oct 28 05:58:36 2007
@@ -0,0 +1,4 @@
+target
+.project
+.classpath
+.settings
Added: jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/.classpath
URL:
http://svn.apache.org/viewvc/jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/.classpath?rev=589346&view=auto
==============================================================================
--- jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/.classpath (added)
+++ jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/.classpath Sun Oct 28
05:58:36 2007
@@ -0,0 +1,23 @@
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
+ <classpathentry kind="src" path="src/test/java"
output="target/test-classes"/>
+ <classpathentry kind="src" path="src/test/resources"
output="target/test-classes" excluding="**/*.java"/>
+ <classpathentry kind="output" path="target/classes"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var"
path="M2_REPO/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.jar"/>
+ <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/org/apache/ws/commons/axiom/axiom-api/1.2.5/axiom-api-1.2.5.jar"/>
+ <classpathentry kind="var" path="M2_REPO/rhino/js/1.6R7/js-1.6R7.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/stax/stax-api/1.0.1/stax-api-1.0.1.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/org/wso2/wsf/javascript/axiom-e4x/0.29/axiom-e4x-0.29.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/org/apache/bsf/bsf-all/3.0-SNAPSHOT/bsf-all-3.0-SNAPSHOT.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/javax/activation/activation/1.1/activation-1.1.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/org/apache/ws/commons/axiom/axiom-impl/1.2.5/axiom-impl-1.2.5.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/xerces/xercesImpl/2.6.2/xercesImpl-2.6.2.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/woodstox/wstx-asl/3.1.0/wstx-asl-3.1.0.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/xml-apis/xml-apis/1.3.03/xml-apis-1.3.03.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/jaxen/jaxen/1.1-beta-9/jaxen-1.1-beta-9.jar"/>
+ <classpathentry kind="var" path="M2_REPO/javax/mail/mail/1.4/mail-1.4.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/org/mozilla/rhino/js-core/1.6R7/js-core-1.6R7.jar"/>
+</classpath>
\ No newline at end of file
Added: jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/.project
URL:
http://svn.apache.org/viewvc/jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/.project?rev=589346&view=auto
==============================================================================
--- jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/.project (added)
+++ jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/.project Sun Oct 28 05:58:36
2007
@@ -0,0 +1,13 @@
+<projectDescription>
+ <name>bsf-testing-e4x-1.6R7-Axiom</name>
+ <comment>Apache BSF testing for JavaScript/E4X with Rhino 1.6R7 uing Axiom
E4X impl</comment>
+ <projects/>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
\ No newline at end of file
Added:
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/.settings/org.eclipse.jdt.core.prefs
URL:
http://svn.apache.org/viewvc/jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/.settings/org.eclipse.jdt.core.prefs?rev=589346&view=auto
==============================================================================
---
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/.settings/org.eclipse.jdt.core.prefs
(added)
+++
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/.settings/org.eclipse.jdt.core.prefs
Sun Oct 28 05:58:36 2007
@@ -0,0 +1,5 @@
+#Sun Oct 28 11:54:21 GMT 2007
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.source=1.4
+org.eclipse.jdt.core.compiler.compliance=1.4
Added: jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/pom.xml
URL:
http://svn.apache.org/viewvc/jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/pom.xml?rev=589346&view=auto
==============================================================================
--- jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/pom.xml (added)
+++ jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/pom.xml Sun Oct 28 05:58:36
2007
@@ -0,0 +1,99 @@
+<?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.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.bsf</groupId>
+ <artifactId>parent</artifactId>
+ <version>3.0-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <packaging>jar</packaging>
+ <groupId>org.apache.bsf.testing</groupId>
+ <artifactId>bsf-testing-e4x-1.6R7-Axiom</artifactId>
+ <name>Apache BSF testing for JavaScript/E4X 1.6R7 Axiom</name>
+ <description>Apache BSF testing for JavaScript/E4X with Rhino 1.6R7 uing
Axiom E4X impl</description>
+
+ <repositories>
+ <!-- This is for the WSO2 E4X impl -->
+ <repository>
+ <id>wso2</id>
+ <url>http://dist.wso2.org/maven2/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.bsf</groupId>
+ <artifactId>bsf-all</artifactId>
+ <version>3.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>rhino</groupId>
+ <artifactId>js</artifactId>
+ <version>1.6R7</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-api</artifactId>
+ <version>1.2.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-impl</artifactId>
+ <version>1.2.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.wso2.wsf.javascript</groupId>
+ <artifactId>axiom-e4x</artifactId>
+ <version>0.29</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-impl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>rhino</groupId>
+ <artifactId>js-core</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
Propchange: jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/pom.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added:
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/java/org/apache/bsf/testing/e4x/HelloTestCase.java
URL:
http://svn.apache.org/viewvc/jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/java/org/apache/bsf/testing/e4x/HelloTestCase.java?rev=589346&view=auto
==============================================================================
---
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/java/org/apache/bsf/testing/e4x/HelloTestCase.java
(added)
+++
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/java/org/apache/bsf/testing/e4x/HelloTestCase.java
Sun Oct 28 05:58:36 2007
@@ -0,0 +1,101 @@
+/*
+ * 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.
+ */
+package org.apache.bsf.testing.e4x;
+
+import java.io.StringReader;
+
+import javax.script.Bindings;
+import javax.script.Invocable;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.bsf.xml.XMLHelper;
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.ContextHelper;
+
+/**
+ * Tests a basic JavaScrip/E4X invocation
+ */
+public class HelloTestCase extends TestCase {
+
+ private XMLHelper xmlHelper;
+ private ScriptEngine engine;
+
+ public void testInvokeFunctionInXML() throws ScriptException,
XMLStreamException, FactoryConfigurationError, NoSuchMethodException {
+ engine.eval("function isXML(xml) { return typeof xml == 'xml';
}" );
+ assertTrue(engine instanceof Invocable);
+ Invocable invocableScript = (Invocable) engine;
+
+ Object xmlIn =
xmlHelper.toScriptXML(createOMElement("<a><b>petra</b></a>"));
+
+ Object o = invocableScript.invokeFunction("isXML", new
Object[]{xmlIn});
+ assertTrue(o instanceof Boolean);
+ assertTrue(((Boolean)o).booleanValue());
+ }
+
+ public void testInvokeFunctionOutXML() throws ScriptException,
XMLStreamException, FactoryConfigurationError, NoSuchMethodException {
+ engine.eval("function hello(xml) { return <foo>{xml.b}</foo>;
}" );
+ assertTrue(engine instanceof Invocable);
+ Invocable invocableScript = (Invocable) engine;
+
+ Object xmlIn =
xmlHelper.toScriptXML(createOMElement("<a><b>petra</b></a>"));
+
+ Object xmlOut = invocableScript.invokeFunction("hello", new
Object[]{xmlIn});
+ OMElement omOut = xmlHelper.toOMElement(xmlOut);
+ assertEquals("<foo><b>petra</b></foo>", omOut.toString());
+ }
+
+ public void testE4X() throws ScriptException, XMLStreamException,
FactoryConfigurationError {
+ Object o =
xmlHelper.toScriptXML(createOMElement("<a><b>petra</b></a>"));
+ OMElement om = xmlHelper.toOMElement(o);
+ assertEquals("<a><b>petra</b></a>", om.toString());
+
+ Bindings bindings = engine.createBindings();
+ bindings.put("o", o);
+ Object x = engine.eval("typeof o", bindings);
+ assertEquals("xml", x);
+ }
+
+ protected OMElement createOMElement(String s) throws
XMLStreamException, FactoryConfigurationError {
+ XMLStreamReader parser =
XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(s));
+ StAXOMBuilder builder = new StAXOMBuilder(parser);
+ OMElement om = builder.getDocumentElement();
+ return om;
+ }
+
+ protected void setUp() {
+ engine = new ScriptEngineManager().getEngineByExtension("js");
+ xmlHelper = XMLHelper.getArgHelper(engine);
+ Context cx = Context.enter();
+ ContextHelper.setTopCallScope(cx, cx.initStandardObjects());
+ }
+
+ protected void tearDown() {
+ Context.exit();
+ }
+}
Propchange:
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/java/org/apache/bsf/testing/e4x/HelloTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/java/org/apache/bsf/testing/e4x/HelloTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/java/org/mozilla/javascript/ContextHelper.java
URL:
http://svn.apache.org/viewvc/jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/java/org/mozilla/javascript/ContextHelper.java?rev=589346&view=auto
==============================================================================
---
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/java/org/mozilla/javascript/ContextHelper.java
(added)
+++
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/java/org/mozilla/javascript/ContextHelper.java
Sun Oct 28 05:58:36 2007
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+package org.mozilla.javascript;
+
+/**
+ * Hack to enable creating E4X XML from Axiom OMElements
+ * outside of a script invocation. To do this requires
+ * Context.topCallScope not be null, but outside of a script
+ * invocation it is null, hence this method to enable setting it.
+ * Could be a bug in the Axiom E4X impl as the XmlBeans impl
+ * does not require this.
+ */
+public class ContextHelper {
+
+ public static void setTopCallScope(Context cx, Scriptable scope) {
+ cx.topCallScope = scope;
+ }
+
+}
Propchange:
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/java/org/mozilla/javascript/ContextHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/java/org/mozilla/javascript/ContextHelper.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]