Java Code Examples for org.apache.hadoop.yarn.webapp.hamlet.Hamlet#getWriter()

The following examples show how to use org.apache.hadoop.yarn.webapp.hamlet.Hamlet#getWriter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestHamlet.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test public void testTable() {
  Hamlet h = newHamlet().
      title("test table").
      link("style.css");

  TABLE t = h.table("#id");

  for (int i = 0; i < 3; ++i) {
    t.tr().td("1").td("2")._();
  }
  t._();

  PrintWriter out = h.getWriter();
  out.flush();
  assertEquals(0, h.nestLevel);
  verify(out).print("<table");
  verify(out).print("</table>");
  verify(out, atLeast(1)).print("</td>");
  verify(out, atLeast(1)).print("</tr>");
}
 
Example 2
Source File: TestHamlet.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test public void testEnumAttrs() {
  Hamlet h = newHamlet().
      meta_http("Content-type", "text/html; charset=utf-8").
      title("test enum attrs").
      link().$rel("stylesheet").
        $media(EnumSet.of(Media.screen, Media.print)).
        $type("text/css").$href("style.css")._().
      link().$rel(EnumSet.of(LinkType.index, LinkType.start)).
        $href("index.html")._();

  h.div("#content")._("content")._();

  PrintWriter out = h.getWriter();
  out.flush();
  assertEquals(0, h.nestLevel);
  verify(out).print(" media=\"screen, print\"");
  verify(out).print(" rel=\"start index\"");
}
 
Example 3
Source File: TestHamlet.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test public void testTable() {
  Hamlet h = newHamlet().
      title("test table").
      link("style.css");

  TABLE t = h.table("#id");

  for (int i = 0; i < 3; ++i) {
    t.tr().td("1").td("2")._();
  }
  t._();

  PrintWriter out = h.getWriter();
  out.flush();
  assertEquals(0, h.nestLevel);
  verify(out).print("<table");
  verify(out).print("</table>");
  verify(out, atLeast(1)).print("</td>");
  verify(out, atLeast(1)).print("</tr>");
}
 
Example 4
Source File: TestHamlet.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test public void testEnumAttrs() {
  Hamlet h = newHamlet().
      meta_http("Content-type", "text/html; charset=utf-8").
      title("test enum attrs").
      link().$rel("stylesheet").
        $media(EnumSet.of(Media.screen, Media.print)).
        $type("text/css").$href("style.css")._().
      link().$rel(EnumSet.of(LinkType.index, LinkType.start)).
        $href("index.html")._();

  h.div("#content")._("content")._();

  PrintWriter out = h.getWriter();
  out.flush();
  assertEquals(0, h.nestLevel);
  verify(out).print(" media=\"screen, print\"");
  verify(out).print(" rel=\"start index\"");
}
 
Example 5
Source File: TestHamlet.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test public void testHamlet() {
  Hamlet h = newHamlet().
      title("test").
      h1("heading 1").
      p("#id.class").
        b("hello").
        em("world!")._().
      div("#footer").
        _("Brought to you by").
        a("http://hostname/", "Somebody")._();

  PrintWriter out = h.getWriter();
  out.flush();
  assertEquals(0, h.nestLevel);
  verify(out).print("<title");
  verify(out).print("test");
  verify(out).print("</title>");
  verify(out).print("<h1");
  verify(out).print("heading 1");
  verify(out).print("</h1>");
  verify(out).print("<p");
  verify(out).print(" id=\"id\"");
  verify(out).print(" class=\"class\"");
  verify(out).print("<b");
  verify(out).print("hello");
  verify(out).print("</b>");
  verify(out).print("<em");
  verify(out).print("world!");
  verify(out).print("</em>");
  verify(out).print("<div");
  verify(out).print(" id=\"footer\"");
  verify(out).print("Brought to you by");
  verify(out).print("<a");
  verify(out).print(" href=\"http://hostname/\"");
  verify(out).print("Somebody");
  verify(out).print("</a>");
  verify(out).print("</div>");
  verify(out, never()).print("</p>");
}
 
