Пример #1
0
  @Test
  public void testClone() {
    Document doc = Jsoup.parse("<title>Hello</title> <p>One<p>Two");
    Document clone = doc.clone();

    assertEquals(
        "<html><head><title>Hello</title> </head><body><p>One</p><p>Two</p></body></html>",
        TextUtil.stripNewlines(clone.html()));
    clone.title("Hello there");
    clone.select("p").first().text("One more").attr("id", "1");
    assertEquals(
        "<html><head><title>Hello there</title> </head><body><p id=\"1\">One more</p><p>Two</p></body></html>",
        TextUtil.stripNewlines(clone.html()));
    assertEquals(
        "<html><head><title>Hello</title> </head><body><p>One</p><p>Two</p></body></html>",
        TextUtil.stripNewlines(doc.html()));
  }
Пример #2
0
 @Test
 public void testNormalisesStructure() {
   Document doc =
       Jsoup.parse(
           "<html><head><script>one</script><noscript><p>two</p></noscript></head><body><p>three</p></body><p>four</p></html>");
   assertEquals(
       "<html><head><script>one</script><noscript></noscript></head><body><p>two</p><p>three</p><p>four</p></body></html>",
       TextUtil.stripNewlines(doc.html()));
 }
Пример #3
0
  @Test
  public void testClonesDeclarations() {
    Document doc = Jsoup.parse("<!DOCTYPE html><html><head><title>Doctype test");
    Document clone = doc.clone();

    assertEquals(doc.html(), clone.html());
    assertEquals(
        "<!DOCTYPE html><html><head><title>Doctype test</title></head><body></body></html>",
        TextUtil.stripNewlines(clone.html()));
  }