Merge trunk changes into beta2 branch

git-svn-id: https://svn.apache.org/repos/asf/jakarta/bsf/branches/bsf-3.0-beta2@591073 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bsf-api/src/main/java/javax/script/ScriptEngineManager.java b/bsf-api/src/main/java/javax/script/ScriptEngineManager.java
index 105f203..85b15a5 100644
--- a/bsf-api/src/main/java/javax/script/ScriptEngineManager.java
+++ b/bsf-api/src/main/java/javax/script/ScriptEngineManager.java
@@ -19,6 +19,7 @@
 
 package javax.script;
 
+import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -93,9 +94,25 @@
                 mimeTypeAssociations.put(data.get(i), factory);
             }            
         }
+        
+        initXMLHelper(loader);
     }
-	
+
     /**
+     * Initialise the xml helper here so BSF clients don't have to.
+     * (Temporary approach for beta2 release)
+     */
+    private void initXMLHelper(ClassLoader loader) {
+    	try {
+			Class xmlHelperClass = Class.forName("org.apache.bsf.xml.XMLHelper", true, loader);
+			Method initMethod = xmlHelperClass.getMethod("init", new Class[]{});
+			initMethod.invoke(null, new Object[]{});
+		} catch (Throwable e) {
+			// ignore
+		}
+	}
+
+	/**
      * Retrieves the associated value for the spefied key in the 
      * GLOBAL_SCOPE
      *  
diff --git a/bsf-utils/pom.xml b/bsf-utils/pom.xml
index b5e4813..041287a 100644
--- a/bsf-utils/pom.xml
+++ b/bsf-utils/pom.xml
@@ -72,7 +72,7 @@
         <dependency>
             <groupId>rhino</groupId>
             <artifactId>js</artifactId>
-            <version>1.6R5</version>
+            <version>1.6R6</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
diff --git a/bsf-utils/src/main/java/org/apache/bsf/xml/JavaScriptE4XAxiomHelper.java b/bsf-utils/src/main/java/org/apache/bsf/xml/JavaScriptE4XAxiomHelper.java
new file mode 100644
index 0000000..a1cbcc6
--- /dev/null
+++ b/bsf-utils/src/main/java/org/apache/bsf/xml/JavaScriptE4XAxiomHelper.java
@@ -0,0 +1,102 @@
+/*
+ * 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.xml;
+
+import javax.script.ScriptEngine;
+import javax.script.ScriptException;
+
+import org.apache.axiom.om.OMElement;
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.ContextFactory;
+import org.mozilla.javascript.ContextHelper;
+import org.mozilla.javascript.Scriptable;
+import org.mozilla.javascript.ScriptableObject;
+import org.mozilla.javascript.xml.XMLLib;
+import org.mozilla.javascript.xml.XMLObject;
+
+/**
+ * XMLHelper for JavaScript E4X using Axiom
+ */
+public class JavaScriptE4XAxiomHelper extends DefaultXMLHelper {
+
+	private Scriptable scope;
+
+    JavaScriptE4XAxiomHelper(ScriptEngine engine) {
+
+    	// tell Rhino to use Axiom E4X impl
+        if (!ContextFactory.hasExplicitGlobal()) {
+	     	ContextFactory.initGlobal(new AxiomE4XContextFactory());
+        }
+
+    	Context cx = Context.enter();
+	    try {
+
+	    	this.scope = cx.initStandardObjects();
+
+	    } finally {
+	        Context.exit();
+	    }
+	}
+
+	public OMElement toOMElement(Object scriptXML) throws ScriptException {
+        if (scriptXML == null) {
+        	return null;
+        }
+
+        if (!(scriptXML instanceof XMLObject)) {
+            return null;
+        }
+
+        Object o = ScriptableObject.callMethod( (Scriptable) scriptXML, "getXmlObject", new Object[0]);
+        return (OMElement) o;
+//        return (OMElement) ScriptableObject.callMethod( (Scriptable) scriptXML, "getXmlObject", new Object[0]);
+	}
+
+	public Object toScriptXML(OMElement om) throws ScriptException {
+        if (om == null) {
+        	return null;
+        }
+        Context cx = Context.enter();
+        try {
+
+        	// TODO: why is this needed? A bug in axiom-e4x?
+	      	ContextHelper.setTopCallScope(cx, scope);
+
+           return cx.newObject(scope, "XML", new Object[]{om});
+
+        } finally {
+            Context.exit();
+        }
+	}
+
+	public static void init() {
+	    ContextFactory.initGlobal(new AxiomE4XContextFactory());
+	}
+}
+
+class AxiomE4XContextFactory extends ContextFactory {
+
+    protected XMLLib.Factory getE4xImplementationFactory() {
+        return org.mozilla.javascript.xml.XMLLib.Factory.create(
+                "org.wso2.javascript.xmlimpl.XMLLibImpl"
+        );
+    }
+}
+
+
diff --git a/bsf-utils/src/main/java/org/apache/bsf/xml/JavaScriptE4XHelper.java b/bsf-utils/src/main/java/org/apache/bsf/xml/JavaScriptE4XHelper.java
index 84fc400..56123ef 100644
--- a/bsf-utils/src/main/java/org/apache/bsf/xml/JavaScriptE4XHelper.java
+++ b/bsf-utils/src/main/java/org/apache/bsf/xml/JavaScriptE4XHelper.java
@@ -19,99 +19,21 @@
 package org.apache.bsf.xml;
 
 import javax.script.ScriptEngine;
