Exemplo n.º 1
0
  /** Test simply building a bean */
  public void testBuildBean() {
    String xml = "<oddjob>" + " <job>" + "  <echo>Hello World</echo>" + " </job>" + "</oddjob>";

    Oddjob oj = new Oddjob();
    oj.setConfiguration(new XMLConfiguration("XML", xml));
    oj.setName("Test");

    JobInfoLookup lookup = new JobInfoLookup(new IconRegistry(), new StandardArooaSession());
    lookup.setRoot(oj, new OurExplorerContext());
    TreeNodeBeanBuilder builder = new TreeNodeBeanBuilder(lookup, "1");
    TreeNodeBean bean = builder.buildRoot();

    assertNotNull(bean);

    assertFalse(bean.isHasChildren());
    assertFalse(bean.isShowChildren());
    assertEquals("Test", bean.getNodeName());

    oj.run();

    builder.refresh(bean);

    assertTrue(bean.isHasChildren());
    assertFalse(bean.isShowChildren());

    bean.expand();

    assertTrue(bean.isHasChildren());
    assertTrue(bean.isShowChildren());
    assertEquals(1, bean.getChildren().size());

    // check child.
    TreeNodeBean[] children = (TreeNodeBean[]) bean.getChildren().toArray(new TreeNodeBean[0]);
    TreeNodeBean child = children[0];
    assertEquals(1, children.length);
    assertFalse(child.isShowChildren());
    assertFalse(child.isHasChildren());
    assertEquals(null, child.getChildren());

    bean.collapse();
    assertFalse(bean.isShowChildren());

    oj.hardReset();

    builder.refresh(bean);

    assertFalse(bean.isHasChildren());
    assertFalse(bean.isShowChildren());
  }
Exemplo n.º 2
0
  /** More complicated bean - tracking down a bug where child displayed twice. */
  public void testBuildBean2() {
    String xml =
        "<oddjob>"
            + " <job>"
            + "  <sequential name='Child 1'>"
            + "   <jobs>"
            + "    <sequential name='Child 2'>"
            + "     <jobs>"
            + "      <echo name='Child 3'>Hello World</echo>"
            + "     </jobs>"
            + "    </sequential>"
            + "   </jobs>"
            + "  </sequential>"
            + " </job>"
            + "</oddjob>";

    Oddjob oj = new Oddjob();
    oj.setConfiguration(new XMLConfiguration("XML", xml));
    oj.setName("Test");
    oj.run();

    JobInfoLookup lookup = new JobInfoLookup(new IconRegistry(), new StandardArooaSession());
    lookup.setRoot(oj, new OurExplorerContext());
    TreeNodeBeanBuilder builder = new TreeNodeBeanBuilder(lookup, "1");
    TreeNodeBean bean = builder.buildRoot();
    bean.expand();

    TreeNodeBean[] children;
    TreeNodeBean child;

    children = (TreeNodeBean[]) bean.getChildren().toArray(new TreeNodeBean[0]);
    child = children[0];
    assertEquals("Child 1", child.getNodeName());

    child.expand();
    children = (TreeNodeBean[]) child.getChildren().toArray(new TreeNodeBean[0]);
    child = children[0];
    assertEquals("Child 2", child.getNodeName());

    child.expand();
    children = (TreeNodeBean[]) child.getChildren().toArray(new TreeNodeBean[0]);
    child = children[0];
    assertEquals("Child 3", child.getNodeName());
  }