Package org.springframework.expression.spel.standard

Examples of org.springframework.expression.spel.standard.SpelExpressionParser.parseExpression()


  public void testGetValueFromRootMap() {
    Map<String, String> map = new HashMap<String, String>();
    map.put("key", "value");

    ExpressionParser spelExpressionParser = new SpelExpressionParser();
    Expression expr = spelExpressionParser.parseExpression("#root['key']");
    assertEquals("value", expr.getValue(map));
  }

  @Test
  public void testGetValuePerformance() throws Exception {
View Full Code Here


    Map<String, String> map = new HashMap<String, String>();
    map.put("key", "value");
    EvaluationContext context = new StandardEvaluationContext(map);

    ExpressionParser spelExpressionParser = new SpelExpressionParser();
    Expression expr = spelExpressionParser.parseExpression("#root['key']");

    StopWatch s = new StopWatch();
    s.start();
    for (int i = 0; i < 10000; i++) {
      expr.getValue(context);
View Full Code Here


  @Test
  public void testParsingSimpleTemplateExpression01() throws Exception {
    SpelExpressionParser parser = new SpelExpressionParser();
    Expression expr = parser.parseExpression("hello ${'world'}", DEFAULT_TEMPLATE_PARSER_CONTEXT);
    Object o = expr.getValue();
    assertEquals("hello world", o.toString());
  }

  @Test
View Full Code Here

  }

  @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());
  }

  @Test
View Full Code Here

  }

  @Test
  public void testParsingSimpleTemplateExpression03() throws Exception {
    SpelExpressionParser parser = new SpelExpressionParser();
    Expression expr = parser.parseExpression("The quick ${'brown'} fox jumped over the ${'lazy'} dog",
        DEFAULT_TEMPLATE_PARSER_CONTEXT);
    Object o = expr.getValue();
    assertEquals("The quick brown fox jumped over the lazy dog", o.toString());
  }
View Full Code Here

  }

  @Test
  public void testParsingSimpleTemplateExpression04() throws Exception {
    SpelExpressionParser parser = new SpelExpressionParser();
    Expression expr = parser.parseExpression("${'hello'} world", DEFAULT_TEMPLATE_PARSER_CONTEXT);
    Object o = expr.getValue();
    assertEquals("hello world", o.toString());

    expr = parser.parseExpression("", DEFAULT_TEMPLATE_PARSER_CONTEXT);
    o = expr.getValue();
View Full Code Here

    SpelExpressionParser parser = new SpelExpressionParser();
    Expression expr = parser.parseExpression("${'hello'} world", DEFAULT_TEMPLATE_PARSER_CONTEXT);
    Object o = expr.getValue();
    assertEquals("hello world", o.toString());

    expr = parser.parseExpression("", DEFAULT_TEMPLATE_PARSER_CONTEXT);
    o = expr.getValue();
    assertEquals("", o.toString());

    expr = parser.parseExpression("abc", DEFAULT_TEMPLATE_PARSER_CONTEXT);
    o = expr.getValue();
View Full Code Here

    expr = parser.parseExpression("", DEFAULT_TEMPLATE_PARSER_CONTEXT);
    o = expr.getValue();
    assertEquals("", o.toString());

    expr = parser.parseExpression("abc", DEFAULT_TEMPLATE_PARSER_CONTEXT);
    o = expr.getValue();
    assertEquals("abc", o.toString());

    expr = parser.parseExpression("abc", DEFAULT_TEMPLATE_PARSER_CONTEXT);
    o = expr.getValue((Object)null);
View Full Code Here

    expr = parser.parseExpression("abc", DEFAULT_TEMPLATE_PARSER_CONTEXT);
    o = expr.getValue();
    assertEquals("abc", o.toString());

    expr = parser.parseExpression("abc", DEFAULT_TEMPLATE_PARSER_CONTEXT);
    o = expr.getValue((Object)null);
    assertEquals("abc", o.toString());
  }

  @Test
View Full Code Here

  }

  @Test
  public void testCompositeStringExpression() throws Exception {
    SpelExpressionParser parser = new SpelExpressionParser();
    Expression ex = parser.parseExpression("hello ${'world'}", DEFAULT_TEMPLATE_PARSER_CONTEXT);
    checkString("hello world", ex.getValue());
    checkString("hello world", ex.getValue(String.class));
    checkString("hello world", ex.getValue((Object)null, String.class));
    checkString("hello world", ex.getValue(new Rooty()));
    checkString("hello world", ex.getValue(new Rooty(), String.class));
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.