1 13 package info.magnolia.cms.util; 14 15 import junit.framework.TestCase; 16 17 21 public class LinkUtilTest extends TestCase { 22 public void testInternalRelativeLinksAreProperlyDetermined() { 23 assertTrue(LinkUtil.isInternalRelativeLink("foo")); 24 assertTrue(LinkUtil.isInternalRelativeLink("foo/bar")); 25 assertTrue(LinkUtil.isInternalRelativeLink("foo/bar.gif")); 26 27 assertFalse(LinkUtil.isInternalRelativeLink("/foo")); 28 assertFalse(LinkUtil.isInternalRelativeLink("/foo/bar")); 29 assertFalse(LinkUtil.isInternalRelativeLink("/foo/bar.gif")); 30 31 assertFalse(LinkUtil.isInternalRelativeLink("http://foo.com/bar.gif")); 32 assertFalse(LinkUtil.isInternalRelativeLink("http://foo.com/bar/baz.gif")); 33 assertFalse(LinkUtil.isInternalRelativeLink("http://foo.com/bar/")); 34 assertFalse(LinkUtil.isInternalRelativeLink("http://foo.com/bar")); 35 assertFalse(LinkUtil.isInternalRelativeLink("http://foo.com/")); 36 assertFalse(LinkUtil.isInternalRelativeLink("http://foo.com")); 37 assertFalse(LinkUtil.isInternalRelativeLink("https://foo.com")); 38 assertFalse(LinkUtil.isInternalRelativeLink("https://foo.com/bar")); 39 assertFalse(LinkUtil.isInternalRelativeLink("ftp://user:pass@server.com/foo/bar")); 40 41 assertFalse(LinkUtil.isInternalRelativeLink("mailto:murdock@a-team.org")); 42 43 assertFalse(LinkUtil.isInternalRelativeLink("#anchor")); 44 assertFalse(LinkUtil.isInternalRelativeLink("#another-anchor")); 45 46 assertFalse(LinkUtil.isInternalRelativeLink("javascript:void(window.open('http://www.google.com','','resizable=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,fullscreen=no,dependent=no,width=200,height=200'))")); 47 assertFalse(LinkUtil.isInternalRelativeLink("javascript:void(window.open('/foo/bar','','resizable=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,fullscreen=no,dependent=no,width=200,height=200'))")); 48 } 49 } 50 | Popular Tags |