]> source.dussan.org Git - archiva.git/blob
029dc7b22f0c516ec49ddc1dfaca17d5d466ffc6
[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                 getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[3]/div[1]/a/img" );
84         }
85         
86         public void deleteRepositoryGroup( String repositoryName )
87         {
88                 //goToRepositoryGroupsPage();
89                 getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[1]/div/a/img" );
90                 waitPage();
91                 assertDeleteRepositoryGroupPage( repositoryName );
92                 clickButtonWithValue( "Confirm" );
93         }
94         
95         ///////////////////////////////
96         // proxy connectors
97         ///////////////////////////////
98         public void goToProxyConnectorsPage()
99         {
100                 clickLinkWithText( "Proxy Connectors" );
101                 assertProxyConnectorsPage();
102         }
103         
104         public void assertProxyConnectorsPage()
105         {
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" );
114         }
115         
116         public void assertAddProxyConnectorPage()
117         {
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" );
131         }
132         
133         // this only fills in the values of required fields in adding Proxy Connectors
134         public void addProxyConnector( String networkProxy, String managedRepo, String remoteRepo )
135         {
136                 goToProxyConnectorsPage();
137                 clickLinkWithText( "Add" );
138                 assertAddProxyConnectorPage();
139                 selectValue( "connector.proxyId" , networkProxy );
140                 selectValue( "connector.sourceRepoId" , managedRepo );
141                 selectValue( "connector.targetRepoId" , remoteRepo );
142         }
143         
144         public void deleteProxyConnector()
145         {
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" );
151         }
152         
153         ///////////////////////////////
154         // network proxies
155         ///////////////////////////////
156         public void goToNetworkProxiesPage()
157         {
158                 clickLinkWithText( "Network Proxies" );
159                 assertNetworkProxiesPage();
160         }
161         
162         public void assertNetworkProxiesPage()
163         {
164                 assertPage( "Apache Archiva \\ Administration - Network Proxies" );
165                 assertTextPresent( "Administration - Network Proxies" );
166                 assertTextPresent( "Network Proxies" );
167                 assertLinkPresent( "Add Network Proxy" );
168         }
169         
170         public void assertAddNetworkProxy()
171         {
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" );
182         }
183         
184         public void addNetworkProxy( String identifier, String protocol, String hostname, String port, String username, String password )
185         {
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" );
196         }
197         
198         public void editNetworkProxies( String fieldName, String value)
199         {
200                 //goToNetworkProxiesPage();
201                 clickLinkWithText( "Edit Network Proxy" );
202                 setFieldValue( fieldName, value);
203                 clickButtonWithValue( "Save Network Proxy" );
204         }
205         
206         public void deleteNetworkProxy()
207         {
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" );
213         }
214         
215         ///////////////////////////////
216         // repositories
217         ///////////////////////////////
218         public void goToRepositoriesPage()
219         {
220                 clickLinkWithText( "Repositories" );
221                 assertRepositoriesPage();
222         }
223         
224         public void assertRepositoriesPage()
225         {
226                 assertPage( "Apache Archiva \\ Administration - Repositories" );
227                 assertTextPresent( "Administration - Repositories" );
228                 assertTextPresent( "Managed Repositories" );
229                 assertTextPresent( "Remote Repositories" );
230         }
231         
232         // remote repositories
233         public void assertAddRemoteRepository()
234         {
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 );
244         }
245         
246         public void assertDeleteRemoteRepositoryPage()
247         {
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" );
254         }
255         
256         public void addRemoteRepository( String identifier, String name, String url, String username, String password, String timeout, String type )
257         {
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" );
268         }
269         
270         public void deleteRemoteRepository()
271         {
272                 goToRepositoriesPage();
273                 clickLinkWithXPath( "//div[@id='contentArea']/div/div[8]/div[1]/a[2]" );
274                 assertDeleteRemoteRepositoryPage();
275                 clickButtonWithValue( "Confirm" );
276         }
277         
278         public void editRemoteRepository( String fieldName, String value)
279         {
280                 goToRepositoriesPage();
281                 clickLinkWithXPath( "//div[@id='contentArea']/div/div[8]/div[1]/a[1]" );
282                 setFieldValue( fieldName, value );
283                 clickButtonWithValue( "Update Repository" );
284         }
285         
286         // managed repositories
287         public void addManagedRepository( String identifier, String name, String directory, String indexDirectory, String type, String cron, String daysOlder, String retentionCount )
288         {
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 );
299                 //TODO  
300                 clickButtonWithValue( "Add Repository" );
301         }
302         
303         public void editManagedRepository( String fieldName, String value )
304         {
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);
309                 //TODO
310                 clickButtonWithValue( "Update Repository" );
311         }
312         
313         public void deleteManagedRepository()
314         {
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" );
318         }
319         
320         public String getRepositoryDir()
321         {
322                 File f = new File( "" );
323                 String artifactFilePath = f.getAbsolutePath();
324                 return artifactFilePath + "/target/";
325         }
326 }