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