Examples of addPropertyAccessor()


Examples of org.springframework.expression.spel.support.StandardEvaluationContext.addPropertyAccessor()

  @Test
  public void testCustomMapAccessor() throws Exception {
    ExpressionParser parser = new SpelExpressionParser();
    StandardEvaluationContext ctx = TestScenarioCreator.getTestEvaluationContext();
    ctx.addPropertyAccessor(new MapAccessor());

    Expression expr = parser.parseExpression("testMap.monday");
    Object value = expr.getValue(ctx, String.class);
    assertEquals("montag", value);
  }
View Full Code Here

Examples of org.springframework.expression.spel.support.StandardEvaluationContext.addPropertyAccessor()

    // Create a parser
    SpelExpressionParser parser = new SpelExpressionParser();
    // Use the standard evaluation context
    StandardEvaluationContext ctx = new StandardEvaluationContext();

    ctx.addPropertyAccessor(new FruitColourAccessor());
    Expression expr = parser.parseRaw("orange");
    Object value = expr.getValue(ctx);
    assertEquals(Color.orange, value);

    try {
View Full Code Here

Examples of org.springframework.expression.spel.support.StandardEvaluationContext.addPropertyAccessor()

    // Create a parser
    SpelExpressionParser parser = new SpelExpressionParser();
    // Use the standard evaluation context
    StandardEvaluationContext ctx = new StandardEvaluationContext();

    ctx.addPropertyAccessor(new VegetableColourAccessor());
    Expression expr = parser.parseRaw("pea");
    Object value = expr.getValue(ctx);
    assertEquals(Color.green, value);

    try {
View Full Code Here

Examples of org.springframework.expression.spel.support.StandardEvaluationContext.addPropertyAccessor()

  }

  @Test
  public void SPR11609() {
    StandardEvaluationContext sec = new StandardEvaluationContext();
    sec.addPropertyAccessor(new MapAccessor());
    Expression exp = new SpelExpressionParser().parseExpression(
        "T(org.springframework.expression.spel.SpelReproTests$MapWithConstant).X");
    assertEquals(1, exp.getValue(sec));
  }
View Full Code Here

Examples of org.springframework.expression.spel.support.StandardEvaluationContext.addPropertyAccessor()

  @Test
  public void SPR5804() throws Exception {
    Map<String, String> m = new HashMap<String, String>();
    m.put("foo", "bar");
    StandardEvaluationContext eContext = new StandardEvaluationContext(m); // root is a map instance
    eContext.addPropertyAccessor(new MapAccessor());
    Expression expr = new SpelExpressionParser().parseRaw("['foo']");
    assertEquals("bar", expr.getValue(eContext));
  }

  @Test
View Full Code Here

Examples of org.springframework.expression.spel.support.StandardEvaluationContext.addPropertyAccessor()

    name = expr.getValue(eContext, String.class);
    assertEquals("Dave", name);

    // MapAccessor required for this to work
    expr = new SpelExpressionParser().parseRaw("jdbcProperties.username");
    eContext.addPropertyAccessor(new MapAccessor());
    name = expr.getValue(eContext, String.class);
    assertEquals("Dave", name);

    // --- dotted property names
View Full Code Here

Examples of org.springframework.expression.spel.support.StandardEvaluationContext.addPropertyAccessor()

    // --- dotted property names

    // lookup foo on the root, then bar on that, then use that as the key into
    // jdbcProperties
    expr = new SpelExpressionParser().parseRaw("jdbcProperties[foo.bar]");
    eContext.addPropertyAccessor(new MapAccessor());
    name = expr.getValue(eContext, String.class);
    assertEquals("Dave2", name);

    // key is foo.bar
    expr = new SpelExpressionParser().parseRaw("jdbcProperties['foo.bar']");
View Full Code Here

Examples of org.springframework.expression.spel.support.StandardEvaluationContext.addPropertyAccessor()

    name = expr.getValue(eContext, String.class);
    assertEquals("Dave2", name);

    // key is foo.bar
    expr = new SpelExpressionParser().parseRaw("jdbcProperties['foo.bar']");
    eContext.addPropertyAccessor(new MapAccessor());
    name = expr.getValue(eContext, String.class);
    assertEquals("Elephant", name);
  }

View Full Code Here

Examples of org.springframework.expression.spel.support.StandardEvaluationContext.addPropertyAccessor()

  /** $ related identifiers */
  @Test
  public void dollarPrefixedIdentifier_SPR7100() {
    Holder h = new Holder();
    StandardEvaluationContext eContext = new StandardEvaluationContext(h);
    eContext.addPropertyAccessor(new MapAccessor());
    h.map.put("$foo", "wibble");
    h.map.put("foo$bar", "wobble");
    h.map.put("foobar$$", "wabble");
    h.map.put("$", "wubble");
    h.map.put("$$", "webble");
View Full Code Here

Examples of org.springframework.expression.spel.support.StandardEvaluationContext.addPropertyAccessor()

  @Test
  public void propertyAccessorOrder_8211() {
    ExpressionParser expressionParser = new SpelExpressionParser();
    StandardEvaluationContext evaluationContext = new StandardEvaluationContext(new ContextObject());

    evaluationContext.addPropertyAccessor(new TestPropertyAccessor("firstContext"));
    evaluationContext.addPropertyAccessor(new TestPropertyAccessor("secondContext"));
    evaluationContext.addPropertyAccessor(new TestPropertyAccessor("thirdContext"));
    evaluationContext.addPropertyAccessor(new TestPropertyAccessor("fourthContext"));

    assertEquals("first", expressionParser.parseExpression("shouldBeFirst").getValue(evaluationContext));
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.