LUCENE-5207: Actually test that it works with mixed classloaders

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene5207@1523421 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2013-09-15 09:06:00 +00:00
parent 8574686af4
commit 90f2793896
1 changed files with 6 additions and 3 deletions

View File

@ -197,13 +197,16 @@ public class TestCustomFunctions extends LuceneTestCase {
}
// this should pass:
JavascriptCompiler.compile("zeroArgMethod()", functions, child);
Expression expr = JavascriptCompiler.compile("zeroArgMethod()", functions, child);
assertEquals(5, expr.evaluate(0, null), DELTA);
// mix foreign and default functions
Map<String,Method> mixedFunctions = new HashMap<>(JavascriptCompiler.DEFAULT_FUNCTIONS);
mixedFunctions.putAll(functions);
JavascriptCompiler.compile("zeroArgMethod()", mixedFunctions, child);
JavascriptCompiler.compile("sqrt(20)", mixedFunctions, child);
expr = JavascriptCompiler.compile("zeroArgMethod()", mixedFunctions, child);
assertEquals(5, expr.evaluate(0, null), DELTA);
expr = JavascriptCompiler.compile("sqrt(20)", mixedFunctions, child);
assertEquals(Math.sqrt(20), expr.evaluate(0, null), DELTA);
try {
JavascriptCompiler.compile("zeroArgMethod()", functions, getClass().getClassLoader());
fail();