]> source.dussan.org Git - archiva.git/blob
f0b191644ebf99a39433460f0ef9b82bb19479c5
[archiva.git] /
1 package org.apache.maven.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 /**
23  * Test archiva proxied repositories configuration
24  *
25  */
26 public class ProxiedRepositoryTest
27     extends AbstractArchivaTestCase
28 {
29     /**
30      *
31      */
32     protected void initialize()
33     {
34         super.initialize();
35
36         createTestRepo();
37     }
38
39     /**
40      * Create a proxied repo which will be used for testing
41      */
42     private void createTestRepo()
43     {
44         clickProxiedRepositories();
45
46         if ( isTextPresent( "There are no proxied repositories configured yet." ) )
47         {
48             clickLinkWithText( "Add Repository" );
49             assertPage( "Configuration" );
50             setFieldValue( "id", "test-proxied" );
51             setFieldValue( "name", "Test Proxied Repository" );
52             setFieldValue( "url", "http://test.com/test-proxied" );
53             clickButtonWithValue( "Add Repository" );
54             waitPage();
55
56             assertPage( "Administration" );
57             assertTextPresent( "Test Proxied Repository" );
58             assertLinkPresent( "Edit Repository" );
59         }
60
61         logout();
62     }
63
64     /**
65      * Test add proxied repo with invalid data
66      */
67     public void testInvalidAddProxiedRepoConfiguration()
68     {
69         clickProxiedRepositories();
70
71         clickLinkWithText( "Add Repository" );
72         assertPage( "Configuration" );
73
74         clickButtonWithValue( "Add Repository", false );
75         assertPage( "Configuration" );
76         assertTextPresent( "You must enter the repository identifier." );
77         assertTextPresent( "You must enter the repository name." );
78         assertTextPresent( "You must enter the repository URL." );
79
80         logout();
81     }
82
83     /**
84      * Test edit proxied repo with valid data
85      */
86     public void testValidEditProxiedRepoConfiguration()
87     {
88         clickProxiedRepositories();
89         clickLinkWithText( "Edit Repository" );
90
91         assertPage( "Configuration" );
92         assertTextPresent( "Edit Proxied Repository" );
93         setFieldValue( "name", "Test Valid" );
94         setFieldValue( "url", "http://valid.org/test-valid" );
95         clickButtonWithValue( "Update Repository" );
96         waitPage();
97
98         assertPage( "Administration" );
99         assertTextPresent( "Test Valid" );
100         assertLinkPresent( "Edit Repository" );
101
102         logout();
103     }
104
105     /**
106      * Test edit proxied repo with invalid data
107      */
108     public void testInvalidEditProxiedRepoConfiguration()
109     {
110         clickProxiedRepositories();
111         clickLinkWithText( "Edit Repository" );
112
113         assertPage( "Configuration" );
114         assertTextPresent( "Edit Proxied Repository" );
115         setFieldValue( "name", "" );
116         setFieldValue( "url", "" );
117         clickButtonWithValue( "Update Repository", false );
118
119         assertPage( "Configuration" );
120         assertTextPresent( "You must enter the repository name." );
121         assertTextPresent( "You must enter the repository URL." );
122
123         logout();
124     }
125
126     /**
127      * Test delete repository, unmodified entry and contents
128      */
129     public void testDeleteRepoUnmodified()
130     {
131         clickProxiedRepositories();
132         clickLinkWithText( "Delete Repository" );
133
134         assertPage( "Configuration" );
135         assertTextPresent( "Delete Proxied Repository" );
136         clickButtonWithValue( "Go" );
137
138         assertPage( "Administration" );
139         assertTextPresent( "Test Proxied Repository" );
140
141         logout();
142     }
143
144     /**
145      * Test delete repository including contents
146      */
147     public void testDeleteRepoRemoveFromDisk()
148     {
149         clickProxiedRepositories();
150         clickLinkWithText( "Delete Repository" );
151
152         assertPage( "Configuration" );
153         clickLinkWithLocator( "deleteProxiedRepository_operationdelete-contents", false );
154         clickButtonWithValue( "Go" );
155
156         assertPage( "Administration" );
157         assertTextNotPresent( "Test Proxied Repository" );
158
159         logout();
160     }
161
162     /**
163      * Test delete repository, unmodified contents/entry deleted
164      */
165     public void testDeleteRepoUnmodifiedContents()
166     {
167         clickProxiedRepositories();
168         clickLinkWithText( "Delete Repository" );
169
170         assertPage( "Configuration" );
171         clickLinkWithLocator( "deleteProxiedRepository_operationdelete-entry", false );
172         clickButtonWithValue( "Go" );
173
174         assertPage( "Administration" );
175         assertTextNotPresent( "Test Proxied Repository" );
176
177         logout();
178     }
179
180     /**
181      * Click Settings from the navigation menu
182      */
183     private void clickProxiedRepositories()
184     {
185         goToLoginPage();
186         submitLoginPage( adminUsername, adminPassword );
187
188         clickLinkWithText( "Proxied Repositories" );
189         assertPage( "Administration" );
190         assertTextPresent( "Proxied Repositories" );
191     }
192
193     /**
194      * Remove the created test repo
195      */
196     protected void removeTestRepo()
197     {
198         if ( !isLinkPresent( "Login" ) )
199         {
200             logout();
201         }
202
203         clickProxiedRepositories();
204
205         if ( isTextPresent( "Delete Repository " ) )
206         {
207             clickLinkWithText( "Delete Repository" );
208             assertPage( "Configuration" );
209             clickLinkWithLocator( "deleteProxiedRepository_operationdelete-entry", false );
210             clickButtonWithValue( "Go" );
211
212             assertPage( "Administration" );
213             assertTextNotPresent( "Test Proxied Repository" );
214         }
215
216         logout();
217     }
218
219     /**
220      * Revert to original value
221      *
222      * @throws Exception
223      */
224     public void tearDown()
225         throws Exception
226     {
227         removeTestRepo();
228
229         super.tearDown();
230     }
231
232 }