Package org.springframework.expression

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


    Expression expression = parser.parseExpression("list[0]");
    TestClass testClass = new TestClass();
    Object o = null;
    o = expression.getValue(new StandardEvaluationContext(testClass));
    assertEquals("", o);
    o = parser.parseExpression("list[3]").getValue(new StandardEvaluationContext(testClass));
    assertEquals("", o);
    assertEquals(4, testClass.list.size());
    try {
      o = parser.parseExpression("list2[3]").getValue(new StandardEvaluationContext(testClass));
      fail();
View Full Code Here


    assertEquals("", o);
    o = parser.parseExpression("list[3]").getValue(new StandardEvaluationContext(testClass));
    assertEquals("", o);
    assertEquals(4, testClass.list.size());
    try {
      o = parser.parseExpression("list2[3]").getValue(new StandardEvaluationContext(testClass));
      fail();
    } catch (EvaluationException ee) {
      ee.printStackTrace();
      // success!
    }
View Full Code Here

      fail();
    } catch (EvaluationException ee) {
      ee.printStackTrace();
      // success!
    }
    o = parser.parseExpression("foo[3]").getValue(new StandardEvaluationContext(testClass));
    assertEquals("", o);
    assertEquals(4, testClass.getFoo().size());
  }

  @Test(expected = SpelEvaluationException.class)
View Full Code Here

  public void testCreateMapsOnAttemptToIndexNull01() throws Exception {
    TestClass testClass = new TestClass();
    StandardEvaluationContext ctx = new StandardEvaluationContext(testClass);
    ExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(true, true));
    Object o = null;
    o = parser.parseExpression("map['a']").getValue(ctx);
    assertNull(o);
    o = parser.parseExpression("map").getValue(ctx);
    assertNotNull(o);

    o = parser.parseExpression("map2['a']").getValue(ctx);
View Full Code Here

    StandardEvaluationContext ctx = new StandardEvaluationContext(testClass);
    ExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(true, true));
    Object o = null;
    o = parser.parseExpression("map['a']").getValue(ctx);
    assertNull(o);
    o = parser.parseExpression("map").getValue(ctx);
    assertNotNull(o);

    o = parser.parseExpression("map2['a']").getValue(ctx);
    // map2 should be null, there is no setter
  }
View Full Code Here

    o = parser.parseExpression("map['a']").getValue(ctx);
    assertNull(o);
    o = parser.parseExpression("map").getValue(ctx);
    assertNotNull(o);

    o = parser.parseExpression("map2['a']").getValue(ctx);
    // map2 should be null, there is no setter
  }

  // wibble2 should be null (cannot be initialized dynamically), there is no setter
  @Test(expected = SpelEvaluationException.class)
View Full Code Here

  public void testCreateObjectsOnAttemptToReferenceNull() throws Exception {
    TestClass testClass = new TestClass();
    StandardEvaluationContext ctx = new StandardEvaluationContext(testClass);
    ExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(true, true));
    Object o = null;
    o = parser.parseExpression("wibble.bar").getValue(ctx);
    assertEquals("hello", o);
    o = parser.parseExpression("wibble").getValue(ctx);
    assertNotNull(o);

    o = parser.parseExpression("wibble2.bar").getValue(ctx);
View Full Code Here

    StandardEvaluationContext ctx = new StandardEvaluationContext(testClass);
    ExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(true, true));
    Object o = null;
    o = parser.parseExpression("wibble.bar").getValue(ctx);
    assertEquals("hello", o);
    o = parser.parseExpression("wibble").getValue(ctx);
    assertNotNull(o);

    o = parser.parseExpression("wibble2.bar").getValue(ctx);
  }
View Full Code Here

    o = parser.parseExpression("wibble.bar").getValue(ctx);
    assertEquals("hello", o);
    o = parser.parseExpression("wibble").getValue(ctx);
    assertNotNull(o);

    o = parser.parseExpression("wibble2.bar").getValue(ctx);
  }


  @SuppressWarnings("rawtypes")
  static class TestClass {
View Full Code Here

  public void initializingCollectionElementsOnWrite() throws Exception {
    TestPerson person = new TestPerson();
    EvaluationContext context = new StandardEvaluationContext(person);
    SpelParserConfiguration config = new SpelParserConfiguration(true, true);
    ExpressionParser parser = new SpelExpressionParser(config);
    Expression expression = parser.parseExpression("name");
    expression.setValue(context, "Oleg");
    assertEquals("Oleg", person.getName());

    expression = parser.parseExpression("address.street");
    expression.setValue(context, "123 High St");
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.