Browse souce code repository at: https://github.com/jjYBdx4IL/java-evaluation/blob/master/src/test/java/tests/javax/script/ScriptEngineTest.java
package tests.javax.script;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

import javax.script.Bindings;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

/**
 *
 * @author jjYBdx4IL
 */
public class ScriptEngineTest {

    @Test
    public void test() throws ScriptException {
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine engine = manager.getEngineByName("javascript");
        Bindings bindings = engine.createBindings();
        bindings.put("example", "123/456/789");

        Object result = engine.eval(
            "var obj = example.split(\"/\"); print(obj[0]); obj[0];",
            bindings);

        assertEquals("123", result);
    }

    @Test
    public void testBindings() throws ScriptException {
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine engine = manager.getEngineByName("javascript");
        Bindings bindings = engine.createBindings();

        engine.eval("var example = \"abc\";", bindings);

        assertEquals("abc", bindings.get("example"));
    }

}
-------------------------------------------------------------------------------
Test set: tests.javax.script.ScriptEngineTest
-------------------------------------------------------------------------------
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.037 s - in tests.javax.script.ScriptEngineTest
test  Time elapsed: 0.02 s
testBindings  Time elapsed: 0.017 s