1 package org.apache.archiva.web.test;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.archiva.web.test.parent.AbstractArtifactManagementTest;
23 import org.testng.annotations.Test;
25 @Test( groups = { "artifactmanagement" }, dependsOnGroups = { "about" } )
26 public class ArtifactManagementTest
27 extends AbstractArtifactManagementTest
30 @Test( alwaysRun = true, dependsOnGroups = "about" )
31 public void testAddArtifactNullValues()
33 goToAddArtifactPage();
34 clickButtonWithValue( "Submit", false );
35 //assertTextPresent( "Please add a file to upload." );
36 assertTextPresent( "You must enter a version." );
37 assertTextPresent( "You must enter a groupId." );
38 assertTextPresent( "You must enter an artifactId." );
39 assertTextPresent( "You must enter a version" );
40 assertTextPresent( "You must enter a packaging" );
43 @Test( dependsOnMethods = { "testAddArtifactNullValues" }, alwaysRun = true )
44 public void testAddArtifactNoGroupId()
46 addArtifact( " ", getArtifactId(), getVersion(), getPackaging(), getArtifactFilePath(), getRepositoryId(),
48 assertTextPresent( "You must enter a groupId." );
51 @Test( dependsOnMethods = { "testAddArtifactNoGroupId" }, alwaysRun = true )
52 public void testAddArtifactNoArtifactId()
54 addArtifact( getGroupId(), " ", getVersion(), getPackaging(), getArtifactFilePath(), getRepositoryId(), false );
55 assertTextPresent( "You must enter an artifactId." );
58 @Test( dependsOnMethods = { "testAddArtifactNoGroupId" }, alwaysRun = true )
59 public void testAddArtifactNoVersion()
61 addArtifact( getGroupId(), getArtifactId(), " ", getPackaging(), getArtifactFilePath(), getRepositoryId(),
63 assertTextPresent( "You must enter a version." );
66 @Test( dependsOnMethods = { "testAddArtifactNoGroupId" }, alwaysRun = true )
67 public void testAddArtifactInvalidVersion()
69 addArtifact( getGroupId(), getArtifactId(), "asdf", getPackaging(), getArtifactFilePath(), getRepositoryId(),
71 assertTextPresent( "Invalid version." );
74 @Test( dependsOnMethods = { "testAddArtifactNoGroupId" }, alwaysRun = true )
75 public void testAddArtifactNoPackaging()
77 addArtifact( getGroupId(), getArtifactId(), getVersion(), " ", getArtifactFilePath(), getRepositoryId(),
79 assertTextPresent( "You must enter a packaging." );
82 @Test( dependsOnMethods = { "testAddArtifactNoGroupId" }, alwaysRun = true )
83 public void testAddArtifactNoFilePath()
85 addArtifact( getGroupId(), getArtifactId(), getVersion(), getPackaging(), " ", getRepositoryId(), true );
86 assertTextPresent( "Please add a file to upload." );
89 @Test( groups = "requiresUpload" )
90 public void testAddArtifactValidValues()
92 String groupId = getProperty( "VALIDARTIFACT_GROUPID" );
93 String artifactId = getProperty( "VALIDARTIFACT_ARTIFACTID" );
95 addArtifact( groupId, artifactId, getVersion(), getPackaging(), getArtifactFilePath(), getRepositoryId(),
97 assertTextPresent( "Artifact '" + groupId + ":" + artifactId + ":" + getVersion()
98 + "' was successfully deployed to repository 'internal'" );
101 @Test( groups = "requiresUpload" )
102 public void testDotNetTypes()
104 String groupId = getProperty( "GROUPID_DOTNETARTIFACT" );
105 String artifactId = getProperty( "ARTIFACTID_DOTNETARTIFACT" );
106 String packaging = getProperty( "PACKAGING_DOTNETARTIFACT" );
108 addArtifact( groupId, artifactId, getVersion(), packaging, getArtifactFilePath(), getRepositoryId(), false );
109 assertTextPresent( "Artifact '" + groupId + ":" + artifactId + ":" + getVersion()
110 + "' was successfully deployed to repository 'internal'" );
111 getSelenium().open( baseUrl + "/browse/" + groupId + "/" + artifactId + "/" + getVersion() );
114 assertTextPresent( "<type>library</type>" );
116 "/archiva/repository/internal/" + groupId + "/" + artifactId + "/" + getVersion() + "/" + artifactId + "-"
118 assertLinkPresent( ".NET Library" );
119 assertElementPresent( "//a[@href='" + basePath + ".dll']" );
120 assertElementPresent( "//a[@href='" + basePath + ".pom']" );
124 @Test( groups = "requiresUpload" )
125 public void testAddArtifactBlockRedeployments()
127 addArtifact( getGroupId(), getArtifactId(), getVersion(), getPackaging(), getArtifactFilePath(),
128 getRepositoryId(), false );
129 assertTextPresent( "Overwriting released artifacts in repository '" + getRepositoryId() + "' is not allowed." );
132 @Test( groups = "requiresUpload" )
133 public void testDeleteArtifact()
136 String groupId = getProperty( "GROUPID1" );
137 String artifactId = getProperty( "ARTIFACTID1" );
138 String version = getProperty( "VERSION1" );
139 String packaging = getProperty( "PACKAGING1" );
140 String repositoryId = getProperty( "REPOSITORYID1" );
141 // TODO: do this differently as it only works in Firefox's chrome mode
142 addArtifact( groupId, artifactId, version, packaging, getArtifactFilePath(), repositoryId, false );
143 assertTextPresent( "Artifact 'delete:delete:1.0' was successfully deployed to repository 'internal'" );
145 deleteArtifact( "delete", "delete", "1.0", "internal" );
146 assertTextPresent( "Artifact 'delete:delete:1.0' was successfully deleted from repository 'internal'" );
149 @Test( alwaysRun = true, dependsOnMethods = { "testAddArtifactNullValues" } )
150 public void testDeleteArtifactNoGroupId()
152 deleteArtifact( " ", "delete", "1.0", "internal" );
153 assertTextPresent( "You must enter a groupId." );
156 @Test( alwaysRun = true, dependsOnMethods = { "testAddArtifactNullValues" } )
157 public void testDeleteArtifactNoArtifactId()
159 deleteArtifact( "delete", " ", "1.0", "internal" );
160 assertTextPresent( "You must enter an artifactId." );
163 @Test( alwaysRun = true, dependsOnMethods = { "testAddArtifactNullValues" } )
164 public void testDeleteArtifactNoVersion()
166 deleteArtifact( "delete", "delete", " ", "internal", false );
167 assertTextPresent( "You must enter a version." );
170 @Test( alwaysRun = true, dependsOnMethods = { "testAddArtifactNullValues" } )
171 public void testDeleteArtifactInvalidVersion()
173 deleteArtifact( "delete", "delete", "asdf", "internal", true );
174 assertTextPresent( "Invalid version." );
177 // HTML select should have the proper value, else it will cause a selenium error: Option with label 'customValue' not found
178 @Test( alwaysRun = true, dependsOnMethods = { "testAddArtifactNullValues" } )
179 public void testDeleteArtifactInvalidValues()
181 deleteArtifact( "<> \\/~+[ ]'\"", "<> \\/~+[ ]'\"", "<>", "internal" );
183 "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
185 "Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
186 // as it's a validation on server side it's not available here but tested in testDeleteArtifactInvalidVersion
187 //assertTextPresent( "Invalid version." );
191 @Test( alwaysRun = true, dependsOnMethods = { "testAddArtifactNullValues" } )
192 public void testDeleteArtifactInvalidGroupId()
194 deleteArtifact( "<> \\/~+[ ]'\"", "delete", "1.0", "internal" );
196 "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
199 @Test( alwaysRun = true, dependsOnMethods = { "testAddArtifactNullValues" } )
200 public void testDeleteArtifactInvalidArtifactId()
202 deleteArtifact( "delete", "<> \\/~+[ ]'\"", "1.0", "internal" );
204 "Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );