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 @Test(dependsOnMethods = { "testWithCorrectUsernamePassword" } )
30 public void testAddManagedRepoValidValues()
32 goToRepositoriesPage();
33 clickLinkWithLocator( "//div[@id='contentArea']/div/div/a[@href='/archiva/admin/addRepository.action']" );
34 addManagedRepository( "managedrepo1", "Managed Repository Sample 1" , getRepositoryDir() + "repository/" , "", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
35 clickButtonWithValue( "Save" );
36 assertTextPresent( "Managed Repository Sample 1" );
37 assertRepositoriesPage();
40 @Test(dependsOnMethods = { "testAddManagedRepoValidValues" } )
41 public void testAddManagedRepoInvalidValues()
43 assertRepositoriesPage();
44 clickLinkWithLocator( "//div[@id='contentArea']/div/div/a[@href='/archiva/admin/addRepository.action']" );
45 addManagedRepository( "", "" , "" , "", "Maven 2.x Repository", "", "", "" );
46 assertTextPresent( "You must enter a repository identifier." );
47 assertTextPresent( "You must enter a repository name." );
48 assertTextPresent( "You must enter a directory." );
49 assertTextPresent( "Invalid cron expression." );
52 @Test(dependsOnMethods = { "testAddManagedRepoInvalidValues" } )
53 public void testAddManagedRepoNoIdentifier()
55 addManagedRepository( "", "name" , "/home" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
56 assertTextPresent( "You must enter a repository identifier." );
59 @Test(dependsOnMethods = { "testAddManagedRepoNoIdentifier" } )
60 public void testAddManagedRepoNoRepoName()
62 addManagedRepository( "identifier", "" , "/home" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
63 assertTextPresent( "You must enter a repository name." );
66 @Test(dependsOnMethods = { "testAddManagedRepoNoRepoName" } )
67 public void testAddManagedRepoNoDirectory()
69 addManagedRepository( "identifier", "name" , "" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
70 assertTextPresent( "You must enter a directory." );
73 @Test(dependsOnMethods = { "testAddManagedRepoNoDirectory" } )
74 public void testAddManagedRepoNoCron()
76 addManagedRepository( "identifier", "name" , "/home" , "/.index", "Maven 2.x Repository", "", "", "" );
77 assertTextPresent( "Invalid cron expression." );
80 @Test(dependsOnMethods = { "testAddManagedRepoNoCron" } )
81 public void testAddManagedRepoForEdit()
83 goToRepositoriesPage();
84 clickLinkWithText( "Add" );
85 addManagedRepository( "managedrepo", "Managed Repository Sample" , getRepositoryDir() + "local-repo/", "", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
86 clickButtonWithValue( "Save" );
87 assertTextPresent( "Managed Repository Sample" );
91 @Test(dependsOnMethods = { "testAddManagedRepoForEdit" } )
92 public void testEditManagedRepo()
94 editManagedRepository( "repository.name" , "Managed Repo" );
95 assertTextPresent( "Managed Repository Sample" );
99 @Test(dependsOnMethods = { "testEditManagedRepo" } )
100 public void testDeleteManageRepo()
102 deleteManagedRepository();
103 //assertTextNotPresent( "managedrepo" );
106 @Test(dependsOnMethods = { "testAddRemoteRepoValidValues" } )
107 public void testAddRemoteRepoNullValues()
109 clickLinkWithLocator( "//div[@id='contentArea']/div/div/a[@href='/archiva/admin/addRemoteRepository.action']" );
110 addRemoteRepository( "" , "" , "" , "" , "" , "" , "Maven 2.x Repository" );
111 assertTextPresent( "You must enter a repository identifier." );
112 assertTextPresent( "You must enter a repository name." );
113 assertTextPresent( "You must enter a url." );
116 @Test(dependsOnMethods = { "testAddRemoteRepoNullValues" } )
117 public void testAddRemoteRepositoryNullIdentifier()
119 addRemoteRepository( "" , "Remote Repository Sample" , "http://repository.codehaus.org/org/codehaus/mojo/" , "" , "" , "" , "Maven 2.x Repository" );
120 assertTextPresent( "You must enter a repository identifier." );
123 @Test(dependsOnMethods = { "testAddRemoteRepositoryNullIdentifier" } )
124 public void testAddRemoteRepoNullName()
126 addRemoteRepository( "remoterepo" , "" , "http://repository.codehaus.org/org/codehaus/mojo/" , "" , "" , "" , "Maven 2.x Repository" );
127 assertTextPresent( "You must enter a repository name." );
130 @Test(dependsOnMethods = { "testAddRemoteRepoNullName" } )
131 public void testAddRemoteRepoNullURL()
133 addRemoteRepository( "remoterepo" , "Remote Repository Sample" , "" , "" , "" , "" , "Maven 2.x Repository" );
134 assertTextPresent( "You must enter a url." );
137 @Test(dependsOnMethods = { "testDeleteManageRepo" } )
138 public void testAddRemoteRepoValidValues()
140 clickLinkWithLocator( "//div[@id='contentArea']/div/div/a[@href='/archiva/admin/addRemoteRepository.action']" );
141 addRemoteRepository( "remoterepo" , "Remote Repository Sample" , "http://repository.codehaus.org/org/codehaus/mojo/" , "" , "" , "" , "Maven 2.x Repository" );
142 assertTextPresent( "Remote Repository Sample" );
145 // *** BUNDLED REPOSITORY TEST ***
147 @Test ( dependsOnMethods = { "testWithCorrectUsernamePassword" }, alwaysRun = true )
\r
148 public void testBundledRepository()
\r
150 String repo1 = baseUrl + "repository/internal/";
151 String repo2 = baseUrl + "repository/snapshots/";
153 assertRepositoryAccess( repo1 );
154 assertRepositoryAccess( repo2 );
156 getSelenium().open( "/archiva" );
\r
159 private void assertRepositoryAccess( String repo )
161 getSelenium().open( "/archiva" );
162 goToRepositoriesPage();
163 assertLinkPresent( repo );
164 clickLinkWithText( repo );
165 assertPage( "Collection: /" );
166 assertTextPresent( "Collection: /" );