]> source.dussan.org Git - archiva.git/blob
137c9ccad0bed7e329a3928fb1363c48319fad36
[archiva.git] /
1 package org.apache.archiva.web.test.parent;
2
3 import java.io.File;
4
5 public abstract class AbstractRepositoryTest 
6         extends AbstractArchivaTest
7 {
8         // Repository Groups
9         public void goToRepositoryGroupsPage()
10         {
11                 clickLinkWithText( "Repository Groups" );
12                 assertRepositoryGroupsPage();
13         }
14         
15         public void assertRepositoryGroupsPage()
16         {
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" );
23         }
24         
25         public void assertAddedRepositoryLink( String repositoryGroupName)
26         {
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 );
32         }
33         
34         public void assertAddedRepositoryToRepositoryGroups( String repositoryName)
35         {
36                 assertPage( "Apache Archiva \\ Administration - Repository Groups" );
37                 assertTextPresent( repositoryName );
38                 assertTextPresent( "Archiva Managed Internal Repository" );
39                 assertAddedRepositoryLink( repositoryName );
40         }
41         
42         public void assertDeleteRepositoryGroupPage( String repositoryName)
43         {
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" );
50         }
51         
52         public void addRepositoryGroup( String repoGroupName )
53         {
54                 goToRepositoryGroupsPage();
55                 setFieldValue( "repositoryGroup.id", repoGroupName );
56                 clickButtonWithValue( "Add Group" );
57         }
58         
59         public void addRepositoryToRepositoryGroup( String repositoryGroupName, String repositoryName )
60         {
61                 goToRepositoryGroupsPage();
62                 String s = getSelenium().getBodyText();
63                 if ( s.contains( "No Repository Groups Defined." ) )
64                 {
65                         setFieldValue( "repositoryGroup.id" , repositoryGroupName );
66                         clickButtonWithValue( "Add Group" );
67                         //assertAddedRepositoryLink( repositoryGroupName );
68                         
69                         selectValue( "addRepositoryToGroup_repoId" , repositoryName );
70                         clickButtonWithValue( "Add Repository" );
71                         assertAddedRepositoryToRepositoryGroups( repositoryName );
72                 }
73                 else
74                 {
75                         //assertAddedRepositoryLink( repositoryGroupName );
76                         selectValue( "addRepositoryToGroup_repoId" , repositoryName );
77                         clickButtonWithValue( "Add Repository" );
78                 }
79         }
80         
81         public void deleteRepositoryInRepositoryGroups()
82         {
83                 goToRepositoryGroupsPage();
84                 getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[3]/div[1]/a/img" );
85                 waitPage();
86         }
87         
88         public void deleteRepositoryGroup( String repositoryName )
89         {
90                 getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[1]/div/a/img" );
91                 waitPage();
92                 assertDeleteRepositoryGroupPage( repositoryName );
93                 clickButtonWithValue( "Confirm" );
94         }
95         
96         ///////////////////////////////
97         // proxy connectors
98         ///////////////////////////////
99         public void goToProxyConnectorsPage()
100         {
101                 clickLinkWithText( "Proxy Connectors" );
102                 assertProxyConnectorsPage();
103         }
104         
105         public void assertProxyConnectorsPage()
106         {
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" );
115         }
116         
117         public void assertAddProxyConnectorPage()
118         {
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" );
132         }
133         
134         // this only fills in the values of required fields in adding Proxy Connectors
135         public void addProxyConnector( String networkProxy, String managedRepo, String remoteRepo )
136         {
137                 goToProxyConnectorsPage();
138                 clickLinkWithText( "Add" );
139                 assertAddProxyConnectorPage();
140                 selectValue( "connector.proxyId" , networkProxy );
141                 selectValue( "connector.sourceRepoId" , managedRepo );
142                 selectValue( "connector.targetRepoId" , remoteRepo );
143         }
144         
145         public void deleteProxyConnector()
146         {
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" );
152         }
153         
154         ///////////////////////////////
155         // network proxies
156         ///////////////////////////////
157         public void goToNetworkProxiesPage()
158         {
159                 clickLinkWithText( "Network Proxies" );
160                 assertNetworkProxiesPage();
161         }
162         
163         public void assertNetworkProxiesPage()
164         {
165                 assertPage( "Apache Archiva \\ Administration - Network Proxies" );
166                 assertTextPresent( "Administration - Network Proxies" );
167                 assertTextPresent( "Network Proxies" );
168                 assertLinkPresent( "Add Network Proxy" );
169         }
170         
171         public void assertAddNetworkProxy()
172         {
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" );
183         }
184         
185         public void addNetworkProxy( String identifier, String protocol, String hostname, String port, String username, String password )
186         {
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" );
197         }
198         
199         public void editNetworkProxies( String fieldName, String value)
200         {
201                 //goToNetworkProxiesPage();
202                 clickLinkWithText( "Edit Network Proxy" );
203                 setFieldValue( fieldName, value);
204                 clickButtonWithValue( "Save Network Proxy" );
205         }
206         
207         public void deleteNetworkProxy()
208         {
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" );
214         }
215         
216         // remote repositories
217         public void assertAddRemoteRepository()
218         {
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 );
228         }
229         
230         public void assertDeleteRemoteRepositoryPage()
231         {
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" );
238         }
239         
240         public void addRemoteRepository( String identifier, String name, String url, String username, String password, String timeout, String type )
241         {
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" );
252         }
253         
254         public void deleteRemoteRepository()
255         {
256                 goToRepositoriesPage();
257                 clickLinkWithXPath( "//div[@id='contentArea']/div/div[8]/div[1]/a[2]" );
258                 assertDeleteRemoteRepositoryPage();
259                 clickButtonWithValue( "Confirm" );
260         }
261         
262         public void editRemoteRepository( String fieldName, String value)
263         {
264                 goToRepositoriesPage();
265                 clickLinkWithXPath( "//div[@id='contentArea']/div/div[8]/div[1]/a[1]" );
266                 setFieldValue( fieldName, value );
267                 clickButtonWithValue( "Update Repository" );
268         }
269         
270         public void editManagedRepository( String fieldName, String value )
271         {
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);
276                 //TODO
277                 clickButtonWithValue( "Update Repository" );
278         }
279         
280         public void deleteManagedRepository()
281         {
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" );
285         }
286         
287         public String getRepositoryDir()
288         {
289                 File f = new File( "" );
290                 String artifactFilePath = f.getAbsolutePath();
291                 return artifactFilePath + "/target/";
292         }
293         
294         /////////////////////////////////////////////
295         // Repository Scanning
296         /////////////////////////////////////////////
297         public void goToRepositoryScanningPage()
298         {
299                 clickLinkWithText( "Repository Scanning" );
300                 assertRepositoryScanningPage();
301         }
302         
303         public void assertRepositoryScanningPage()
304         {
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 );
312                 
313                 String autoremove = "**/*.bak,**/*~,**/*-";
314                 String [] arrayAutoremove = autoremove.split( "," );
315                 for ( String arrayautoremove : arrayAutoremove )
316                         assertTextPresent( arrayautoremove );
317                 
318                 String ignored = "**/.htaccess,**/KEYS,**/*.rb,**/*.sh,**/.svn/**,**/.DAV/**";
319                 String [] arrayIgnored = ignored.split( "," );
320                 for ( String arrayignored : arrayIgnored )
321                         assertTextPresent( arrayignored );
322                 
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 );
327         }
328         
329         /////////////////////////////////////////////
330         // Database
331         /////////////////////////////////////////////
332         public void goToDatabasePage()
333         {
334                 clickLinkWithText( "Database" );
335                 assertDatabasePage();
336         }
337         
338         public void assertDatabasePage()
339         {
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" );
349         }
350 }