1 package org.apache.archiva.web.test;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.archiva.web.test.parent.AbstractRepositoryTest;
23 import org.testng.annotations.Test;
25 @Test( groups = { "repository" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true )
26 public class RepositoryTest
27 extends AbstractRepositoryTest
30 public void testAddManagedRepoValidValues()
32 goToRepositoriesPage();
33 getSelenium().open( "/archiva/admin/addRepository.action" );
34 addManagedRepository( "managedrepo1", "Managed Repository Sample 1", getRepositoryDir() + "repository/", "",
35 "Maven 2.x Repository", "0 0 * * * ?", "", "", true );
36 clickButtonWithValue( "Save" );
37 assertTextPresent( "Managed Repository Sample 1" );
38 assertRepositoriesPage();
41 @Test( dependsOnMethods = { "testAddManagedRepoValidValues" } )
42 public void testAddManagedRepoInvalidValues()
44 getSelenium().open( "/archiva/admin/addRepository.action" );
46 addManagedRepository( "<> \\/~+[ ]'\"", "<>\\~+[]'\"", "<> ~+[ ]'\"", "<> ~+[ ]'\"", "Maven 2.x Repository", "",
49 "Identifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
51 "Directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
53 "Repository Name must only contain alphanumeric characters, white-spaces(' '), forward-slashes(/), open-parenthesis('('), close-parenthesis(')'), underscores(_), dots(.), and dashes(-)." );
55 "Index directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
56 assertTextPresent( "Repository Purge By Retention Count needs to be between 1 and 100." );
57 assertTextPresent( "Repository Purge By Days Older Than needs to be larger than 0." );
58 assertTextPresent( "Cron expression is required." );
62 public void testAddManagedRepoInvalidIdentifier()
64 getSelenium().open( "/archiva/admin/addRepository.action" );
66 addManagedRepository( "<> \\/~+[ ]'\"", "name", "/home", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "1",
69 "Identifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
73 public void testAddManagedRepoInvalidRepoName()
75 getSelenium().open( "/archiva/admin/addRepository.action" );
77 addManagedRepository( "identifier", "<>\\~+[]'\"", "/home", "/.index", "Maven 2.x Repository", "0 0 * * * ?",
80 "Repository Name must only contain alphanumeric characters, white-spaces(' '), forward-slashes(/), open-parenthesis('('), close-parenthesis(')'), underscores(_), dots(.), and dashes(-)." );
84 public void testAddManagedRepoInvalidDirectory()
86 getSelenium().open( "/archiva/admin/addRepository.action" );
88 addManagedRepository( "identifier", "name", "<> ~+[ ]'\"", "/.index", "Maven 2.x Repository", "0 0 * * * ?",
91 "Directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
95 public void testAddManagedRepoInvalidIndexDir()
97 getSelenium().open( "/archiva/admin/addRepository.action" );
99 addManagedRepository( "identifier", "name", "/home", "<> ~+[ ]'\"", "Maven 2.x Repository", "0 0 * * * ?", "1",
102 "Index directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
106 public void testAddManagedRepoInvalidRetentionCount()
108 getSelenium().open( "/archiva/admin/addRepository.action" );
110 addManagedRepository( "identifier", "name", "/home", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "1",
112 assertTextPresent( "Repository Purge By Retention Count needs to be between 1 and 100." );
116 public void testAddManagedRepoInvalidDaysOlder()
118 getSelenium().open( "/archiva/admin/addRepository.action" );
120 addManagedRepository( "identifier", "name", "/home", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "-1",
122 assertTextPresent( "Repository Purge By Days Older Than needs to be larger than 0." );
126 public void testAddManagedRepoBlankValues()
128 getSelenium().open( "/archiva/admin/addRepository.action" );
130 addManagedRepository( "", "", "", "", "Maven 2.x Repository", "", "", "", false );
131 assertTextPresent( "You must enter a repository identifier." );
132 assertTextPresent( "You must enter a repository name." );
133 assertTextPresent( "You must enter a directory." );
134 assertTextPresent( "Cron expression is required." );
138 public void testAddManagedRepoNoIdentifier()
140 getSelenium().open( "/archiva/admin/addRepository.action" );
142 addManagedRepository( "", "name", "/home", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "", false );
143 assertTextPresent( "You must enter a repository identifier." );
147 public void testAddManagedRepoNoRepoName()
149 getSelenium().open( "/archiva/admin/addRepository.action" );
151 addManagedRepository( "identifier", "", "/home", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "",
153 assertTextPresent( "You must enter a repository name." );
157 public void testAddManagedRepoNoDirectory()
159 getSelenium().open( "/archiva/admin/addRepository.action" );
161 addManagedRepository( "identifier", "name", "", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "",
163 assertTextPresent( "You must enter a directory." );
167 public void testAddManagedRepoNoCron()
169 getSelenium().open( "/archiva/admin/addRepository.action" );
171 addManagedRepository( "identifier", "name", "/home", "/.index", "Maven 2.x Repository", "", "", "", false );
173 assertTextPresent( "Cron expression is required." );
177 public void testAddManagedRepoForEdit()
179 getSelenium().open( "/archiva/admin/addRepository.action" );
180 addManagedRepository( "managedrepo", "Managed Repository Sample", getRepositoryDir() + "local-repo/", "",
181 "Maven 2.x Repository", "0 0 * * * ?", "", "", true );
182 clickButtonWithValue( "Save" );
183 assertTextPresent( "Managed Repository Sample" );
186 @Test( dependsOnMethods = { "testAddManagedRepoForEdit" } )
187 public void testEditManagedRepoInvalidValues()
189 editManagedRepository( "<>\\~+[]'\"", "<> ~+[ ]'\"", "<> ~+[ ]'\"", "Maven 2.x Repository", "", "-1", "101" );
191 "Directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
193 "Repository Name must only contain alphanumeric characters, white-spaces(' '), forward-slashes(/), open-parenthesis('('), close-parenthesis(')'), underscores(_), dots(.), and dashes(-)." );
195 "Index directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
196 assertTextPresent( "Repository Purge By Retention Count needs to be between 1 and 100." );
197 assertTextPresent( "Repository Purge By Days Older Than needs to be larger than 0." );
198 assertTextPresent( "Cron expression is required." );
201 @Test( dependsOnMethods = { "testAddManagedRepoForEdit" } )
202 public void testEditManagedRepoInvalidRepoName()
204 editManagedRepository( "<>\\~+[]'\"", "/home", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "1", "1" );
206 "Repository Name must only contain alphanumeric characters, white-spaces(' '), forward-slashes(/), open-parenthesis('('), close-parenthesis(')'), underscores(_), dots(.), and dashes(-)." );
209 @Test( dependsOnMethods = { "testAddManagedRepoForEdit" } )
210 public void testEditManagedRepoInvalidDirectory()
212 editManagedRepository( "name", "<> ~+[ ]'\"", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "1", "1" );
214 "Directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
217 @Test( dependsOnMethods = { "testAddManagedRepoForEdit" } )
218 public void testEditManagedRepoInvalidIndexDir()
220 editManagedRepository( "name", "/home", "<> ~+[ ]'\"", "Maven 2.x Repository", "0 0 * * * ?", "1", "1" );
222 "Index directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
225 @Test( dependsOnMethods = { "testAddManagedRepoForEdit" } )
226 public void testEditManagedRepoInvalidCronBadText()
228 editManagedRepository( "name", "/home", "/.index", "Maven 2.x Repository", "asdf", "1", "1" );
229 assertTextPresent( "Invalid cron expression." );
232 @Test( dependsOnMethods = { "testAddManagedRepoForEdit" } )
233 public void testEditManagedRepoInvalidCronBadValue()
235 editManagedRepository( "name", "/home", "/.index", "Maven 2.x Repository", "60 0 * * * ?", "1", "1" );
236 assertTextPresent( "Invalid cron expression." );
239 @Test( dependsOnMethods = { "testAddManagedRepoForEdit" } )
240 public void testEditManagedRepoInvalidCronTooManyElements()
242 editManagedRepository( "name", "/home", "/.index", "Maven 2.x Repository", "* * * * * * * *", "1", "1" );
243 assertTextPresent( "Invalid cron expression." );
246 @Test( dependsOnMethods = { "testAddManagedRepoForEdit" } )
247 public void testEditManagedRepoInvalidRetentionCount()
249 editManagedRepository( "name", "/home", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "1", "101" );
250 assertTextPresent( "Repository Purge By Retention Count needs to be between 1 and 100." );
253 @Test( dependsOnMethods = { "testAddManagedRepoForEdit" } )
254 public void testEditManagedRepoInvalidDaysOlder()
256 editManagedRepository( "name", "/home", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "-1", "1" );
257 assertTextPresent( "Repository Purge By Days Older Than needs to be larger than 0." );
261 @Test( dependsOnMethods = { "testAddManagedRepoForEdit" } )
262 public void testEditManagedRepo()
264 editManagedRepository( "repository.name", "Managed Repo" );
265 assertTextPresent( "Managed Repository Sample" );
269 @Test( dependsOnMethods = { "testEditManagedRepo" }, enabled = false )
270 public void testDeleteManageRepo()
272 deleteManagedRepository();
273 // assertTextNotPresent( "managedrepo" );
276 @Test( dependsOnMethods = { "testAddRemoteRepoValidValues" } )
277 public void testAddRemoteRepoNullValues()
279 getSelenium().open( "/archiva/admin/addRemoteRepository.action" );
280 addRemoteRepository( "", "", "", "", "", "", "Maven 2.x Repository", false );
281 assertTextPresent( "You must enter a repository identifier." );
282 assertTextPresent( "You must enter a repository name." );
283 assertTextPresent( "You must enter a url." );
287 public void testAddRemoteRepositoryNullIdentifier()
289 getSelenium().open( "/archiva/admin/addRemoteRepository.action" );
290 addRemoteRepository( "", "Remote Repository Sample", "http://repository.codehaus.org/org/codehaus/mojo/", "",
291 "", "", "Maven 2.x Repository", false );
292 assertTextPresent( "You must enter a repository identifier." );
295 @Test( dependsOnMethods = { "testAddRemoteRepositoryNullIdentifier" } )
296 public void testAddRemoteRepoNullName()
298 addRemoteRepository( "remoterepo", "", "http://repository.codehaus.org/org/codehaus/mojo/", "", "", "",
299 "Maven 2.x Repository", false );
300 assertTextPresent( "You must enter a repository name." );
304 public void testAddRemoteRepoNullURL()
306 getSelenium().open( "/archiva/admin/addRemoteRepository.action" );
307 addRemoteRepository( "remoterepo", "Remote Repository Sample", "", "", "", "", "Maven 2.x Repository", false );
308 assertTextPresent( "You must enter a url." );
311 @Test( dependsOnMethods = { "testAddRemoteRepoNullURL" } )
312 public void testAddProxyConnectorValidValues()
315 getSelenium().open( "/archiva/admin/addProxyConnector.action" );
316 addProxyConnector( "(direct connection)", "internal", "remoterepo" );
317 assertTextPresent( "remoterepo" );
318 assertTextPresent( "Remote Repository Sample" );
322 public void testAddRemoteRepoValidValues()
324 getSelenium().open( "/archiva/admin/addRemoteRepository.action" );
325 addRemoteRepository( "remoterepo", "Remote Repository Sample",
326 "http://repository.codehaus.org/org/codehaus/mojo/", "", "", "", "Maven 2.x Repository",
328 assertTextPresent( "Remote Repository Sample" );
331 // *** BUNDLED REPOSITORY TEST ***
333 @Test( dependsOnMethods = { "testWithCorrectUsernamePassword" }, alwaysRun = true )
334 public void testBundledRepository()
336 String repo1 = baseUrl + "repository/internal/";
337 String repo2 = baseUrl + "repository/snapshots/";
339 assertRepositoryAccess( repo1 );
340 assertRepositoryAccess( repo2 );
342 getSelenium().open( "/archiva" );
345 private void assertRepositoryAccess( String repo )
347 getSelenium().open( "/archiva" );
348 goToRepositoriesPage();
349 assertLinkPresent( repo );
350 clickLinkWithText( repo );
351 assertPage( "Collection: /" );
352 assertTextPresent( "Collection: /" );