Package org.mvel2.tests.core.res

Examples of org.mvel2.tests.core.res.Foo


  public void testExecuteCoercionTwice2() {
    OptimizerFactory.setDefaultOptimizer("ASM");

    Map<String, Object> vars = new HashMap<String, Object>();
    vars.put("foo",
        new Foo());
    vars.put("$value",
        new Long(5));

    ExpressionCompiler compiler = new ExpressionCompiler("with (foo) { countTest = $value };");
View Full Code Here


  }

  protected static Map createTestMap() {
    Map map = new HashMap();
    map.put("foo", new Foo());
    map.put("a", null);
    map.put("b", null);
    map.put("c", "cat");
    map.put("BWAH", "");
View Full Code Here

  public void testIsDefOperator5() {
    assertEquals(true, test("!isdef _v1"));
  }

  public void testIsDefOperator6() {
    Foo foo = new Foo();
    assertEquals(true, MVEL.eval("isdef name", foo));
    assertEquals(true, MVEL.executeExpression(MVEL.compileExpression("isdef name"), foo));
  }
View Full Code Here

    assertEquals(str, result);
  }

  public void testMacroSupport() {
    Map<String, Object> vars = new HashMap<String, Object>();
    vars.put("foo", new Foo());

    Map<String, Interceptor> interceptors = new HashMap<String, Interceptor>();
    Map<String, Macro> macros = new HashMap<String, Macro>();

    interceptors.put("Modify", new Interceptor() {
View Full Code Here

  }


  public void testMacroSupportWithStrings() {
    Map<String, Object> vars = new HashMap<String, Object>();
    Foo foo = new Foo();
    vars.put("foo", foo);

    Map<String, Macro> macros = new HashMap<String, Macro>();

    macros.put("modify", new Macro() {
View Full Code Here

  }


  public void testMacroSupportWithDebugging() {
    Map<String, Object> vars = new HashMap<String, Object>();
    vars.put("foo", new Foo());

    Map<String, Interceptor> interceptors = new HashMap<String, Interceptor>();
    Map<String, Macro> macros = new HashMap<String, Macro>();

    interceptors.put("Modify", new Interceptor() {
View Full Code Here

        Bar.class);

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

    Foo foo = new Foo();

    executeSetExpression(s,
        foo,
        "12");

    assertEquals(12,
        foo.getBar().getIntarray()[0].intValue());

    foo = new Foo();

    executeSetExpression(s,
        foo,
        "13");

    assertEquals(13,
        foo.getBar().getIntarray()[0].intValue());

    OptimizerFactory.setDefaultOptimizer("ASM");

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

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

    foo = new Foo();

    executeSetExpression(s,
        foo,
        "12");

    assertEquals(12,
        foo.getBar().getIntarray()[0].intValue());

    executeSetExpression(s,
        foo,
        "13");

    assertEquals(13,
        foo.getBar().getIntarray()[0].intValue());
  }
View Full Code Here

  public void testInterfaceResolution() {
    Serializable ex = compileExpression("foo.collectionTest.size()");

    Map map = createTestMap();
    Foo foo = (Foo) map.get("foo");
    foo.setCollectionTest(new HashSet());
    Object result1 = executeExpression(ex, foo, map);

    foo.setCollectionTest(new ArrayList());
    Object result2 = executeExpression(ex, foo, map);

    assertEquals(result1, result2);
  }
View Full Code Here

  }

  public void testDynamicDeop() {
    Serializable s = compileExpression("name");

    assertEquals("dog", executeExpression(s, new Foo()));
    assertEquals("dog", executeExpression(s, new Foo().getBar()));
  }
View Full Code Here

  public void testNonHashMapImplMapPutMVEL302() {
    test("map=new java.util.Hashtable();map.foo='bar'");
  }

  public void testNullSafeWithDynamicOptimizerMVEL305() {
    Foo foo = new Foo();
    foo.setBar(null);
    OptimizerFactory.setDefaultOptimizer(OptimizerFactory.DYNAMIC);
    Serializable s = MVEL.compileExpression("this.?bar.name");
    // Iterate 100 times to ensure JIT ASM kicks in
    for (int i = 1; i < 100; i++) {
        assertNull(MVEL.executeExpression(s, foo));
View Full Code Here

TOP

Related Classes of org.mvel2.tests.core.res.Foo

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.