-import javax.script.ScriptException;
-import javax.xml.stream.XMLStreamException;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.xmlbeans.XmlObject;
-import org.mozilla.javascript.Context;
-import org.mozilla.javascript.Scriptable;
-import org.mozilla.javascript.ScriptableObject;
-import org.mozilla.javascript.Wrapper;
-import org.mozilla.javascript.xml.XMLObject;
 
 /**
  * XMLHelper for JavaScript E4X
  */
 public class JavaScriptE4XHelper extends DefaultXMLHelper {
 
-	private Scriptable scope;
+	public static XMLHelper getXMLHelper(ScriptEngine engine) {
 
-    private static boolean axiomE4XImpl = false;
-    static {
-        try {
-            Class.forName("org.mozilla.javascript.xmlimpl.AxiomNode");
-            axiomE4XImpl = true;
-        } catch (ClassNotFoundException ignore) {}
-    }
-
-    JavaScriptE4XHelper(ScriptEngine engine) {
-	    Context cx = Context.enter();
-	    try {
-	        this.scope = cx.initStandardObjects();
-	    } finally {
-	        Context.exit();
-	    }
-	}
-
-	public OMElement toOMElement(Object scriptXML) throws ScriptException {
-        if (scriptXML == null) {
-        	return null;
-        }
-
-        if (!(scriptXML instanceof XMLObject)) {
-            return null;
-        }
-
-        if (axiomE4XImpl) {
-            return (OMElement) ScriptableObject.callMethod(
-                (Scriptable) scriptXML, "getXmlObject", new Object[0]);
-
-        } else {
-            // TODO: E4X Bug? Shouldn't need this copy, but without it the outer element gets lost???
-            Scriptable jsXML =
-                (Scriptable) ScriptableObject.callMethod((Scriptable) scriptXML, "copy", new Object[0]);
-            Wrapper wrapper =
-                (Wrapper) ScriptableObject.callMethod((XMLObject)jsXML, "getXmlObject", new Object[0]);
-
-            XmlObject xmlObject = (XmlObject) wrapper.unwrap();
-
-            try {
-                StAXOMBuilder builder = new StAXOMBuilder(xmlObject.newInputStream());
-                return builder.getDocumentElement();
-
-            } catch (XMLStreamException e) {
-            	throw new ScriptException(e);
-            }
-        }
-	}
-
-	public Object toScriptXML(OMElement om) throws ScriptException {
-        if (om == null) {
-        	return null;
-        }
-        Context cx = Context.enter();
-        try {
-        	if (axiomE4XImpl) {
-
-        		return cx.newObject(scope, "XML", new Object[]{om});
-
-        	} else {
-
-        		XmlObject xml = null;
-                try {
-                    xml = XmlObject.Factory.parse(om.getXMLStreamReader());
-                } catch (Exception e) {
-                	throw new ScriptException(e);
-                }
-                Object wrappedXML = cx.getWrapFactory().wrap(cx, scope, xml, XmlObject.class);
-                return cx.newObject(scope, "XML", new Object[]{wrappedXML});
-
-        	}
-        } finally {
-            Context.exit();
-        }
+		try {
+			Class.forName("org.wso2.javascript.xmlimpl.XMLLibImpl", true, JavaScriptE4XHelper.class.getClassLoader());
+			return new JavaScriptE4XAxiomHelper(engine);
+		} catch (ClassNotFoundException e) {
+			// TODO: also support Rhino 1.6R7 DOM based E4X impl 
+			return new JavaScriptE4XXmlBeansHelper(engine);
+		}
 	}
 
 }
diff --git a/bsf-utils/src/main/java/org/apache/bsf/xml/JavaScriptE4XXmlBeansHelper.java b/bsf-utils/src/main/java/org/apache/bsf/xml/JavaScriptE4XXmlBeansHelper.java
new file mode 100644
index 0000000..7e9b9c1
--- /dev/null
+++ b/bsf-utils/src/main/java/org/apache/bsf/xml/JavaScriptE4XXmlBeansHelper.java
@@ -0,0 +1,97 @@
+/*
+ * 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.xml;
+
+import javax.script.ScriptEngine;
+import javax.script.ScriptException;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.xmlbeans.XmlObject;
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.Scriptable;
+import org.mozilla.javascript.ScriptableObject;
+import org.mozilla.javascript.Wrapper;
+import org.mozilla.javascript.xml.XMLObject;
+
+/**
+ * XMLHelper for JavaScript E4X using XmlBeans
+ */
+public class JavaScriptE4XXmlBeansHelper extends DefaultXMLHelper {
+
+	private Scriptable scope;
+
+    JavaScriptE4XXmlBeansHelper(ScriptEngine engine) {
+	    Context cx = Context.enter();
+	    try {
+	        this.scope = cx.initStandardObjects();
+	    } finally {
+	        Context.exit();
+	    }
+	}
+
+	public OMElement toOMElement(Object scriptXML) throws ScriptException {
+        if (scriptXML == null) {
+        	return null;
+        }
+
+        if (!(scriptXML instanceof XMLObject)) {
+            return null;
+        }
+
+        // TODO: E4X Bug? Shouldn't need this copy, but without it the outer element gets lost???
+        Scriptable jsXML =
+            (Scriptable) ScriptableObject.callMethod((Scriptable) scriptXML, "copy", new Object[0]);
+        Wrapper wrapper =
+            (Wrapper) ScriptableObject.callMethod((XMLObject)jsXML, "getXmlObject", new Object[0]);
+
+        XmlObject xmlObject = (XmlObject) wrapper.unwrap();
+
+        try {
+            StAXOMBuilder builder = new StAXOMBuilder(xmlObject.newInputStream());
+            return builder.getDocumentElement();
+
+        } catch (XMLStreamException e) {
+        	throw new ScriptException(e);
+        }
+	}
+
+	public Object toScriptXML(OMElement om) throws ScriptException {
+        if (om == null) {
+        	return null;
+        }
+        Context cx = Context.enter();
+        try {
+
+    		XmlObject xml = null;
+            try {
+                xml = XmlObject.Factory.parse(om.getXMLStreamReader());
+            } catch (Exception e) {
+            	throw new ScriptException(e);
+            }
+            Object wrappedXML = cx.getWrapFactory().wrap(cx, scope, xml, XmlObject.class);
+            return cx.newObject(scope, "XML", new Object[]{wrappedXML});
+
+        } finally {
+            Context.exit();
+        }
+	}
+
+}
diff --git a/bsf-utils/src/main/java/org/apache/bsf/xml/XMLHelper.java b/bsf-utils/src/main/java/org/apache/bsf/xml/XMLHelper.java
index 52c64a1..b95459d 100644
--- a/bsf-utils/src/main/java/org/apache/bsf/xml/XMLHelper.java
+++ b/bsf-utils/src/main/java/org/apache/bsf/xml/XMLHelper.java
@@ -32,21 +32,33 @@
  */
 public abstract class XMLHelper {
 
+	/**
+	 * Register axiom-e4x if its available
+	 * @deprecated temp approach for beta2 release
+	 */
+	public static void init() {
+		try {
+			Class.forName("org.wso2.javascript.xmlimpl.XMLLibImpl", true, JavaScriptE4XHelper.class.getClassLoader());
+			JavaScriptE4XAxiomHelper.init();
+		} catch (ClassNotFoundException e) {
+		}
+	}
+
 	public static XMLHelper getArgHelper(ScriptEngine engine) {
-		// TODO: better discovery mechanisim than hardcoded class names 
+		// TODO: better discovery mechanisim than hardcoded class names
 		if (engine == null) {
 			return null;
 		}
 		String language = engine.getFactory().getLanguageName();
 		if ("ECMAScript".endsWith(language)) {
-			return new JavaScriptE4XHelper(engine);
+			return JavaScriptE4XHelper.getXMLHelper(engine);
 		} else if ("ruby".endsWith(language)) {
 			return new JRubyReXMLHelper(engine);
 		} else {
 			return new DefaultXMLHelper();
 		}
 	}
-
+	
 	public abstract Object toScriptXML(OMElement om) throws ScriptException;
 	public abstract OMElement toOMElement(Object scriptXML) throws ScriptException;
 
diff --git a/bsf-utils/src/main/java/org/mozilla/javascript/ContextHelper.java b/bsf-utils/src/main/java/org/mozilla/javascript/ContextHelper.java
new file mode 100644
index 0000000..7d6231a
--- /dev/null
+++ b/bsf-utils/src/main/java/org/mozilla/javascript/ContextHelper.java
@@ -0,0 +1,37 @@
+/*
+ * 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) {
+		if (cx.topCallScope == null) {
+			cx.topCallScope = scope;
+		}
+	}
+
+}
diff --git a/testing/e4x-1.6R7-Axiom/pom.xml b/testing/e4x-1.6R7-Axiom/pom.xml
new file mode 100644
index 0000000..5e2536f
--- /dev/null
+++ b/testing/e4x-1.6R7-Axiom/pom.xml
@@ -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>
diff --git a/testing/e4x-1.6R7-Axiom/src/test/java/org/apache/bsf/testing/e4x/HelloTestCase.java b/testing/e4x-1.6R7-Axiom/src/test/java/org/apache/bsf/testing/e4x/HelloTestCase.java
new file mode 100644
index 0000000..4acdbbc
--- /dev/null
+++ b/testing/e4x-1.6R7-Axiom/src/test/java/org/apache/bsf/testing/e4x/HelloTestCase.java
@@ -0,0 +1,94 @@
+/*
+ * 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;
+
+/**
+ * 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);
+    }
+
+}
diff --git a/testing/pom.xml b/testing/pom.xml
index 5dee458..19be52b 100644
--- a/testing/pom.xml
+++ b/testing/pom.xml
@@ -38,6 +38,7 @@
             </activation>
             <modules>
                 <module>e4x</module>
+                <module>e4x-1.6R7-Axiom</module>
                 <module>groovy</module>
                 <module>groovy-1.1</module>
                 <module>javascript</module>