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: " + repositoryName );
71 assertButtonWithValuePresent( "Confirm" );
72 assertButtonWithValuePresent( "Cancel" );
75 public void addRepositoryGroup( String repoGroupName )
77 goToRepositoryGroupsPage();
78 setFieldValue( "repositoryGroup.id", repoGroupName );
79 clickButtonWithValue( "Add Group" );
82 public void addRepositoryToRepositoryGroup( String repositoryGroupName, String repositoryName )
84 goToRepositoryGroupsPage();
85 String s = getSelenium().getBodyText();
86 if ( s.contains( "No Repository Groups Defined." ) )
88 setFieldValue( "repositoryGroup.id" , repositoryGroupName );
89 clickButtonWithValue( "Add Group" );
90 //assertAddedRepositoryLink( repositoryGroupName );
92 selectValue( "addRepositoryToGroup_repoId" , repositoryName );
93 clickButtonWithValue( "Add Repository" );
94 assertAddedRepositoryToRepositoryGroups( repositoryName );
98 //assertAddedRepositoryLink( repositoryGroupName );
99 selectValue( "addRepositoryToGroup_repoId" , repositoryName );
100 clickButtonWithValue( "Add Repository" );
104 public void deleteRepositoryInRepositoryGroups()
106 goToRepositoryGroupsPage();
107 getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[3]/div[1]/a/img" );
111 public void deleteRepositoryGroup( String repositoryName )
113 getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[1]/div/a/img" );
115 assertDeleteRepositoryGroupPage( repositoryName );
116 clickButtonWithValue( "Confirm" );
119 ///////////////////////////////
121 ///////////////////////////////
122 public void goToProxyConnectorsPage()
124 clickLinkWithText( "Proxy Connectors" );
125 assertProxyConnectorsPage();
128 public void assertProxyConnectorsPage()
130 assertPage( "Apache Archiva \\ Administration - Proxy Connectors" );
131 assertTextPresent( "Administration - Proxy Connectors" );
132 assertTextPresent( "Repository Proxy Connectors" );
133 assertTextPresent( "internal" );
134 assertTextPresent( "Archiva Managed Internal Repository" );
135 assertTextPresent( "Proxy Connector" );
136 assertTextPresent( "Central Repository" );
137 assertTextPresent( "Java.net Repository for Maven 2" );
140 public void assertAddProxyConnectorPage()
142 assertPage( "Apache Archiva \\ Admin: Add Proxy Connector" );
143 assertTextPresent( "Admin: Add Proxy Connector" );
144 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.";
145 String[] arrayProxy = proxy.split( "," );
146 for ( String arrayproxy : arrayProxy )
147 assertTextPresent( arrayproxy );
148 /*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";
149 String[] arrayProxyElements = proxyElements.split( "," );
150 for ( String arrayproxyelements : arrayProxyElements )
151 assertTextPresent( arrayproxyelements );*/
152 assertButtonWithValuePresent( "Add Property" );
153 assertButtonWithValuePresent( "Add Pattern" );
154 assertButtonWithValuePresent( "Add Proxy Connector" );
157 // this only fills in the values of required fields in adding Proxy Connectors
158 public void addProxyConnector( String networkProxy, String managedRepo, String remoteRepo )
160 goToProxyConnectorsPage();
161 clickLinkWithText( "Add" );
162 assertAddProxyConnectorPage();
163 selectValue( "connector.proxyId" , networkProxy );
164 selectValue( "connector.sourceRepoId" , managedRepo );
165 selectValue( "connector.targetRepoId" , remoteRepo );
168 public void deleteProxyConnector()
170 goToProxyConnectorsPage();
171 clickLinkWithXPath( "//div[@id='contentArea']/div[2]/div[1]/div[2]/div[1]/a[3]/img" );
172 assertPage( "Apache Archiva \\ Admin: Delete Proxy Connectors" );
173 clickButtonWithValue( "Delete" );
174 assertPage( "Apache Archiva \\ Administration - Proxy Connectors" );
177 ///////////////////////////////
179 ///////////////////////////////
180 public void goToNetworkProxiesPage()
182 clickLinkWithText( "Network Proxies" );
183 assertNetworkProxiesPage();
186 public void assertNetworkProxiesPage()
188 assertPage( "Apache Archiva \\ Administration - Network Proxies" );
189 assertTextPresent( "Administration - Network Proxies" );
190 assertTextPresent( "Network Proxies" );
191 assertLinkPresent( "Add Network Proxy" );
194 public void assertAddNetworkProxy()
196 assertPage( "Apache Archiva \\ Admin: Add Network Proxy" );
197 assertTextPresent( "Admin: Add Network Proxy" );
198 assertTextPresent( "Add network proxy:" );
199 assertTextPresent( "Identifier*:" );
200 assertTextPresent( "Protocol*:" );
201 assertTextPresent( "Hostname*:" );
202 assertTextPresent( "Port*:" );
203 assertTextPresent( "Username:" );
204 assertTextPresent( "Password:" );
205 assertButtonWithValuePresent( "Save Network Proxy" );
208 public void addNetworkProxy( String identifier, String protocol, String hostname, String port, String username, String password )
210 //goToNetworkProxiesPage();
211 clickLinkWithText( "Add Network Proxy" );
212 assertAddNetworkProxy();
213 setFieldValue( "proxy.id" , identifier );
214 setFieldValue( "proxy.protocol" , protocol );
215 setFieldValue( "proxy.host" , hostname );
216 setFieldValue( "proxy.port" , port );
217 setFieldValue( "proxy.username" , username );
218 setFieldValue( "proxy.password" , password );
219 clickButtonWithValue( "Save Network Proxy" );
222 public void editNetworkProxies( String fieldName, String value)
224 //goToNetworkProxiesPage();
225 clickLinkWithText( "Edit Network Proxy" );
226 setFieldValue( fieldName, value);
227 clickButtonWithValue( "Save Network Proxy" );
230 public void deleteNetworkProxy()
232 //goToNetworkProxiesPage();
233 clickLinkWithText( "Delete Network Proxy" );
234 assertPage( "Apache Archiva \\ Admin: Delete Network Proxy" );
235 assertTextPresent( "WARNING: This operation can not be undone." );
236 clickButtonWithValue( "Delete" );
239 // remote repositories
240 public void assertAddRemoteRepository()
242 assertPage( "Apache Archiva \\ Admin: Add Remote Repository" );
243 String remote = "Identifier*:,Name*:,URL*:,Username:,Password:,Timeout in seconds:,Type:";
244 String[] arrayRemote = remote.split( "," );
245 for ( String arrayremote : arrayRemote )
246 assertTextPresent( arrayremote );
247 String remoteElements = "addRemoteRepository_repository_id,addRemoteRepository_repository_name,addRemoteRepository_repository_url,addRemoteRepository_repository_username,addRemoteRepository_repository_password,addRemoteRepository_repository_timeout,addRemoteRepository_repository_layout";
248 String[] arrayRemoteElements = remoteElements.split( "," );
249 for ( String arrayremotelement : arrayRemoteElements )
250 assertElementPresent( arrayremotelement );
253 public void assertDeleteRemoteRepositoryPage()
255 assertPage( "Apache Archiva \\ Admin: Delete Remote Repository" );
256 assertTextPresent( "Admin: Delete Remote Repository" );
257 assertTextPresent( "WARNING: This operation can not be undone." );
258 assertTextPresent( "Are you sure you want to delete the following remote repository?" );
259 assertButtonWithValuePresent( "Confirm" );
260 assertButtonWithValuePresent( "Cancel" );
263 public void addRemoteRepository( String identifier, String name, String url, String username, String password, String timeout, String type )
265 //goToRepositoriesPage();
266 assertAddRemoteRepository();
267 setFieldValue( "addRemoteRepository_repository_id" , identifier );
268 setFieldValue( "addRemoteRepository_repository_name" , name );
269 setFieldValue( "addRemoteRepository_repository_url" , url );
270 setFieldValue( "addRemoteRepository_repository_username" , username );
271 setFieldValue( "addRemoteRepository_repository_password" , password );
272 setFieldValue( "addRemoteRepository_repository_timeout" , timeout );
273 selectValue( "addRemoteRepository_repository_layout" , type );
274 clickButtonWithValue( "Add Repository" );
277 public void deleteRemoteRepository()
279 goToRepositoriesPage();
280 clickLinkWithXPath( "//div[@id='contentArea']/div/div[8]/div[1]/a[2]" );
281 assertDeleteRemoteRepositoryPage();
282 clickButtonWithValue( "Confirm" );
285 public void editRemoteRepository( String fieldName, String value)
287 goToRepositoriesPage();
288 clickLinkWithXPath( "//div[@id='contentArea']/div/div[8]/div[1]/a[1]" );
289 setFieldValue( fieldName, value );
290 clickButtonWithValue( "Update Repository" );
293 public void editManagedRepository( String fieldName, String value )
295 goToRepositoriesPage();
296 clickLinkWithXPath( "//div[@id='contentArea']/div/div[5]/div[1]/a[1]/img" );
297 assertPage( "Apache Archiva \\ Admin: Edit Managed Repository" );
298 setFieldValue(fieldName, value);
300 clickButtonWithValue( "Update Repository" );
303 public void deleteManagedRepository()
305 clickLinkWithXPath( "//div[@id='contentArea']/div/div[5]/div[1]/a[2]" );
306 assertPage( "Apache Archiva \\ Admin: Delete Managed Repository" );
307 clickButtonWithValue( "Delete Configuration Only" );
310 public String getRepositoryDir()
312 File f = new File( "" );
313 String artifactFilePath = f.getAbsolutePath();
314 return artifactFilePath + "/target/";
317 /////////////////////////////////////////////
318 // Repository Scanning
319 /////////////////////////////////////////////
320 public void goToRepositoryScanningPage()
322 clickLinkWithText( "Repository Scanning" );
323 assertRepositoryScanningPage();
326 public void assertRepositoryScanningPage()
328 assertPage( "Apache Archiva \\ Administration - Repository Scanning" );
329 assertTextPresent( "Administration - Repository Scanning" );
330 assertTextPresent( "Repository Scanning - File Types" );
331 String artifactsTypes = "**/*.pom,**/*.jar,**/*.ear,**/*.war,**/*.car,**/*.sar,**/*.mar,**/*.rar,**/*.dtd,**/*.tld,**/*.tar.gz,**/*.tar.bz2,**/*.zip";
332 String [] arrayArtifactTypes = artifactsTypes.split( "," );
333 for (int i = 0; i < arrayArtifactTypes.length; i++)
334 Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[1]/table."+i+".0"), arrayArtifactTypes[i]);
336 String autoremove = "**/*.bak,**/*~,**/*-";
337 String [] arrayAutoremove = autoremove.split( "," );
338 for (int i = 0; i < arrayAutoremove.length; i++)
339 Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[2]/table."+i+".0"), arrayAutoremove[i]);
341 String ignored = "**/.htaccess,**/KEYS,**/*.rb,**/*.sh,**/.svn/**,**/.DAV/**";
342 String [] arrayIgnored = ignored.split( "," );
343 for (int i = 0; i < arrayIgnored.length; i++)
344 Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[3]/table."+i+".0"), arrayIgnored[i]);
346 String indexableContent = "**/*.txt,**/*.TXT,**/*.block,**/*.config,**/*.pom,**/*.xml,**/*.xsd,**/*.dtd,**/*.tld";
347 String [] arrayIndexableContent = indexableContent.split( "," );
348 for (int i = 0; i < arrayIndexableContent.length; i++)
349 Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[4]/table."+i+".0"), arrayIndexableContent[i]);
352 /////////////////////////////////////////////
354 /////////////////////////////////////////////
355 public void goToDatabasePage()
357 clickLinkWithText( "Database" );
358 assertDatabasePage();
361 public void assertDatabasePage()
363 assertPage( "Apache Archiva \\ Administration - Database" );
364 assertTextPresent( "Administration - Database" );
365 assertTextPresent( "Database - Unprocessed Artifacts Scanning" );
366 assertTextPresent( "Cron:" );
367 assertElementPresent( "database_cron" );
368 assertButtonWithValuePresent( "Update Cron" );
369 assertButtonWithValuePresent( "Update Database Now" );
370 assertTextPresent( "Database - Unprocessed Artifacts Scanning" );
371 assertTextPresent( "Database - Artifact Cleanup Scanning" );