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