public void test_Get_Source() throws Throwable {
    ASTProperty p = new ASTProperty(0);
    p.setIndexedAccess(false);
    ASTConst pRef = new ASTConst(0);
    pRef.setValue("nested");
    pRef.jjtSetParent(p);
    p.jjtAddChild(pRef, 0);

    Map root = new Root().getMap();

    OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null);
    context.setRoot(root);
    context.setCurrentObject(root);
    context.setCurrentNode(pRef);

    assertEquals(".get(\"nested\")", p.toGetSourceString(context, root));
    assertEquals(Object.class, context.getCurrentType());
    assertEquals(Map.class, context.getCurrentAccessor());
    assertEquals(root.getClass(), context.getPreviousType());
    assertEquals(null, context.getPreviousAccessor());

    assertEquals(root.get("nested"), context.getCurrentObject());

    assert Map.class.isAssignableFrom(context.getCurrentAccessor());

    assertEquals(root.getClass(), context.getPreviousType());
    assertEquals(null, context.getPreviousAccessor());
  }
  public void test_Indexed_Object_Type() throws Throwable {
    // ASTChain chain = new ASTChain(0);

    ASTProperty listp = new ASTProperty(0);
    listp.setIndexedAccess(false);
    // listp.jjtSetParent(chain);

    ASTConst listc = new ASTConst(0);
    listc.setValue("list");
    listc.jjtSetParent(listp);
    listp.jjtAddChild(listc, 0);

    // chain.jjtAddChild(listp, 0);

    ASTProperty p = new ASTProperty(0);
    p.setIndexedAccess(true);

    ASTProperty pindex = new ASTProperty(0);

    ASTConst pRef = new ASTConst(0);
    pRef.setValue("genericIndex");
    pRef.jjtSetParent(pindex);
    pindex.jjtAddChild(pRef, 0);

    p.jjtAddChild(pindex, 0);
    // chain.jjtAddChild(p, 1);

    Root root = new Root();

    OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null);
    context.setRoot(root);
    context.setCurrentObject(root);
    context.setCurrentNode(listp);

    assertEquals(".getList()", listp.toGetSourceString(context, root));
    assertEquals(List.class, context.getCurrentType());
    assertEquals(Root.class, context.getCurrentAccessor());
    assertEquals(null, context.getPreviousAccessor());
    assertEquals(root.getClass(), context.getPreviousType());
    assertEquals(root.getList(), context.getCurrentObject());

    // re test with chain

    context = (OgnlContext) Ognl.createDefaultContext(null);
    context.setRoot(root);
    context.setCurrentObject(root);

    ASTChain chain = new ASTChain(0);
    listp.jjtSetParent(chain);
    chain.jjtAddChild(listp, 0);

    context.setCurrentNode(chain);

    assertEquals(".getList()", chain.toGetSourceString(context, root));
    assertEquals(List.class, context.getCurrentType());
    assertEquals(Root.class, context.getCurrentAccessor());
    assertEquals(null, context.getPreviousAccessor());
    assertEquals(Root.class, context.getPreviousType());
    assertEquals(root.getList(), context.getCurrentObject());

    // test with only getIndex

    assertEquals(
        ".get(ognl.OgnlOps#getIntValue(((org.ognl.test.objects.Root)$2)..getGenericIndex().toString()))",
        p.toGetSourceString(context, root.getList()));
    assertEquals(root.getArray(), context.getCurrentObject());
    assertEquals(Object.class, context.getCurrentType());
  }