1 package org.apache.maven.scm.provider.integrity.repository;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.scm.ScmTestCase;
23 import org.apache.maven.scm.manager.ScmManager;
24 import org.apache.maven.scm.repository.ScmRepository;
25
26
27
28
29
30
31
32 public class IntegrityScmProviderRepositoryTest
33 extends ScmTestCase
34 {
35 private ScmManager scmManager;
36
37
38
39
40 public void setUp()
41 throws Exception
42 {
43 super.setUp();
44 scmManager = getScmManager();
45 }
46
47
48
49
50
51
52 public void testMinimumUrlString()
53 throws Exception
54 {
55
56 testValidUrl( "scm:integrity|#/repo/project", "#/repo/project", "", 0, "", "" );
57 }
58
59
60
61
62
63
64 public void testWithHostname()
65 throws Exception
66 {
67
68 testValidUrl( "scm:integrity|@localhost|#/repo/project", "#/repo/project", "localhost", 0, "", "" );
69 }
70
71
72
73
74
75
76 public void testWithHostAndPort()
77 throws Exception
78 {
79
80 testValidUrl( "scm:integrity|@localhost:7001|#/repo/project", "#/repo/project", "localhost", 7001, "", "" );
81 }
82
83
84
85
86
87
88 public void testWithUser()
89 throws Exception
90 {
91
92 testValidUrl( "scm:integrity|dsouza@|#/repo/project", "#/repo/project", "", 0, "dsouza", "" );
93 }
94
95
96
97
98
99
100 public void testWithUserAndPassword()
101 throws Exception
102 {
103
104 testValidUrl( "scm:integrity|dsouza/password@|#/repo/project", "#/repo/project", "", 0, "dsouza", "password" );
105 }
106
107
108
109
110
111
112 public void testWithUserAndHost()
113 throws Exception
114 {
115
116 testValidUrl( "scm:integrity|dsouza@localhost|#/repo/project", "#/repo/project", "localhost", 0, "dsouza", "" );
117 }
118
119
120
121
122
123
124 public void testWithUserAndHostPort()
125 throws Exception
126 {
127
128 testValidUrl( "scm:integrity|dsouza@localhost:7001|#/repo/project", "#/repo/project", "localhost", 7001,
129 "dsouza", "" );
130 }
131
132
133
134
135
136
137 public void testWithUserPasswordAndHost()
138 throws Exception
139 {
140
141 testValidUrl( "scm:integrity|dsouza/password@localhost|#/repo/project", "#/repo/project", "localhost", 0,
142 "dsouza", "password" );
143 }
144
145
146
147
148
149
150 public void testWithWholeURL()
151 throws Exception
152 {
153
154 testValidUrl( "scm:integrity|dsouza/password@localhost:7001|#/repo/project", "#/repo/project", "localhost",
155 7001, "dsouza", "password" );
156 }
157
158
159
160
161
162
163
164
165
166
167
168
169 private void testValidUrl( String scmUrl, String expectedConfigPath, String expectedHost, int expectedPort,
170 String expectedUser, String expectedPassword )
171 throws Exception
172 {
173 ScmRepository repo = scmManager.makeScmRepository( scmUrl );
174 assertNotNull( "ScmManager.makeScmRepository() returned null", repo );
175 assertNotNull( "The provider repository was null.", repo.getProviderRepository() );
176 assertTrue( "The SCM Repository isn't a " + IntegrityScmProviderRepository.class.getName() + ".",
177 repo.getProviderRepository() instanceof IntegrityScmProviderRepository );
178 IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repo.getProviderRepository();
179 assertEquals( "Configration Path is incorrect", expectedConfigPath, iRepo.getConfigruationPath() );
180 assertEquals( "Hostname is incorrect", expectedHost, iRepo.getHost() );
181 assertEquals( "Port is incorrect", expectedPort, iRepo.getPort() );
182 assertEquals( "Username is incorrect", expectedUser, iRepo.getUser() );
183 assertEquals( "Password is incorrect", expectedPassword, iRepo.getPassword() );
184 }
185 }