Example 6
Source File: TestHamlet.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test public void testScriptStyle() {
  Hamlet h = newHamlet().
      script("a.js").script("b.js").
      style("h1 { font-size: 1.2em }");

  PrintWriter out = h.getWriter();
  out.flush();
  assertEquals(0, h.nestLevel);
  verify(out, times(2)).print(" type=\"text/javascript\"");
  verify(out).print(" type=\"text/css\"");
}
 
Example 7
Source File: TestHamlet.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test public void testPreformatted() {
  Hamlet h = newHamlet().
      div().
        i("inline before pre").
        pre().
          _("pre text1\npre text2").
          i("inline in pre").
          _("pre text after inline")._().
        i("inline after pre")._();

  PrintWriter out = h.getWriter();
  out.flush();
  assertEquals(5, h.indents);
}
 
Example 8
Source File: TestHamlet.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test public void testSubViews() {
  Hamlet h = newHamlet().
      title("test sub-views").
      div("#view1")._(TestView1.class)._().
      div("#view2")._(TestView2.class)._();

  PrintWriter out = h.getWriter();
  out.flush();
  assertEquals(0, h.nestLevel);
  verify(out).print("["+ TestView1.class.getName() +"]");
  verify(out).print("["+ TestView2.class.getName() +"]");
}
 
Example 9
Source File: TestHamlet.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test public void testHamlet() {
  Hamlet h = newHamlet().
      title("test").
      h1("heading 1").
      p("#id.class").
        b("hello").
        em("world!")._().
      div("#footer").
        _("Brought to you by").
        a("http://hostname/", "Somebody")._();

  PrintWriter out = h.getWriter();
  out.flush();
  assertEquals(0, h.nestLevel);
  verify(out).print("<title");
  verify(out).print("test");
  verify(out).print("</title>");
  verify(out).print("<h1");
  verify(out).print("heading 1");
  verify(out).print("</h1>");
  verify(out).print("<p");
  verify(out).print(" id=\"id\"");
  verify(out).print(" class=\"class\"");
  verify(out).print("<b");
  verify(out).print("hello");
  verify(out).print("</b>");
  verify(out).print("<em");
  verify(out).print("world!");
  verify(out).print("</em>");
  verify(out).print("<div");
  verify(out).print(" id=\"footer\"");
  verify(out).print("Brought to you by");
  verify(out).print("<a");
  verify(out).print(" href=\"http://hostname/\"");
  verify(out).print("Somebody");
  verify(out).print("</a>");
  verify(out).print("</div>");
  verify(out, never()).print("</p>");
}
 
Example 10
Source File: TestHamlet.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test public void testScriptStyle() {
  Hamlet h = newHamlet().
      script("a.js").script("b.js").
      style("h1 { font-size: 1.2em }");

  PrintWriter out = h.getWriter();
  out.flush();
  assertEquals(0, h.nestLevel);
  verify(out, times(2)).print(" type=\"text/javascript\"");
  verify(out).print(" type=\"text/css\"");
}
 
Example 11
Source File: TestHamlet.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test public void testPreformatted() {
  Hamlet h = newHamlet().
      div().
        i("inline before pre").
        pre().
          _("pre text1\npre text2").
          i("inline in pre").
          _("pre text after inline")._().
        i("inline after pre")._();

  PrintWriter out = h.getWriter();
  out.flush();
  assertEquals(5, h.indents);
}
 
Example 12
Source File: TestHamlet.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test public void testSubViews() {
  Hamlet h = newHamlet().
      title("test sub-views").
      div("#view1")._(TestView1.class)._().
      div("#view2")._(TestView2.class)._();

  PrintWriter out = h.getWriter();
  out.flush();
  assertEquals(0, h.nestLevel);
  verify(out).print("["+ TestView1.class.getName() +"]");
  verify(out).print("["+ TestView2.class.getName() +"]");
}