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", enabled = false )
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(), true );
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 // FIXME: currently broken - is dotnet-library
119 assertLinkPresent( ".NET Library" );
120 assertElementPresent( "//a[@href='" + basePath + ".dll']" );
121 assertElementPresent( "//a[@href='" + basePath + ".pom']" );
125 @Test( groups = "requiresUpload" )
126 public void testAddArtifactBlockRedeployments()
128 addArtifact( getGroupId(), getArtifactId(), getVersion(), getPackaging(), getArtifactFilePath(),
129 getRepositoryId(), true );
130 assertTextPresent( "Overwriting released artifacts in repository '" + getRepositoryId() + "' is not allowed." );
133 @Test( groups = "requiresUpload" )
134 public void testDeleteArtifact()
137 String groupId = getProperty( "GROUPID1" );
138 String artifactId = getProperty( "ARTIFACTID1" );
139 String version = getProperty( "VERSION1" );
140 String packaging = getProperty( "PACKAGING1" );
141 String repositoryId = getProperty( "REPOSITORYID1" );
142 // TODO: do this differently as it only works in Firefox's chrome mode
143 addArtifact( groupId, artifactId, version, packaging, getArtifactFilePath(), repositoryId, true );
144 assertTextPresent( "Artifact 'delete:delete:1.0' was successfully deployed to repository 'internal'" );
146 deleteArtifact( "delete", "delete", "1.0", "internal", true );
147 assertTextPresent( "Artifact 'delete:delete:1.0' was successfully deleted from repository 'internal'" );
150 @Test( alwaysRun = true, dependsOnMethods = { "testAddArtifactNullValues" } )
151 public void testDeleteArtifactNoGroupId()
153 deleteArtifact( " ", "delete", "1.0", "internal" );
154 assertTextPresent( "You must enter a groupId." );
157 @Test( alwaysRun = true, dependsOnMethods = { "testAddArtifactNullValues" } )
158 public void testDeleteArtifactNoArtifactId()
160 deleteArtifact( "delete", " ", "1.0", "internal" );
161 assertTextPresent( "You must enter an artifactId." );
164 @Test( alwaysRun = true, dependsOnMethods = { "testAddArtifactNullValues" } )
165 public void testDeleteArtifactNoVersion()
167 deleteArtifact( "delete", "delete", " ", "internal", false );
168 assertTextPresent( "You must enter a version." );
171 @Test( alwaysRun = true, dependsOnMethods = { "testAddArtifactNullValues" } )
172 public void testDeleteArtifactInvalidVersion()
174 deleteArtifact( "delete", "delete", "asdf", "internal", true );
175 assertTextPresent( "Invalid version." );
178 // HTML select should have the proper value, else it will cause a selenium error: Option with label 'customValue' not found
179 @Test( alwaysRun = true, dependsOnMethods = { "testAddArtifactNullValues" } )
180 public void testDeleteArtifactInvalidValues()
182 deleteArtifact( "<> \\/~+[ ]'\"", "<> \\/~+[ ]'\"", "<>", "internal" );
184 "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
186 "Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
187 // as it's a validation on server side it's not available here but tested in testDeleteArtifactInvalidVersion
188 //assertTextPresent( "Invalid version." );
192 @Test( alwaysRun = true, dependsOnMethods = { "testAddArtifactNullValues" } )
193 public void testDeleteArtifactInvalidGroupId()
195 deleteArtifact( "<> \\/~+[ ]'\"", "delete", "1.0", "internal" );
197 "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
200 @Test( alwaysRun = true, dependsOnMethods = { "testAddArtifactNullValues" } )
201 public void testDeleteArtifactInvalidArtifactId()
203 deleteArtifact( "delete", "<> \\/~+[ ]'\"", "1.0", "internal" );
205 "Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );