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.AbstractBrowseTest;
23 import org.testng.Assert;
24 import org.testng.annotations.Test;
28 @Test( groups = { "browse" }, dependsOnMethods = { "testAddArtifactNullValues" } )
29 public class BrowseTest
30 extends AbstractBrowseTest
32 public void testBrowseArtifactPageTabs()
35 clickLinkWithText( getProperty( "ARTIFACT_GROUPID" ) + "/" );
36 clickLinkWithText( getProperty( "ARTIFACT_ARTIFACTID" ) + "/" );
37 clickLinkWithText( getProperty( "ARTIFACT_VERSION" ) + "/" );
39 assertTextPresent( "Info" );
40 assertTextPresent( "Dependencies" );
41 assertTextPresent( "Dependency Tree" );
42 assertTextPresent( "Used By" );
43 assertTextPresent( "Mailing Lists" );
44 assertTextPresent( "Metadata" );
47 public void testBrowseArtifact()
53 @Test( dependsOnMethods = { "testAddArtifactValidValues" }, groups = { "requiresUpload" } )
54 public void testClickArtifactFromBrowse()
58 clickLinkWithText( getProperty( "ARTIFACT_ARTIFACTID" ) + "/" );
59 assertPage( "Apache Archiva \\ Browse Repository" );
60 assertTextPresent( "Artifacts" );
64 @Test( groups = { "requiresUpload" } )
65 public void testCorrectRepositoryInBrowse()
67 String releasesRepo = getProperty( "RELEASES_REPOSITORY" );
69 // create releases repository first
70 goToRepositoriesPage();
71 clickLinkWithText( "Add" );
72 addManagedRepository( getProperty( "RELEASES_REPOSITORY" ), "Releases Repository",
73 new File( getBasedir(), "target/repository/releases" ).getPath(), "",
74 "Maven 2.x Repository", "0 0 * * * ?", "", "", true );
75 assertTextPresent( "Releases Repository" );
77 String snapshotsRepo = getProperty( "SNAPSHOTS_REPOSITORY" );
80 "src/test/resources/snapshots/org/apache/maven/archiva/web/test/foo-bar/1.0-SNAPSHOT/foo-bar-1.0-SNAPSHOT.jar";
81 // TODO: do this differently as uploading doesn't work on browsers other than *chrome (below as well)
82 // upload a snapshot artifact to repository 'releases'
83 addArtifact( "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar", path, releasesRepo, true );
85 "Artifact 'archiva:archiva-webapp:1.0-SNAPSHOT' was successfully deployed to repository '" + releasesRepo
90 assertGroupsPage( "archiva/" );
91 assertArtifactsPage( "archiva-webapp/" );
92 assertArtifactInfoPage( "1.0-SNAPSHOT/", releasesRepo, "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar" );
94 // upload a snapshot artifact to repository 'snapshots'
95 addArtifact( "continuum", "continuum-core", "1.0-SNAPSHOT", "jar", path, snapshotsRepo, true );
97 "Artifact 'continuum:continuum-core:1.0-SNAPSHOT' was successfully deployed to repository '" + snapshotsRepo
102 assertGroupsPage( "continuum/" );
103 assertArtifactsPage( "continuum-core/" );
104 assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "continuum", "continuum-core", "1.0-SNAPSHOT", "jar" );
108 @Test( groups = { "requiresUpload" } )
109 public void testBuildNumberOfSnapshotArtifact()
111 String snapshotsRepo = getProperty( "SNAPSHOTS_REPOSITORY" );
114 "src/test/resources/snapshots/org/apache/maven/archiva/web/test/foo-bar/1.0-SNAPSHOT/foo-bar-1.0-SNAPSHOT.jar";
115 // TODO: do this differently as uploading doesn't work on browsers other than *chrome (below as well)
116 // upload a snapshot artifact to repository 'releases'
117 addArtifact( "archiva", "archiva-multiple-artifacts", "1.0-SNAPSHOT", "jar", path, snapshotsRepo, true );
119 "Artifact 'archiva:archiva-multiple-artifacts:1.0-SNAPSHOT' was successfully deployed to repository '"
120 + snapshotsRepo + "'" );
124 assertGroupsPage( "archiva/" );
125 assertArtifactsPage( "archiva-multiple-artifacts/" );
126 assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "archiva", "archiva-multiple-artifacts", "1.0-SNAPSHOT",
129 addArtifact( "archiva", "archiva-multiple-artifacts", "1.0-SNAPSHOT", "jar", path, snapshotsRepo, true );
131 "Artifact 'archiva:archiva-multiple-artifacts:1.0-SNAPSHOT' was successfully deployed to repository '"
132 + snapshotsRepo + "'" );
136 assertGroupsPage( "archiva/" );
137 assertArtifactsPage( "archiva-multiple-artifacts/" );
138 assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "archiva", "archiva-multiple-artifacts", "1.0-SNAPSHOT",
141 String firstSnapshotVersion = getText( "//div[@id='download']/div[@id='accordion']/p[2]/a/" );
142 Assert.assertTrue( firstSnapshotVersion.endsWith( "-1" ) );
144 String secondSnapshotVersion = getText( "//div[@id='download']/div[@id='accordion']/p[1]/a/" );
145 Assert.assertTrue( secondSnapshotVersion.endsWith( "-2" ) );
148 public void testAddMetadataPropertyEmpty()
151 clickLinkWithText( getProperty( "ARTIFACT_GROUPID" ) + "/" );
152 clickLinkWithText( getProperty( "ARTIFACT_ARTIFACTID" ) + "/" );
153 clickLinkWithText( getProperty( "ARTIFACT_VERSION" ) + "/" );
154 clickLinkWithText( "Metadata" );
156 assertTextPresent( "No metadata content." );
157 assertButtonWithValuePresent( "Add" );
159 clickButtonWithValue( "Add" );
163 assertTextPresent( "Property Name and Property Value are required." );
166 @Test( dependsOnMethods = { "testAddMetadataPropertyEmpty" } )
167 public void testAddMetadataProperty()
169 addMetadataProperty();
172 @Test( dependsOnMethods = { "testAddMetadataProperty" } )
173 public void testDeleteMetadataProperty()
175 deleteMetadataProperty();
178 @Test( dependsOnMethods = { "testDeleteMetadataProperty" } )
179 public void testMetadataAccessWithRepositoryObserverRole()
181 addMetadataProperty();
186 clickLinkWithText( getProperty( "ARTIFACT_GROUPID" ) + "/" );
187 clickLinkWithText( getProperty( "ARTIFACT_ARTIFACTID" ) + "/" );
188 clickLinkWithText( getProperty( "ARTIFACT_VERSION" ) + "/" );
189 clickLinkWithText( "Metadata" );
193 assertTextNotPresent( "No metadata content." );
194 assertButtonWithValueNotPresent( "Add" );
195 assertTextNotPresent( "Add Property" );
196 assertImgWithAltNotPresent( "Delete" );
198 login( getAdminUsername(), getAdminPassword() );
200 deleteMetadataProperty();
203 private void addMetadataProperty()
206 clickLinkWithText( getProperty( "ARTIFACT_GROUPID" ) + "/" );
207 clickLinkWithText( getProperty( "ARTIFACT_ARTIFACTID" ) + "/" );
208 clickLinkWithText( getProperty( "ARTIFACT_VERSION" ) + "/" );
209 clickLinkWithText( "Metadata" );
211 assertTextPresent( "No metadata content." );
212 assertButtonWithValuePresent( "Add" );
213 assertTextPresent( "Add Property" );
215 setFieldValue( "propertyName", "foo" );
216 setFieldValue( "propertyValue", "bar" );
218 clickButtonWithValue( "Add" );
222 assertTextNotPresent( "No metadata content." );
223 assertTextPresent( "foo=bar" );
226 private void deleteMetadataProperty()
229 clickLinkWithText( getProperty( "ARTIFACT_GROUPID" ) + "/" );
230 clickLinkWithText( getProperty( "ARTIFACT_ARTIFACTID" ) + "/" );
231 clickLinkWithText( getProperty( "ARTIFACT_VERSION" ) + "/" );
232 clickLinkWithText( "Metadata" );
234 assertTextPresent( "foo=bar" );
235 assertButtonWithValuePresent( "Add" );
236 assertTextPresent( "Add Property" );
238 clickImgWithAlt( "Delete" );
242 assertTextNotPresent( "foo=bar" );
243 assertTextPresent( "Property successfully deleted." );
244 assertImgWithAltNotPresent( "Delete" );
245 assertTextPresent( "No metadata content." );
248 private void assertArtifactInfoPage( String version, String artifactInfoRepositoryId, String artifactInfoGroupId,
249 String artifactInfoArtifactId, String artifactInfoVersion,
250 String artifactInfoPackaging )
252 clickLinkWithText( version );
253 assertPage( "Apache Archiva \\ Browse Repository" );
254 assertTextPresent( artifactInfoRepositoryId );
255 assertTextPresent( artifactInfoGroupId );
256 assertTextPresent( artifactInfoArtifactId );
257 assertTextPresent( artifactInfoVersion );
258 assertTextPresent( artifactInfoPackaging );
261 private void assertArtifactsPage( String artifactId )
263 clickLinkWithText( artifactId );
264 assertPage( "Apache Archiva \\ Browse Repository" );
265 assertTextPresent( "Versions" );
268 private void assertGroupsPage( String groupId )
270 clickLinkWithText( groupId );
271 assertPage( "Apache Archiva \\ Browse Repository" );
272 assertTextPresent( "Artifacts" );