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" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
26 public class ArtifactManagementTest
27 extends AbstractArtifactManagementTest
31 public void testAddArtifactNullValues()
33 goToAddArtifactPage();
34 clickButtonWithValue( "Submit" );
35 assertTextPresent( "Please add a file to upload." );
36 assertTextPresent( "Invalid 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" } )
44 public void testAddArtifactNoGroupId()
46 addArtifact( " " , getArtifactId(), getVersion(), getPackaging() , getArtifactFilePath(), getRepositoryId() );
47 assertTextPresent( "You must enter a groupId." );
50 @Test(dependsOnMethods = { "testAddArtifactNoGroupId" } )
51 public void testAddArtifactNoArtifactId()
54 addArtifact( getGroupId() , " ", getVersion(), getPackaging() , getArtifactFilePath(), getRepositoryId() );
55 assertTextPresent( "You must enter an artifactId." );
58 @Test(dependsOnMethods = { "testAddArtifactNoGroupId" } )
59 public void testAddArtifactNoVersion()
61 addArtifact( getGroupId() , getArtifactId(), " ", getPackaging() , getArtifactFilePath(), getRepositoryId() );
62 assertTextPresent( "You must enter a version." );
65 @Test(dependsOnMethods = { "testAddArtifactNoGroupId" } )
66 public void testAddArtifactInvalidVersion()
68 addArtifact( getGroupId() , getArtifactId(), "asdf", getPackaging() , getArtifactFilePath(), getRepositoryId() );
69 assertTextPresent( "Invalid version." );
72 @Test(dependsOnMethods = { "testAddArtifactNoGroupId" } )
73 public void testAddArtifactNoPackaging()
75 addArtifact( getGroupId() , getArtifactId(), getVersion(), " " , getArtifactFilePath(), getRepositoryId() );
76 assertTextPresent( "You must enter a packaging." );
79 @Test(dependsOnMethods = { "testAddArtifactNoGroupId" } )
80 public void testAddArtifactNoFilePath()
82 addArtifact( getGroupId() , getArtifactId(), getVersion(), getPackaging() , " ", getRepositoryId() );
83 assertTextPresent( "Please add a file to upload." );
86 @Test(groups = "requiresUpload")
87 public void testAddArtifactValidValues()
89 String groupId = getProperty( "VALIDARTIFACT_GROUPID" );
90 String artifactId = getProperty( "VALIDARTIFACT_ARTIFACTID" );
92 addArtifact( groupId , artifactId, getVersion(), getPackaging() , getArtifactFilePath(), getRepositoryId() );
93 assertTextPresent( "Artifact '" + groupId + ":" + artifactId + ":" + getVersion() + "' was successfully deployed to repository 'internal'" );
96 @Test( groups = "requiresUpload" )
97 public void testDotNetTypes()
99 String groupId = getProperty( "GROUPID_DOTNETARTIFACT" );
100 String artifactId = getProperty( "ARTIFACTID_DOTNETARTIFACT" );
101 String packaging = getProperty ( "PACKAGING_DOTNETARTIFACT" );
103 addArtifact( groupId, artifactId, getVersion(), packaging, getArtifactFilePath(),
105 assertTextPresent( "Artifact '" + groupId + ":" + artifactId + ":" + getVersion() + "' was successfully deployed to repository 'internal'" );
106 getSelenium().open( baseUrl + "/browse/" + groupId + "/" + artifactId + "/" + getVersion() );
109 assertTextPresent( "<type>library</type>" );
111 "/archiva/repository/internal/" + groupId + "/" + artifactId + "/" + getVersion() + "/dotNetTypes-" +
113 assertLinkPresent( ".NET Library" );
114 assertElementPresent( "//a[@href='" + basePath + ".dll']" );
115 assertElementPresent( "//a[@href='" + basePath + ".pom']" );
119 @Test(groups = "requiresUpload")
120 public void testAddArtifactBlockRedeployments()
122 addArtifact( getGroupId() , getArtifactId(), getVersion(), getPackaging() , getArtifactFilePath(), getRepositoryId() );
123 assertTextPresent( "Overwriting released artifacts in repository '" + getRepositoryId() + "' is not allowed." );
126 @Test(groups = "requiresUpload")
127 public void testDeleteArtifact()
130 String groupId = getProperty( "GROUPID1" );
131 String artifactId = getProperty( "ARTIFACTID1" );
132 String version = getProperty( "VERSION1" );
133 String packaging = getProperty( "PACKAGING1" );
134 String repositoryId = getProperty( "REPOSITORYID1" );
135 // TODO: do this differently as it only works in Firefox's chrome mode
136 addArtifact( groupId , artifactId, version, packaging , getArtifactFilePath(), repositoryId );
137 assertTextPresent( "Artifact 'delete:delete:1.0' was successfully deployed to repository 'internal'" );
139 deleteArtifact( "delete", "delete", "1.0", "internal");
140 assertTextPresent( "Artifact 'delete:delete:1.0' was successfully deleted from repository 'internal'" );
143 public void testDeleteArtifactNoGroupId()
145 deleteArtifact( " ", "delete", "1.0", "internal");
146 assertTextPresent( "You must enter a groupId." );
149 public void testDeleteArtifactNoArtifactId()
151 deleteArtifact( "delete", " ", "1.0", "internal");
152 assertTextPresent( "You must enter an artifactId." );
155 public void testDeleteArtifactNoVersion()
157 deleteArtifact( "delete", "delete", " ", "internal");
158 assertTextPresent( "Invalid version." );
159 assertTextPresent( "You must enter a version." );
162 public void testDeleteArtifactInvalidVersion()
164 deleteArtifact( "delete", "delete", "asdf", "internal");
165 assertTextPresent( "Invalid version." );