Package de.odysseus.el.tree

Examples of de.odysseus.el.tree.Tree


    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 testGetValueReference() {
    Tree tree = null;
    Bindings bindings = null;

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

    tree = parse("${property_long_1}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertNotNull(getNode(tree).getValueReference(bindings, context));
  }
View Full Code Here

    bindings = tree.bind(null, context.getVariableMapper());
    assertNotNull(getNode(tree).getValueReference(bindings, context));
  }

  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
    try { getNode(tree).invoke(bindings, context, int.class, new Class[0], null); fail(); } catch (ELException e) {}
    // bad arg types
    try { getNode(tree).invoke(bindings, context, long.class, new Class[]{String.class}, null); fail(); } catch (ELException e) {}
    // bad args
    try { getNode(tree).invoke(bindings, context, long.class, new Class[0], new Object[]{""}); fail(); } catch (ELException e) {}

    tree = parse("${var_method_1_expr}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertEquals(1l, getNode(tree).invoke(bindings, context, long.class, new Class[0], null));
   
    tree = parse("${property_method_1_expr}");
    bindings = tree.bind(null, context.getVariableMapper());
    assertEquals(1l, getNode(tree).invoke(bindings, context, null, new Class[0], null));

  }
View Full Code Here

    assertEquals(1l, getNode(tree).invoke(bindings, context, null, new Class[0], null));

  }

  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

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

    assertEquals(expression, tree.getRoot().getStructuralId(null));
    return tree;
  }

  static Tree verifyEvalExpression(String canonical) {
    Tree tree = parse(canonical);
    assertFalse(tree.getRoot().isLiteralText());
    assertEquals(canonical, tree.getRoot().getStructuralId(null));
    return tree;
  }
View Full Code Here

    assertEquals(canonical, tree.getRoot().getStructuralId(null));
    return tree;
  }

  static Tree verifyEvalExpression(String canonical, String expression) {
    Tree tree = parse(expression);
    assertFalse(tree.getRoot().isLiteralText());
    assertEquals(canonical, tree.getRoot().getStructuralId(null));
    return verifyEvalExpression(canonical);
  }
View Full Code Here

    assertEquals(canonical, tree.getRoot().getStructuralId(null));
    return verifyEvalExpression(canonical);
  }

  static Tree verifyEvalExpression(String canonical, String expression1, String expression2) {
    Tree tree = parse(expression2);
    assertFalse(tree.getRoot().isLiteralText());
    assertEquals(canonical, tree.getRoot().getStructuralId(null));
    return verifyEvalExpression(canonical, expression1);
  }
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.