]> source.dussan.org Git - archiva.git/blob
f92ea26c6a293e37304976053ebba0cac7404446
[archiva.git] /
1 package org.apache.archiva.web.test.parent;
2
3 import java.io.*;
4
5 public abstract class AbstractArtifactManagementTest 
6         extends AbstractArchivaTest
7 {
8         
9         public String getGroupId()
10         {
11                 String groupId = getProperty( "GROUPID" ) ;
12                 return groupId;
13         }
14         
15         public String getArtifactId()
16         {
17                 String artifactId = getProperty( "ARTIFACTID" ) ;
18                 return artifactId;
19         }
20         
21         public String getVersion()
22         {
23                 String version = getProperty( "VERSION" ) ;
24                 return version;
25         }
26         
27         public String getPackaging()
28         {
29                 String packaging = getProperty( "PACKAGING" ) ;
30                 return packaging;
31         }
32         
33         public String getArtifactFilePath()
34         {
35                 File f = new File( "src/test/it-resources/snapshots/org/apache/maven/archiva/web/test/foo-bar/1.0-SNAPSHOT/foo-bar-1.0-SNAPSHOT.jar" ); 
36                 try
37                 {
38                         return f.getCanonicalPath();
39                 }
40                 catch ( IOException e )
41                 {
42                         return f.getAbsolutePath();
43                 }
44         }
45         
46         public String getRepositoryId()
47         {
48                 String repositoryId = getProperty( "REPOSITORYID" ) ;
49                 return repositoryId;
50         }
51         
52         public void goToDeleteArtifactPage()
53         {
54                 clickLinkWithText( "Delete Artifact" );
55                 assertDeleteArtifactPage();
56         }
57                 
58         public void deleteArtifact( String groupId, String artifactId, String version, String repositoryId )
59         {
60                 goToDeleteArtifactPage();
61                 setFieldValue( "groupId" , groupId );
62                 setFieldValue( "artifactId" , artifactId );
63                 setFieldValue( "version" , version );
64                 selectValue( "repositoryId" ,  repositoryId );
65                 clickButtonWithValue( "Submit" ) ;
66         }
67         
68         public void assertDeleteArtifactPage()
69         {
70                 assertPage( "Apache Archiva \\ Delete Artifact" );
71                 assertTextPresent( "Delete Artifact" );
72                 assertTextPresent( "Group Id*:" );
73                 assertTextPresent( "Artifact Id*:" );
74                 assertTextPresent( "Version*:" );
75                 assertTextPresent( "Repository Id:" );
76                 assertElementPresent( "groupId" );
77                 assertElementPresent( "artifactId" );
78                 assertElementPresent( "version" );
79                 assertElementPresent( "repositoryId" );
80                 assertButtonWithValuePresent( "Submit" );
81         }
82         
83         // Legacy Support
84         public void goToLegacySupportPage()
85         {
86                 clickLinkWithText( "Legacy Support" );
87                 assertLegacySupportPage();
88         }
89         
90         public void assertLegacySupportPage()
91         {
92                 assertPage( "Apache Archiva \\ Administration - Legacy Support" );
93                 assertTextPresent( "Administration - Legacy Artifact Path Resolution" );
94                 assertTextPresent( "Path Mappings" );
95                 assertLinkPresent( "Add" );
96         }
97         
98         public void addLegacyArtifactPath( String path, String groupId, String artifactId, String version, String classifier, String type)
99         {
100                 assertAddLegacyArtifactPathPage();
101                 setFieldValue( "legacyArtifactPath.path" , path );
102                 setFieldValue( "groupId" , groupId );
103                 setFieldValue( "artifactId" , artifactId );
104                 setFieldValue( "version" , version );
105                 setFieldValue( "classifier" , classifier );
106                 setFieldValue( "type" , type );
107                 clickButtonWithValue( "Add Legacy Artifact Path" );
108         }
109         
110         public void assertAddLegacyArtifactPathPage()
111         {
112                 assertPage( "Apache Archiva \\ Admin: Add Legacy Artifact Path" );
113                 assertTextPresent( "Admin: Add Legacy Artifact Path" );
114                 assertTextPresent( "Enter the legacy path to map to a particular artifact reference, then adjust the fields as necessary." );
115                 String element = "addLegacyArtifactPath_legacyArtifactPath_path,addLegacyArtifactPath_groupId,addLegacyArtifactPath_artifactId,addLegacyArtifactPath_version,addLegacyArtifactPath_classifier,addLegacyArtifactPath_type";
116                 String[] arrayElement = element.split( "," );
117                 for ( String arrayelement : arrayElement )
118                         assertElementPresent( arrayelement );
119                 assertButtonWithValuePresent( "Add Legacy Artifact Path" );
120         }
121 }