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" }, enabled = false )
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." );
59 assertTextPresent( "Invalid cron expression." );
63 public void testAddManagedRepoInvalidIdentifier()
65 getSelenium().open( "/archiva/admin/addRepository.action" );
67 addManagedRepository( "<> \\/~+[ ]'\"", "name", "/home", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "1",
70 "Identifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
74 public void testAddManagedRepoInvalidRepoName()
76 getSelenium().open( "/archiva/admin/addRepository.action" );
78 addManagedRepository( "identifier", "<>\\~+[]'\"", "/home", "/.index", "Maven 2.x Repository", "0 0 * * * ?",
81 "Repository Name must only contain alphanumeric characters, white-spaces(' '), forward-slashes(/), open-parenthesis('('), close-parenthesis(')'), underscores(_), dots(.), and dashes(-)." );
85 public void testAddManagedRepoInvalidDirectory()
87 getSelenium().open( "/archiva/admin/addRepository.action" );
89 addManagedRepository( "identifier", "name", "<> ~+[ ]'\"", "/.index", "Maven 2.x Repository", "0 0 * * * ?",
92 "Directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
96 public void testAddManagedRepoInvalidIndexDir()
98 getSelenium().open( "/archiva/admin/addRepository.action" );
100 addManagedRepository( "identifier", "name", "/home", "<> ~+[ ]'\"", "Maven 2.x Repository", "0 0 * * * ?", "1",
103 "Index directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
107 public void testAddManagedRepoInvalidRetentionCount()
109 getSelenium().open( "/archiva/admin/addRepository.action" );
111 addManagedRepository( "identifier", "name", "/home", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "1",
113 assertTextPresent( "Repository Purge By Retention Count needs to be between 1 and 100." );
117 public void testAddManagedRepoInvalidDaysOlder()
119 getSelenium().open( "/archiva/admin/addRepository.action" );
121 addManagedRepository( "identifier", "name", "/home", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "-1",
123 assertTextPresent( "Repository Purge By Days Older Than needs to be larger than 0." );
126 @Test( enabled = false )
127 public void testAddManagedRepoBlankValues()
129 getSelenium().open( "/archiva/admin/addRepository.action" );
131 addManagedRepository( "", "", "", "", "Maven 2.x Repository", "", "", "", false );
132 assertTextPresent( "You must enter a repository identifier." );
133 assertTextPresent( "You must enter a repository name." );
134 assertTextPresent( "You must enter a directory." );
136 assertTextPresent( "Invalid cron expression." );
140 public void testAddManagedRepoNoIdentifier()
142 getSelenium().open( "/archiva/admin/addRepository.action" );
144 addManagedRepository( "", "name", "/home", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "", false );
145 assertTextPresent( "You must enter a repository identifier." );
149 public void testAddManagedRepoNoRepoName()
151 getSelenium().open( "/archiva/admin/addRepository.action" );
153 addManagedRepository( "identifier", "", "/home", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "",
155 assertTextPresent( "You must enter a repository name." );
159 public void testAddManagedRepoNoDirectory()
161 getSelenium().open( "/archiva/admin/addRepository.action" );
163 addManagedRepository( "identifier", "name", "", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "",
165 assertTextPresent( "You must enter a directory." );
168 @Test( enabled = false )
169 public void testAddManagedRepoNoCron()
171 getSelenium().open( "/archiva/admin/addRepository.action" );
173 addManagedRepository( "identifier", "name", "/home", "/.index", "Maven 2.x Repository", "", "", "", false );
176 assertTextPresent( "Invalid cron expression." );
180 public void testAddManagedRepoForEdit()
182 getSelenium().open( "/archiva/admin/addRepository.action" );
183 addManagedRepository( "managedrepo", "Managed Repository Sample", getRepositoryDir() + "local-repo/", "",
184 "Maven 2.x Repository", "0 0 * * * ?", "", "", true );
185 clickButtonWithValue( "Save" );
186 assertTextPresent( "Managed Repository Sample" );
189 @Test( dependsOnMethods = { "testAddManagedRepoForEdit" }, enabled = false )
190 public void testEditManagedRepoInvalidValues()
192 editManagedRepository( "<>\\~+[]'\"", "<> ~+[ ]'\"", "<> ~+[ ]'\"", "Maven 2.x Repository", "", "-1", "101" );
194 "Directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
196 "Repository Name must only contain alphanumeric characters, white-spaces(' '), forward-slashes(/), open-parenthesis('('), close-parenthesis(')'), underscores(_), dots(.), and dashes(-)." );
198 "Index directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
199 assertTextPresent( "Repository Purge By Retention Count needs to be between 1 and 100." );
200 assertTextPresent( "Repository Purge By Days Older Than needs to be larger than 0." );
202 assertTextPresent( "Invalid cron expression." );
205 @Test( dependsOnMethods = { "testAddManagedRepoForEdit" } )
206 public void testEditManagedRepoInvalidRepoName()
208 editManagedRepository( "<>\\~+[]'\"", "/home", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "1", "1" );
210 "Repository Name must only contain alphanumeric characters, white-spaces(' '), forward-slashes(/), open-parenthesis('('), close-parenthesis(')'), underscores(_), dots(.), and dashes(-)." );
213 @Test( dependsOnMethods = { "testAddManagedRepoForEdit" } )
214 public void testEditManagedRepoInvalidDirectory()
216 editManagedRepository( "name", "<> ~+[ ]'\"", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "1", "1" );
218 "Directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
221 @Test( dependsOnMethods = { "testAddManagedRepoForEdit" } )
222 public void testEditManagedRepoInvalidIndexDir()
224 editManagedRepository( "name", "/home", "<> ~+[ ]'\"", "Maven 2.x Repository", "0 0 * * * ?", "1", "1" );
226 "Index directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
229 @Test( dependsOnMethods = { "testAddManagedRepoForEdit" }, enabled = false )
230 public void testEditManagedRepoInvalidCron()
232 editManagedRepository( "name", "/home", "/.index", "Maven 2.x Repository", "", "1", "1" );
234 assertTextPresent( "Invalid cron expression." );
237 @Test( dependsOnMethods = { "testAddManagedRepoForEdit" } )
238 public void testEditManagedRepoInvalidRetentionCount()
240 editManagedRepository( "name", "/home", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "1", "101" );
241 assertTextPresent( "Repository Purge By Retention Count needs to be between 1 and 100." );
244 @Test( dependsOnMethods = { "testAddManagedRepoForEdit" } )
245 public void testEditManagedRepoInvalidDaysOlder()
247 editManagedRepository( "name", "/home", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "-1", "1" );
248 assertTextPresent( "Repository Purge By Days Older Than needs to be larger than 0." );
252 @Test( dependsOnMethods = { "testAddManagedRepoForEdit" } )
253 public void testEditManagedRepo()
255 editManagedRepository( "repository.name", "Managed Repo" );
256 assertTextPresent( "Managed Repository Sample" );
260 @Test( dependsOnMethods = { "testEditManagedRepo" }, enabled = false )
261 public void testDeleteManageRepo()
263 deleteManagedRepository();
264 // assertTextNotPresent( "managedrepo" );
267 @Test( dependsOnMethods = { "testAddRemoteRepoValidValues" } )
268 public void testAddRemoteRepoNullValues()
270 getSelenium().open( "/archiva/admin/addRemoteRepository.action" );
271 addRemoteRepository( "", "", "", "", "", "", "Maven 2.x Repository", false );
272 assertTextPresent( "You must enter a repository identifier." );
273 assertTextPresent( "You must enter a repository name." );
274 assertTextPresent( "You must enter a url." );
278 public void testAddRemoteRepositoryNullIdentifier()
280 getSelenium().open( "/archiva/admin/addRemoteRepository.action" );
281 addRemoteRepository( "", "Remote Repository Sample", "http://repository.codehaus.org/org/codehaus/mojo/", "",
282 "", "", "Maven 2.x Repository", false );
283 assertTextPresent( "You must enter a repository identifier." );
286 @Test( dependsOnMethods = { "testAddRemoteRepositoryNullIdentifier" } )
287 public void testAddRemoteRepoNullName()
289 addRemoteRepository( "remoterepo", "", "http://repository.codehaus.org/org/codehaus/mojo/", "", "", "",
290 "Maven 2.x Repository", false );
291 assertTextPresent( "You must enter a repository name." );
295 public void testAddRemoteRepoNullURL()
297 getSelenium().open( "/archiva/admin/addRemoteRepository.action" );
298 addRemoteRepository( "remoterepo", "Remote Repository Sample", "", "", "", "", "Maven 2.x Repository", false );
299 assertTextPresent( "You must enter a url." );
302 @Test( dependsOnMethods = { "testAddRemoteRepoNullURL" } )
303 public void testAddProxyConnectorValidValues()
306 getSelenium().open( "/archiva/admin/addProxyConnector.action" );
307 addProxyConnector( "(direct connection)", "internal", "remoterepo" );
308 assertTextPresent( "remoterepo" );
309 assertTextPresent( "Remote Repository Sample" );
313 public void testAddRemoteRepoValidValues()
315 getSelenium().open( "/archiva/admin/addRemoteRepository.action" );
316 addRemoteRepository( "remoterepo", "Remote Repository Sample",
317 "http://repository.codehaus.org/org/codehaus/mojo/", "", "", "", "Maven 2.x Repository",
319 assertTextPresent( "Remote Repository Sample" );
322 // *** BUNDLED REPOSITORY TEST ***
324 @Test( dependsOnMethods = { "testWithCorrectUsernamePassword" }, alwaysRun = true )
325 public void testBundledRepository()
327 String repo1 = baseUrl + "repository/internal/";
328 String repo2 = baseUrl + "repository/snapshots/";
330 assertRepositoryAccess( repo1 );
331 assertRepositoryAccess( repo2 );
333 getSelenium().open( "/archiva" );
336 private void assertRepositoryAccess( String repo )
338 getSelenium().open( "/archiva" );
339 goToRepositoriesPage();
340 assertLinkPresent( repo );
341 clickLinkWithText( repo );
342 assertPage( "Collection: /" );
343 assertTextPresent( "Collection: /" );