summaryrefslogtreecommitdiff
path: root/src/test/java/org/javacs/UrlsTest.java
blob: d94d5895e9dba94abcfc2c35d1277227ac55ffa6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package org.javacs;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;

import java.net.URL;
import org.junit.Test;

public class UrlsTest {

    @Test
    public void pathToUrl_whenPathStartsWithForwardSlash() throws Exception {
        URL actual = Urls.pathToUrl("/a/b/c");
        assertThat(actual.getProtocol(), equalTo("file"));
    }

    @Test
    public void pathToUrl_whenPathStartsWithProtocol() throws Exception {
        URL actual = Urls.pathToUrl("file:///a/b/c");
        assertThat(actual.getProtocol(), equalTo("file"));
    }

    @Test
    public void pathToUrl_whenPathStartsWithDriveLetter_usingForwardSlashes() throws Exception {
        URL actual = Urls.pathToUrl("c:/a/b/c");
        assertThat(actual.getProtocol(), equalTo("file"));
    }

    @Test
    public void pathToUrl_whenPathStartsWithDriveLetter_usingBackslashes() throws Exception {
        URL actual = Urls.pathToUrl("c:\\a\\b\\c");
        assertThat(actual.getProtocol(), equalTo("file"));
    }
}