diff --git a/src/test/java/org/jsoup/nodes/NodeTest.java b/src/test/java/org/jsoup/nodes/NodeTest.java index 6e42343a7e..0675f7b27e 100644 --- a/src/test/java/org/jsoup/nodes/NodeTest.java +++ b/src/test/java/org/jsoup/nodes/NodeTest.java @@ -7,6 +7,7 @@ import org.jsoup.select.NodeVisitor; import org.junit.jupiter.api.Test; +import java.util.Collections; import java.util.List; import static org.jsoup.parser.Parser.*; @@ -175,6 +176,22 @@ public void handlesAbsOnProtocolessAbsoluteUris() { assertEquals("One foo three", p.html()); } + /** + * test case for + * Issue #2212 + */ + @Test public void testReplaceTwice() { + Document doc = Jsoup.parse("
Child OneChild TwoChild ThreeChild Four
"); + Elements children = doc.select("p").first().children(); + // first swap 0 and 1 + children.set(0, children.set(1, children.get(0))); + // then swap 1 and 2 + children.set(2, children.set(1, children.get(2))); + + assertEquals("Child TwoChild ThreeChild OneChild Four", + TextUtil.stripNewlines(children.html())); + } + @Test public void ownerDocument() { Document doc = Jsoup.parse("Hello"); Element p = doc.select("p").first();