Package de.odysseus.el.tree

Examples of de.odysseus.el.tree.Bindings


    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));
View Full Code Here


    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));
View Full Code Here

    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));
View Full Code Here

    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) {}
   
View Full Code Here

    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) {}
   
View Full Code Here

    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) {}
View Full Code Here

  }

  public void testAppendStructure() {
    StringBuilder s = null;

    Bindings bindings = new Bindings(null, null);
   
    s = new StringBuilder();
    parseNode("${f()}").appendStructure(s, bindings);
    parseNode("${f(x)}").appendStructure(s, bindings);
    parseNode("${f(x,y)}").appendStructure(s, bindings);
View Full Code Here

    // variable v
    context.setVariable("v", new ObjectValueExpression(new Long(0), long.class));
  }

  public void testSerialize() throws Exception {
    Bindings bindings = null;

    bindings = new Bindings(null, null);
    assertEquals(bindings, deserialize(serialize(bindings)));

    bindings = parse("${ns:f()+v+g(1)+x}").bind(context.getFunctionMapper(), context.getVariableMapper());
    assertEquals(bindings, deserialize(serialize(bindings)));
  }
View Full Code Here

    bindings = parse("${ns:f()+v+g(1)+x}").bind(context.getFunctionMapper(), context.getVariableMapper());
    assertEquals(bindings, deserialize(serialize(bindings)));
  }
 
  public void testEqualsAndHashcode() throws Exception {
    Bindings bindings1 = null;
    Bindings bindings2 = null;

    bindings1 = new Bindings(null, null);
    bindings2 = new Bindings(null, null);
    assertEquals(bindings1, bindings2);
    assertEquals(bindings1.hashCode(), bindings2.hashCode());

    bindings1 = new Bindings(new Method[0], new ValueExpression[0]);
    bindings2 = new Bindings(null, null);
    assertEquals(bindings1, bindings2);
    assertEquals(bindings1.hashCode(), bindings2.hashCode());

    Tree tree = parse("${ns:f()+v+g(1)}+x");
    bindings1 = tree.bind(context.getFunctionMapper(), context.getVariableMapper());
    bindings2 = tree.bind(context.getFunctionMapper(), context.getVariableMapper());
    assertEquals(bindings1, bindings2);
    assertEquals(bindings1.hashCode(), bindings2.hashCode());
  }
View Full Code Here

    context.setVariable("v0", new ObjectValueExpression(0, long.class));
    context.setVariable("v1", new ObjectValueExpression(1, long.class));
  }

  public void testBindFunctions() throws Exception {
    Bindings bindings = null;
   
    bindings = parse("${ns:f0()}").bind(context.getFunctionMapper(), null);
    assertSame(context.getFunctionMapper().resolveFunction("ns", "f0"), bindings.getFunction(0));
    try { bindings.getFunction(1); fail(); } catch (Exception e) {}
   
    bindings = parse("${ns:f1(1)}").bind(context.getFunctionMapper(), null);
    assertSame(context.getFunctionMapper().resolveFunction("ns", "f1"), bindings.getFunction(0));
    try { bindings.getFunction(1); fail(); } catch (Exception e) {}

    bindings = parse("${ns:f0()+ns:f1(1)}").bind(context.getFunctionMapper(), null);
    assertSame(context.getFunctionMapper().resolveFunction("ns", "f0"), bindings.getFunction(0));
    assertSame(context.getFunctionMapper().resolveFunction("ns", "f1"), bindings.getFunction(1));
    try { bindings.getFunction(2); fail(); } catch (Exception e) {}

    // the same for default namespace functions g0(), g1()
    bindings = parse("${g0()}").bind(context.getFunctionMapper(), null);
    assertSame(context.getFunctionMapper().resolveFunction("", "g0"), bindings.getFunction(0));
    try { bindings.getFunction(1); fail(); } catch (Exception e) {}
   
    bindings = parse("${g1(1)}").bind(context.getFunctionMapper(), null);
    assertSame(context.getFunctionMapper().resolveFunction("", "g1"), bindings.getFunction(0));
    try { bindings.getFunction(1); fail(); } catch (Exception e) {}

    bindings = parse("${g0()+g1(1)}").bind(context.getFunctionMapper(), null);
    assertSame(context.getFunctionMapper().resolveFunction("", "g0"), bindings.getFunction(0));
    assertSame(context.getFunctionMapper().resolveFunction("", "g1"), bindings.getFunction(1));
    try { bindings.getFunction(2); fail(); } catch (Exception e) {}

    try { parse("${foo()}").bind(context.getFunctionMapper(), null); fail(); } catch (Exception e) {}
    try { parse("${g1()}").bind(context.getFunctionMapper(), null); fail(); } catch (Exception e) {}
    try { parse("${g1(1,2)}").bind(context.getFunctionMapper(), null); fail(); } catch (Exception e) {}
  }
View Full Code Here

TOP

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

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.