Package org.springframework.binding.expression

Examples of org.springframework.binding.expression.Expression


  private TestBean bean = new TestBean();

  public void testParseSimple() {
    String exp = "flag";
    Expression e = parser.parseExpression(exp, null);
    assertNotNull(e);
    Boolean b = (Boolean) e.getValue(bean);
    assertFalse(b.booleanValue());
  }
View Full Code Here


  }

  public void testParseSimpleAllowDelimited() {
    parser.setAllowDelimitedEvalExpressions(true);
    String exp = "${flag}";
    Expression e = parser.parseExpression(exp, null);
    assertNotNull(e);
    Boolean b = (Boolean) e.getValue(bean);
    assertFalse(b.booleanValue());
  }
View Full Code Here

    }
  }

  public void testParseTemplateSimpleLiteral() {
    String exp = "flag";
    Expression e = parser.parseExpression(exp, new FluentParserContext().template());
    assertNotNull(e);
    assertEquals("flag", e.getValue(bean));
  }
View Full Code Here

    assertNotNull(e);
    assertEquals("flag", e.getValue(bean));
  }

  public void testParseTemplateEmpty() {
    Expression e = parser.parseExpression("", new FluentParserContext().template());
    assertNotNull(e);
    assertEquals("", e.getValue(bean));
  }
View Full Code Here

    assertEquals("", e.getValue(bean));
  }

  public void testParseTemplateComposite() {
    String exp = "hello ${flag} ${flag} ${flag}";
    Expression e = parser.parseExpression(exp, new FluentParserContext().template());
    assertNotNull(e);
    String str = (String) e.getValue(bean);
    assertEquals("hello false false false", str);
  }
View Full Code Here

    }
  }

  public void testGetValueType() {
    String exp = "flag";
    Expression e = parser.parseExpression(exp, null);
    assertEquals(boolean.class, e.getValueType(bean));
  }
View Full Code Here

    assertEquals(boolean.class, e.getValueType(bean));
  }

  public void testGetValueTypeNullCollectionValue() {
    String exp = "list[0]";
    Expression e = parser.parseExpression(exp, null);
    assertEquals(null, e.getValueType(bean));
  }
View Full Code Here

    Expression e = parser.parseExpression(exp, null);
    assertEquals(null, e.getValueType(bean));
  }

  public void testSetValueWithCoersion() {
    Expression e = parser.parseExpression("date", null);
    e.setValue(bean, "2008-9-15");
  }
View Full Code Here

    Expression e = parser.parseExpression("date", null);
    e.setValue(bean, "2008-9-15");
  }

  public void testSetBogusValueWithCoersion() {
    Expression e = parser.parseExpression("date", null);
    try {
      e.setValue(bean, "bogus");
      fail("Should have failed tme");
    } catch (ValueCoercionException ex) {
      assertTrue(ex.getCause() instanceof TypeMismatchException);
    }
  }
View Full Code Here

      .createExpressionFactory());

  public void testResolveMap() {
    LocalAttributeMap map = new LocalAttributeMap();
    map.put("foo", "bar");
    Expression exp = parser.parseExpression("foo", new FluentParserContext().evaluate(AttributeMap.class));
    Expression exp2 = parser.parseExpression("bogus", new FluentParserContext().evaluate(AttributeMap.class));
    assertEquals("bar", exp.getValue(map));
    assertEquals(null, exp2.getValue(map));
  }
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.