summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst
diff options
context:
space:
mode:
authorThomas Wolf <thomas.wolf@paranor.ch>2017-12-09 16:27:18 -0500
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2017-12-09 16:27:18 -0500
commitcde32497b5399168ef0262075775eceaf4a57574 (patch)
treebc737b3be637f6d3d99ddded007dba559eb4d239 /org.eclipse.jgit.test/tst
parentc861c0e2ee3eb919e8d43f7244e891084ac58513 (diff)
parent93462447b47565b80b134833777933edef26a5de (diff)
downloadjgit-cde32497b5399168ef0262075775eceaf4a57574.tar.gz
jgit-cde32497b5399168ef0262075775eceaf4a57574.zip
Merge "URIishTest: more Windows file-protocol tests"
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/URIishTest.java82
1 files changed, 82 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/URIishTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/URIishTest.java
index e55d373347..9bd30b8837 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/URIishTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/URIishTest.java
@@ -198,6 +198,10 @@ public class URIishTest {
URIish u = new URIish(str);
assertEquals("file", u.getScheme());
assertFalse(u.isRemote());
+ assertEquals(null, u.getHost());
+ assertEquals(-1, u.getPort());
+ assertEquals(null, u.getUser());
+ assertEquals(null, u.getPass());
assertEquals("D:/m y", u.getRawPath());
assertEquals("D:/m y", u.getPath());
assertEquals("file:///D:/m y", u.toString());
@@ -206,6 +210,84 @@ public class URIishTest {
}
@Test
+ public void testFileProtoWindowsWithHost() throws Exception {
+ final String str = "file://localhost/D:/m y";
+ URIish u = new URIish(str);
+ assertEquals("file", u.getScheme());
+ assertTrue(u.isRemote());
+ assertEquals("localhost", u.getHost());
+ assertEquals(-1, u.getPort());
+ assertEquals(null, u.getUser());
+ assertEquals(null, u.getPass());
+ assertEquals("D:/m y", u.getRawPath());
+ assertEquals("D:/m y", u.getPath());
+ assertEquals("file://localhost/D:/m y", u.toString());
+ assertEquals("file://localhost/D:/m%20y", u.toASCIIString());
+ assertEquals(u, new URIish(str));
+ }
+
+ @Test
+ public void testFileProtoWindowsWithHostAndPort() throws Exception {
+ final String str = "file://localhost:80/D:/m y";
+ URIish u = new URIish(str);
+ assertEquals("file", u.getScheme());
+ assertTrue(u.isRemote());
+ assertEquals("localhost", u.getHost());
+ assertEquals(80, u.getPort());
+ assertEquals(null, u.getUser());
+ assertEquals(null, u.getPass());
+ assertEquals("D:/m y", u.getRawPath());
+ assertEquals("D:/m y", u.getPath());
+ assertEquals("file://localhost:80/D:/m y", u.toString());
+ assertEquals("file://localhost:80/D:/m%20y", u.toASCIIString());
+ assertEquals(u, new URIish(str));
+ }
+
+ @Test
+ public void testFileProtoWindowsWithHostAndEmptyPortIsAmbiguous()
+ throws Exception {
+ final String str = "file://localhost:/D:/m y";
+ URIish u = new URIish(str);
+ assertEquals("file", u.getScheme());
+ assertFalse(u.isRemote());
+ assertEquals(null, u.getHost());
+ assertEquals(-1, u.getPort());
+ assertEquals(null, u.getUser());
+ assertEquals(null, u.getPass());
+ assertEquals("localhost:/D:/m y", u.getRawPath());
+ assertEquals("localhost:/D:/m y", u.getPath());
+ assertEquals("file:///localhost:/D:/m y", u.toString());
+ assertEquals("file:///localhost:/D:/m%20y", u.toASCIIString());
+ assertEquals(u, new URIish(str));
+ }
+
+ @Test
+ public void testFileProtoWindowsMissingHostSlash() throws Exception {
+ final String str = "file://D:/m y";
+ URIish u = new URIish(str);
+ assertEquals("file", u.getScheme());
+ assertFalse(u.isRemote());
+ assertEquals("D:/m y", u.getRawPath());
+ assertEquals("D:/m y", u.getPath());
+ assertEquals("file:///D:/m y", u.toString());
+ assertEquals("file:///D:/m%20y", u.toASCIIString());
+ assertEquals(u, new URIish(str));
+ }
+
+ @Test
+ public void testFileProtoWindowsMissingHostSlash2() throws Exception {
+ final String str = "file://D: /m y";
+ URIish u = new URIish(str);
+ assertEquals("file", u.getScheme());
+ assertFalse(u.isRemote());
+ assertEquals("D: /m y", u.getRawPath());
+ assertEquals("D: /m y", u.getPath());
+ assertEquals("file:///D: /m y", u.toString());
+ assertEquals("file:///D:%20/m%20y", u.toASCIIString());
+ assertEquals(u, new URIish(str));
+ }
+
+ @Test
public void testGitProtoUnix() throws Exception {
final String str = "git://example.com/home/m y";
URIish u = new URIish(str);