use of org.springframework.expression.spel.standard.SpelExpressionParser in project spring-framework by spring-projects.
the class SpelReproTests method dollars.
@Test
public void dollars() {
StandardEvaluationContext eContext = new StandardEvaluationContext(new XX());
Expression expr = null;
expr = new SpelExpressionParser().parseRaw("m['$foo']");
eContext.setVariable("file_name", "$foo");
assertEquals("wibble", expr.getValue(eContext, String.class));
}
use of org.springframework.expression.spel.standard.SpelExpressionParser in project spring-framework by spring-projects.
the class SpelReproTests method SPR9486_multiplyFloatWithDouble.
@Test
public void SPR9486_multiplyFloatWithDouble() {
Number expectedNumber = 10.21f * 10.2;
ExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext context = new StandardEvaluationContext();
Expression expression = parser.parseExpression("10.21f * 10.2");
Number result = expression.getValue(context, null, Number.class);
assertEquals(expectedNumber, result);
}
use of org.springframework.expression.spel.standard.SpelExpressionParser in project spring-framework by spring-projects.
the class SpelReproTests method dollarPrefixedIdentifier_SPR7100.
/** $ related identifiers */
@Test
public void dollarPrefixedIdentifier_SPR7100() {
Holder h = new Holder();
StandardEvaluationContext eContext = new StandardEvaluationContext(h);
eContext.addPropertyAccessor(new MapAccessor());
h.map.put("$foo", "wibble");
h.map.put("foo$bar", "wobble");
h.map.put("foobar$$", "wabble");
h.map.put("$", "wubble");
h.map.put("$$", "webble");
h.map.put("$_$", "tribble");
String name = null;
Expression expr = null;
expr = new SpelExpressionParser().parseRaw("map.$foo");
name = expr.getValue(eContext, String.class);
assertEquals("wibble", name);
expr = new SpelExpressionParser().parseRaw("map.foo$bar");
name = expr.getValue(eContext, String.class);
assertEquals("wobble", name);
expr = new SpelExpressionParser().parseRaw("map.foobar$$");
name = expr.getValue(eContext, String.class);
assertEquals("wabble", name);
expr = new SpelExpressionParser().parseRaw("map.$");
name = expr.getValue(eContext, String.class);
assertEquals("wubble", name);
expr = new SpelExpressionParser().parseRaw("map.$$");
name = expr.getValue(eContext, String.class);
assertEquals("webble", name);
expr = new SpelExpressionParser().parseRaw("map.$_$");
name = expr.getValue(eContext, String.class);
assertEquals("tribble", name);
}
use of org.springframework.expression.spel.standard.SpelExpressionParser in project spring-framework by spring-projects.
the class SpelReproTests method SPR9486_floatDivideByDouble.
@Test
public void SPR9486_floatDivideByDouble() {
Number expectedNumber = -10.21f / -10.2;
ExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext context = new StandardEvaluationContext();
Expression expression = parser.parseExpression("-10.21f / -10.2");
Number result = expression.getValue(context, null, Number.class);
assertEquals(expectedNumber, result);
}
use of org.springframework.expression.spel.standard.SpelExpressionParser in project spring-framework by spring-projects.
the class TemplateExpressionParsingTests method testParsingSimpleTemplateExpression02.
@Test
public void testParsingSimpleTemplateExpression02() throws Exception {
SpelExpressionParser parser = new SpelExpressionParser();
Expression expr = parser.parseExpression("hello ${'to'} you", DEFAULT_TEMPLATE_PARSER_CONTEXT);
Object o = expr.getValue();
assertEquals("hello to you", o.toString());
}
Aggregations