Пример #1
0
  public void testParseFileLongerThan2048chars() throws ParseException {
    StringBuilder b = new StringBuilder();
    for (int i = 0; i < 2048 * 3; i++) {
      b.append('*');
    }

    String code =
        "<!doctype html>\n"
            + "<html>\n"
            + "<title></title>\n"
            + "<body>\n"
            + b.toString()
            + "</body>\n"
            + "</html>\n";

    //        ParseTreeBuilder.setLoggerLevel(Level.ALL);
    HtmlParseResult result = parse(code);
    Node root = result.root();

    assertNotNull(root);
    //        ElementUtils.dumpTree(root);

    OpenTag body = ElementUtils.query(result.root(), "html/body");
    assertNotNull(body);

    CloseTag bodyEnd = body.matchingCloseTag();
    assertNotNull(bodyEnd);

    assertEquals(6190, bodyEnd.from());
    assertEquals(6197, bodyEnd.to());
  }
Пример #2
0
  public void testDuplicatedEntriesInHtmlModel() {
    HtmlModel model = HtmlModelFactory.getModel(HtmlVersion.HTML5);
    assertNotNull(model);

    Collection<HtmlTag> tags = model.getAllTags();

    Collection<HtmlTag> names = new HashSet<HtmlTag>();
    StringBuilder sb = new StringBuilder();
    for (HtmlTag t : tags) {
      if (!names.add(t)) {
        sb.append(t.toString());
        sb.append("(");
        sb.append(t.hashCode());
        sb.append(")");
        sb.append(", ");
      }
    }
    assertTrue("found duplicated entry/ies: " + sb.toString(), sb.length() == 0);
  }