1010import org .junit .runners .Parameterized .Parameters ;
1111
1212@ RunWith (Parameterized .class )
13- public class AutolinkWwwUrlTest extends AutolinkUrlTest {
13+ public class AutolinkWwwUrlTest extends AutolinkTestCase {
1414
1515 @ Parameters (name = "{1}" )
1616 public static Iterable <Object []> data () {
1717 return Arrays .asList (new Object [][]{
18- {LinkExtractor .builder ().linkTypes (EnumSet .of (LinkType .URL )).build (), "URL " },
18+ {LinkExtractor .builder ().linkTypes (EnumSet .of (LinkType .WWW )).build (), "WWW " },
1919 {LinkExtractor .builder ().build (), "all" }
2020 });
2121 }
@@ -41,12 +41,26 @@ public void linked() {
4141 assertLinked ("www.s.com" ,"|www.s.com|" );
4242 assertLinked ("www.fo.uk" ,"|www.fo.uk|" );
4343 }
44-
44+
45+ @ Test
46+ public void html () {
47+ assertLinked ("<a href=\" somelink\" >www.example.org</a>" , "<a href=\" somelink\" >|www.example.org|</a>" );
48+ assertLinked ("<a href=\" www.example.org\" >sometext</a>" , "<a href=\" |www.example.org|\" >sometext</a>" );
49+ assertLinked ("<p>www.example.org</p>" , "<p>|www.example.org|</p>" );
50+ }
51+
52+ @ Test
53+ public void multiple () {
54+ assertLinked ("www.one.org/ www.two.org/" , "|www.one.org/| |www.two.org/|" );
55+ assertLinked ("www.one.org/ : www.two.org/" , "|www.one.org/| : |www.two.org/|" );
56+ assertLinked ("(www.one.org/)(www.two.org/)" , "(|www.one.org/|)(|www.two.org/|)" );
57+ }
58+
4559 @ Test
46- public void schemes () {
47- assertLinked ("http:// www.something .com" , "|http:// www.something .com|" );
48- assertLinked ("http://something.com" , "|http://something.com |" );
49- assertLinked ("http://something.co.uk" , "|http://something.co.uk |" );
60+ public void international () {
61+ assertLinked ("www.üñîçøðé .com/ä" , "| www.üñîçøðé .com/ä |" );
62+ assertLinked ("www.example.org/ \u00A1 " , "|www.example.org/ \u00A1 |" );
63+ assertLinked ("www.example.org/ \u00A2 " , "|www.example.org/ \u00A2 |" );
5064 }
5165
5266 @ Override
@@ -55,6 +69,6 @@ protected LinkExtractor getLinkExtractor() {
5569 }
5670
5771 private void assertLinked (String input , String expected ) {
58- super .assertLinked (input , expected , LinkType .URL );
72+ super .assertLinked (input , expected , LinkType .WWW );
5973 }
6074}
0 commit comments