SOLR-1725: fix test assumptions

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1369874 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris M. Hostetter 2012-08-06 16:29:37 +00:00
parent 462ff90d8e
commit ee280234f4
2 changed files with 22 additions and 10 deletions

View File

@ -25,6 +25,9 @@ import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.io.StringReader;
import org.junit.Assume;
import org.junit.BeforeClass;
/**
* Sanity tests basic functionality of {@link ScriptEngineManager} and
* {@link ScriptEngine} w/o excercising any Lucene specific code.
@ -33,6 +36,12 @@ public class ScriptEngineTest extends LuceneTestCase {
private ScriptEngineManager manager;
@BeforeClass
public static void beforeClass() throws Exception {
Assume.assumeNotNull((new ScriptEngineManager()).getEngineByExtension("js"));
Assume.assumeNotNull((new ScriptEngineManager()).getEngineByName("JavaScript"));
}
@Override
public void setUp() throws Exception {
super.setUp();
@ -83,13 +92,17 @@ public class ScriptEngineTest extends LuceneTestCase {
assertEquals(3, result.intValue());
}
// public void testJRuby() throws ScriptException, NoSuchMethodException { // Simply adding jruby.jar to Solr's lib/ directory gets this test passing
// ScriptEngine engine = manager.getEngineByName("jruby");
// assertNotNull(engine);
// engine.eval("def add(a,b); a + b; end");
// Long result = (Long) ((Invocable)engine).invokeFunction("add", 1, 2);
// assertNotNull(result);
// assertEquals(3, result.intValue());
// }
public void testJRuby() throws ScriptException, NoSuchMethodException {
// Simply adding jruby.jar to Solr's lib/ directory gets this test passing
ScriptEngine engine = manager.getEngineByName("jruby");
Assume.assumeNotNull(engine);
assertNotNull(engine);
engine.eval("def add(a,b); a + b; end");
Long result = (Long) ((Invocable)engine).invokeFunction("add", 1, 2);
assertNotNull(result);
assertEquals(3, result.intValue());
}
}

View File

@ -45,9 +45,8 @@ public class StatelessScriptUpdateProcessorFactoryTest extends UpdateProcessorTe
@BeforeClass
public static void beforeClass() throws Exception {
initCore("solrconfig-script-updateprocessor.xml", "schema12.xml");
Assume.assumeNotNull((new ScriptEngineManager()).getEngineByExtension("js"));
initCore("solrconfig-script-updateprocessor.xml", "schema12.xml");
}
/**