-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#339 - Mark JSoup converter module as deprecated and for removal.
Upgrade Jsoup dependency for last release of this sub-module. Users should use W3CDom class from Jsoup instead.
- Loading branch information
Showing
3 changed files
with
68 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
openhtmltopdf-jsoup-dom-converter/src/test/java/com/openhtmltopdf/TestJsoupToDom.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.openhtmltopdf; | ||
|
||
import org.jsoup.Jsoup; | ||
import org.jsoup.helper.W3CDom; | ||
import org.junit.Assert; | ||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
|
||
public class TestJsoupToDom { | ||
private W3CDom helper = new W3CDom(); | ||
|
||
private void run(String html) { | ||
org.jsoup.nodes.Document docIn = Jsoup.parse(html); | ||
|
||
org.w3c.dom.Document docOut1 = helper.fromJsoup(docIn); | ||
org.w3c.dom.Document docOut2 = DOMBuilder.jsoup2DOM(docIn); | ||
|
||
System.out.println(); | ||
System.out.println("-----JSOUP Conversion-----"); | ||
System.out.println(helper.asString(docOut1)); | ||
|
||
System.out.println(); | ||
System.out.println("-----OpenHTMLToPDF Conversion------"); | ||
System.out.println(helper.asString(docOut2)); | ||
|
||
Assert.assertEquals(helper.asString(docOut1), helper.asString(docOut2)); | ||
} | ||
|
||
@Test | ||
public void testSimple() { | ||
run("<html><head></head><body style=\"font-size: 12px;\">Some text<img src=\"test.jpg\"></body></html>"); | ||
} | ||
|
||
@Test | ||
@Ignore // Ours is broken as it strips the xmlns attribute from the svg. | ||
public void testSVG() { | ||
run( | ||
"<html>\n" + | ||
"<body>\n" + | ||
"\n" + | ||
"<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"100\" width=\"100\">\n" + | ||
" <circle cx=\"50\" cy=\"50\" r=\"40\" stroke=\"black\" stroke-width=\"3\" fill=\"red\" />\n" + | ||
"</svg> \n" + | ||
" \n" + | ||
"</body>\n" + | ||
"</html>" | ||
); | ||
} | ||
|
||
} |