forked from code4craft/webmagic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable jsoup entity escape by Default. Set Html.DISABLE_HTML_ENTITY_…
…ESCAPE to false to enable it. code4craft#149
- Loading branch information
1 parent
4e6e946
commit 9866297
Showing
2 changed files
with
35 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ | |
import org.junit.Test; | ||
import us.codecraft.webmagic.selector.Html; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* @author [email protected] <br> | ||
* Date: 13-4-21 | ||
|
@@ -13,9 +15,19 @@ public class HtmlTest { | |
@Test | ||
public void testRegexSelector() { | ||
Html selectable = new Html("aaaaaaab"); | ||
// Assert.assertEquals("abbabbab", (selectable.regex("(.*)").replace("aa(a)", "$1bb").toString())); | ||
System.out.println(selectable.regex("(.*)").replace("aa(a)", "$1bb").toString()); | ||
|
||
assertThat(selectable.regex("(a+b)").replace("aa(a)", "$1bb").toString()).isEqualTo("abbabbab"); | ||
} | ||
|
||
@Test | ||
public void testDisableJsoupHtmlEntityEscape() throws Exception { | ||
Html html = new Html("aaaaaaa&b"); | ||
assertThat(html.regex("(aaaaaaa&b)").toString()).isEqualTo("aaaaaaa&b"); | ||
} | ||
|
||
@Test | ||
public void testEnableJsoupHtmlEntityEscape() throws Exception { | ||
Html.DISABLE_HTML_ENTITY_ESCAPE = false; | ||
Html html = new Html("aaaaaaa&b"); | ||
assertThat(html.regex("(aaaaaaa&b)").toString()).isEqualTo("aaaaaaa&b"); | ||
} | ||
} |