Package org.springframework.scripting.support

Examples of org.springframework.scripting.support.StaticScriptSource


  @Resource
  private Configuration config;

  @Test
  public void testRhinoScript() throws Exception {
    ScriptSource script = new StaticScriptSource("msg = 'Hello, world!'");

    Jsr223ScriptEvaluator eval = new Jsr223ScriptEvaluator();
    eval.setLanguage("javascript");

    assertEquals("Hello, world!", eval.evaluate(script));
View Full Code Here


    ctx.getBean("distcp");
  }

  @Test
  public void testNullCfg() throws Exception {
    ScriptSource script = new StaticScriptSource("null");
   
    HdfsScriptRunner hsfb = new HdfsScriptRunner();
    GenericApplicationContext gac = new GenericApplicationContext();
    gac.refresh();
    hsfb.setApplicationContext(gac);
View Full Code Here

    @Test
    public void test() throws ExecutionException, InterruptedException {
        ScriptEvaluator scriptEvaluator = new GroovyScriptEvaluator();

        //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);
  }
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);
  }
View Full Code Here

  @Test
  public void testGroovyScriptFromStringUsingJsr223() {
    StandardScriptEvaluator evaluator = new StandardScriptEvaluator();
    evaluator.setLanguage("Groovy");
    Object result = evaluator.evaluate(new StaticScriptSource("return 3 * 2"));
    assertEquals(6, result);
  }
View Full Code Here

    StandardScriptEvaluator evaluator = new StandardScriptEvaluator();
    evaluator.setLanguage("Groovy");
    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

public class BshScriptEvaluatorTests {

  @Test
  public void testBshScriptFromString() {
    ScriptEvaluator evaluator = new BshScriptEvaluator();
    Object result = evaluator.evaluate(new StaticScriptSource("return 3 * 2;"));
    assertEquals(6, result);
  }
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

  public void setScriptSource(String scriptSource, String language) {
    Assert.hasText(language, "Language must contain the script language");
    Assert.hasText(scriptSource, "Script source must contain the script source to evaluate");

    this.language = language;
    this.scriptSource = new StaticScriptSource(scriptSource);
  }
View Full Code Here

TOP

Related Classes of org.springframework.scripting.support.StaticScriptSource

Copyright © 2018 www.massapicom. 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.