diff options
author | Tom Simmons <tomasimmons@gmail.com> | 2018-09-07 23:46:59 -0400 |
---|---|---|
committer | Tom Simmons <tomasimmons@gmail.com> | 2018-09-07 23:46:59 -0400 |
commit | 4e04128da924cffc540f0ec00a27138d9a1fbf6e (patch) | |
tree | a37a732cbf4c2cfe11168601e042fe0440b7e164 /src/test | |
parent | 75fb3de74598ee463985ad9f91ff5c5c33f0cc18 (diff) | |
download | java-language-server-4e04128da924cffc540f0ec00a27138d9a1fbf6e.zip |
Refactor
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/org/javacs/UrlsTest.java | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/src/test/java/org/javacs/UrlsTest.java b/src/test/java/org/javacs/UrlsTest.java index 4c2a9da..fe2a4bf 100644 --- a/src/test/java/org/javacs/UrlsTest.java +++ b/src/test/java/org/javacs/UrlsTest.java @@ -1,8 +1,11 @@ package org.javacs; +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThat; import java.net.URL; import org.junit.Test; @@ -10,38 +13,32 @@ import org.junit.Test; public class UrlsTest { @Test - public void of_whenPathStartsWithSlash() throws Exception { - URL actual = Urls.of("file:///a/b/c"); - assertEquals("file", actual.getProtocol()); - assertEquals("/a/b/c", actual.getPath()); + public void of_whenPathStartsWithForwardSlash() throws Exception { + URL actual = Urls.of("/a/b/c"); + assertThat(actual.getProtocol(), equalTo("file")); + assertThat(actual.getPath(), containsString("/a/b/c")); } @Test public void of_whenPathStartsWithProtocol() throws Exception { URL actual = Urls.of("file:///a/b/c"); - assertEquals("file", actual.getProtocol()); - assertEquals("/a/b/c", actual.getPath()); + assertThat("file", equalTo(actual.getProtocol())); + assertThat(actual.getPath(), containsString("/a/b/c")); } @Test - public void of_whenPathStartsWithDriveLetter() throws Exception { + public void of_whenPathStartsWithDriveLetter_usingForwardSlashes() + throws Exception { URL actual = Urls.of("c:/a/b/c"); - assertEquals("file", actual.getProtocol()); - } - - @Test - public void isSystemPath_whenPathStartsWithSlash() { - assertTrue(Urls.isSystemPath("/a/b/c")); - } - - @Test - public void isSystemPath_whenPathStartsWithDriveLetter() { - assertTrue(Urls.isSystemPath("c:/a/b/c")); - assertTrue(Urls.isSystemPath("c:\\a\\b\\c")); + assertThat(actual.getProtocol(), equalTo("file")); + assertThat(actual.getPath(), containsString("/a/b/c")); } @Test - public void isSystemPath_whenPathStartsWithProtocol() { - assertFalse(Urls.isSystemPath("file://a/b/c")); + public void of_whenPathStartsWithDriveLetter_usingBackslashes() + throws Exception { + URL actual = Urls.of("c:\\a\\b\\c"); + assertThat(actual.getProtocol(), equalTo("file")); + assertThat(actual.getPath(), containsString("/a/b/c")); } }
\ No newline at end of file |