Refactor JsoupParserTest

This commit is contained in:
pivovarit 2017-01-11 07:20:55 +01:00
parent 4772976bda
commit 94c315c1c2

View File

@ -1,17 +1,19 @@
package com.baeldung.jsoup; package com.baeldung.jsoup;
import java.io.IOException;
import org.jsoup.HttpStatusException; import org.jsoup.HttpStatusException;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.jsoup.nodes.Document; import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element; import org.jsoup.nodes.Element;
import org.jsoup.parser.Tag; import org.jsoup.parser.Tag;
import org.jsoup.select.Elements; import org.jsoup.select.Elements;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class JsoupParserTest { public class JsoupParserTest {
Document doc; Document doc;
@ -70,7 +72,7 @@ public class JsoupParserTest {
Elements children = firstSection.children(); Elements children = firstSection.children();
Elements siblings = firstSection.siblingElements(); Elements siblings = firstSection.siblingElements();
sections.stream().forEach(el -> System.out.println("section: " + el)); sections.forEach(el -> System.out.println("section: " + el));
} }
@Test @Test
@ -96,9 +98,9 @@ public class JsoupParserTest {
firstArticle.select("h2").html("<div><span></span></div>"); firstArticle.select("h2").html("<div><span></span></div>");
Element link = new Element(Tag.valueOf("a"), "") Element link = new Element(Tag.valueOf("a"), "")
.text("Checkout this amazing website!") .text("Checkout this amazing website!")
.attr("href", "http://baeldung.com") .attr("href", "http://baeldung.com")
.attr("target", "_blank"); .attr("target", "_blank");
firstArticle.appendChild(link); firstArticle.appendChild(link);
doc.select("li.navbar-link").remove(); doc.select("li.navbar-link").remove();