Package org.springframework.binding.expression

Examples of org.springframework.binding.expression.Expression


    parser.putContextFactory(TestBean.class, new TestELContextFactory());
  }

  public void testParseSimpleEvalExpressionNoParserContext() {
    String expressionString = "3 + 4";
    Expression exp = parser.parseExpression(expressionString, null);
    assertEquals(new Long(7), exp.getValue(null));
  }
View Full Code Here


    }
  }

  public void testParseNull() {
    Expression exp = parser.parseExpression("null", null);
    assertEquals(null, exp.getValue(null));
  }
View Full Code Here

    }
  }

  public void testParseSimpleEvalExpressionNoEvalContextWithTypeCoersion() {
    String expressionString = "3 + 4";
    Expression exp = parser
        .parseExpression(expressionString, new FluentParserContext().expectResult(Integer.class));
    assertEquals(new Integer(7), exp.getValue(null));
  }
View Full Code Here

    assertEquals(new Integer(7), exp.getValue(null));
  }

  public void testParseBeanEvalExpressionNoParserContext() {
    String expressionString = "value";
    Expression exp = parser.parseExpression(expressionString, null);
    assertEquals("foo", exp.getValue(new TestBean()));
  }
View Full Code Here

    assertEquals("foo", exp.getValue(new TestBean()));
  }

  public void testParseEvalExpressionWithContextTypeCoersion() {
    String expressionString = "maximum";
    Expression exp = parser.parseExpression(expressionString, new FluentParserContext().expectResult(Long.class));
    assertEquals(new Long(2), exp.getValue(new TestBean()));
  }
View Full Code Here

    assertEquals(new Long(2), exp.getValue(new TestBean()));
  }

  public void testParseEvalExpressionWithContextCustomELVariableResolver() {
    String expressionString = "specialProperty";
    Expression exp = parser.parseExpression(expressionString, new FluentParserContext().evaluate(TestBean.class));
    assertEquals("Custom resolver resolved this special property!", exp.getValue(new TestBean()));
  }
View Full Code Here

  }

  public void testParseBeanEvalExpressionInvalidELVariable() {
    try {
      String expressionString = "bogus";
      Expression exp = parser.parseExpression(expressionString, new FluentParserContext()
          .evaluate(TestBean.class));
      exp.getValue(new TestBean());
      fail("Should have failed");
    } catch (EvaluationException e) {

    }
  }
View Full Code Here

    }
  }

  public void testParseLiteralExpression() {
    String expressionString = "'value'";
    Expression exp = parser.parseExpression(expressionString, null);
    assertEquals("value", exp.getValue(null));
  }
View Full Code Here

    assertEquals("value", exp.getValue(null));
  }

  public void testParseTemplateExpression() {
    String expressionString = "text text text #{value} text text text#{value}";
    Expression exp = parser.parseExpression(expressionString, new FluentParserContext().template());
    TestBean target = new TestBean();
    assertEquals("text text text foo text text textfoo", exp.getValue(target));
  }
View Full Code Here

    assertEquals("text text text foo text text textfoo", exp.getValue(target));
  }

  public void testParseTemplateExpressionWithVariables() {
    String expressionString = "#{value}#{max}";
    Expression exp = parser.parseExpression(expressionString, new FluentParserContext().template().variable(
        new ExpressionVariable("max", "maximum")));
    TestBean target = new TestBean();
    assertEquals("foo2", exp.getValue(target));
  }
View Full Code Here

TOP

Related Classes of org.springframework.binding.expression.Expression

Copyright © 2018 www.massapicom. 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.