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 getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[3]/div[1]/a/img" );
86 public void deleteRepositoryGroup( String repositoryName )
88 //goToRepositoryGroupsPage();
89 getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[1]/div/a/img" );
91 assertDeleteRepositoryGroupPage( repositoryName );
92 clickButtonWithValue( "Confirm" );
95 ///////////////////////////////
97 ///////////////////////////////
98 public void goToProxyConnectorsPage()
100 clickLinkWithText( "Proxy Connectors" );
101 assertProxyConnectorsPage();
104 public void assertProxyConnectorsPage()
106 assertPage( "Apache Archiva \\ Administration - Proxy Connectors" );
107 assertTextPresent( "Administration - Proxy Connectors" );
108 assertTextPresent( "Repository Proxy Connectors" );
109 assertTextPresent( "internal" );
110 assertTextPresent( "Archiva Managed Internal Repository" );
111 assertTextPresent( "Proxy Connector" );
112 assertTextPresent( "Central Repository" );
113 assertTextPresent( "Java.net Repository for Maven 2" );
116 public void assertAddProxyConnectorPage()
118 assertPage( "Apache Archiva \\ Admin: Add Proxy Connector" );
119 assertTextPresent( "Admin: Add Proxy Connector" );
120 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.";
121 String[] arrayProxy = proxy.split( "," );
122 for ( String arrayproxy : arrayProxy )
123 assertTextPresent( arrayproxy );
124 /*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";
125 String[] arrayProxyElements = proxyElements.split( "," );
126 for ( String arrayproxyelements : arrayProxyElements )
127 assertTextPresent( arrayproxyelements );*/
128 assertButtonWithValuePresent( "Add Property" );
129 assertButtonWithValuePresent( "Add Pattern" );
130 assertButtonWithValuePresent( "Add Proxy Connector" );
133 // this only fills in the values of required fields in adding Proxy Connectors
134 public void addProxyConnector( String networkProxy, String managedRepo, String remoteRepo )
136 goToProxyConnectorsPage();
137 clickLinkWithText( "Add" );
138 assertAddProxyConnectorPage();
139 selectValue( "connector.proxyId" , networkProxy );
140 selectValue( "connector.sourceRepoId" , managedRepo );
141 selectValue( "connector.targetRepoId" , remoteRepo );
144 public void deleteProxyConnector()
146 goToProxyConnectorsPage();
147 clickLinkWithXPath( "//div[@id='contentArea']/div[2]/div[1]/div[2]/div[1]/a[3]/img" );
148 assertPage( "Apache Archiva \\ Admin: Delete Proxy Connectors" );
149 clickButtonWithValue( "Delete" );
150 assertPage( "Apache Archiva \\ Administration - Proxy Connectors" );
153 ///////////////////////////////
155 ///////////////////////////////
156 public void goToNetworkProxiesPage()
158 clickLinkWithText( "Network Proxies" );
159 assertNetworkProxiesPage();
162 public void assertNetworkProxiesPage()
164 assertPage( "Apache Archiva \\ Administration - Network Proxies" );
165 assertTextPresent( "Administration - Network Proxies" );
166 assertTextPresent( "Network Proxies" );
167 assertLinkPresent( "Add Network Proxy" );
170 public void assertAddNetworkProxy()
172 assertPage( "Apache Archiva \\ Admin: Add Network Proxy" );
173 assertTextPresent( "Admin: Add Network Proxy" );
174 assertTextPresent( "Add network proxy:" );
175 assertTextPresent( "Identifier*:" );
176 assertTextPresent( "Protocol*:" );
177 assertTextPresent( "Hostname*:" );
178 assertTextPresent( "Port*:" );
179 assertTextPresent( "Username:" );
180 assertTextPresent( "Password:" );
181 assertButtonWithValuePresent( "Save Network Proxy" );
184 public void addNetworkProxy( String identifier, String protocol, String hostname, String port, String username, String password )
186 //goToNetworkProxiesPage();
187 clickLinkWithText( "Add Network Proxy" );
188 assertAddNetworkProxy();
189 setFieldValue( "proxy.id" , identifier );
190 setFieldValue( "proxy.protocol" , protocol );
191 setFieldValue( "proxy.host" , hostname );
192 setFieldValue( "proxy.port" , port );
193 setFieldValue( "proxy.username" , username );
194 setFieldValue( "proxy.password" , password );
195 clickButtonWithValue( "Save Network Proxy" );
198 public void editNetworkProxies( String fieldName, String value)
200 //goToNetworkProxiesPage();
201 clickLinkWithText( "Edit Network Proxy" );
202 setFieldValue( fieldName, value);
203 clickButtonWithValue( "Save Network Proxy" );
206 public void deleteNetworkProxy()
208 //goToNetworkProxiesPage();
209 clickLinkWithText( "Delete Network Proxy" );
210 assertPage( "Apache Archiva \\ Admin: Delete Network Proxy" );
211 assertTextPresent( "WARNING: This operation can not be undone." );
212 clickButtonWithValue( "Delete" );
215 ///////////////////////////////
217 ///////////////////////////////
218 public void goToRepositoriesPage()
220 clickLinkWithText( "Repositories" );
221 assertRepositoriesPage();
224 public void assertRepositoriesPage()
226 assertPage( "Apache Archiva \\ Administration - Repositories" );
227 assertTextPresent( "Administration - Repositories" );
228 assertTextPresent( "Managed Repositories" );
229 assertTextPresent( "Remote Repositories" );
232 // remote repositories
233 public void assertAddRemoteRepository()
235 assertPage( "Apache Archiva \\ Admin: Add Remote Repository" );
236 String remote = "Identifier*:,Name*:,URL*:,Username:,Password:,Timeout in seconds:,Type:";
237 String[] arrayRemote = remote.split( "," );
238 for ( String arrayremote : arrayRemote )
239 assertTextPresent( arrayremote );
240 String remoteElements = "addRemoteRepository_repository_id,addRemoteRepository_repository_name,addRemoteRepository_repository_url,addRemoteRepository_repository_username,addRemoteRepository_repository_password,addRemoteRepository_repository_timeout,addRemoteRepository_repository_layout";
241 String[] arrayRemoteElements = remoteElements.split( "," );
242 for ( String arrayremotelement : arrayRemoteElements )
243 assertElementPresent( arrayremotelement );
246 public void assertDeleteRemoteRepositoryPage()
248 assertPage( "Apache Archiva \\ Admin: Delete Remote Repository" );
249 assertTextPresent( "Admin: Delete Remote Repository" );
250 assertTextPresent( "WARNING: This operation can not be undone." );
251 assertTextPresent( "Are you sure you want to delete the following remote repository?" );
252 assertButtonWithValuePresent( "Confirm" );
253 assertButtonWithValuePresent( "Cancel" );
256 public void addRemoteRepository( String identifier, String name, String url, String username, String password, String timeout, String type )
258 //goToRepositoriesPage();
259 assertAddRemoteRepository();
260 setFieldValue( "addRemoteRepository_repository_id" , identifier );
261 setFieldValue( "addRemoteRepository_repository_name" , name );
262 setFieldValue( "addRemoteRepository_repository_url" , url );
263 setFieldValue( "addRemoteRepository_repository_username" , username );
264 setFieldValue( "addRemoteRepository_repository_password" , password );
265 setFieldValue( "addRemoteRepository_repository_timeout" , timeout );
266 selectValue( "addRemoteRepository_repository_layout" , type );
267 clickButtonWithValue( "Add Repository" );
270 public void deleteRemoteRepository()
272 goToRepositoriesPage();
273 clickLinkWithXPath( "//div[@id='contentArea']/div/div[8]/div[1]/a[2]" );
274 assertDeleteRemoteRepositoryPage();
275 clickButtonWithValue( "Confirm" );
278 public void editRemoteRepository( String fieldName, String value)
280 goToRepositoriesPage();
281 clickLinkWithXPath( "//div[@id='contentArea']/div/div[8]/div[1]/a[1]" );
282 setFieldValue( fieldName, value );
283 clickButtonWithValue( "Update Repository" );
286 // managed repositories
287 public void addManagedRepository( String identifier, String name, String directory, String indexDirectory, String type, String cron, String daysOlder, String retentionCount )
289 //goToRepositoriesPage();
290 //clickLinkWithText( "Add" );
291 setFieldValue( "repository.id" , identifier );
292 setFieldValue( "repository.name" , name );
293 setFieldValue( "repository.location" , directory );
294 setFieldValue( "repository.indexDir" , indexDirectory );
295 selectValue( "repository.layout", type );
296 setFieldValue( "repository.refreshCronExpression" , cron );
297 setFieldValue( "repository.daysOlder" , daysOlder );
298 setFieldValue( "repository.retentionCount" , retentionCount );
300 clickButtonWithValue( "Add Repository" );
303 public void editManagedRepository( String fieldName, String value )
305 //goToRepositoriesPage();
306 clickLinkWithXPath( "//div[@id='contentArea']/div/div[5]/div[1]/a[1]/img" );
307 assertPage( "Apache Archiva \\ Admin: Edit Managed Repository" );
308 setFieldValue(fieldName, value);
310 clickButtonWithValue( "Update Repository" );
313 public void deleteManagedRepository()
315 clickLinkWithXPath( "//div[@id='contentArea']/div/div[5]/div[1]/a[2]" );
316 assertPage( "Apache Archiva \\ Admin: Delete Managed Repository" );
317 clickButtonWithValue( "Delete Configuration Only" );
320 public String getRepositoryDir()
322 File f = new File( "" );
323 String artifactFilePath = f.getAbsolutePath();
324 return artifactFilePath + "/target/";