package org.mozilla.focus.utils;

import junit.framework.Assert;

import org.junit.Test;

public class UrlUtilsTest {
    @Test
    public void urlsMatchExceptForTrailingSlash() throws Exception {
        Assert.assertTrue(UrlUtils.urlsMatchExceptForTrailingSlash("http://www.mozilla.org", "http://www.mozilla.org"));
        Assert.assertTrue(UrlUtils.urlsMatchExceptForTrailingSlash("http://www.mozilla.org/", "http://www.mozilla.org"));
        Assert.assertTrue(UrlUtils.urlsMatchExceptForTrailingSlash("http://www.mozilla.org", "http://www.mozilla.org/"));

        Assert.assertFalse(UrlUtils.urlsMatchExceptForTrailingSlash("http://mozilla.org", "http://www.mozilla.org"));
        Assert.assertFalse(UrlUtils.urlsMatchExceptForTrailingSlash("http://www.mozilla.org/", "http://mozilla.org"));

        Assert.assertFalse(UrlUtils.urlsMatchExceptForTrailingSlash("http://www.mozilla.org", "https://www.mozilla.org"));
        Assert.assertFalse(UrlUtils.urlsMatchExceptForTrailingSlash("https://www.mozilla.org", "http://www.mozilla.org"));

        // Same length of domain, but otherwise different:
        Assert.assertFalse(UrlUtils.urlsMatchExceptForTrailingSlash("http://www.allizom.org", "http://www.mozilla.org"));
        Assert.assertFalse(UrlUtils.urlsMatchExceptForTrailingSlash("http://www.allizom.org/", "http://www.mozilla.org"));
        Assert.assertFalse(UrlUtils.urlsMatchExceptForTrailingSlash("http://www.allizom.org", "http://www.mozilla.org/"));

        // Check upper/lower case is OK:
        Assert.assertTrue(UrlUtils.urlsMatchExceptForTrailingSlash("http://www.MOZILLA.org", "http://www.mozilla.org"));
        Assert.assertTrue(UrlUtils.urlsMatchExceptForTrailingSlash("http://www.MOZILLA.org/", "http://www.mozilla.org"));
        Assert.assertTrue(UrlUtils.urlsMatchExceptForTrailingSlash("http://www.MOZILLA.org", "http://www.mozilla.org/"));
    }

}
@@ -1882,9 +1882,1133 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void isPermittedResourceProtocol() %7B%0A        Assert.assertTrue(UrlUtils.isPermittedResourceProtocol(%22http:%22));%0A        Assert.assertTrue(UrlUtils.isPermittedResourceProtocol(%22https:%22));%0A%0A        Assert.assertTrue(UrlUtils.isPermittedResourceProtocol(%22http://foobar.com%22));%0A        Assert.assertTrue(UrlUtils.isPermittedResourceProtocol(%22https://foobar.com%22));%0A%0A        Assert.assertTrue(UrlUtils.isPermittedResourceProtocol(%22data:???????????????%22));%0A        Assert.assertTrue(UrlUtils.isPermittedResourceProtocol(%22file:///android_asset/something/index.html%22));%0A%0A        Assert.assertFalse(UrlUtils.isPermittedResourceProtocol(%22nielsenwebid://nuid/999%22));%0A    %7D%0A%0A    @Test%0A    public void isPermittedProtocol() %7B%0A        Assert.assertTrue(UrlUtils.isSupportedProtocol(%22http:%22));%0A        Assert.assertTrue(UrlUtils.isSupportedProtocol(%22http://mozilla.org%22));%0A        Assert.assertTrue(UrlUtils.isSupportedProtocol(%22error:-1%22));%0A        Assert.assertTrue(UrlUtils.isSupportedProtocol(%22data:?????%22));%0A%0A        Assert.assertFalse(UrlUtils.isSupportedProtocol(%22market:details?id=org.mozilla.firefox%22));%0A    %7D%0A
 %7D

Add more UrlUtil tests (#387)