]> source.dussan.org Git - archiva.git/blob
7533a452b7658f8d746ac2ae68273944cff482d5
[archiva.git] /
1 package org.apache.archiva.web.test.parent;
2
3 import java.io.File;
4
5 public abstract class AbstractArtifactManagementTest 
6         extends AbstractArchivaTest
7 {
8         
9         public String getGroupId()
10         {
11                 String groupId = p.getProperty( "GROUPID" ) ;
12                 return groupId;
13         }
14         
15         public String getArtifactId()
16         {
17                 String artifactId = p.getProperty( "GROUPID" ) ;
18                 return artifactId;
19         }
20         
21         public String getVersion()
22         {
23                 String version = p.getProperty( "VERSION" ) ;
24                 return version;
25         }
26         
27         public String getPackaging()
28         {
29                 String packaging = p.getProperty( "PACKAGING" ) ;
30                 return packaging;
31         }
32         
33         public String getArtifactFilePath()
34         {
35                 File f = new File( "" );
36                 String artifactFilePath = f.getAbsolutePath();
37                 return artifactFilePath + "/src/test/it-resources/snapshots/org/apache/maven/archiva/web/test/foo-bar/1.0-SNAPSHOT/foo-bar-1.0-SNAPSHOT.jar" ;
38         }
39         
40         public String getRepositoryId()
41         {
42                 String repositoryId = p.getProperty( "REPOSITORYID" ) ;
43                 return repositoryId;
44         }
45         
46         public void goToAddArtifactPage()
47         {
48                 clickLinkWithText( "Upload Artifact" );
49                 assertAddArtifactPage();
50         }
51         
52         public void goToDeleteArtifactPage()
53         {
54                 clickLinkWithText( "Delete Artifact" );
55                 assertDeleteArtifactPage();
56         }
57                 
58         public void addArtifact( String groupId, String artifactId, String version, String packaging, String artifactFilePath, String repositoryId )
59         {
60                 addArtifact(groupId, artifactId, version, packaging, true,  artifactFilePath, repositoryId);
61         }
62         
63         public void addArtifact( String groupId, String artifactId, String version, String packaging, boolean generatePom, String artifactFilePath, String repositoryId)
64         {
65                 goToAddArtifactPage();
66                 setFieldValue( "groupId" , groupId );
67                 setFieldValue( "artifactId" , artifactId );
68                 setFieldValue( "version" , version );
69                 setFieldValue( "packaging" , packaging );
70                 
71                 if ( generatePom )
72                 {
73                         checkField( "generatePom" );
74                 }
75                 
76                 setFieldValue( "artifact" , artifactFilePath );
77                 setFieldValue( "repositoryId" , repositoryId );
78                 
79                 clickButtonWithValue( "Submit" );
80         }
81         
82         public void deleteArtifact( String groupId, String artifactId, String version, String repositoryId )
83         {
84                 goToDeleteArtifactPage();
85                 setFieldValue( "groupId" , groupId );
86                 setFieldValue( "artifactId" , artifactId );
87                 setFieldValue( "version" , version );
88                 selectValue( "repositoryId" ,  repositoryId );
89                 clickButtonWithValue( "Submit" ) ;
90         }
91         
92         public void assertAddArtifactPage()
93         {
94                 assertPage( "Apache Archiva \\ Upload Artifact" );
95                 assertTextPresent( "Upload Artifact" );
96                 
97                 String artifact = "Upload Artifact,Group Id*:,Artifact Id*:,Version*:,Packaging*:,Classifier:,Generate Maven 2 POM,Artifact File*:,POM File:,Repository Id:";
98                 String[] arrayArtifact = artifact.split( "," );
99                 for ( String arrayartifact : arrayArtifact )
100                         assertTextPresent( arrayartifact );
101                 
102                 String artifactElements = "upload_groupId,upload_artifactId,upload_version,upload_packaging,upload_classifier,upload_generatePom,upload_artifact,upload_pom,upload_repositoryId,upload_0";
103                 String[] arrayArtifactElements = artifactElements.split( "," );
104                 for ( String artifactelements : arrayArtifactElements )
105                         assertElementPresent( artifactelements );
106         }
107         
108         public void assertDeleteArtifactPage()
109         {
110                 assertPage( "Apache Archiva \\ Delete Artifact" );
111                 assertTextPresent( "Delete Artifact" );
112                 assertTextPresent( "Group Id*:" );
113                 assertTextPresent( "Artifact Id*:" );
114                 assertTextPresent( "Version*:" );
115                 assertTextPresent( "Repository Id:" );
116                 assertElementPresent( "groupId" );
117                 assertElementPresent( "artifactId" );
118                 assertElementPresent( "version" );
119                 assertElementPresent( "repositoryId" );
120                 assertButtonWithValuePresent( "Submit" );
121         }
122 }