Пример #1
0
  /**
   * Test method for {@link htmlflow.HtmlWriterComposite#doWriteBefore(java.io.PrintStream, int)} .
   */
  @Test
  public void testDoWrite() throws Exception {

    HtmlView<Task> taskView2 = new HtmlView<Task>();

    taskView2.head().title("Task Details");
    taskView2
        .body()
        .heading(0, "Task Details")
        .hr()
        .div()
        .text("Id: ")
        .text(binderGetId())
        .br()
        .text("Title: ")
        .text(binderGetTitle())
        .br()
        .text("Description: ")
        .text(binderGetDescription())
        .br()
        .text("Priority: ")
        .text(binderGetPriority());
    Task t2 = new Task("Unit Test", "Test of element name", Priority.High, Status.Progress);
    ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream();
    PrintStream out2 = new PrintStream(byteArrayOutputStream2);
    taskView2.setPrintStream(out2).write(0, t2);
    System.out.println(byteArrayOutputStream2.toString());
  }
Пример #2
0
  @Test
  public void testIdAndClassAttribute() throws Exception {
    HtmlView<Task> taskView = new HtmlView<Task>();
    assertEquals(
        ElementType.DIV + " elementwas expected",
        ElementType.DIV.toString(),
        taskView.body().div().getElementName());

    String divClass = "divClass";
    String divId = "divId";
    taskView.body().div().classAttr(divClass).idAttr(divId);
    Task t1 = new Task("Unit Test", "Test of element name", Priority.High, Status.Progress);
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    PrintStream out = new PrintStream(byteArrayOutputStream);
    taskView.setPrintStream(out).write(0, t1);
    String result = byteArrayOutputStream.toString();
    System.out.println(result);
    assertTrue(result.contains("<div"));
    assertTrue(result.contains("</div>"));
    assertTrue(result.contains(divClass));
    assertTrue(result.contains(divId));
  }