Test Case:
import static org.junit.Assert.assertEquals;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import org.junit.Test;
public class JavaScriptEngineFactoryTest {
@Test
public void test() throws ScriptException {
ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript");
engine.put("x", 10);
engine.put("y", 20);
assertEquals(30.0, engine.eval("x + y"));
}
}
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import org.junit.Test;
public class JavaScriptEngineFactoryTest {
@Test
public void test() throws ScriptException {
ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript");
engine.put("x", 10);
engine.put("y", 20);
assertEquals(30.0, engine.eval("x + y"));
}
}