Author: sebb
Date: Tue Apr 6 19:45:32 2010
New Revision: 931290
URL:
http://svn.apache.org/viewvc?rev=931290&view=revLog:
Check for implementation that does not support E4X and skip tests that depend on it.
Modified:
jakarta/bsf/branches/bsf3.x/testing/e4x-1.6R7-Axiom/src/test/java/org/apache/bsf/testing/e4x/E4xAxiomTestCase.java
jakarta/bsf/branches/bsf3.x/testing/e4x/src/test/java/org/apache/bsf/testing/e4x/HelloTestCase.java
Modified: jakarta/bsf/branches/bsf3.x/testing/e4x-1.6R7-Axiom/src/test/java/org/apache/bsf/testing/e4x/E4xAxiomTestCase.java
URL:
http://svn.apache.org/viewvc/jakarta/bsf/branches/bsf3.x/testing/e4x-1.6R7-Axiom/src/test/java/org/apache/bsf/testing/e4x/E4xAxiomTestCase.java?rev=931290&r1=931289&r2=931290&view=diff==============================================================================
--- jakarta/bsf/branches/bsf3.x/testing/e4x-1.6R7-Axiom/src/test/java/org/apache/bsf/testing/e4x/E4xAxiomTestCase.java (original)
+++ jakarta/bsf/branches/bsf3.x/testing/e4x-1.6R7-Axiom/src/test/java/org/apache/bsf/testing/e4x/E4xAxiomTestCase.java Tue Apr 6 19:45:32 2010
@@ -45,6 +45,10 @@ public class E4xAxiomTestCase extends Te
private ScriptEngine engine;
public void testInvokeFunctionInXML() throws ScriptException, XMLStreamException, FactoryConfigurationError, NoSuchMethodException {
+ if (!engineSupportsE4X(engine, "testInvokeFunctionInXML()")){
+ return;
+ }
+
engine.eval("function isXML(xml) { return typeof xml == 'xml'; }" );
assertTrue(engine instanceof Invocable);
Invocable invocableScript = (Invocable) engine;
@@ -57,6 +61,9 @@ public class E4xAxiomTestCase extends Te
}
public void testInvokeFunctionOutXML() throws ScriptException, XMLStreamException, FactoryConfigurationError, NoSuchMethodException {
+ if (!engineSupportsE4X(engine, "testInvokeFunctionOutXML()")){
+ return;
+ }
engine.eval("function hello(xml) { return <foo>{xml.b}</foo>; }" );
assertTrue(engine instanceof Invocable);
Invocable invocableScript = (Invocable) engine;
@@ -76,6 +83,9 @@ public class E4xAxiomTestCase extends Te
Bindings bindings = engine.createBindings();
bindings.put("o", o);
Object x = engine.eval("typeof o", bindings);
+ if (!engineSupportsE4X(engine, "the rest of testE4X()")){
+ return;
+ }
assertEquals("xml", x);
}
@@ -92,4 +102,13 @@ public class E4xAxiomTestCase extends Te
xmlHelper = XMLHelper.getArgHelper(engine);
}
+ private static boolean engineSupportsE4X(ScriptEngine engine, String message){
+ final String name = engine.getClass().getName();
+ // This engine does not support E4X
+ if (name.equals("com.sun.script.javascript.RhinoScriptEngine")){
+ System.out.println("*** "+name + " does not support E4X, skipping "+message);
+ return false;
+ }
+ return true;
+ }
}
Modified: jakarta/bsf/branches/bsf3.x/testing/e4x/src/test/java/org/apache/bsf/testing/e4x/HelloTestCase.java
URL:
http://svn.apache.org/viewvc/jakarta/bsf/branches/bsf3.x/testing/e4x/src/test/java/org/apache/bsf/testing/e4x/HelloTestCase.java?rev=931290&r1=931289&r2=931290&view=diff==============================================================================
--- jakarta/bsf/branches/bsf3.x/testing/e4x/src/test/java/org/apache/bsf/testing/e4x/HelloTestCase.java (original)
+++ jakarta/bsf/branches/bsf3.x/testing/e4x/src/test/java/org/apache/bsf/testing/e4x/HelloTestCase.java Tue Apr 6 19:45:32 2010
@@ -38,7 +38,7 @@ import org.mozilla.javascript.Context;
import org.mozilla.javascript.ContextHelper;
/**
- * Tests a basic JavaScrip/E4X invocation
+ * Tests a basic JavaScript/E4X invocation
*/
public class HelloTestCase extends TestCase {
@@ -70,6 +70,10 @@ public class HelloTestCase extends TestC
OMElement om = convertor.toOMElement(o);
assertEquals("<a><b>petra</b></a>", om.toString());
+ if (!engineSupportsE4X(engine, "rest of testE4X()")){
+ return;
+ }
+
Bindings bindings = engine.createBindings();
bindings.put("o", o);
Object x = engine.eval("typeof o", bindings);
@@ -94,4 +98,14 @@ public class HelloTestCase extends TestC
Context.exit();
}
}
+
+ private static boolean engineSupportsE4X(ScriptEngine engine, String message){
+ final String name = engine.getClass().getName();
+ // This engine does not support E4X
+ if (name.equals("com.sun.script.javascript.RhinoScriptEngine")){
+ System.out.println("*** "+name + " does not support E4X, skipping "+message);
+ return false;
+ }
+ return true;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail:
bsf-dev-unsubscribe@...
For additional commands, e-mail:
bsf-dev-help@...