1
2
3
4
5
6
7
8
9
10 package org.eclipse.jgit.api;
11
12 import static org.junit.Assert.assertArrayEquals;
13 import static org.junit.Assert.assertEquals;
14
15 import org.eclipse.jgit.api.RemoteSetUrlCommand.UriType;
16 import org.eclipse.jgit.transport.RemoteConfig;
17 import org.eclipse.jgit.transport.URIish;
18 import org.junit.Test;
19
20 public class RemoteSetUrlCommandTest extends AbstractRemoteCommandTest {
21
22 @Test
23 public void testSetUrl() throws Exception {
24
25 setupRemote();
26
27
28 RemoteSetUrlCommand cmd = Git.wrap(db).remoteSetUrl();
29 cmd.setRemoteName(REMOTE_NAME);
30 URIish newUri = new URIish("git://test.com/test");
31 cmd.setRemoteUri(newUri);
32 RemoteConfig remote = cmd.call();
33
34
35 assertEquals(REMOTE_NAME, remote.getName());
36 assertArrayEquals(new URIish[] { newUri }, remote.getURIs().toArray());
37
38
39 assertRemoteConfigEquals(remote,
40 new RemoteConfig(db.getConfig(), REMOTE_NAME));
41 }
42
43 @Test
44 public void testSetPushUrl() throws Exception {
45
46 RemoteConfig remoteConfig = setupRemote();
47
48
49 RemoteSetUrlCommand cmd = Git.wrap(db).remoteSetUrl();
50 cmd.setRemoteName(REMOTE_NAME);
51 URIish newUri = new URIish("git://test.com/test");
52 cmd.setRemoteUri(newUri);
53 cmd.setUriType(UriType.PUSH);
54 RemoteConfig remote = cmd.call();
55
56
57
58 assertEquals(REMOTE_NAME, remote.getName());
59 assertEquals(remoteConfig.getURIs(), remote.getURIs());
60 assertArrayEquals(new URIish[] { newUri },
61 remote.getPushURIs().toArray());
62
63
64 assertRemoteConfigEquals(remote,
65 new RemoteConfig(db.getConfig(), REMOTE_NAME));
66 }
67
68 }