1 package org.apache.maven.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
23 * Test archiva proxied repositories configuration
26 public class ProxiedRepositoryTest
27 extends AbstractArchivaTestCase
32 protected void initialize()
40 * Create a proxied repo which will be used for testing
42 private void createTestRepo()
44 clickProxiedRepositories();
46 if ( isTextPresent( "There are no proxied repositories configured yet." ) )
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" );
56 assertPage( "Administration" );
57 assertTextPresent( "Test Proxied Repository" );
58 assertLinkPresent( "Edit Repository" );
65 * Test add proxied repo with invalid data
67 public void testInvalidAddProxiedRepoConfiguration()
69 clickProxiedRepositories();
71 clickLinkWithText( "Add Repository" );
72 assertPage( "Configuration" );
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." );
84 * Test edit proxied repo with valid data
86 public void testValidEditProxiedRepoConfiguration()
88 clickProxiedRepositories();
89 clickLinkWithText( "Edit Repository" );
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" );
98 assertPage( "Administration" );
99 assertTextPresent( "Test Valid" );
100 assertLinkPresent( "Edit Repository" );
106 * Test edit proxied repo with invalid data
108 public void testInvalidEditProxiedRepoConfiguration()
110 clickProxiedRepositories();
111 clickLinkWithText( "Edit Repository" );
113 assertPage( "Configuration" );
114 assertTextPresent( "Edit Proxied Repository" );
115 setFieldValue( "name", "" );
116 setFieldValue( "url", "" );
117 clickButtonWithValue( "Update Repository", false );
119 assertPage( "Configuration" );
120 assertTextPresent( "You must enter the repository name." );
121 assertTextPresent( "You must enter the repository URL." );
127 * Test delete repository, unmodified entry and contents
129 public void testDeleteRepoUnmodified()
131 clickProxiedRepositories();
132 clickLinkWithText( "Delete Repository" );
134 assertPage( "Configuration" );
135 assertTextPresent( "Delete Proxied Repository" );
136 clickButtonWithValue( "Go" );
138 assertPage( "Administration" );
139 assertTextPresent( "Test Proxied Repository" );
145 * Test delete repository including contents
147 public void testDeleteRepoRemoveFromDisk()
149 clickProxiedRepositories();
150 clickLinkWithText( "Delete Repository" );
152 assertPage( "Configuration" );
153 clickLinkWithLocator( "deleteProxiedRepository_operationdelete-contents", false );
154 clickButtonWithValue( "Go" );
156 assertPage( "Administration" );
157 assertTextNotPresent( "Test Proxied Repository" );
163 * Test delete repository, unmodified contents/entry deleted
165 public void testDeleteRepoUnmodifiedContents()
167 clickProxiedRepositories();
168 clickLinkWithText( "Delete Repository" );
170 assertPage( "Configuration" );
171 clickLinkWithLocator( "deleteProxiedRepository_operationdelete-entry", false );
172 clickButtonWithValue( "Go" );
174 assertPage( "Administration" );
175 assertTextNotPresent( "Test Proxied Repository" );
181 * Click Settings from the navigation menu
183 private void clickProxiedRepositories()
186 submitLoginPage( adminUsername, adminPassword );
188 clickLinkWithText( "Proxied Repositories" );
189 assertPage( "Administration" );
190 assertTextPresent( "Proxied Repositories" );
194 * Remove the created test repo
196 protected void removeTestRepo()
198 if ( !isLinkPresent( "Login" ) )
203 clickProxiedRepositories();
205 if ( isTextPresent( "Delete Repository " ) )
207 clickLinkWithText( "Delete Repository" );
208 assertPage( "Configuration" );
209 clickLinkWithLocator( "deleteProxiedRepository_operationdelete-entry", false );
210 clickButtonWithValue( "Go" );
212 assertPage( "Administration" );
213 assertTextNotPresent( "Test Proxied Repository" );
220 * Revert to original value
224 public void tearDown()