示例#1
0
  public void testFieldCoercion1() {
    ParserContext ctx = new ParserContext();
    ctx.setStrongTyping(true);
    ctx.addInput("bar", Bar.class);

    Serializable s = compileSetExpression("bar.assignTest", ctx);

    Foo foo = new Foo();

    executeSetExpression(s, foo, 12);

    assertEquals("12", foo.getBar().getAssignTest());

    foo = new Foo();

    executeSetExpression(s, foo, 13);

    assertEquals("13", foo.getBar().getAssignTest());

    OptimizerFactory.setDefaultOptimizer("ASM");

    ctx = new ParserContext();
    ctx.setStrongTyping(true);
    ctx.addInput("bar", Bar.class);

    s = compileSetExpression("bar.assignTest", ctx);

    foo = new Foo();

    executeSetExpression(s, foo, 12);

    assertEquals("12", foo.getBar().getAssignTest());

    executeSetExpression(s, foo, 13);

    assertEquals("13", foo.getBar().getAssignTest());
  }
示例#2
0
  public void testListCoercion() {
    ParserContext ctx = new ParserContext();
    ctx.setStrongTyping(true);
    ctx.addInput("bar", Bar.class);

    Serializable s = compileSetExpression("bar.testList[0]", ctx);

    Foo foo = new Foo();
    foo.getBar().getTestList().add(new Integer(-1));

    executeSetExpression(s, foo, "12");

    assertEquals(12, foo.getBar().getTestList().get(0).intValue());

    foo = new Foo();
    foo.getBar().getTestList().add(new Integer(-1));

    executeSetExpression(s, foo, "13");

    assertEquals(13, foo.getBar().getTestList().get(0).intValue());

    OptimizerFactory.setDefaultOptimizer("ASM");

    ctx = new ParserContext();
    ctx.setStrongTyping(true);
    ctx.addInput("bar", Bar.class);

    s = compileSetExpression("bar.testList[0]", ctx);

    foo = new Foo();
    foo.getBar().getTestList().add(new Integer(-1));

    executeSetExpression(s, foo, "12");

    assertEquals(12, foo.getBar().getTestList().get(0).intValue());

    executeSetExpression(s, foo, "13");

    assertEquals(13, foo.getBar().getTestList().get(0).intValue());
  }