1 package org.apache.archiva.web.test.parent;
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 import org.testng.Assert;
25 public abstract class AbstractRepositoryTest
26 extends AbstractArchivaTest
29 public void goToRepositoryGroupsPage()
31 if ( !getTitle().equals( "Apache Archiva \\ Administration - Repository Groups" ) )
33 clickLinkWithText( "Repository Groups" );
35 assertRepositoryGroupsPage();
38 public void assertRepositoryGroupsPage()
40 assertPage( "Apache Archiva \\ Administration - Repository Groups" );
41 assertTextPresent( "Administration - Repository Groups" );
42 assertTextPresent( "Identifier*:" );
43 assertElementPresent( "repositoryGroup.id" );
44 assertButtonWithValuePresent( "Add Group" );
45 assertTextPresent( "Repository Groups" );
48 public void assertAddedRepositoryLink( String repositoryGroupName )
50 assertPage( "Apache Archiva \\ Administration - Repository Groups" );
51 String repositoryGroupUrlValue = "repository/" + repositoryGroupName + "/";
52 String baseUrlValue = "archiva";
53 String repositoryGroupLink = baseUrl.replaceFirst( baseUrlValue, repositoryGroupUrlValue );
54 assertTextPresent( repositoryGroupLink );
57 public void assertAddedRepositoryToRepositoryGroups( String repositoryName )
59 assertPage( "Apache Archiva \\ Administration - Repository Groups" );
60 assertTextPresent( repositoryName );
61 assertTextPresent( "Archiva Managed Internal Repository" );
62 assertAddedRepositoryLink( repositoryName );
65 public void assertDeleteRepositoryGroupPage( String repositoryName )
67 assertPage( "Apache Archiva \\ Admin: Delete Repository Group" );
68 assertTextPresent( "WARNING: This operation can not be undone." );
69 assertTextPresent( "Are you sure you want to delete the following repository group?" );
70 assertTextPresent( "ID:" );
71 assertTextPresent( repositoryName );
72 assertButtonWithValuePresent( "Confirm" );
73 assertButtonWithValuePresent( "Cancel" );
76 public void addRepositoryGroup( String repoGroupName )
78 goToRepositoryGroupsPage();
79 setFieldValue( "repositoryGroup.id", repoGroupName );
80 clickButtonWithValue( "Add Group" );
83 public void addRepositoryToRepositoryGroup( String repositoryGroupName, String repositoryName )
85 goToRepositoryGroupsPage();
86 String s = getSelenium().getBodyText();
87 if ( s.contains( "No Repository Groups Defined." ) )
89 setFieldValue( "repositoryGroup.id", repositoryGroupName );
90 clickButtonWithValue( "Add Group" );
91 // assertAddedRepositoryLink( repositoryGroupName );
93 selectValue( "addRepositoryToGroup_repoId", repositoryName );
94 clickButtonWithValue( "Add Repository" );
95 assertAddedRepositoryToRepositoryGroups( repositoryName );
99 // assertAddedRepositoryLink( repositoryGroupName );
100 selectValue( "addRepositoryToGroup_repoId", repositoryName );
101 clickButtonWithValue( "Add Repository" );
105 public void deleteRepositoryInRepositoryGroups()
107 goToRepositoryGroupsPage();
108 getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[3]/div[1]/a/img" );
112 public void deleteRepositoryGroup( String repositoryName )
114 getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[1]/div/a/img" );
116 assertDeleteRepositoryGroupPage( repositoryName );
117 clickButtonWithValue( "Confirm" );
120 // /////////////////////////////
122 // /////////////////////////////
123 public void goToProxyConnectorsPage()
125 clickLinkWithText( "Proxy Connectors" );
126 assertProxyConnectorsPage();
129 public void assertProxyConnectorsPage()
131 assertPage( "Apache Archiva \\ Administration - Proxy Connectors" );
132 assertTextPresent( "Administration - Proxy Connectors" );
133 assertTextPresent( "Repository Proxy Connectors" );
134 assertTextPresent( "internal" );
135 assertTextPresent( "Archiva Managed Internal Repository" );
136 assertTextPresent( "Proxy Connector" );
137 assertTextPresent( "Central Repository" );
138 assertTextPresent( "Java.net Repository for Maven 2" );
141 public void assertAddProxyConnectorPage()
143 assertPage( "Apache Archiva \\ Admin: Add Proxy Connector" );
144 assertTextPresent( "Admin: Add Proxy Connector" );
146 "Network Proxy*:,Managed Repository*:,Remote Repository*:,Policies:,Return error when:,On remote error:,Releases:,Snapshots:,Checksum:,Cache failures:,Properties:,No properties have been set.,Black List:,No black list patterns have been set.,White List:,No white list patterns have been set.";
147 String[] arrayProxy = proxy.split( "," );
148 for ( String arrayproxy : arrayProxy )
149 assertTextPresent( arrayproxy );
151 * String proxyElements =
152 * "addProxyConnector_connector_proxyId,addProxyConnector_connector_sourceRepoId,addProxyConnector_connector_targetRepoId,policy_propagate-errors-on-update,policy_propagate-errors,policy_releases,policy_snapshots,policy_checksum,policy_cache-failures,propertiesEntry,propertiesValue,blackListEntry,whiteListEntry"
153 * ; String[] arrayProxyElements = proxyElements.split( "," ); for ( String arrayproxyelements :
154 * arrayProxyElements ) assertTextPresent( arrayproxyelements );
156 assertButtonWithValuePresent( "Add Property" );
157 assertButtonWithValuePresent( "Add Pattern" );
158 assertButtonWithValuePresent( "Add Proxy Connector" );
161 // this only fills in the values of required fields in adding Proxy Connectors
162 public void addProxyConnector( String networkProxy, String managedRepo, String remoteRepo )
164 goToProxyConnectorsPage();
165 clickLinkWithText( "Add" );
166 assertAddProxyConnectorPage();
167 selectValue( "connector.proxyId", networkProxy );
168 selectValue( "connector.sourceRepoId", managedRepo );
169 selectValue( "connector.targetRepoId", remoteRepo );
172 public void deleteProxyConnector()
174 goToProxyConnectorsPage();
175 clickLinkWithXPath( "//div[@id='contentArea']/div[2]/div[1]/div[2]/div[1]/a[3]/img" );
176 assertPage( "Apache Archiva \\ Admin: Delete Proxy Connectors" );
177 clickButtonWithValue( "Delete" );
178 assertPage( "Apache Archiva \\ Administration - Proxy Connectors" );
181 // /////////////////////////////
183 // /////////////////////////////
184 public void goToNetworkProxiesPage()
186 clickLinkWithText( "Network Proxies" );
187 assertNetworkProxiesPage();
190 public void assertNetworkProxiesPage()
192 assertPage( "Apache Archiva \\ Administration - Network Proxies" );
193 assertTextPresent( "Administration - Network Proxies" );
194 assertTextPresent( "Network Proxies" );
195 assertLinkPresent( "Add Network Proxy" );
198 public void assertAddNetworkProxy()
200 assertPage( "Apache Archiva \\ Admin: Add Network Proxy" );
201 assertTextPresent( "Admin: Add Network Proxy" );
202 assertTextPresent( "Add network proxy:" );
203 assertTextPresent( "Identifier*:" );
204 assertTextPresent( "Protocol*:" );
205 assertTextPresent( "Hostname*:" );
206 assertTextPresent( "Port*:" );
207 assertTextPresent( "Username:" );
208 assertTextPresent( "Password:" );
209 assertButtonWithValuePresent( "Save Network Proxy" );
212 public void addNetworkProxy( String identifier, String protocol, String hostname, String port, String username,
215 // goToNetworkProxiesPage();
216 clickLinkWithText( "Add Network Proxy" );
217 assertAddNetworkProxy();
218 setFieldValue( "proxy.id", identifier );
219 setFieldValue( "proxy.protocol", protocol );
220 setFieldValue( "proxy.host", hostname );
221 setFieldValue( "proxy.port", port );
222 setFieldValue( "proxy.username", username );
223 setFieldValue( "proxy.password", password );
224 clickButtonWithValue( "Save Network Proxy" );
227 public void editNetworkProxies( String fieldName, String value )
229 // goToNetworkProxiesPage();
230 clickLinkWithText( "Edit Network Proxy" );
231 setFieldValue( fieldName, value );
232 clickButtonWithValue( "Save Network Proxy" );
235 public void deleteNetworkProxy()
237 // goToNetworkProxiesPage();
238 clickLinkWithText( "Delete Network Proxy" );
239 assertPage( "Apache Archiva \\ Admin: Delete Network Proxy" );
240 assertTextPresent( "WARNING: This operation can not be undone." );
241 clickButtonWithValue( "Delete" );
244 // remote repositories
245 public void assertAddRemoteRepository()
247 assertPage( "Apache Archiva \\ Admin: Add Remote Repository" );
248 String remote = "Identifier*:,Name*:,URL*:,Username:,Password:,Timeout in seconds:,Type:";
249 String[] arrayRemote = remote.split( "," );
250 for ( String arrayremote : arrayRemote )
251 assertTextPresent( arrayremote );
252 String remoteElements =
253 "addRemoteRepository_repository_id,addRemoteRepository_repository_name,addRemoteRepository_repository_url,addRemoteRepository_repository_username,addRemoteRepository_repository_password,addRemoteRepository_repository_timeout,addRemoteRepository_repository_layout";
254 String[] arrayRemoteElements = remoteElements.split( "," );
255 for ( String arrayremotelement : arrayRemoteElements )
256 assertElementPresent( arrayremotelement );
259 public void assertDeleteRemoteRepositoryPage()
261 assertPage( "Apache Archiva \\ Admin: Delete Remote Repository" );
262 assertTextPresent( "Admin: Delete Remote Repository" );
263 assertTextPresent( "WARNING: This operation can not be undone." );
264 assertTextPresent( "Are you sure you want to delete the following remote repository?" );
265 assertButtonWithValuePresent( "Confirm" );
266 assertButtonWithValuePresent( "Cancel" );
269 public void addRemoteRepository( String identifier, String name, String url, String username, String password,
270 String timeout, String type )
272 // goToRepositoriesPage();
273 assertAddRemoteRepository();
274 setFieldValue( "addRemoteRepository_repository_id", identifier );
275 setFieldValue( "addRemoteRepository_repository_name", name );
276 setFieldValue( "addRemoteRepository_repository_url", url );
277 setFieldValue( "addRemoteRepository_repository_username", username );
278 setFieldValue( "addRemoteRepository_repository_password", password );
279 setFieldValue( "addRemoteRepository_repository_timeout", timeout );
280 selectValue( "addRemoteRepository_repository_layout", type );
281 clickButtonWithValue( "Add Repository" );
284 public void deleteRemoteRepository()
286 goToRepositoriesPage();
287 clickLinkWithXPath( "//div[@id='contentArea']/div/div[8]/div[1]/a[2]" );
288 assertDeleteRemoteRepositoryPage();
289 clickButtonWithValue( "Confirm" );
292 public void editRemoteRepository( String fieldName, String value )
294 goToRepositoriesPage();
295 clickLinkWithXPath( "//div[@id='contentArea']/div/div[8]/div[1]/a[1]" );
296 setFieldValue( fieldName, value );
297 clickButtonWithValue( "Update Repository" );
300 public void editManagedRepository( String fieldName, String value )
302 goToRepositoriesPage();
303 clickLinkWithXPath( "//div[@id='contentArea']/div/div[5]/div[1]/a[1]/img" );
304 assertPage( "Apache Archiva \\ Admin: Edit Managed Repository" );
305 setFieldValue( fieldName, value );
307 clickButtonWithValue( "Update Repository" );
310 public void deleteManagedRepository()
312 clickLinkWithXPath( "//div[@id='contentArea']/div/div[5]/div[1]/a[2]" );
313 assertPage( "Apache Archiva \\ Admin: Delete Managed Repository" );
314 clickButtonWithValue( "Delete Configuration Only" );
317 public String getRepositoryDir()
319 File f = new File( "" );
320 String artifactFilePath = f.getAbsolutePath();
321 return artifactFilePath + "/target/";
324 // ///////////////////////////////////////////
325 // Repository Scanning
326 // ///////////////////////////////////////////
327 public void goToRepositoryScanningPage()
329 clickLinkWithText( "Repository Scanning" );
330 assertRepositoryScanningPage();
333 public void assertRepositoryScanningPage()
335 assertPage( "Apache Archiva \\ Administration - Repository Scanning" );
336 assertTextPresent( "Administration - Repository Scanning" );
337 assertTextPresent( "Repository Scanning - File Types" );
338 String artifactsTypes =
339 "**/*.pom,**/*.jar,**/*.ear,**/*.war,**/*.car,**/*.sar,**/*.mar,**/*.rar,**/*.dtd,**/*.tld,**/*.tar.gz,**/*.tar.bz2,**/*.zip";
340 String[] arrayArtifactTypes = artifactsTypes.split( "," );
341 for ( int i = 0; i < arrayArtifactTypes.length; i++ )
342 Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[1]/table." + i + ".0" ),
343 arrayArtifactTypes[i] );
345 String autoremove = "**/*.bak,**/*~,**/*-";
346 String[] arrayAutoremove = autoremove.split( "," );
347 for ( int i = 0; i < arrayAutoremove.length; i++ )
348 Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[2]/table." + i + ".0" ),
349 arrayAutoremove[i] );
351 String ignored = "**/.htaccess,**/KEYS,**/*.rb,**/*.sh,**/.svn/**,**/.DAV/**";
352 String[] arrayIgnored = ignored.split( "," );
353 for ( int i = 0; i < arrayIgnored.length; i++ )
354 Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[3]/table." + i + ".0" ),
357 String indexableContent =
358 "**/*.txt,**/*.TXT,**/*.block,**/*.config,**/*.pom,**/*.xml,**/*.xsd,**/*.dtd,**/*.tld";
359 String[] arrayIndexableContent = indexableContent.split( "," );
360 for ( int i = 0; i < arrayIndexableContent.length; i++ )
361 Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[4]/table." + i + ".0" ),
362 arrayIndexableContent[i] );
365 // ///////////////////////////////////////////
367 // ///////////////////////////////////////////
368 public void goToDatabasePage()
370 clickLinkWithText( "Database" );
371 assertDatabasePage();
374 public void assertDatabasePage()
376 assertPage( "Apache Archiva \\ Administration - Database" );
377 assertTextPresent( "Administration - Database" );
378 assertTextPresent( "Database - Unprocessed Artifacts Scanning" );
379 assertTextPresent( "Cron:" );
380 assertElementPresent( "database_cron" );
381 assertButtonWithValuePresent( "Update Cron" );
382 assertButtonWithValuePresent( "Update Database Now" );
383 assertTextPresent( "Database - Unprocessed Artifacts Scanning" );
384 assertTextPresent( "Database - Artifact Cleanup Scanning" );