]> source.dussan.org Git - archiva.git/blob
1864f9bef6e306da872f1c27549cbb5d6a060ee5
[archiva.git] /
1 package org.apache.archiva.web.test;
2
3 /*
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
11  *
12  *   http://www.apache.org/licenses/LICENSE-2.0
13  *
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
19  * under the License.
20  */
21
22 import org.apache.archiva.web.test.parent.AbstractRepositoryTest;
23 import org.testng.annotations.Test;
24
25 @Test( groups = { "repository" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true )
26 public class RepositoryTest
27         extends AbstractRepositoryTest
28 {
29         @Test(dependsOnMethods = { "testWithCorrectUsernamePassword" } )
30         public void testAddManagedRepoValidValues()
31         {
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();
38         }
39         
40         @Test(dependsOnMethods = { "testAddManagedRepoValidValues" } )
41         public void testAddManagedRepoInvalidValues()
42         {                               
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." );
50         }
51         
52         @Test(dependsOnMethods = { "testAddManagedRepoInvalidValues" } )
53         public void testAddManagedRepoNoIdentifier()
54         {               
55                 addManagedRepository( "", "name" , "/home" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
56                 assertTextPresent( "You must enter a repository identifier." );
57         }
58         
59         @Test(dependsOnMethods = { "testAddManagedRepoNoIdentifier" } )
60         public void testAddManagedRepoNoRepoName()
61         {
62                 addManagedRepository( "identifier", "" , "/home" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
63                 assertTextPresent( "You must enter a repository name." );
64         }
65         
66         @Test(dependsOnMethods = { "testAddManagedRepoNoRepoName" } )
67         public void testAddManagedRepoNoDirectory()
68         {
69                 addManagedRepository( "identifier", "name" , "" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
70                 assertTextPresent( "You must enter a directory." );
71         }
72         
73         @Test(dependsOnMethods = { "testAddManagedRepoNoDirectory" } )
74         public void testAddManagedRepoNoCron()
75         {
76                 addManagedRepository( "identifier", "name" , "/home" , "/.index", "Maven 2.x Repository", "", "", "" );
77                 assertTextPresent( "Invalid cron expression." );
78         }
79         
80         @Test(dependsOnMethods = { "testAddManagedRepoNoCron" } )
81         public void testAddManagedRepoForEdit()
82         {
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" );
88         }
89
90         //TODO
91         @Test(dependsOnMethods = { "testAddManagedRepoForEdit" } )
92         public void testEditManagedRepo()
93         {
94                 editManagedRepository( "repository.name" , "Managed Repo" );
95                 assertTextPresent( "Managed Repository Sample" );
96         }
97         
98         //TODO
99         @Test(dependsOnMethods = { "testEditManagedRepo" } )
100         public void testDeleteManageRepo()
101         {
102                 deleteManagedRepository();
103                 //assertTextNotPresent( "managedrepo" );
104         }
105         
106         @Test(dependsOnMethods = { "testAddRemoteRepoValidValues" } )
107         public void testAddRemoteRepoNullValues()
108         {               
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." );
114         }
115         
116         @Test(dependsOnMethods = { "testAddRemoteRepoNullValues" } )
117         public void testAddRemoteRepositoryNullIdentifier()
118         {
119                 addRemoteRepository( "" , "Remote Repository Sample" , "http://repository.codehaus.org/org/codehaus/mojo/" , "" , "" , "" , "Maven 2.x Repository" );
120                 assertTextPresent( "You must enter a repository identifier." );
121         }
122         
123         @Test(dependsOnMethods = { "testAddRemoteRepositoryNullIdentifier" } )
124         public void testAddRemoteRepoNullName()
125         {
126                 addRemoteRepository( "remoterepo" , "" , "http://repository.codehaus.org/org/codehaus/mojo/" , "" , "" , "" , "Maven 2.x Repository" );
127                 assertTextPresent( "You must enter a repository name." );
128         }
129         
130         @Test(dependsOnMethods = { "testAddRemoteRepoNullName" } )
131         public void testAddRemoteRepoNullURL()
132         {
133                 addRemoteRepository( "remoterepo" , "Remote Repository Sample" , "" , "" , "" , "" , "Maven 2.x Repository" );
134                 assertTextPresent( "You must enter a url." );
135         }
136
137         @Test(dependsOnMethods = { "testDeleteManageRepo" } )
138         public void testAddRemoteRepoValidValues()
139         {               
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" );
143         }
144     \r
145     // *** BUNDLED REPOSITORY TEST ***
146     \r
147     @Test ( dependsOnMethods = { "testWithCorrectUsernamePassword" }, alwaysRun = true )\r
148     public void testBundledRepository()\r
149     {
150         String repo1 = baseUrl + "repository/internal/";
151         String repo2 = baseUrl + "repository/snapshots/";
152         
153         assertRepositoryAccess( repo1 );
154         assertRepositoryAccess( repo2 );
155         
156         getSelenium().open( "/archiva" );\r
157     }
158     
159     private void assertRepositoryAccess( String repo )
160     {
161         getSelenium().open( "/archiva" );
162         goToRepositoriesPage();
163         assertLinkPresent( repo );
164         clickLinkWithText( repo );
165         assertPage( "Collection: /" );
166         assertTextPresent( "Collection: /" );
167     }
168 }