use of com.gargoylesoftware.htmlunit.html.HtmlHeading4 in project maven-doxia-sitetools by apache.
the class NestedItemsVerifier method verify.
/**
* {@inheritDoc}
*/
public void verify(String file) throws Exception {
HtmlPage page = htmlPage(file);
assertNotNull(page);
HtmlElement element = page.getHtmlElementById("contentBox");
assertNotNull(element);
HtmlDivision division = (HtmlDivision) element;
assertNotNull(division);
Iterator<HtmlElement> elementIterator = division.getHtmlElementDescendants().iterator();
// ----------------------------------------------------------------------
// Verify link
// ----------------------------------------------------------------------
HtmlSection section = (HtmlSection) elementIterator.next();
assertNotNull(section);
HtmlHeading2 h2 = (HtmlHeading2) elementIterator.next();
assertNotNull(h2);
assertEquals("List Section", h2.asText().trim());
HtmlAnchor a = (HtmlAnchor) elementIterator.next();
assertNotNull(a);
assertEquals("List_Section", a.getAttribute("name"));
// ----------------------------------------------------------------------
// Unordered lists
// ----------------------------------------------------------------------
section = (HtmlSection) elementIterator.next();
assertNotNull(section);
section = (HtmlSection) elementIterator.next();
assertNotNull(section);
HtmlHeading4 h4 = (HtmlHeading4) elementIterator.next();
assertNotNull(h4);
assertEquals("Unordered lists", h4.asText().trim());
a = (HtmlAnchor) elementIterator.next();
assertNotNull(a);
assertEquals("Unordered_lists", a.getAttribute("name"));
HtmlParagraph p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("Below is an unordered list, followed by six paragraphs.", p.asText().trim());
HtmlUnorderedList ul = (HtmlUnorderedList) elementIterator.next();
assertNotNull(ul);
HtmlListItem li = (HtmlListItem) elementIterator.next();
assertNotNull(li);
assertEquals("Item 1.", li.getFirstChild().asText().trim());
ul = (HtmlUnorderedList) elementIterator.next();
assertNotNull(ul);
li = (HtmlListItem) elementIterator.next();
assertNotNull(li);
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("Item 11.", p.getFirstChild().asText().trim());
li = (HtmlListItem) elementIterator.next();
assertNotNull(li);
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("Item 12.", p.getFirstChild().asText().trim());
li = (HtmlListItem) elementIterator.next();
assertNotNull(li);
assertEquals("Item 13.", li.getFirstChild().asText().trim());
li = (HtmlListItem) elementIterator.next();
assertNotNull(li);
assertEquals("Item 14.", li.getFirstChild().asText().trim());
li = (HtmlListItem) elementIterator.next();
assertNotNull(li);
assertEquals("Item 2.", li.getFirstChild().asText().trim());
li = (HtmlListItem) elementIterator.next();
assertNotNull(li);
assertEquals("Item 3.", li.getFirstChild().asText().trim());
li = (HtmlListItem) elementIterator.next();
assertNotNull(li);
assertEquals("Item 4.", li.getFirstChild().asText().trim());
ul = (HtmlUnorderedList) elementIterator.next();
assertNotNull(ul);
li = (HtmlListItem) elementIterator.next();
assertNotNull(li);
assertEquals("Item 41.", li.getFirstChild().asText().trim());
li = (HtmlListItem) elementIterator.next();
assertNotNull(li);
assertEquals("Item 42.", li.getFirstChild().asText().trim());
li = (HtmlListItem) elementIterator.next();
assertNotNull(li);
assertEquals("Item 43.", li.getFirstChild().asText().trim());
li = (HtmlListItem) elementIterator.next();
assertNotNull(li);
assertEquals("Item 44.", li.getFirstChild().asText().trim());
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("Paragraph 1 below list.", p.asText().trim());
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("Paragraph 2 below list.", p.asText().trim());
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("Paragraph 3 below list.", p.asText().trim());
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("Paragraph 4 below list.", p.asText().trim());
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("Paragraph 5 below list.", p.asText().trim());
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("Paragraph 6 below list.", p.asText().trim());
// ----------------------------------------------------------------------
// Ordered lists
// ----------------------------------------------------------------------
section = (HtmlSection) elementIterator.next();
assertNotNull(section);
h4 = (HtmlHeading4) elementIterator.next();
assertNotNull(h4);
assertEquals("Ordered lists", h4.asText().trim());
a = (HtmlAnchor) elementIterator.next();
assertNotNull(a);
assertEquals("Ordered_lists", a.getAttribute("name"));
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("Below is an ordered list, followed by six paragraphs.", p.asText().trim());
HtmlOrderedList ol = (HtmlOrderedList) elementIterator.next();
assertNotNull(ol);
li = (HtmlListItem) elementIterator.next();
assertNotNull(li);
assertEquals("Item 1.", li.getFirstChild().asText().trim());
ol = (HtmlOrderedList) elementIterator.next();
assertNotNull(ol);
li = (HtmlListItem) elementIterator.next();
assertNotNull(li);
assertEquals("Item 11.", li.getFirstChild().asText().trim());
li = (HtmlListItem) elementIterator.next();
assertNotNull(li);
assertEquals("Item 12.", li.getFirstChild().asText().trim());
li = (HtmlListItem) elementIterator.next();
assertNotNull(li);
assertEquals("Item 13.", li.getFirstChild().asText().trim());
li = (HtmlListItem) elementIterator.next();
assertNotNull(li);
assertEquals("Item 14.", li.getFirstChild().asText().trim());
li = (HtmlListItem) elementIterator.next();
assertNotNull(li);
assertEquals("Item 2.", li.getFirstChild().asText().trim());
li = (HtmlListItem) elementIterator.next();
assertNotNull(li);
assertEquals("Item 3.", li.getFirstChild().asText().trim());
li = (HtmlListItem) elementIterator.next();
assertNotNull(li);
assertEquals("Item 4.", li.getFirstChild().asText().trim());
ol = (HtmlOrderedList) elementIterator.next();
assertNotNull(ol);
li = (HtmlListItem) elementIterator.next();
assertNotNull(li);
assertEquals("Item 41.", li.getFirstChild().asText().trim());
li = (HtmlListItem) elementIterator.next();
assertNotNull(li);
assertEquals("Item 42.", li.getFirstChild().asText().trim());
li = (HtmlListItem) elementIterator.next();
assertNotNull(li);
assertEquals("Item 43.", li.getFirstChild().asText().trim());
li = (HtmlListItem) elementIterator.next();
assertNotNull(li);
assertEquals("Item 44.", li.getFirstChild().asText().trim());
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("Paragraph 1 below list.", p.asText().trim());
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("Paragraph 2 below list.", p.asText().trim());
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("Paragraph 3 below list.", p.asText().trim());
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("Paragraph 4 below list.", p.asText().trim());
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("Paragraph 5 below list.", p.asText().trim());
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("Paragraph 6 below list.", p.asText().trim());
// ----------------------------------------------------------------------
// Definition lists
// ----------------------------------------------------------------------
section = (HtmlSection) elementIterator.next();
assertNotNull(section);
h4 = (HtmlHeading4) elementIterator.next();
assertNotNull(h4);
assertEquals("Definition lists", h4.asText().trim());
a = (HtmlAnchor) elementIterator.next();
assertNotNull(a);
assertEquals("Definition_lists", a.getAttribute("name"));
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("Below is a definition list, followed by six paragraphs.", p.asText().trim());
HtmlDefinitionList dl = (HtmlDefinitionList) elementIterator.next();
assertNotNull(dl);
HtmlDefinitionTerm dt = (HtmlDefinitionTerm) elementIterator.next();
assertNotNull(dt);
assertEquals("Term 1.", dt.getFirstChild().asText().trim());
HtmlDefinitionDescription dd = (HtmlDefinitionDescription) elementIterator.next();
assertNotNull(dd);
assertEquals("Description 1.", dd.getFirstChild().asText().trim());
dt = (HtmlDefinitionTerm) elementIterator.next();
assertNotNull(dt);
assertEquals("Term 2.", dt.getFirstChild().asText().trim());
dd = (HtmlDefinitionDescription) elementIterator.next();
assertNotNull(dd);
assertEquals("Description 2.", dd.getFirstChild().asText().trim());
dl = (HtmlDefinitionList) elementIterator.next();
assertNotNull(dl);
dt = (HtmlDefinitionTerm) elementIterator.next();
assertNotNull(dt);
assertEquals("Term 21.", dt.getFirstChild().asText().trim());
dd = (HtmlDefinitionDescription) elementIterator.next();
assertNotNull(dd);
assertEquals("Description 21.", dd.getFirstChild().asText().trim());
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("Paragraph 1 below list.", p.asText().trim());
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("Paragraph 2 below list.", p.asText().trim());
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("Paragraph 3 below list.", p.asText().trim());
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("Paragraph 4 below list.", p.asText().trim());
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("Paragraph 5 below list.", p.asText().trim());
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("Paragraph 6 below list.", p.asText().trim());
assertFalse(elementIterator.hasNext());
}
use of com.gargoylesoftware.htmlunit.html.HtmlHeading4 in project maven-doxia-sitetools by apache.
the class EntitiesVerifier method verify.
/**
* {@inheritDoc}
*/
public void verify(String file) throws Exception {
HtmlPage page = htmlPage(file);
assertNotNull(page);
HtmlMeta author = (HtmlMeta) page.getElementsByName("author").get(0);
assertNotNull(author);
assertTrue(author.toString().indexOf("Ligature \u00C6") > 0);
assertEquals("Ligature \u00C6", author.getContentAttribute());
author = (HtmlMeta) page.getElementsByName("author").get(1);
assertNotNull(author);
assertTrue(author.toString().indexOf("Ampersand &") > 0);
assertEquals("Ampersand &", author.getContentAttribute());
author = (HtmlMeta) page.getElementsByName("author").get(2);
assertNotNull(author);
assertTrue(author.toString().indexOf("Less than <") > 0);
assertEquals("Less than <", author.getContentAttribute());
author = (HtmlMeta) page.getElementsByName("author").get(3);
assertNotNull(author);
assertTrue(author.toString().indexOf("Greater than >") > 0);
assertEquals("Greater than >", author.getContentAttribute());
author = (HtmlMeta) page.getElementsByName("author").get(4);
assertNotNull(author);
assertEquals("Apostrophe '", author.getContentAttribute());
author = (HtmlMeta) page.getElementsByName("author").get(5);
assertNotNull(author);
assertTrue(author.toString().indexOf("Quote "") > 0);
assertEquals("Quote \"", author.getContentAttribute());
author = (HtmlMeta) page.getElementsByName("author").get(6);
assertNotNull(author);
assertTrue(author.toString().indexOf("test@email.com") > 0);
assertEquals("test@email.com", author.getContentAttribute());
author = (HtmlMeta) page.getElementsByName("author").get(7);
assertNotNull(author);
assertTrue(author.toString().indexOf("test\u00A9email.com") > 0);
assertEquals("test\u00A9email.com", author.getContentAttribute());
HtmlElement element = page.getHtmlElementById("contentBox");
assertNotNull(element);
HtmlDivision division = (HtmlDivision) element;
assertNotNull(division);
Iterator<HtmlElement> elementIterator = division.getHtmlElementDescendants().iterator();
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
HtmlSection section = (HtmlSection) elementIterator.next();
HtmlHeading2 h2 = (HtmlHeading2) elementIterator.next();
assertNotNull(h2);
assertEquals(h2.asText().trim(), "section name with entities: '&' '\u0391' ' ' '\uD835\uDFED'");
HtmlAnchor a = (HtmlAnchor) elementIterator.next();
assertNotNull(a);
assertEquals("section_name_with_entities:_.27.26.27_.27.CE.91.27_.27.C2.A0.27_.27.3F.3F.27", a.getAttribute("name"));
section = (HtmlSection) elementIterator.next();
assertNotNull(section);
section = (HtmlSection) elementIterator.next();
assertNotNull(section);
HtmlHeading4 h4 = (HtmlHeading4) elementIterator.next();
assertNotNull(h4);
assertEquals("Entities", h4.asText().trim());
a = (HtmlAnchor) elementIterator.next();
assertNotNull(a);
assertEquals("Entities", a.getAttribute("name"));
section = (HtmlSection) elementIterator.next();
assertNotNull(section);
HtmlHeading3 h3 = (HtmlHeading3) elementIterator.next();
assertNotNull(h3);
assertEquals("Generic Entities: '&' '<' '>' '\"' '''", h3.asText().trim());
a = (HtmlAnchor) elementIterator.next();
HtmlParagraph p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("'&' '<' '>' '\"' '''", p.asText().trim());
section = (HtmlSection) elementIterator.next();
assertNotNull(section);
h3 = (HtmlHeading3) elementIterator.next();
assertNotNull(h3);
assertEquals("Local Entities: '\u0391' '\u0392' '\u0393' '\uD835\uDFED'", h3.asText().trim());
a = (HtmlAnchor) elementIterator.next();
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("'\u0391' '\u0392' '\u0393' '\uD835\uDFED\uD835\uDFED' '\u0159\u0159' '\u0159'", p.asText().trim());
section = (HtmlSection) elementIterator.next();
assertNotNull(section);
h3 = (HtmlHeading3) elementIterator.next();
assertNotNull(h3);
assertEquals("DTD Entities: ' ' '\u00A1' '\u00A2'", h3.asText().trim());
a = (HtmlAnchor) elementIterator.next();
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("' ' '\u00A1' '\u00A2'", p.asText().trim());
section = (HtmlSection) elementIterator.next();
assertNotNull(section);
h4 = (HtmlHeading4) elementIterator.next();
assertNotNull(h4);
assertEquals("CDATA", h4.asText().trim());
a = (HtmlAnchor) elementIterator.next();
assertNotNull(a);
assertEquals("CDATA", a.getAttribute("name"));
HtmlDivision div = (HtmlDivision) elementIterator.next();
assertNotNull(div);
HtmlPreformattedText pre = (HtmlPreformattedText) elementIterator.next();
assertNotNull(pre);
assertEquals("<project xmlns:ant=\"jelly:ant\">", pre.asText().trim());
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("' ' '¡'", p.asText().trim());
assertFalse(elementIterator.hasNext());
}
Aggregations