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 getSelenium().open( "/archiva/admin/repositoryGroups.action" );
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, boolean wait )
78 goToRepositoryGroupsPage();
79 setFieldValue( "repositoryGroup.id", repoGroupName );
80 clickButtonWithValue( "Add Group", wait );
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" );
140 public void assertAddProxyConnectorPage()
142 assertPage( "Apache Archiva \\ Admin: Add Proxy Connector" );
143 assertTextPresent( "Admin: Add Proxy Connector" );
145 "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 );
150 * String proxyElements =
151 * "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"
152 * ; String[] arrayProxyElements = proxyElements.split( "," ); for ( String arrayproxyelements :
153 * arrayProxyElements ) assertTextPresent( arrayproxyelements );
155 assertButtonWithValuePresent( "Add Property" );
156 assertButtonWithValuePresent( "Add Pattern" );
157 assertButtonWithValuePresent( "Add Proxy Connector" );
160 // this only fills in the values of required fields in adding Proxy Connectors
161 public void addProxyConnector( String networkProxy, String managedRepo, String remoteRepo )
163 goToProxyConnectorsPage();
164 clickLinkWithText( "Add" );
165 assertAddProxyConnectorPage();
166 selectValue( "connector.proxyId", networkProxy );
167 selectValue( "connector.sourceRepoId", managedRepo );
168 selectValue( "connector.targetRepoId", remoteRepo );
169 clickButtonWithValue( "Add Proxy Connector" );
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 // /////////////////////////////
185 public void editNetworkProxies( String fieldName, String value )
187 // goToNetworkProxiesPage();
188 clickLinkWithText( "Edit Network Proxy" );
189 setFieldValue( fieldName, value );
190 clickButtonWithValue( "Save Network Proxy" );
193 public void deleteNetworkProxy()
195 // goToNetworkProxiesPage();
196 clickLinkWithText( "Delete Network Proxy" );
197 assertPage( "Apache Archiva \\ Admin: Delete Network Proxy" );
198 assertTextPresent( "WARNING: This operation can not be undone." );
199 clickButtonWithValue( "Delete" );
202 // remote repositories
203 public void assertAddRemoteRepository()
205 assertPage( "Apache Archiva \\ Admin: Add Remote Repository" );
206 String remote = "Identifier*:,Name*:,URL*:,Username:,Password:,Timeout in seconds:,Type:";
207 String[] arrayRemote = remote.split( "," );
208 for ( String arrayremote : arrayRemote )
209 assertTextPresent( arrayremote );
210 String remoteElements =
211 "addRemoteRepository_repository_id,addRemoteRepository_repository_name,addRemoteRepository_repository_url,addRemoteRepository_repository_userName,addRemoteRepository_repository_password,addRemoteRepository_repository_timeout,addRemoteRepository_repository_layout";
212 String[] arrayRemoteElements = remoteElements.split( "," );
213 for ( String arrayremotelement : arrayRemoteElements )
214 assertElementPresent( arrayremotelement );
217 public void assertDeleteRemoteRepositoryPage()
219 assertPage( "Apache Archiva \\ Admin: Delete Remote Repository" );
220 assertTextPresent( "Admin: Delete Remote Repository" );
221 assertTextPresent( "WARNING: This operation can not be undone." );
222 assertTextPresent( "Are you sure you want to delete the following remote repository?" );
223 assertButtonWithValuePresent( "Confirm" );
224 assertButtonWithValuePresent( "Cancel" );
227 public void addRemoteRepository( String identifier, String name, String url, String username, String password,
228 String timeout, String type, boolean wait )
230 assertAddRemoteRepository();
231 setFieldValue( "addRemoteRepository_repository_id", identifier );
232 setFieldValue( "addRemoteRepository_repository_name", name );
233 setFieldValue( "addRemoteRepository_repository_url", url );
234 setFieldValue( "addRemoteRepository_repository_userName", username );
235 setFieldValue( "addRemoteRepository_repository_password", password );
236 setFieldValue( "addRemoteRepository_repository_timeout", timeout );
237 selectValue( "addRemoteRepository_repository_layout", type );
238 clickButtonWithValue( "Add Repository", wait );
241 public void deleteRemoteRepository()
243 goToRepositoriesPage();
244 clickLinkWithXPath( "//div[@id='contentArea']/div/div[8]/div[1]/a[2]" );
245 assertDeleteRemoteRepositoryPage();
246 clickButtonWithValue( "Confirm" );
249 public void editRemoteRepository( String fieldName, String value )
251 goToRepositoriesPage();
252 clickLinkWithXPath( "//div[@id='contentArea']/div/div[8]/div[1]/a[1]" );
253 setFieldValue( fieldName, value );
254 clickButtonWithValue( "Update Repository" );
257 public void editManagedRepository( String fieldName, String value )
259 goToRepositoriesPage();
260 clickLinkWithXPath( "//div[@id='contentArea']/div/div[5]/div[1]/a[1]/img" );
261 assertPage( "Apache Archiva \\ Admin: Edit Managed Repository" );
262 setFieldValue( fieldName, value );
264 clickButtonWithValue( "Update Repository" );
267 public void editManagedRepository(String name, String directory, String indexDirectory, String type, String cron, String daysOlder, String retentionCount)
269 goToRepositoriesPage();
270 clickLinkWithXPath( "//div[@id='contentArea']/div/div[5]/div[1]/a[1]/img" );
271 assertPage( "Apache Archiva \\ Admin: Edit Managed Repository" );
272 setFieldValue( "repository.name" , name );
273 setFieldValue( "repository.location" , directory );
274 setFieldValue( "repository.indexDirectory" , indexDirectory );
275 selectValue( "repository.layout", type );
276 setFieldValue( "repository.cronExpression" , cron );
277 setFieldValue( "repository.daysOlder" , daysOlder );
278 setFieldValue( "repository.retentionCount" , retentionCount );
279 clickButtonWithValue( "Update Repository" );
282 public void deleteManagedRepository()
284 clickLinkWithXPath( "//div[@id='contentArea']/div/div[5]/div[1]/a[2]" );
285 assertPage( "Apache Archiva \\ Admin: Delete Managed Repository" );
286 clickButtonWithValue( "Delete Configuration Only" );
289 public String getRepositoryDir()
291 File f = new File( "" );
292 String artifactFilePath = f.getAbsolutePath();
293 return artifactFilePath + "/target/";
296 // ///////////////////////////////////////////
297 // Repository Scanning
298 // ///////////////////////////////////////////
299 public void goToRepositoryScanningPage()
301 getSelenium().open( "/archiva/admin/repositoryScanning.action" );
302 assertRepositoryScanningPage();
305 public void assertRepositoryScanningPage()
307 assertPage( "Apache Archiva \\ Administration - Repository Scanning" );
308 assertTextPresent( "Administration - Repository Scanning" );
309 assertTextPresent( "Repository Scanning - File Types" );
310 String artifactsTypes =
311 "**/*.pom,**/*.jar,**/*.ear,**/*.war,**/*.car,**/*.sar,**/*.mar,**/*.rar,**/*.dtd,**/*.tld,**/*.tar.gz,**/*.tar.bz2,**/*.zip";
312 String[] arrayArtifactTypes = artifactsTypes.split( "," );
313 for ( int i = 0; i < arrayArtifactTypes.length; i++ )
314 Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[1]/table." + i + ".0" ),
315 arrayArtifactTypes[i] );
317 String autoremove = "**/*.bak,**/*~,**/*-";
318 String[] arrayAutoremove = autoremove.split( "," );
319 for ( int i = 0; i < arrayAutoremove.length; i++ )
320 Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[2]/table." + i + ".0" ),
321 arrayAutoremove[i] );
323 String ignored = "**/.htaccess,**/KEYS,**/*.rb,**/*.sh,**/.svn/**,**/.DAV/**";
324 String[] arrayIgnored = ignored.split( "," );
325 for ( int i = 0; i < arrayIgnored.length; i++ )
326 Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[3]/table." + i + ".0" ),
329 String indexableContent =
330 "**/*.txt,**/*.TXT,**/*.block,**/*.config,**/*.pom,**/*.xml,**/*.xsd,**/*.dtd,**/*.tld";
331 String[] arrayIndexableContent = indexableContent.split( "," );
332 for ( int i = 0; i < arrayIndexableContent.length; i++ )
333 Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[4]/table." + i + ".0" ),
334 arrayIndexableContent[i] );
337 // ///////////////////////////////////////////
339 // ///////////////////////////////////////////
340 public void goToDatabasePage()
342 clickLinkWithText( "Database" );
343 assertDatabasePage();
346 public void assertDatabasePage()
348 assertPage( "Apache Archiva \\ Administration - Database" );
349 assertTextPresent( "Administration - Database" );
350 assertTextPresent( "Database - Unprocessed Artifacts Scanning" );
351 assertTextPresent( "Cron:" );
352 assertElementPresent( "database_cron" );
353 assertButtonWithValuePresent( "Update Cron" );
354 assertButtonWithValuePresent( "Update Database Now" );
355 assertTextPresent( "Database - Unprocessed Artifacts Scanning" );
356 assertTextPresent( "Database - Artifact Cleanup Scanning" );