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
29 public void testAddManagedRepoValidValues()
31 goToRepositoriesPage();
32 getSelenium().open( "/archiva/admin/addRepository.action" );
33 addManagedRepository( "managedrepo1", "Managed Repository Sample 1" , getRepositoryDir() + "repository/" , "", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
34 clickButtonWithValue( "Save" );
35 assertTextPresent( "Managed Repository Sample 1" );
36 assertRepositoriesPage();
39 @Test(dependsOnMethods = { "testAddManagedRepoValidValues" } )
40 public void testAddManagedRepoInvalidValues()
42 goToRepositoriesPage();
43 getSelenium().open( "/archiva/admin/addRepository.action" ); ;
44 addManagedRepository( "", "" , "" , "", "Maven 2.x Repository", "", "", "" );
45 assertTextPresent( "You must enter a repository identifier." );
46 assertTextPresent( "You must enter a repository name." );
47 assertTextPresent( "You must enter a directory." );
48 assertTextPresent( "Invalid cron expression." );
51 @Test(dependsOnMethods = { "testAddManagedRepoInvalidValues" } )
52 public void testAddManagedRepoNoIdentifier()
54 addManagedRepository( "", "name" , "/home" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
55 assertTextPresent( "You must enter a repository identifier." );
58 @Test(dependsOnMethods = { "testAddManagedRepoNoIdentifier" } )
59 public void testAddManagedRepoNoRepoName()
61 addManagedRepository( "identifier", "" , "/home" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
62 assertTextPresent( "You must enter a repository name." );
65 @Test(dependsOnMethods = { "testAddManagedRepoNoRepoName" } )
66 public void testAddManagedRepoNoDirectory()
68 addManagedRepository( "identifier", "name" , "" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
69 assertTextPresent( "You must enter a directory." );
72 @Test(dependsOnMethods = { "testAddManagedRepoNoDirectory" } )
73 public void testAddManagedRepoNoCron()
75 addManagedRepository( "identifier", "name" , "/home" , "/.index", "Maven 2.x Repository", "", "", "" );
76 assertTextPresent( "Invalid cron expression." );
79 @Test(dependsOnMethods = { "testAddManagedRepoNoCron" } )
80 public void testAddManagedRepoForEdit()
82 goToRepositoriesPage();
83 clickLinkWithText( "Add" );
84 addManagedRepository( "managedrepo", "Managed Repository Sample" , getRepositoryDir() + "local-repo/", "", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
85 clickButtonWithValue( "Save" );
86 assertTextPresent( "Managed Repository Sample" );
90 @Test(dependsOnMethods = { "testAddManagedRepoForEdit" } )
91 public void testEditManagedRepo()
93 editManagedRepository( "repository.name" , "Managed Repo" );
94 assertTextPresent( "Managed Repository Sample" );
98 @Test(dependsOnMethods = { "testEditManagedRepo" } )
99 public void testDeleteManageRepo()
101 deleteManagedRepository();
102 //assertTextNotPresent( "managedrepo" );
105 @Test(dependsOnMethods = { "testAddRemoteRepoValidValues" } )
106 public void testAddRemoteRepoNullValues()
108 getSelenium().open( "/archiva/admin/addRemoteRepository.action" );
109 addRemoteRepository( "" , "" , "" , "" , "" , "" , "Maven 2.x Repository" );
110 assertTextPresent( "You must enter a repository identifier." );
111 assertTextPresent( "You must enter a repository name." );
112 assertTextPresent( "You must enter a url." );
115 @Test(dependsOnMethods = { "testAddRemoteRepoNullValues" } )
116 public void testAddRemoteRepositoryNullIdentifier()
118 addRemoteRepository( "" , "Remote Repository Sample" , "http://repository.codehaus.org/org/codehaus/mojo/" , "" , "" , "" , "Maven 2.x Repository" );
119 assertTextPresent( "You must enter a repository identifier." );
122 @Test(dependsOnMethods = { "testAddRemoteRepositoryNullIdentifier" } )
123 public void testAddRemoteRepoNullName()
125 addRemoteRepository( "remoterepo" , "" , "http://repository.codehaus.org/org/codehaus/mojo/" , "" , "" , "" , "Maven 2.x Repository" );
126 assertTextPresent( "You must enter a repository name." );
129 @Test(dependsOnMethods = { "testAddRemoteRepoNullName" } )
130 public void testAddRemoteRepoNullURL()
132 addRemoteRepository( "remoterepo" , "Remote Repository Sample" , "" , "" , "" , "" , "Maven 2.x Repository" );
133 assertTextPresent( "You must enter a url." );
136 @Test(dependsOnMethods = { "testDeleteManageRepo" } )
137 public void testAddRemoteRepoValidValues()
139 getSelenium().open( "/archiva/admin/addRemoteRepository.action" );
140 addRemoteRepository( "remoterepo" , "Remote Repository Sample" , "http://repository.codehaus.org/org/codehaus/mojo/" , "" , "" , "" , "Maven 2.x Repository" );
141 assertTextPresent( "Remote Repository Sample" );
144 // *** BUNDLED REPOSITORY TEST ***
146 @Test ( dependsOnMethods = { "testWithCorrectUsernamePassword" }, alwaysRun = true )
\r
147 public void testBundledRepository()
\r
149 String repo1 = baseUrl + "repository/internal/";
150 String repo2 = baseUrl + "repository/snapshots/";
152 assertRepositoryAccess( repo1 );
153 assertRepositoryAccess( repo2 );
155 getSelenium().open( "/archiva" );
\r
158 private void assertRepositoryAccess( String repo )
160 getSelenium().open( "/archiva" );
161 goToRepositoriesPage();
162 assertLinkPresent( repo );
163 clickLinkWithText( repo );
164 assertPage( "Collection: /" );
165 assertTextPresent( "Collection: /" );