Ejemplo n.º 1
0
  public void testExample() {

    Oddjob oddjob = new Oddjob();
    oddjob.setConfiguration(
        new XMLConfiguration(
            "org/oddjob/values/types/TokenizerExample.xml", getClass().getClassLoader()));

    ConsoleCapture console = new ConsoleCapture();
    try (ConsoleCapture.Close close = console.captureConsole()) {

      oddjob.run();
    }

    assertEquals(ParentState.COMPLETE, oddjob.lastStateEvent().getState());

    console.dump(logger);

    String[] lines = console.getLines();

    assertEquals("I'm 1", lines[0].trim());
    assertEquals("I'm 2", lines[1].trim());
    assertEquals("I'm 3", lines[2].trim());
    assertEquals("I'm 4", lines[3].trim());

    assertEquals(12, lines.length);

    oddjob.destroy();
  }
Ejemplo n.º 2
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());
  }
Ejemplo n.º 3
0
  public void testSimpleExample() throws ArooaPropertyException, ArooaConversionException {

    File file = new File(getClass().getResource("GroovyExpressionSimple.xml").getFile());

    Oddjob oddjob = new Oddjob();
    oddjob.setFile(file);

    oddjob.run();

    assertEquals(ParentState.COMPLETE, oddjob.lastStateEvent().getState());

    OddjobLookup lookup = new OddjobLookup(oddjob);

    assertEquals(new Integer(4), lookup.lookup("vars.result", Integer.class));
    assertEquals("4", lookup.lookup("echo.text"));

    oddjob.destroy();
  }
Ejemplo n.º 4
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());
  }