Search in sources :

Example 96 with StandardEvaluationContext

use of org.springframework.expression.spel.support.StandardEvaluationContext in project spring-framework by spring-projects.

the class SpelReproTests method SPR10162_onlyBridgeMethod.

@Test
public void SPR10162_onlyBridgeMethod() throws Exception {
    ReflectivePropertyAccessor accessor = new ReflectivePropertyAccessor();
    StandardEvaluationContext context = new StandardEvaluationContext();
    Object target = new OnlyBridgeMethod();
    TypedValue value = accessor.read(context, target, "property");
    assertEquals(Integer.class, value.getTypeDescriptor().getType());
}
Also used : StandardEvaluationContext(org.springframework.expression.spel.support.StandardEvaluationContext) ReflectivePropertyAccessor(org.springframework.expression.spel.support.ReflectivePropertyAccessor) TypedValue(org.springframework.expression.TypedValue) Test(org.junit.Test)

Example 97 with StandardEvaluationContext

use of org.springframework.expression.spel.support.StandardEvaluationContext in project spring-framework by spring-projects.

the class SpelReproTests method SPR9486_floatEqFloat.

@Test
public void SPR9486_floatEqFloat() {
    Boolean expectedResult = 10.215f == 10.2109f;
    ExpressionParser parser = new SpelExpressionParser();
    StandardEvaluationContext context = new StandardEvaluationContext();
    Expression expression = parser.parseExpression("10.215f == 10.2109f");
    Boolean result = expression.getValue(context, null, Boolean.class);
    assertEquals(expectedResult, result);
}
Also used : SpelExpressionParser(org.springframework.expression.spel.standard.SpelExpressionParser) StandardEvaluationContext(org.springframework.expression.spel.support.StandardEvaluationContext) SpelExpression(org.springframework.expression.spel.standard.SpelExpression) Expression(org.springframework.expression.Expression) ExpressionParser(org.springframework.expression.ExpressionParser) SpelExpressionParser(org.springframework.expression.spel.standard.SpelExpressionParser) Test(org.junit.Test)

Example 98 with StandardEvaluationContext

use of org.springframework.expression.spel.support.StandardEvaluationContext in project spring-framework by spring-projects.

the class SpelReproTests method SPR10210.

@Test
public void SPR10210() throws Exception {
    StandardEvaluationContext context = new StandardEvaluationContext();
    context.setVariable("bridgeExample", new org.springframework.expression.spel.spr10210.D());
    Expression parseExpression = parser.parseExpression("#bridgeExample.bridgeMethod()");
    parseExpression.getValue(context);
}
Also used : StandardEvaluationContext(org.springframework.expression.spel.support.StandardEvaluationContext) SpelExpression(org.springframework.expression.spel.standard.SpelExpression) Expression(org.springframework.expression.Expression) Test(org.junit.Test)

Example 99 with StandardEvaluationContext

use of org.springframework.expression.spel.support.StandardEvaluationContext in project spring-framework by spring-projects.

the class SpelReproTests method SPR9486_floatGreaterThanFloat.

@Test
public void SPR9486_floatGreaterThanFloat() {
    Boolean expectedNumber = -10.21f > -10.2f;
    ExpressionParser parser = new SpelExpressionParser();
    StandardEvaluationContext context = new StandardEvaluationContext();
    Expression expression = parser.parseExpression("-10.21f > -10.2f");
    Boolean result = expression.getValue(context, null, Boolean.class);
    assertEquals(expectedNumber, result);
}
Also used : SpelExpressionParser(org.springframework.expression.spel.standard.SpelExpressionParser) StandardEvaluationContext(org.springframework.expression.spel.support.StandardEvaluationContext) SpelExpression(org.springframework.expression.spel.standard.SpelExpression) Expression(org.springframework.expression.Expression) ExpressionParser(org.springframework.expression.ExpressionParser) SpelExpressionParser(org.springframework.expression.spel.standard.SpelExpressionParser) Test(org.junit.Test)

Example 100 with StandardEvaluationContext

use of org.springframework.expression.spel.support.StandardEvaluationContext in project spring-framework by spring-projects.

the class SpelReproTests method SPR9486_floatLessThanOrEqualFloat.

@Test
public void SPR9486_floatLessThanOrEqualFloat() {
    Boolean expectedNumber = -10.21f <= -10.22f;
    ExpressionParser parser = new SpelExpressionParser();
    StandardEvaluationContext context = new StandardEvaluationContext();
    Expression expression = parser.parseExpression("-10.21f <= -10.22f");
    Boolean result = expression.getValue(context, null, Boolean.class);
    assertEquals(expectedNumber, result);
}
Also used : SpelExpressionParser(org.springframework.expression.spel.standard.SpelExpressionParser) StandardEvaluationContext(org.springframework.expression.spel.support.StandardEvaluationContext) SpelExpression(org.springframework.expression.spel.standard.SpelExpression) Expression(org.springframework.expression.Expression) ExpressionParser(org.springframework.expression.ExpressionParser) SpelExpressionParser(org.springframework.expression.spel.standard.SpelExpressionParser) Test(org.junit.Test)

Aggregations

StandardEvaluationContext (org.springframework.expression.spel.support.StandardEvaluationContext)241 Test (org.junit.Test)207 Expression (org.springframework.expression.Expression)153 SpelExpressionParser (org.springframework.expression.spel.standard.SpelExpressionParser)151 SpelExpression (org.springframework.expression.spel.standard.SpelExpression)103 ExpressionParser (org.springframework.expression.ExpressionParser)79 EvaluationContext (org.springframework.expression.EvaluationContext)43 ArrayList (java.util.ArrayList)27 List (java.util.List)14 HashMap (java.util.HashMap)12 EvaluationException (org.springframework.expression.EvaluationException)12 TypedValue (org.springframework.expression.TypedValue)12 Map (java.util.Map)11 TypeDescriptor (org.springframework.core.convert.TypeDescriptor)8 BigInteger (java.math.BigInteger)7 LinkedHashMap (java.util.LinkedHashMap)7 AccessException (org.springframework.expression.AccessException)6 ExpressionState (org.springframework.expression.spel.ExpressionState)6 Inventor (org.springframework.expression.spel.testresources.Inventor)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5