Package de.odysseus.el.tree

Examples of de.odysseus.el.tree.Tree


  public void testIsLeftValue() {
    assertTrue(parseNode("${foo}").isLeftValue());
  }

  public void testGetType() {
    Tree tree = null;
    Bindings bindings = null;

    tree = parse("${var_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertEquals(null, getNode(tree).getType(bindings, context));

    tree = parse("${property_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertEquals(Object.class, getNode(tree).getType(bindings, context));

    tree = parse("${var_var_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertEquals(null, getNode(tree).getType(bindings, context));

    tree = parse("${var_property_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertEquals(Object.class, getNode(tree).getType(bindings, context));

    tree = parse("${indentifier_string}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertEquals(null, getNode(tree).getType(bindings, context));
  }
View Full Code Here


    bindings = tree.bind(null, context.getVariableMapper());
    assertEquals(null, getNode(tree).getType(bindings, context));
  }

  public void testIsReadOnly() {
    Tree tree = null;
    Bindings bindings = null;
   
    tree = parse("${var_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertTrue(getNode(tree).isReadOnly(bindings, context));

    tree = parse("${property_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertFalse(getNode(tree).isReadOnly(bindings, context));

    tree = parse("${var_var_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertTrue(getNode(tree).isReadOnly(bindings, context));

    tree = parse("${var_property_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertFalse(getNode(tree).isReadOnly(bindings, context));

    tree = parse("${indentifier_string}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertTrue(getNode(tree).isReadOnly(bindings, context));
  }
View Full Code Here

    bindings = tree.bind(null, context.getVariableMapper());
    assertTrue(getNode(tree).isReadOnly(bindings, context));
  }

  public void testSetValue() {
    Tree tree = null;
    Bindings bindings = null;

    tree = parse("${bad}");
    bindings = tree.bind(null, context.getVariableMapper());
    getNode(tree).setValue(bindings, context, "good");
    assertEquals("good", getNode(tree).getValue(bindings, context, null));

    tree = parse("${var_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    try { getNode(tree).setValue(bindings, context, 2l); fail(); } catch (ELException e) {}

    tree = parse("${property_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertEquals(1l, getNode(tree).getValue(bindings, context, null));
    getNode(tree).setValue(bindings, context, 2l);
    assertEquals(2l, getNode(tree).getValue(bindings, context, null));

    tree = parse("${var_var_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    try { getNode(tree).setValue(bindings, context, 2l); fail(); } catch (ELException e) {}

    tree = parse("${var_property_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertEquals(2l, getNode(tree).getValue(bindings, context, null));
    getNode(tree).setValue(bindings, context, 1l);
    assertEquals(1l, getNode(tree).getValue(bindings, context, null));

    tree = parse("${indentifier_string}");
    bindings = tree.bind(null, context.getVariableMapper());
    try { getNode(tree).setValue(bindings, context, "bar"); fail(); } catch (ELException e) {}
  }
View Full Code Here

    bindings = tree.bind(null, context.getVariableMapper());
    try { getNode(tree).setValue(bindings, context, "bar"); fail(); } catch (ELException e) {}
  }

  public void testGetValue() {
    Tree tree = null;
    Bindings bindings = null;

    tree = parse("${bad}");
    bindings = tree.bind(null, context.getVariableMapper());
    try { getNode(tree).getValue(bindings, context, null); fail(); } catch (ELException e) {}
   
    tree = parse("${var_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertEquals(1l, getNode(tree).getValue(bindings, context, null));
    assertEquals("1", getNode(tree).getValue(bindings, context, String.class));
  }
View Full Code Here

    assertEquals(1l, getNode(tree).getValue(bindings, context, null));
    assertEquals("1", getNode(tree).getValue(bindings, context, String.class));
  }
 
  public void testInvoke() {
    Tree tree = null;
    Bindings bindings = null;

    tree = parse("${bad}");
    bindings = tree.bind(null, context.getVariableMapper());
    try { getNode(tree).invoke(bindings, context, long.class, new Class[0], null); fail(); } catch (ELException e) {}
   
    tree = parse("${var_method_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertEquals(1l, getNode(tree).invoke(bindings, context, long.class, new Class[0], null));
   
    tree = parse("${property_method_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertEquals(1l, getNode(tree).invoke(bindings, context, null, new Class[0], null));

    // no return type - ok
    assertEquals(1l, getNode(tree).invoke(bindings, context, long.class, new Class[0], null));
    // bad return type
View Full Code Here

    // bad args
    try { getNode(tree).invoke(bindings, context, long.class, new Class[0], new Object[]{""}); fail(); } catch (ELException e) {}
  }

  public void testGetMethodInfo() {
    Tree tree = null;
    Bindings bindings = null;
    MethodInfo info = null;

    tree = parse("${bad}");
    bindings = tree.bind(null, context.getVariableMapper());
    try { getNode(tree).getMethodInfo(bindings, context, long.class, new Class[0]); fail(); } catch (ELException e) {}
   
    tree = parse("${var_method_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    info = getNode(tree).getMethodInfo(bindings, context, long.class, new Class[0]);
    assertEquals("method_1", info.getName());
    assertTrue(Arrays.equals(new Class[0], info.getParamTypes()));
    assertEquals(long.class, info.getReturnType());
   
    tree = parse("${property_method_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    info = getNode(tree).getMethodInfo(bindings, context, long.class, new Class[0]);
    assertEquals("method_1", info.getName());
    assertTrue(Arrays.equals(new Class[0], info.getParamTypes()));
    assertEquals(long.class, info.getReturnType());
View Full Code Here

    context.setFunction("", "g1", getClass().getMethod("bar", new Class[]{int.class}));
    context.setFunction("", "g2", getClass().getMethod("foobar", new Class[]{int.class, int.class}));
  }

  public void testEval() {
    Tree tree = null;

    tree = parse("${ns:f0()}");
    assertEquals(foo(), getNode(tree).eval(tree.bind(context.getFunctionMapper(), null), null));

    tree = parse("${ns:f1(42)}");
    assertEquals(bar(42), getNode(tree).eval(tree.bind(context.getFunctionMapper(), null), null));

    tree = parse("${ns:f2(21,21)}");
    assertEquals(foobar(21,21), getNode(tree).eval(tree.bind(context.getFunctionMapper(), null), null));

    tree = parse("${g0()}");
    assertEquals(foo(), getNode(tree).eval(tree.bind(context.getFunctionMapper(), null), null));

    tree = parse("${g1(42)}");
    assertEquals(bar(42), getNode(tree).eval(tree.bind(context.getFunctionMapper(), null), null));

    tree = parse("${g2(21,21)}");
    assertEquals(foobar(21,21), getNode(tree).eval(tree.bind(context.getFunctionMapper(), null), null));
  }
View Full Code Here

  public void testSetValue() {
    try { parseNode("${f()}").setValue(null, null, null); fail(); } catch (ELException e) {}
  }

  public void testGetValue() {
    Tree tree = null;

    tree = parse("${ns:f0()}");

    assertEquals(foo(), getNode(tree).getValue(tree.bind(context.getFunctionMapper(), null), null, null));
    assertEquals("" + foo(), getNode(tree).getValue(tree.bind(context.getFunctionMapper(), null), null, String.class));
  }
View Full Code Here

public class TreeStoreTest extends TestCase {
  public void test() {
    TreeStore store = new TreeStore(BUILDER, new Cache(1));
    assertSame(BUILDER, store.getBuilder());

    Tree tree = store.get("1");
    assertNotNull(tree);
    assertSame(tree, store.get("1"));
  }
View Full Code Here

import de.odysseus.el.tree.Tree;
import de.odysseus.el.tree.impl.ast.AstBinary;

public class ParserTest extends TestCase {
  static Tree verifyLiteralExpression(String expression) {
    Tree tree = parse(expression);
    assertTrue(tree.getRoot().isLiteralText());
    assertEquals(expression, tree.getRoot().getStructuralId(null));
    return tree;
  }
View Full Code Here

TOP

Related Classes of de.odysseus.el.tree.Tree

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.