import junit.framework.TestCase;
 
 
public class UrlAnalyzerTest extends TestCase {
 
    public void testEmpty() throws Exception {
        assertFalse(a("").check());
    }
 
    public void testScheme() throws Exception {
        assertEquals("http", a("http://www.google.de").getScheme());
    }
 
    public void testSchemeSec() throws Exception {
        assertEquals("https", a("https://www.google.de").getScheme());
    }
 
    public void testServerName() throws Exception {
        assertEquals("www.google.de", a("http://www.google.de").getServer());
        assertEquals("www.google.de", a("https://www.google.de").getServer());
        assertEquals("www.google.de", a("https://www.google.de/image").getServer());
    }
 
    public void testPath() throws Exception {
        assertEquals("/image/logo/", a("http://www.google.de/image/logo/").getPath());
    }
 
    private UrlAnalyzer a (String url) {
        return new UrlAnalyzer(url);
    }
 
}
 
 
public class UrlAnalyzer {
    private String url;
 
    public UrlAnalyzer(String u) {
        url = u;
        if (url.charAt(url.length()-1) != '/') url += '/';
    }
 
    public boolean check() {
        return false;
    }
 
    public Object getScheme() {
        if(isHttps(url)) //is https
            return(url.substring(0, 5));
        else
            return(url.substring(0, 4));
 
    }
 
    public Object getServer() {
        return(url.substring(firstServerIndex(), firstPathIndex()-1));
    }
 
    private boolean isHttps(String url) {
        return url.charAt(4) == 's';
    }
 
    public Object getPath() {
        return url.substring(firstPathIndex());
    }
 
    private int firstPathIndex() {
        return url.indexOf("/", firstServerIndex());
    }
 
    private int firstServerIndex() {
        return isHttps(url) ? 8 : 7;
    }
 
 
}