Exemplo n.º 1
0
  public void testSetCoercion2() {
    ParserContext ctx = new ParserContext();
    ctx.setStrongTyping(true);
    ctx.addInput("sampleBean", SampleBean.class);

    Serializable s = compileSetExpression("sampleBean.map2['bleh']", ctx);

    Foo foo = new Foo();
    executeSetExpression(s, foo, "12");

    assertEquals(12, foo.getSampleBean().getMap2().get("bleh").intValue());

    foo = new Foo();
    executeSetExpression(s, foo, "13");

    assertEquals(13, foo.getSampleBean().getMap2().get("bleh").intValue());

    OptimizerFactory.setDefaultOptimizer("ASM");

    ctx = new ParserContext();
    ctx.setStrongTyping(true);
    ctx.addInput("sampleBean", SampleBean.class);

    s = compileSetExpression("sampleBean.map2['bleh']", ctx);

    foo = new Foo();
    executeSetExpression(s, foo, "12");

    assertEquals(12, foo.getSampleBean().getMap2().get("bleh").intValue());

    executeSetExpression(s, foo, new Integer(12));

    assertEquals(12, foo.getSampleBean().getMap2().get("bleh").intValue());
  }
Exemplo n.º 2
0
  public void testSetCoercion() {
    Serializable s = compileSetExpression("name");

    Foo foo = new Foo();
    executeSetExpression(s, foo, 12);
    assertEquals("12", foo.getName());

    foo = new Foo();
    setProperty(foo, "name", 12);
    assertEquals("12", foo.getName());
  }
Exemplo n.º 3
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());
  }
Exemplo n.º 4
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());
  }