use of org.springframework.expression.spel.support.StandardEvaluationContext in project spring-framework by spring-projects.
the class SpelCompilationCoverageTests method functionReferenceVarargs.
@Test
public void functionReferenceVarargs() throws Exception {
EvaluationContext ctx = new StandardEvaluationContext();
Method m = getClass().getDeclaredMethod("join", String[].class);
ctx.setVariable("join", m);
expression = parser.parseExpression("#join('a','b','c')");
assertEquals("abc", expression.getValue(ctx));
assertCanCompile(expression);
assertEquals("abc", expression.getValue(ctx));
}
use of org.springframework.expression.spel.support.StandardEvaluationContext in project spring-framework by spring-projects.
the class LiteralTests method testNotWritable.
@Test
public void testNotWritable() throws Exception {
SpelExpression expr = (SpelExpression) parser.parseExpression("37");
assertFalse(expr.isWritable(new StandardEvaluationContext()));
expr = (SpelExpression) parser.parseExpression("37L");
assertFalse(expr.isWritable(new StandardEvaluationContext()));
expr = (SpelExpression) parser.parseExpression("true");
assertFalse(expr.isWritable(new StandardEvaluationContext()));
}
use of org.springframework.expression.spel.support.StandardEvaluationContext in project spring-framework by spring-projects.
the class MapAccessTests method testVariableMapAccess.
@Test
public void testVariableMapAccess() throws Exception {
ExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext ctx = TestScenarioCreator.getTestEvaluationContext();
ctx.setVariable("day", "saturday");
Expression expr = parser.parseExpression("testMap[#day]");
Object value = expr.getValue(ctx, String.class);
assertEquals("samstag", value);
}
use of org.springframework.expression.spel.support.StandardEvaluationContext in project spring-framework by spring-projects.
the class MapAccessTests method testCustomMapAccessor.
@Test
public void testCustomMapAccessor() throws Exception {
ExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext ctx = TestScenarioCreator.getTestEvaluationContext();
ctx.addPropertyAccessor(new MapAccessor());
Expression expr = parser.parseExpression("testMap.monday");
Object value = expr.getValue(ctx, String.class);
assertEquals("montag", value);
}
use of org.springframework.expression.spel.support.StandardEvaluationContext in project spring-framework by spring-projects.
the class MethodInvocationTests method testMethodOfClass.
@Test
public void testMethodOfClass() throws Exception {
Expression expression = parser.parseExpression("getName()");
Object value = expression.getValue(new StandardEvaluationContext(String.class));
assertEquals(value, "java.lang.String");
}
Aggregations