Package org.springframework.scripting

Examples of org.springframework.scripting.ScriptEvaluator.evaluate()


        //ResourceScriptSource 外部的
        ScriptSource source = new StaticScriptSource("i+j");
        Map<String, Object> args = new HashMap<>();
        args.put("i", 1);
        args.put("j", 2);
        System.out.println(scriptEvaluator.evaluate(source, args));
    }
}
View Full Code Here


public class GroovyScriptEvaluatorTests {

  @Test
  public void testGroovyScriptFromString() {
    ScriptEvaluator evaluator = new GroovyScriptEvaluator();
    Object result = evaluator.evaluate(new StaticScriptSource("return 3 * 2"));
    assertEquals(6, result);
  }

  @Test
  public void testGroovyScriptFromFile() {
View Full Code Here

  }

  @Test
  public void testGroovyScriptFromFile() {
    ScriptEvaluator evaluator = new GroovyScriptEvaluator();
    Object result = evaluator.evaluate(new ResourceScriptSource(new ClassPathResource("simple.groovy", getClass())));
    assertEquals(6, result);
  }

  @Test
  public void testGroovyScriptWithArguments() {
View Full Code Here

  public void testGroovyScriptWithArguments() {
    ScriptEvaluator evaluator = new GroovyScriptEvaluator();
    Map<String, Object> arguments = new HashMap<String, Object>();
    arguments.put("a", 3);
    arguments.put("b", 2);
    Object result = evaluator.evaluate(new StaticScriptSource("return a * b"), arguments);
    assertEquals(6, result);
  }

  @Test
  public void testGroovyScriptFromStringUsingJsr223() {
View Full Code Here

  }

  @Test
  public void testGroovyScriptFromFileUsingJsr223() {
    ScriptEvaluator evaluator = new StandardScriptEvaluator();
    Object result = evaluator.evaluate(new ResourceScriptSource(new ClassPathResource("simple.groovy", getClass())));
    assertEquals(6, result);
  }

  @Test
  public void testGroovyScriptWithArgumentsUsingJsr223() {
View Full Code Here

public class BshScriptEvaluatorTests {

  @Test
  public void testBshScriptFromString() {
    ScriptEvaluator evaluator = new BshScriptEvaluator();
    Object result = evaluator.evaluate(new StaticScriptSource("return 3 * 2;"));
    assertEquals(6, result);
  }

  @Test
  public void testBshScriptFromFile() {
View Full Code Here

  }

  @Test
  public void testBshScriptFromFile() {
    ScriptEvaluator evaluator = new BshScriptEvaluator();
    Object result = evaluator.evaluate(new ResourceScriptSource(new ClassPathResource("simple.bsh", getClass())));
    assertEquals(6, result);
  }

  @Test
  public void testGroovyScriptWithArguments() {
View Full Code Here

  public void testGroovyScriptWithArguments() {
    ScriptEvaluator evaluator = new BshScriptEvaluator();
    Map<String, Object> arguments = new HashMap<String, Object>();
    arguments.put("a", 3);
    arguments.put("b", 2);
    Object result = evaluator.evaluate(new StaticScriptSource("return a * b;"), arguments);
    assertEquals(6, result);
  }

}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.