org.springframework.scripting.support.StandardScriptEvaluator Java Examples

The following examples show how to use org.springframework.scripting.support.StandardScriptEvaluator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GroovyScriptEvaluatorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testGroovyScriptFromStringUsingJsr223() {
	StandardScriptEvaluator evaluator = new StandardScriptEvaluator();
	evaluator.setLanguage("Groovy");
	Object result = evaluator.evaluate(new StaticScriptSource("return 3 * 2"));
	assertEquals(6, result);
}
 
Example #2
Source File: GroovyScriptEvaluatorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testGroovyScriptWithArgumentsUsingJsr223() {
	StandardScriptEvaluator evaluator = new StandardScriptEvaluator();
	evaluator.setLanguage("Groovy");
	Map<String, Object> arguments = new HashMap<>();
	arguments.put("a", 3);
	arguments.put("b", 2);
	Object result = evaluator.evaluate(new StaticScriptSource("return a * b"), arguments);
	assertEquals(6, result);
}
 
Example #3
Source File: GroovyScriptEvaluatorTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testGroovyScriptFromStringUsingJsr223() {
	StandardScriptEvaluator evaluator = new StandardScriptEvaluator();
	evaluator.setLanguage("Groovy");
	Object result = evaluator.evaluate(new StaticScriptSource("return 3 * 2"));
	assertEquals(6, result);
}
 
Example #4
Source File: GroovyScriptEvaluatorTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testGroovyScriptWithArgumentsUsingJsr223() {
	StandardScriptEvaluator evaluator = new StandardScriptEvaluator();
	evaluator.setLanguage("Groovy");
	Map<String, Object> arguments = new HashMap<>();
	arguments.put("a", 3);
	arguments.put("b", 2);
	Object result = evaluator.evaluate(new StaticScriptSource("return a * b"), arguments);
	assertEquals(6, result);
}
 
Example #5
Source File: GroovyScriptEvaluatorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testGroovyScriptFromStringUsingJsr223() {
	StandardScriptEvaluator evaluator = new StandardScriptEvaluator();
	evaluator.setLanguage("Groovy");
	Object result = evaluator.evaluate(new StaticScriptSource("return 3 * 2"));
	assertEquals(6, result);
}
 
Example #6
Source File: GroovyScriptEvaluatorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testGroovyScriptWithArgumentsUsingJsr223() {
	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);
}
 
Example #7
Source File: GroovyScriptEvaluatorTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Test
public void testGroovyScriptFromFileUsingJsr223() {
	ScriptEvaluator evaluator = new StandardScriptEvaluator();
	Object result = evaluator.evaluate(new ResourceScriptSource(new ClassPathResource("simple.groovy", getClass())));
	assertEquals(6, result);
}
 
Example #8
Source File: GroovyScriptEvaluatorTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Test
public void testGroovyScriptFromFileUsingJsr223() {
	ScriptEvaluator evaluator = new StandardScriptEvaluator();
	Object result = evaluator.evaluate(new ResourceScriptSource(new ClassPathResource("simple.groovy", getClass())));
	assertEquals(6, result);
}
 
Example #9
Source File: GroovyScriptEvaluatorTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Test
public void testGroovyScriptFromFileUsingJsr223() {
	ScriptEvaluator evaluator = new StandardScriptEvaluator();
	Object result = evaluator.evaluate(new ResourceScriptSource(new ClassPathResource("simple.groovy", getClass())));
	assertEquals(6, result);
}