Fix RemoteRefUpdate to delete local tracking ref upon successful deletion
[egit/zawir.git] / org.spearce.jgit.test / tst / org / spearce / jgit / transport / URIishTest.java
blob2e5e84748d1b2a54e3cdc2b5d3bdb69eea4d2734
1 /*
2 * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
3 * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or
8 * without modification, are permitted provided that the following
9 * conditions are met:
11 * - Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
14 * - Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer in the documentation and/or other materials provided
17 * with the distribution.
19 * - Neither the name of the Git Development Community nor the
20 * names of its contributors may be used to endorse or promote
21 * products derived from this software without specific prior
22 * written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
25 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
26 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
27 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
29 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
36 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 package org.spearce.jgit.transport;
41 import junit.framework.TestCase;
43 public class URIishTest extends TestCase {
45 public void testUnixFile() throws Exception {
46 final String str = "/home/m y";
47 URIish u = new URIish(str);
48 assertNull(u.getScheme());
49 assertFalse(u.isRemote());
50 assertEquals(str, u.getPath());
51 assertEquals(str, u.toString());
52 assertEquals(u, new URIish(str));
55 public void testWindowsFile() throws Exception {
56 final String str = "D:/m y";
57 URIish u = new URIish(str);
58 assertNull(u.getScheme());
59 assertFalse(u.isRemote());
60 assertEquals(str, u.getPath());
61 assertEquals(str, u.toString());
62 assertEquals(u, new URIish(str));
65 public void testFileProtoUnix() throws Exception {
66 final String str = "file:///home/m y";
67 URIish u = new URIish(str);
68 assertEquals("file", u.getScheme());
69 assertFalse(u.isRemote());
70 assertEquals("/home/m y", u.getPath());
71 assertEquals(str, u.toString());
72 assertEquals(u, new URIish(str));
75 public void testFileProtoWindows() throws Exception {
76 final String str = "file:///D:/m y";
77 URIish u = new URIish(str);
78 assertEquals("file", u.getScheme());
79 assertFalse(u.isRemote());
80 assertEquals("D:/m y", u.getPath());
81 assertEquals(str, u.toString());
82 assertEquals(u, new URIish(str));
85 public void testGitProtoUnix() throws Exception {
86 final String str = "git://example.com/home/m y";
87 URIish u = new URIish(str);
88 assertEquals("git", u.getScheme());
89 assertTrue(u.isRemote());
90 assertEquals("example.com", u.getHost());
91 assertEquals("/home/m y", u.getPath());
92 assertEquals(str, u.toString());
93 assertEquals(u, new URIish(str));
96 public void testGitProtoUnixPort() throws Exception {
97 final String str = "git://example.com:333/home/m y";
98 URIish u = new URIish(str);
99 assertEquals("git", u.getScheme());
100 assertTrue(u.isRemote());
101 assertEquals("example.com", u.getHost());
102 assertEquals("/home/m y", u.getPath());
103 assertEquals(333, u.getPort());
104 assertEquals(str, u.toString());
105 assertEquals(u, new URIish(str));
108 public void testGitProtoWindowsPort() throws Exception {
109 final String str = "git://example.com:338/D:/m y";
110 URIish u = new URIish(str);
111 assertEquals("git", u.getScheme());
112 assertTrue(u.isRemote());
113 assertEquals("D:/m y", u.getPath());
114 assertEquals(338, u.getPort());
115 assertEquals("example.com", u.getHost());
116 assertEquals(str, u.toString());
117 assertEquals(u, new URIish(str));
120 public void testGitProtoWindows() throws Exception {
121 final String str = "git://example.com/D:/m y";
122 URIish u = new URIish(str);
123 assertEquals("git", u.getScheme());
124 assertTrue(u.isRemote());
125 assertEquals("D:/m y", u.getPath());
126 assertEquals("example.com", u.getHost());
127 assertEquals(-1, u.getPort());
128 assertEquals(str, u.toString());
129 assertEquals(u, new URIish(str));
132 public void testScpStyleWithoutUser() throws Exception {
133 final String str = "example.com:some/p ath";
134 URIish u = new URIish(str);
135 assertNull(u.getScheme());
136 assertTrue(u.isRemote());
137 assertEquals("some/p ath", u.getPath());
138 assertEquals("example.com", u.getHost());
139 assertEquals(-1, u.getPort());
140 assertEquals(str, u.toString());
141 assertEquals(u, new URIish(str));
144 public void testScpStyleWithUser() throws Exception {
145 final String str = "user@example.com:some/p ath";
146 URIish u = new URIish(str);
147 assertNull(u.getScheme());
148 assertTrue(u.isRemote());
149 assertEquals("some/p ath", u.getPath());
150 assertEquals("user", u.getUser());
151 assertEquals("example.com", u.getHost());
152 assertEquals(-1, u.getPort());
153 assertEquals(str, u.toString());
154 assertEquals(u, new URIish(str));
157 public void testGitSshProto() throws Exception {
158 final String str = "git+ssh://example.com/some/p ath";
159 URIish u = new URIish(str);
160 assertEquals("git+ssh", u.getScheme());
161 assertTrue(u.isRemote());
162 assertEquals("/some/p ath", u.getPath());
163 assertEquals("example.com", u.getHost());
164 assertEquals(-1, u.getPort());
165 assertEquals(str, u.toString());
166 assertEquals(u, new URIish(str));
169 public void testSshGitProto() throws Exception {
170 final String str = "ssh+git://example.com/some/p ath";
171 URIish u = new URIish(str);
172 assertEquals("ssh+git", u.getScheme());
173 assertTrue(u.isRemote());
174 assertEquals("/some/p ath", u.getPath());
175 assertEquals("example.com", u.getHost());
176 assertEquals(-1, u.getPort());
177 assertEquals(str, u.toString());
178 assertEquals(u, new URIish(str));
181 public void testSshProto() throws Exception {
182 final String str = "ssh://example.com/some/p ath";
183 URIish u = new URIish(str);
184 assertEquals("ssh", u.getScheme());
185 assertTrue(u.isRemote());
186 assertEquals("/some/p ath", u.getPath());
187 assertEquals("example.com", u.getHost());
188 assertEquals(-1, u.getPort());
189 assertEquals(str, u.toString());
190 assertEquals(u, new URIish(str));
193 public void testSshProtoWithUserAndPort() throws Exception {
194 final String str = "ssh://user@example.com:33/some/p ath";
195 URIish u = new URIish(str);
196 assertEquals("ssh", u.getScheme());
197 assertTrue(u.isRemote());
198 assertEquals("/some/p ath", u.getPath());
199 assertEquals("example.com", u.getHost());
200 assertEquals("user", u.getUser());
201 assertNull(u.getPass());
202 assertEquals(33, u.getPort());
203 assertEquals(str, u.toString());
204 assertEquals(u, new URIish(str));
207 public void testSshProtoWithUserPassAndPort() throws Exception {
208 final String str = "ssh://user:pass@example.com:33/some/p ath";
209 URIish u = new URIish(str);
210 assertEquals("ssh", u.getScheme());
211 assertTrue(u.isRemote());
212 assertEquals("/some/p ath", u.getPath());
213 assertEquals("example.com", u.getHost());
214 assertEquals("user", u.getUser());
215 assertEquals("pass", u.getPass());
216 assertEquals(33, u.getPort());
217 assertEquals(str, u.toPrivateString());
218 assertEquals(u.setPass(null).toPrivateString(), u.toString());
219 assertEquals(u, new URIish(str));