1 package org.apache.archiva.web.test.parent;
5 public abstract class AbstractRepositoryTest
6 extends AbstractArchivaTest
9 public void goToRepositoryGroupsPage()
11 clickLinkWithText( "Repository Groups" );
12 assertRepositoryGroupsPage();
15 public void assertRepositoryGroupsPage()
17 assertPage( "Apache Archiva \\ Administration - Repository Groups" );
18 assertTextPresent( "Administration - Repository Groups" );
19 assertTextPresent( "Identifier*:" );
20 assertElementPresent( "repositoryGroup.id" );
21 assertButtonWithValuePresent( "Add Group" );
22 assertTextPresent( "Repository Groups" );
25 public void assertAddedRepositoryLink( String repositoryGroupName)
27 assertPage( "Apache Archiva \\ Administration - Repository Groups" );
28 String repositoryGroupUrlValue = "repository/" + repositoryGroupName + "/";
29 String baseUrlValue = "archiva";
30 String repositoryGroupLink = baseUrl.replaceFirst( baseUrlValue, repositoryGroupUrlValue);
31 assertTextPresent( repositoryGroupLink );
34 public void assertAddedRepositoryToRepositoryGroups( String repositoryName)
36 assertPage( "Apache Archiva \\ Administration - Repository Groups" );
37 assertTextPresent( repositoryName );
38 assertTextPresent( "Archiva Managed Internal Repository" );
39 assertAddedRepositoryLink( repositoryName );
42 public void assertDeleteRepositoryGroupPage( String repositoryName)
44 assertPage( "Apache Archiva \\ Admin: Delete Repository Group" );
45 assertTextPresent( "WARNING: This operation can not be undone." );
46 assertTextPresent( "Are you sure you want to delete the following repository group?" );
47 assertTextPresent( "ID: " + repositoryName );
48 assertButtonWithValuePresent( "Confirm" );
49 assertButtonWithValuePresent( "Cancel" );
52 public void addRepositoryGroup( String repoGroupName )
54 goToRepositoryGroupsPage();
55 setFieldValue( "repositoryGroup.id", repoGroupName );
56 clickButtonWithValue( "Add Group" );
59 public void addRepositoryToRepositoryGroup( String repositoryGroupName, String repositoryName )
61 goToRepositoryGroupsPage();
62 String s = getSelenium().getBodyText();
63 if ( s.contains( "No Repository Groups Defined." ) )
65 setFieldValue( "repositoryGroup.id" , repositoryGroupName );
66 clickButtonWithValue( "Add Group" );
67 //assertAddedRepositoryLink( repositoryGroupName );
69 selectValue( "addRepositoryToGroup_repoId" , repositoryName );
70 clickButtonWithValue( "Add Repository" );
71 assertAddedRepositoryToRepositoryGroups( repositoryName );
75 //assertAddedRepositoryLink( repositoryGroupName );
76 selectValue( "addRepositoryToGroup_repoId" , repositoryName );
77 clickButtonWithValue( "Add Repository" );
81 public void deleteRepositoryInRepositoryGroups()
83 goToRepositoryGroupsPage();
84 getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[3]/div[1]/a/img" );
88 public void deleteRepositoryGroup( String repositoryName )
90 getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[1]/div/a/img" );
92 assertDeleteRepositoryGroupPage( repositoryName );
93 clickButtonWithValue( "Confirm" );
96 ///////////////////////////////
98 ///////////////////////////////
99 public void goToProxyConnectorsPage()
101 clickLinkWithText( "Proxy Connectors" );
102 assertProxyConnectorsPage();
105 public void assertProxyConnectorsPage()
107 assertPage( "Apache Archiva \\ Administration - Proxy Connectors" );
108 assertTextPresent( "Administration - Proxy Connectors" );
109 assertTextPresent( "Repository Proxy Connectors" );
110 assertTextPresent( "internal" );
111 assertTextPresent( "Archiva Managed Internal Repository" );
112 assertTextPresent( "Proxy Connector" );
113 assertTextPresent( "Central Repository" );
114 assertTextPresent( "Java.net Repository for Maven 2" );
117 public void assertAddProxyConnectorPage()
119 assertPage( "Apache Archiva \\ Admin: Add Proxy Connector" );
120 assertTextPresent( "Admin: Add Proxy Connector" );
121 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.";
122 String[] arrayProxy = proxy.split( "," );
123 for ( String arrayproxy : arrayProxy )
124 assertTextPresent( arrayproxy );
125 /*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";
126 String[] arrayProxyElements = proxyElements.split( "," );
127 for ( String arrayproxyelements : arrayProxyElements )
128 assertTextPresent( arrayproxyelements );*/
129 assertButtonWithValuePresent( "Add Property" );
130 assertButtonWithValuePresent( "Add Pattern" );
131 assertButtonWithValuePresent( "Add Proxy Connector" );
134 // this only fills in the values of required fields in adding Proxy Connectors
135 public void addProxyConnector( String networkProxy, String managedRepo, String remoteRepo )
137 goToProxyConnectorsPage();
138 clickLinkWithText( "Add" );
139 assertAddProxyConnectorPage();
140 selectValue( "connector.proxyId" , networkProxy );
141 selectValue( "connector.sourceRepoId" , managedRepo );
142 selectValue( "connector.targetRepoId" , remoteRepo );
145 public void deleteProxyConnector()
147 goToProxyConnectorsPage();
148 clickLinkWithXPath( "//div[@id='contentArea']/div[2]/div[1]/div[2]/div[1]/a[3]/img" );
149 assertPage( "Apache Archiva \\ Admin: Delete Proxy Connectors" );
150 clickButtonWithValue( "Delete" );
151 assertPage( "Apache Archiva \\ Administration - Proxy Connectors" );
154 ///////////////////////////////
156 ///////////////////////////////
157 public void goToNetworkProxiesPage()
159 clickLinkWithText( "Network Proxies" );
160 assertNetworkProxiesPage();
163 public void assertNetworkProxiesPage()
165 assertPage( "Apache Archiva \\ Administration - Network Proxies" );
166 assertTextPresent( "Administration - Network Proxies" );
167 assertTextPresent( "Network Proxies" );
168 assertLinkPresent( "Add Network Proxy" );
171 public void assertAddNetworkProxy()
173 assertPage( "Apache Archiva \\ Admin: Add Network Proxy" );
174 assertTextPresent( "Admin: Add Network Proxy" );
175 assertTextPresent( "Add network proxy:" );
176 assertTextPresent( "Identifier*:" );
177 assertTextPresent( "Protocol*:" );
178 assertTextPresent( "Hostname*:" );
179 assertTextPresent( "Port*:" );
180 assertTextPresent( "Username:" );
181 assertTextPresent( "Password:" );
182 assertButtonWithValuePresent( "Save Network Proxy" );
185 public void addNetworkProxy( String identifier, String protocol, String hostname, String port, String username, String password )
187 //goToNetworkProxiesPage();
188 clickLinkWithText( "Add Network Proxy" );
189 assertAddNetworkProxy();
190 setFieldValue( "proxy.id" , identifier );
191 setFieldValue( "proxy.protocol" , protocol );
192 setFieldValue( "proxy.host" , hostname );
193 setFieldValue( "proxy.port" , port );
194 setFieldValue( "proxy.username" , username );
195 setFieldValue( "proxy.password" , password );
196 clickButtonWithValue( "Save Network Proxy" );
199 public void editNetworkProxies( String fieldName, String value)
201 //goToNetworkProxiesPage();
202 clickLinkWithText( "Edit Network Proxy" );
203 setFieldValue( fieldName, value);
204 clickButtonWithValue( "Save Network Proxy" );
207 public void deleteNetworkProxy()
209 //goToNetworkProxiesPage();
210 clickLinkWithText( "Delete Network Proxy" );
211 assertPage( "Apache Archiva \\ Admin: Delete Network Proxy" );
212 assertTextPresent( "WARNING: This operation can not be undone." );
213 clickButtonWithValue( "Delete" );
216 // remote repositories
217 public void assertAddRemoteRepository()
219 assertPage( "Apache Archiva \\ Admin: Add Remote Repository" );
220 String remote = "Identifier*:,Name*:,URL*:,Username:,Password:,Timeout in seconds:,Type:";
221 String[] arrayRemote = remote.split( "," );
222 for ( String arrayremote : arrayRemote )
223 assertTextPresent( arrayremote );
224 String remoteElements = "addRemoteRepository_repository_id,addRemoteRepository_repository_name,addRemoteRepository_repository_url,addRemoteRepository_repository_username,addRemoteRepository_repository_password,addRemoteRepository_repository_timeout,addRemoteRepository_repository_layout";
225 String[] arrayRemoteElements = remoteElements.split( "," );
226 for ( String arrayremotelement : arrayRemoteElements )
227 assertElementPresent( arrayremotelement );
230 public void assertDeleteRemoteRepositoryPage()
232 assertPage( "Apache Archiva \\ Admin: Delete Remote Repository" );
233 assertTextPresent( "Admin: Delete Remote Repository" );
234 assertTextPresent( "WARNING: This operation can not be undone." );
235 assertTextPresent( "Are you sure you want to delete the following remote repository?" );
236 assertButtonWithValuePresent( "Confirm" );
237 assertButtonWithValuePresent( "Cancel" );
240 public void addRemoteRepository( String identifier, String name, String url, String username, String password, String timeout, String type )
242 //goToRepositoriesPage();
243 assertAddRemoteRepository();
244 setFieldValue( "addRemoteRepository_repository_id" , identifier );
245 setFieldValue( "addRemoteRepository_repository_name" , name );
246 setFieldValue( "addRemoteRepository_repository_url" , url );
247 setFieldValue( "addRemoteRepository_repository_username" , username );
248 setFieldValue( "addRemoteRepository_repository_password" , password );
249 setFieldValue( "addRemoteRepository_repository_timeout" , timeout );
250 selectValue( "addRemoteRepository_repository_layout" , type );
251 clickButtonWithValue( "Add Repository" );
254 public void deleteRemoteRepository()
256 goToRepositoriesPage();
257 clickLinkWithXPath( "//div[@id='contentArea']/div/div[8]/div[1]/a[2]" );
258 assertDeleteRemoteRepositoryPage();
259 clickButtonWithValue( "Confirm" );
262 public void editRemoteRepository( String fieldName, String value)
264 goToRepositoriesPage();
265 clickLinkWithXPath( "//div[@id='contentArea']/div/div[8]/div[1]/a[1]" );
266 setFieldValue( fieldName, value );
267 clickButtonWithValue( "Update Repository" );
270 public void editManagedRepository( String fieldName, String value )
272 //goToRepositoriesPage();
273 clickLinkWithXPath( "//div[@id='contentArea']/div/div[5]/div[1]/a[1]/img" );
274 assertPage( "Apache Archiva \\ Admin: Edit Managed Repository" );
275 setFieldValue(fieldName, value);
277 clickButtonWithValue( "Update Repository" );
280 public void deleteManagedRepository()
282 clickLinkWithXPath( "//div[@id='contentArea']/div/div[5]/div[1]/a[2]" );
283 assertPage( "Apache Archiva \\ Admin: Delete Managed Repository" );
284 clickButtonWithValue( "Delete Configuration Only" );
287 public String getRepositoryDir()
289 File f = new File( "" );
290 String artifactFilePath = f.getAbsolutePath();
291 return artifactFilePath + "/target/";
294 /////////////////////////////////////////////
295 // Repository Scanning
296 /////////////////////////////////////////////
297 public void goToRepositoryScanningPage()
299 clickLinkWithText( "Repository Scanning" );
300 assertRepositoryScanningPage();
303 public void assertRepositoryScanningPage()
305 assertPage( "Apache Archiva \\ Administration - Repository Scanning" );
306 assertTextPresent( "Administration - Repository Scanning" );
307 assertTextPresent( "Repository Scanning - File Types" );
308 String artifactsTypes = "**/*.pom,**/*.jar,**/*.ear,**/*.war,**/*.car,**/*.sar,**/*.mar,**/*.rar,**/*.dtd,**/*.tld,**/*.tar.gz,**/*.tar.bz2,**/*.zip";
309 String [] arrayArtifactTypes = artifactsTypes.split( "," );
310 for (String artifacttypes : arrayArtifactTypes )
311 assertTextPresent( artifacttypes );
313 String autoremove = "**/*.bak,**/*~,**/*-";
314 String [] arrayAutoremove = autoremove.split( "," );
315 for ( String arrayautoremove : arrayAutoremove )
316 assertTextPresent( arrayautoremove );
318 String ignored = "**/.htaccess,**/KEYS,**/*.rb,**/*.sh,**/.svn/**,**/.DAV/**";
319 String [] arrayIgnored = ignored.split( "," );
320 for ( String arrayignored : arrayIgnored )
321 assertTextPresent( arrayignored );
323 String indexableContent = "**/*.txt,**/*.TXT,**/*.block,**/*.config,**/*.pom,**/*.xml,**/*.xsd,**/*.dtd,**/*.tld";
324 String [] arrayIndexableContent = indexableContent.split( "," );
325 for ( String indexablecontent : arrayIndexableContent )
326 assertTextPresent( indexablecontent );
329 /////////////////////////////////////////////
331 /////////////////////////////////////////////
332 public void goToDatabasePage()
334 clickLinkWithText( "Database" );
335 assertDatabasePage();
338 public void assertDatabasePage()
340 assertPage( "Apache Archiva \\ Administration - Database" );
341 assertTextPresent( "Administration - Database" );
342 assertTextPresent( "Database - Unprocessed Artifacts Scanning" );
343 assertTextPresent( "Cron:" );
344 assertElementPresent( "database_cron" );
345 assertButtonWithValuePresent( "Update Cron" );
346 assertButtonWithValuePresent( "Update Database Now" );
347 assertTextPresent( "Database - Unprocessed Artifacts Scanning" );
348 assertTextPresent( "Database - Artifact Cleanup Scanning" );