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
22 import org.junit.Assert;
26 public abstract class AbstractRepositoryTest
27 extends AbstractArchivaTest
30 public void goToRepositoryGroupsPage()
32 if ( !getTitle().equals( "Apache Archiva \\ Administration - Repository Groups" ) )
34 getSelenium().open( "/archiva/admin/repositoryGroups.action" );
36 assertRepositoryGroupsPage();
39 public void assertRepositoryGroupsPage()
41 assertPage( "Apache Archiva \\ Administration - Repository Groups" );
42 assertTextPresent( "Administration - Repository Groups" );
43 assertTextPresent( "Identifier*:" );
44 assertElementPresent( "repositoryGroup.id" );
45 assertButtonWithValuePresent( "Add Group" );
46 assertTextPresent( "Repository Groups" );
49 public void assertAddedRepositoryLink( String repositoryGroupName )
51 assertPage( "Apache Archiva \\ Administration - Repository Groups" );
52 String repositoryGroupUrlValue = "repository/" + repositoryGroupName + "/";
53 String baseUrlValue = "archiva";
54 String repositoryGroupLink = baseUrl.replaceFirst( baseUrlValue, repositoryGroupUrlValue );
55 assertTextPresent( repositoryGroupLink );
58 public void assertAddedRepositoryToRepositoryGroups( String repositoryName )
60 assertPage( "Apache Archiva \\ Administration - Repository Groups" );
61 assertTextPresent( repositoryName );
62 assertTextPresent( "Archiva Managed Internal Repository" );
63 assertAddedRepositoryLink( repositoryName );
66 public void assertDeleteRepositoryGroupPage( String repositoryName )
68 assertPage( "Apache Archiva \\ Admin: Delete Repository Group" );
69 assertTextPresent( "WARNING: This operation can not be undone." );
70 assertTextPresent( "Are you sure you want to delete the following repository group?" );
71 assertTextPresent( "ID:" );
72 assertTextPresent( repositoryName );
73 assertButtonWithValuePresent( "Confirm" );
74 assertButtonWithValuePresent( "Cancel" );
77 public void addRepositoryGroup( String repoGroupName, boolean wait )
79 goToRepositoryGroupsPage();
80 setFieldValue( "repositoryGroup.id", repoGroupName );
81 clickButtonWithValue( "Add Group", wait );
84 public void addRepositoryToRepositoryGroup( String repositoryGroupName, String repositoryName )
86 goToRepositoryGroupsPage();
87 String s = getSelenium().getBodyText();
88 if ( s.contains( "No Repository Groups Defined." ) )
90 setFieldValue( "repositoryGroup.id", repositoryGroupName );
91 clickButtonWithValue( "Add Group" );
92 // assertAddedRepositoryLink( repositoryGroupName );
94 selectValue( "addRepositoryToGroup_repoId", repositoryName );
95 clickButtonWithValue( "Add Repository" );
96 assertAddedRepositoryToRepositoryGroups( repositoryName );
100 // assertAddedRepositoryLink( repositoryGroupName );
101 selectValue( "addRepositoryToGroup_repoId", repositoryName );
102 clickButtonWithValue( "Add Repository" );
106 public void deleteRepositoryInRepositoryGroups()
108 goToRepositoryGroupsPage();
109 getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[3]/div[1]/a/img" );
113 public void deleteRepositoryGroup( String repositoryName )
115 getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[1]/div/a/img" );
117 assertDeleteRepositoryGroupPage( repositoryName );
118 clickButtonWithValue( "Confirm" );
121 // /////////////////////////////
123 // /////////////////////////////
124 public void goToProxyConnectorsPage()
126 clickLinkWithText( "Proxy Connectors" );
127 assertProxyConnectorsPage();
130 public void assertProxyConnectorsPage()
132 assertPage( "Apache Archiva \\ Administration - Proxy Connectors" );
133 assertTextPresent( "Administration - Proxy Connectors" );
134 assertTextPresent( "Repository Proxy Connectors" );
135 assertTextPresent( "internal" );
136 assertTextPresent( "Archiva Managed Internal Repository" );
137 assertTextPresent( "Proxy Connector" );
138 assertTextPresent( "Central Repository" );
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 )
150 assertTextPresent( arrayproxy );
153 * String proxyElements =
154 * "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"
155 * ; String[] arrayProxyElements = proxyElements.split( "," ); for ( String arrayproxyelements :
156 * arrayProxyElements ) assertTextPresent( arrayproxyelements );
158 assertButtonWithValuePresent( "Add Property" );
159 assertButtonWithValuePresent( "Add Pattern" );
160 assertButtonWithValuePresent( "Add Proxy Connector" );
163 // this only fills in the values of required fields in adding Proxy Connectors
164 public void addProxyConnector( String networkProxy, String managedRepo, String remoteRepo )
166 goToProxyConnectorsPage();
167 clickLinkWithText( "Add" );
168 assertAddProxyConnectorPage();
169 selectValue( "connector.proxyId", networkProxy );
170 selectValue( "connector.sourceRepoId", managedRepo );
171 selectValue( "connector.targetRepoId", remoteRepo );
172 clickButtonWithValue( "Add Proxy Connector" );
175 public void deleteProxyConnector()
177 goToProxyConnectorsPage();
178 clickLinkWithXPath( "//div[@id='contentArea']/div[2]/div[1]/div[2]/div[1]/a[3]/img" );
179 assertPage( "Apache Archiva \\ Admin: Delete Proxy Connectors" );
180 clickButtonWithValue( "Delete" );
181 assertPage( "Apache Archiva \\ Administration - Proxy Connectors" );
184 // /////////////////////////////
186 // /////////////////////////////
188 public void editNetworkProxies( String fieldName, String value )
190 // goToNetworkProxiesPage();
191 clickLinkWithText( "Edit Network Proxy" );
192 setFieldValue( fieldName, value );
193 clickButtonWithValue( "Save Network Proxy" );
196 public void deleteNetworkProxy()
198 // goToNetworkProxiesPage();
199 clickLinkWithText( "Delete Network Proxy" );
200 assertPage( "Apache Archiva \\ Admin: Delete Network Proxy" );
201 assertTextPresent( "WARNING: This operation can not be undone." );
202 clickButtonWithValue( "Delete" );
205 // remote repositories
206 public void assertAddRemoteRepository()
208 assertPage( "Apache Archiva \\ Admin: Add Remote Repository" );
209 String remote = "Identifier*:,Name*:,URL*:,Username:,Password:,Timeout in seconds:,Type:";
210 String[] arrayRemote = remote.split( "," );
211 for ( String arrayremote : arrayRemote )
213 assertTextPresent( arrayremote );
215 String remoteElements =
216 "addRemoteRepository_repository_id,addRemoteRepository_repository_name,addRemoteRepository_repository_url,addRemoteRepository_repository_userName,addRemoteRepository_repository_password,addRemoteRepository_repository_timeout,addRemoteRepository_repository_layout";
217 String[] arrayRemoteElements = remoteElements.split( "," );
218 for ( String arrayremotelement : arrayRemoteElements )
220 assertElementPresent( arrayremotelement );
224 public void assertDeleteRemoteRepositoryPage()
226 assertPage( "Apache Archiva \\ Admin: Delete Remote Repository" );
227 assertTextPresent( "Admin: Delete Remote Repository" );
228 assertTextPresent( "WARNING: This operation can not be undone." );
229 assertTextPresent( "Are you sure you want to delete the following remote repository?" );
230 assertButtonWithValuePresent( "Confirm" );
231 assertButtonWithValuePresent( "Cancel" );
234 public void addRemoteRepository( String identifier, String name, String url, String username, String password,
235 String timeout, String type, boolean wait )
237 assertAddRemoteRepository();
238 setFieldValue( "addRemoteRepository_repository_id", identifier );
239 setFieldValue( "addRemoteRepository_repository_name", name );
240 setFieldValue( "addRemoteRepository_repository_url", url );
241 setFieldValue( "addRemoteRepository_repository_userName", username );
242 setFieldValue( "addRemoteRepository_repository_password", password );
243 setFieldValue( "addRemoteRepository_repository_timeout", timeout );
244 selectValue( "addRemoteRepository_repository_layout", type );
245 clickButtonWithValue( "Add Repository", wait );
248 public void deleteRemoteRepository()
250 goToRepositoriesPage();
251 clickLinkWithXPath( "//div[@id='contentArea']/div/div[8]/div[1]/a[2]" );
252 assertDeleteRemoteRepositoryPage();
253 clickButtonWithValue( "Confirm" );
256 public void editRemoteRepository( String fieldName, String value )
258 goToRepositoriesPage();
259 clickLinkWithXPath( "//div[@id='contentArea']/div/div[8]/div[1]/a[1]" );
260 setFieldValue( fieldName, value );
261 clickButtonWithValue( "Update Repository" );
264 public void editManagedRepository( String fieldName, String value )
266 goToRepositoriesPage();
267 clickLinkWithXPath( "//div[@id='contentArea']/div/div[5]/div[1]/a[1]/img" );
268 assertPage( "Apache Archiva \\ Admin: Edit Managed Repository" );
269 setFieldValue( fieldName, value );
271 clickButtonWithValue( "Update Repository" );
274 public void editManagedRepository( String name, String directory, String indexDirectory, String type, String cron,
275 String daysOlder, String retentionCount )
277 goToRepositoriesPage();
278 clickLinkWithXPath( "//div[@id='contentArea']/div/div[5]/div[1]/a[1]/img" );
279 assertPage( "Apache Archiva \\ Admin: Edit Managed Repository" );
280 setFieldValue( "repository.name", name );
281 setFieldValue( "repository.location", directory );
282 setFieldValue( "repository.indexDirectory", indexDirectory );
283 selectValue( "repository.layout", type );
284 setFieldValue( "repository.cronExpression", cron );
285 setFieldValue( "repository.daysOlder", daysOlder );
286 setFieldValue( "repository.retentionCount", retentionCount );
287 clickButtonWithValue( "Update Repository" );
290 public void deleteManagedRepository()
292 clickLinkWithXPath( "//div[@id='contentArea']/div/div[5]/div[1]/a[2]" );
293 assertPage( "Apache Archiva \\ Admin: Delete Managed Repository" );
294 clickButtonWithValue( "Delete Configuration Only" );
297 public String getRepositoryDir()
299 File f = new File( "" );
300 String artifactFilePath = f.getAbsolutePath();
301 return artifactFilePath + "/target/";
304 // ///////////////////////////////////////////
305 // Repository Scanning
306 // ///////////////////////////////////////////
307 public void goToRepositoryScanningPage()
309 getSelenium().open( "/archiva/admin/repositoryScanning.action" );
310 assertRepositoryScanningPage();
313 public void assertRepositoryScanningPage()
315 assertPage( "Apache Archiva \\ Administration - Repository Scanning" );
316 assertTextPresent( "Administration - Repository Scanning" );
317 assertTextPresent( "Repository Scanning - File Types" );
318 String artifactsTypes =
319 "**/*.pom,**/*.jar,**/*.ear,**/*.war,**/*.car,**/*.sar,**/*.mar,**/*.rar,**/*.dtd,**/*.tld,**/*.tar.gz,**/*.tar.bz2,**/*.zip";
320 String[] arrayArtifactTypes = artifactsTypes.split( "," );
321 for ( int i = 0; i < arrayArtifactTypes.length; i++ )
323 Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[1]/table." + i + ".0" ),
324 arrayArtifactTypes[i] );
327 String autoremove = "**/*.bak,**/*~,**/*-";
328 String[] arrayAutoremove = autoremove.split( "," );
329 for ( int i = 0; i < arrayAutoremove.length; i++ )
331 Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[2]/table." + i + ".0" ),
332 arrayAutoremove[i] );
335 String ignored = "**/.htaccess,**/KEYS,**/*.rb,**/*.sh,**/.svn/**,**/.DAV/**";
336 String[] arrayIgnored = ignored.split( "," );
337 for ( int i = 0; i < arrayIgnored.length; i++ )
339 Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[3]/table." + i + ".0" ),
343 String indexableContent =
344 "**/*.txt,**/*.TXT,**/*.block,**/*.config,**/*.pom,**/*.xml,**/*.xsd,**/*.dtd,**/*.tld";
345 String[] arrayIndexableContent = indexableContent.split( "," );
346 for ( int i = 0; i < arrayIndexableContent.length; i++ )
348 Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[4]/table." + i + ".0" ),
349 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" );