public void testHtml5Model() throws ParseException { String code = "<!doctype html><title>hi</title>"; HtmlParseResult result = parse(code); HtmlModel model = result.model(); assertNotNull(model); // assertEquals("html5model", model.getModelId()); Collection<HtmlTag> all = model.getAllTags(); assertNotNull(all); assertEquals(ElementDescriptor.values().length, all.size()); HtmlTag table = HtmlTagProvider.getTagForElement("table"); assertNotNull(table); assertTrue(all.contains(table)); // try to modify the unmodifiable collection try { all.remove(table); assertTrue("The tags collection can be modified!", false); } catch (UnsupportedOperationException t) { // ok } }
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); }