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" );
145 String proxy = "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.";
146 String[] arrayProxy = proxy.split( "," );
147 for ( String arrayproxy : arrayProxy )
148 assertTextPresent( arrayproxy );
149 /*String proxyElements = "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";
150 String[] arrayProxyElements = proxyElements.split( "," );
151 for ( String arrayproxyelements : arrayProxyElements )
152 assertTextPresent( arrayproxyelements );*/
153 assertButtonWithValuePresent( "Add Property" );
154 assertButtonWithValuePresent( "Add Pattern" );
155 assertButtonWithValuePresent( "Add Proxy Connector" );
158 // this only fills in the values of required fields in adding Proxy Connectors
159 public void addProxyConnector( String networkProxy, String managedRepo, String remoteRepo )
161 goToProxyConnectorsPage();
162 clickLinkWithText( "Add" );
163 assertAddProxyConnectorPage();
164 selectValue( "connector.proxyId" , networkProxy );
165 selectValue( "connector.sourceRepoId" , managedRepo );
166 selectValue( "connector.targetRepoId" , remoteRepo );
169 public void deleteProxyConnector()
171 goToProxyConnectorsPage();
172 clickLinkWithXPath( "//div[@id='contentArea']/div[2]/div[1]/div[2]/div[1]/a[3]/img" );
173 assertPage( "Apache Archiva \\ Admin: Delete Proxy Connectors" );
174 clickButtonWithValue( "Delete" );
175 assertPage( "Apache Archiva \\ Administration - Proxy Connectors" );
178 ///////////////////////////////
180 ///////////////////////////////
181 public void goToNetworkProxiesPage()
183 clickLinkWithText( "Network Proxies" );
184 assertNetworkProxiesPage();
187 public void assertNetworkProxiesPage()
189 assertPage( "Apache Archiva \\ Administration - Network Proxies" );
190 assertTextPresent( "Administration - Network Proxies" );
191 assertTextPresent( "Network Proxies" );
192 assertLinkPresent( "Add Network Proxy" );
195 public void assertAddNetworkProxy()
197 assertPage( "Apache Archiva \\ Admin: Add Network Proxy" );
198 assertTextPresent( "Admin: Add Network Proxy" );
199 assertTextPresent( "Add network proxy:" );
200 assertTextPresent( "Identifier*:" );
201 assertTextPresent( "Protocol*:" );
202 assertTextPresent( "Hostname*:" );
203 assertTextPresent( "Port*:" );
204 assertTextPresent( "Username:" );
205 assertTextPresent( "Password:" );
206 assertButtonWithValuePresent( "Save Network Proxy" );
209 public void addNetworkProxy( String identifier, String protocol, String hostname, String port, String username, String password )
211 //goToNetworkProxiesPage();
212 clickLinkWithText( "Add Network Proxy" );
213 assertAddNetworkProxy();
214 setFieldValue( "proxy.id" , identifier );
215 setFieldValue( "proxy.protocol" , protocol );
216 setFieldValue( "proxy.host" , hostname );
217 setFieldValue( "proxy.port" , port );
218 setFieldValue( "proxy.username" , username );
219 setFieldValue( "proxy.password" , password );
220 clickButtonWithValue( "Save Network Proxy" );
223 public void editNetworkProxies( String fieldName, String value)
225 //goToNetworkProxiesPage();
226 clickLinkWithText( "Edit Network Proxy" );
227 setFieldValue( fieldName, value);
228 clickButtonWithValue( "Save Network Proxy" );
231 public void deleteNetworkProxy()
233 //goToNetworkProxiesPage();
234 clickLinkWithText( "Delete Network Proxy" );
235 assertPage( "Apache Archiva \\ Admin: Delete Network Proxy" );
236 assertTextPresent( "WARNING: This operation can not be undone." );
237 clickButtonWithValue( "Delete" );
240 // remote repositories
241 public void assertAddRemoteRepository()
243 assertPage( "Apache Archiva \\ Admin: Add Remote Repository" );
244 String remote = "Identifier*:,Name*:,URL*:,Username:,Password:,Timeout in seconds:,Type:";
245 String[] arrayRemote = remote.split( "," );
246 for ( String arrayremote : arrayRemote )
247 assertTextPresent( arrayremote );
248 String remoteElements = "addRemoteRepository_repository_id,addRemoteRepository_repository_name,addRemoteRepository_repository_url,addRemoteRepository_repository_username,addRemoteRepository_repository_password,addRemoteRepository_repository_timeout,addRemoteRepository_repository_layout";
249 String[] arrayRemoteElements = remoteElements.split( "," );
250 for ( String arrayremotelement : arrayRemoteElements )
251 assertElementPresent( arrayremotelement );
254 public void assertDeleteRemoteRepositoryPage()
256 assertPage( "Apache Archiva \\ Admin: Delete Remote Repository" );
257 assertTextPresent( "Admin: Delete Remote Repository" );
258 assertTextPresent( "WARNING: This operation can not be undone." );
259 assertTextPresent( "Are you sure you want to delete the following remote repository?" );
260 assertButtonWithValuePresent( "Confirm" );
261 assertButtonWithValuePresent( "Cancel" );
264 public void addRemoteRepository( String identifier, String name, String url, String username, String password, String timeout, String type )
266 //goToRepositoriesPage();
267 assertAddRemoteRepository();
268 setFieldValue( "addRemoteRepository_repository_id" , identifier );
269 setFieldValue( "addRemoteRepository_repository_name" , name );
270 setFieldValue( "addRemoteRepository_repository_url" , url );
271 setFieldValue( "addRemoteRepository_repository_username" , username );
272 setFieldValue( "addRemoteRepository_repository_password" , password );
273 setFieldValue( "addRemoteRepository_repository_timeout" , timeout );
274 selectValue( "addRemoteRepository_repository_layout" , type );
275 clickButtonWithValue( "Add Repository" );
278 public void deleteRemoteRepository()
280 goToRepositoriesPage();
281 clickLinkWithXPath( "//div[@id='contentArea']/div/div[8]/div[1]/a[2]" );
282 assertDeleteRemoteRepositoryPage();
283 clickButtonWithValue( "Confirm" );
286 public void editRemoteRepository( String fieldName, String value)
288 goToRepositoriesPage();
289 clickLinkWithXPath( "//div[@id='contentArea']/div/div[8]/div[1]/a[1]" );
290 setFieldValue( fieldName, value );
291 clickButtonWithValue( "Update Repository" );
294 public void editManagedRepository( String fieldName, String value )
296 goToRepositoriesPage();
297 clickLinkWithXPath( "//div[@id='contentArea']/div/div[5]/div[1]/a[1]/img" );
298 assertPage( "Apache Archiva \\ Admin: Edit Managed Repository" );
299 setFieldValue(fieldName, value);
301 clickButtonWithValue( "Update Repository" );
304 public void deleteManagedRepository()
306 clickLinkWithXPath( "//div[@id='contentArea']/div/div[5]/div[1]/a[2]" );
307 assertPage( "Apache Archiva \\ Admin: Delete Managed Repository" );
308 clickButtonWithValue( "Delete Configuration Only" );
311 public String getRepositoryDir()
313 File f = new File( "" );
314 String artifactFilePath = f.getAbsolutePath();
315 return artifactFilePath + "/target/";
318 /////////////////////////////////////////////
319 // Repository Scanning
320 /////////////////////////////////////////////
321 public void goToRepositoryScanningPage()
323 clickLinkWithText( "Repository Scanning" );
324 assertRepositoryScanningPage();
327 public void assertRepositoryScanningPage()
329 assertPage( "Apache Archiva \\ Administration - Repository Scanning" );
330 assertTextPresent( "Administration - Repository Scanning" );
331 assertTextPresent( "Repository Scanning - File Types" );
332 String artifactsTypes = "**/*.pom,**/*.jar,**/*.ear,**/*.war,**/*.car,**/*.sar,**/*.mar,**/*.rar,**/*.dtd,**/*.tld,**/*.tar.gz,**/*.tar.bz2,**/*.zip";
333 String [] arrayArtifactTypes = artifactsTypes.split( "," );
334 for (int i = 0; i < arrayArtifactTypes.length; i++)
335 Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[1]/table."+i+".0"), arrayArtifactTypes[i]);
337 String autoremove = "**/*.bak,**/*~,**/*-";
338 String [] arrayAutoremove = autoremove.split( "," );
339 for (int i = 0; i < arrayAutoremove.length; i++)
340 Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[2]/table."+i+".0"), arrayAutoremove[i]);
342 String ignored = "**/.htaccess,**/KEYS,**/*.rb,**/*.sh,**/.svn/**,**/.DAV/**";
343 String [] arrayIgnored = ignored.split( "," );
344 for (int i = 0; i < arrayIgnored.length; i++)
345 Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[3]/table."+i+".0"), arrayIgnored[i]);
347 String indexableContent = "**/*.txt,**/*.TXT,**/*.block,**/*.config,**/*.pom,**/*.xml,**/*.xsd,**/*.dtd,**/*.tld";
348 String [] arrayIndexableContent = indexableContent.split( "," );
349 for (int i = 0; i < arrayIndexableContent.length; i++)
350 Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[4]/table."+i+".0"), arrayIndexableContent[i]);
353 /////////////////////////////////////////////
355 /////////////////////////////////////////////
356 public void goToDatabasePage()
358 clickLinkWithText( "Database" );
359 assertDatabasePage();
362 public void assertDatabasePage()
364 assertPage( "Apache Archiva \\ Administration - Database" );
365 assertTextPresent( "Administration - Database" );
366 assertTextPresent( "Database - Unprocessed Artifacts Scanning" );
367 assertTextPresent( "Cron:" );
368 assertElementPresent( "database_cron" );
369 assertButtonWithValuePresent( "Update Cron" );
370 assertButtonWithValuePresent( "Update Database Now" );
371 assertTextPresent( "Database - Unprocessed Artifacts Scanning" );
372 assertTextPresent( "Database - Artifact Cleanup Scanning" );