Skip to content

Commit

Permalink
Test for prolog
Browse files Browse the repository at this point in the history
Fixes jhy#652
  • Loading branch information
jhy committed May 7, 2016
1 parent 4eb4f2b commit c090381
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ jsoup changelog
* In XML documents, detect the charset from the XML prolog - <?xml encoding="UTF-8"?>
<https://github.com/jhy/jsoup/issues/701>

* Fixed an issue where created XML documents would have an incorrect prolog.
<https://github.com/jhy/jsoup/issues/652>

* Fixed an issue where namespaced tags (like <fb:comment>) would cause Element.cssSelector() to fail.
<https://github.com/jhy/jsoup/pull/677>

Expand Down
13 changes: 13 additions & 0 deletions src/test/java/org/jsoup/parser/XmlTreeBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.util.List;

import static org.jsoup.nodes.Document.OutputSettings.Syntax;
Expand Down Expand Up @@ -154,4 +155,16 @@ public void testParseDeclarationAttributes() {
assertEquals("version=\"1\" encoding=\"UTF-8\" something=\"else\"", decl.getWholeDeclaration());
assertEquals("<?xml version=\"1\" encoding=\"UTF-8\" something=\"else\"?>", decl.outerHtml());
}

@Test
public void testCreatesValidProlog() {
Document document = Document.createShell("");
document.outputSettings().syntax(Syntax.xml);
document.charset(Charset.forName("utf-8"));
assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<html>\n" +
" <head></head>\n" +
" <body></body>\n" +
"</html>", document.outerHtml());
}
}

0 comments on commit c090381

Please sign in to comment.