Package org.springframework.binding.expression

Examples of org.springframework.binding.expression.Expression


    TestBean target = new TestBean();
    assertEquals("foo2", exp.getValue(target));
  }

  public void testVariablesWithCoersion() {
    Expression exp = parser.parseExpression("max", new FluentParserContext().variable(new ExpressionVariable("max",
        "maximum", new FluentParserContext().expectResult(Long.class))));
    TestBean target = new TestBean();
    assertEquals(new Long(2), exp.getValue(target));
  }
View Full Code Here


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

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

  // assertEquals(null, e.getValueType(target));
  // }

  public void testGetExpressionString() {
    String expressionString = "maximum";
    Expression exp = parser.parseExpression(expressionString, null);
    assertEquals("maximum", exp.getExpressionString());
  }
View Full Code Here

    assertEquals("maximum", exp.getExpressionString());
  }

  public void testGetExpressionType() {
    String expressionString = "maximum";
    Expression exp = parser.parseExpression(expressionString, null);
    TestBean context = new TestBean();
    assertEquals(int.class, exp.getValueType(context));
  }
View Full Code Here

    assertEquals(int.class, exp.getValueType(context));
  }

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

    assertEquals("2", exp.getValue(context));
  }

  public void testGetValueCoersionError() {
    String expressionString = "maximum";
    Expression exp = parser.parseExpression(expressionString, new FluentParserContext()
        .expectResult(TestBean.class));
    TestBean context = new TestBean();
    try {
      exp.getValue(context);
      fail("Should have failed with coersion");
    } catch (ValueCoercionException e) {
    }
  }
View Full Code Here

    }
  }

  public void testSetValue() {
    String expressionString = "maximum";
    Expression exp = parser.parseExpression(expressionString, null);
    TestBean context = new TestBean();
    exp.setValue(context, new Integer(5));
    assertEquals(5, context.getMaximum());
  }
View Full Code Here

    assertEquals(5, context.getMaximum());
  }

  public void testSetValueWithTypeCoersion() {
    String expressionString = "maximum";
    Expression exp = parser.parseExpression(expressionString, null);
    TestBean context = new TestBean();
    exp.setValue(context, "5");
    assertEquals(5, context.getMaximum());
  }
View Full Code Here

    assertEquals(5, context.getMaximum());
  }

  public void testSetValueCoersionError() {
    String expressionString = "maximum";
    Expression exp = parser.parseExpression(expressionString, null);
    TestBean context = new TestBean();
    try {
      exp.setValue(context, "bogus");
      fail("Should have failed with coersion");
    } catch (ValueCoercionException e) {
    }
  }
View Full Code Here

  }

  public void testStartWithMapper() {
    DefaultMapper attributeMapper = new DefaultMapper();
    ExpressionParser parser = DefaultExpressionParserFactory.getExpressionParser();
    Expression x = parser.parseExpression("attr", new FluentParserContext().evaluate(AttributeMap.class));
    Expression y = parser.parseExpression("flowScope.attr", new FluentParserContext()
        .evaluate(RequestContext.class));
    attributeMapper.addMapping(new DefaultMapping(x, y));
    flow.setInputMapper(attributeMapper);
    MockRequestControlContext context = new MockRequestControlContext(flow);
    LocalAttributeMap sessionInput = new LocalAttributeMap();
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.