JAVA-18808 (#13589)

* [JAVA-18808] Fixed test cases

* [JAVA-18808] Fixed test cases

* [JAVA-18808] Fixed test cases

* [JAVA-18808] Clean up

---------

Co-authored-by: Dhawal Kapil <dhawalkapil@gmail.com>
This commit is contained in:
panos-kakos 2023-03-19 19:46:52 +02:00 committed by GitHub
parent fd83fd8182
commit ef3e667606
2 changed files with 23 additions and 28 deletions

View File

@ -47,7 +47,7 @@ public class JsoupParserIntegrationTest {
} }
@Test @Test
public void examplesSelectors() { public void examplesSelectors() throws IOException {
Elements links = doc.select("a"); Elements links = doc.select("a");
Elements logo = doc.select(".spring-logo--container"); Elements logo = doc.select(".spring-logo--container");
Elements pagination = doc.select("#pagination_control"); Elements pagination = doc.select("#pagination_control");
@ -57,52 +57,46 @@ public class JsoupParserIntegrationTest {
Element pag = doc.getElementById("pagination_control"); Element pag = doc.getElementById("pagination_control");
Elements desktopOnly = doc.getElementsByClass("desktopOnly"); Elements desktopOnly = doc.getElementsByClass("desktopOnly");
Elements sections = doc.select("section"); Elements articles = doc.select("article");
Element firstSection = sections.first(); Element firstArticle = articles.first();
Elements sectionParagraphs = firstSection.select(".paragraph"); Elements sectionParagraphs = firstArticle.select(".paragraph");
} }
@Test @Test
public void examplesTraversing() { public void examplesTraversing() throws IOException {
Elements sections = doc.select("section"); Elements articles = doc.select("article");
Element firstSection = sections.first(); Element firstArticle = articles.first();
Element lastSection = sections.last(); Element lastSection = articles.last();
Element secondSection = sections.get(2); Element secondSection = articles.get(2);
Elements allParents = firstSection.parents(); Elements allParents = firstArticle.parents();
Element parent = firstSection.parent(); Element parent = firstArticle.parent();
Elements children = firstSection.children(); Elements children = firstArticle.children();
Elements siblings = firstSection.siblingElements(); Elements siblings = firstArticle.siblingElements();
sections.forEach(el -> System.out.println("section: " + el)); articles.forEach(el -> System.out.println("article: " + el));
} }
@Test @Test
public void examplesExtracting() { public void examplesExtracting() throws IOException {
Element firstArticle = doc.select("article") Element firstArticle = doc.select("article")
.first(); .first();
Element timeElement = firstArticle.select("time") Element titleElement = firstArticle.select("h1 a")
.first(); .first();
String dateTimeOfFirstArticle = timeElement.attr("datetime");
Element sectionDiv = firstArticle.select("section div") String titleText = titleElement.text();
.first();
String sectionDivText = sectionDiv.text();
String articleHtml = firstArticle.html(); String articleHtml = firstArticle.html();
String outerHtml = firstArticle.outerHtml(); String outerHtml = firstArticle.outerHtml();
} }
@Test @Test
public void examplesModifying() { public void examplesModifying() throws IOException {
Element firstArticle = doc.select("article") Element firstArticle = doc.select("article")
.first(); .first();
Element timeElement = firstArticle.select("time") Element h1Element = firstArticle.select("h1")
.first();
Element sectionDiv = firstArticle.select("section div")
.first(); .first();
String dateTimeOfFirstArticle = timeElement.attr("datetime"); h1Element.text("foo bar");
timeElement.attr("datetime", "2016-12-16 15:19:54.3");
sectionDiv.text("foo bar");
firstArticle.select("h2") firstArticle.select("h2")
.html("<div><span></span></div>"); .html("<div><span></span></div>");

View File

@ -891,6 +891,7 @@
<module>asm</module> <module>asm</module>
<module>atomikos</module> <module>atomikos</module>
<module>atomix</module> <module>atomix</module>
<!-- <module>axon</module>--><!-- JAVA-18408 -->
<module>bazel</module> <module>bazel</module>
<module>code-generation</module> <module>code-generation</module>
@ -1158,7 +1159,7 @@
<module>asm</module> <module>asm</module>
<module>atomikos</module> <module>atomikos</module>
<module>atomix</module> <module>atomix</module>
<!-- <module>axon</module>--><!-- JAVA-18408 --> <!-- <module>axon</module>--><!-- JAVA-18408 -->
<module>bazel</module> <module>bazel</module>
<module>code-generation</module> <module>code-generation</module>