Package org.springframework.expression

Examples of org.springframework.expression.ExpressionParser.parseExpression()


    assertEquals("",value);

    // Now turn off growing and reference off the end
    ctx = new StandardEvaluationContext(instance);
    parser = new SpelExpressionParser(new SpelParserConfiguration(false, false));
    e =  parser.parseExpression("listOfStrings[3]");
    try {
      e.getValue(ctx,String.class);
      fail();
    } catch (SpelEvaluationException see) {
      assertEquals(SpelMessage.COLLECTION_INDEX_OUT_OF_BOUNDS,see.getMessageCode());
View Full Code Here


  @Test
  public void increment01root() {
    Integer i = 42;
    StandardEvaluationContext ctx = new StandardEvaluationContext(i);
    ExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(true, true));
    Expression e =  parser.parseExpression("#this++");
    assertEquals(42,i.intValue());
    try {
      e.getValue(ctx,Integer.class);
      fail();
    } catch (SpelEvaluationException see) {
View Full Code Here

    StandardEvaluationContext ctx = new StandardEvaluationContext(helper);
    ExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(true, true));
    Expression e = null;

    // BigDecimal
    e = parser.parseExpression("bd++");
    assertTrue(new BigDecimal("2").equals(helper.bd));
    BigDecimal return_bd = e.getValue(ctx,BigDecimal.class);
    assertTrue(new BigDecimal("2").equals(return_bd));
    assertTrue(new BigDecimal("3").equals(helper.bd));
View Full Code Here

    BigDecimal return_bd = e.getValue(ctx,BigDecimal.class);
    assertTrue(new BigDecimal("2").equals(return_bd));
    assertTrue(new BigDecimal("3").equals(helper.bd));

    // double
    e = parser.parseExpression("ddd++");
    assertEquals(2.0d,helper.ddd,0d);
    double return_ddd = e.getValue(ctx,Double.TYPE);
    assertEquals(2.0d,return_ddd,0d);
    assertEquals(3.0d,helper.ddd,0d);
View Full Code Here

    double return_ddd = e.getValue(ctx,Double.TYPE);
    assertEquals(2.0d,return_ddd,0d);
    assertEquals(3.0d,helper.ddd,0d);

    // float
    e = parser.parseExpression("fff++");
    assertEquals(3.0f,helper.fff,0d);
    float return_fff = e.getValue(ctx,Float.TYPE);
    assertEquals(3.0f,return_fff,0d);
    assertEquals(4.0f,helper.fff,0d);
View Full Code Here

    float return_fff = e.getValue(ctx,Float.TYPE);
    assertEquals(3.0f,return_fff,0d);
    assertEquals(4.0f,helper.fff,0d);

    // long
    e = parser.parseExpression("lll++");
    assertEquals(66666L,helper.lll);
    long return_lll = e.getValue(ctx,Long.TYPE);
    assertEquals(66666L,return_lll);
    assertEquals(66667L,helper.lll);
View Full Code Here

    long return_lll = e.getValue(ctx,Long.TYPE);
    assertEquals(66666L,return_lll);
    assertEquals(66667L,helper.lll);

    // int
    e = parser.parseExpression("iii++");
    assertEquals(42,helper.iii);
    int return_iii = e.getValue(ctx,Integer.TYPE);
    assertEquals(42,return_iii);
    assertEquals(43,helper.iii);
    return_iii = e.getValue(ctx,Integer.TYPE);
View Full Code Here

    return_iii = e.getValue(ctx,Integer.TYPE);
    assertEquals(43,return_iii);
    assertEquals(44,helper.iii);

    // short
    e = parser.parseExpression("sss++");
    assertEquals(15,helper.sss);
    short return_sss = e.getValue(ctx,Short.TYPE);
    assertEquals(15,return_sss);
    assertEquals(16,helper.sss);
  }
View Full Code Here

    ExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(true, true));
    Expression e = null;


    // BigDecimal
    e = parser.parseExpression("++bd");
    assertTrue(new BigDecimal("2").equals(helper.bd));
    BigDecimal return_bd = e.getValue(ctx,BigDecimal.class);
    assertTrue(new BigDecimal("3").equals(return_bd));
    assertTrue(new BigDecimal("3").equals(helper.bd));
View Full Code Here

    BigDecimal return_bd = e.getValue(ctx,BigDecimal.class);
    assertTrue(new BigDecimal("3").equals(return_bd));
    assertTrue(new BigDecimal("3").equals(helper.bd));

    // double
    e = parser.parseExpression("++ddd");
    assertEquals(2.0d,helper.ddd,0d);
    double return_ddd = e.getValue(ctx,Double.TYPE);
    assertEquals(3.0d,return_ddd,0d);
    assertEquals(3.0d,helper.ddd,0d);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.