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
24 import org.apache.archiva.web.test.parent.AbstractBrowseTest;
25 import org.testng.Assert;
26 import org.testng.annotations.Test;
28 @Test( groups = { "browse" }, dependsOnMethods = { "testAddArtifactNullValues" } )
29 public class BrowseTest
30 extends AbstractBrowseTest
33 public void testBrowseArtifact()
39 public void testClickArtifactFromBrowse()
43 clickLinkWithText( getProperty( "ARTIFACT_ARTIFACTID" ) + "/" );
44 assertPage( "Apache Archiva \\ Browse Repository" );
45 assertTextPresent( "Artifacts" );
49 @Test( groups = { "requiresUpload" } )
50 public void testCorrectRepositoryInBrowse()
52 String releasesRepo = getProperty( "RELEASES_REPOSITORY" );
54 // create releases repository first
55 goToRepositoriesPage();
56 clickLinkWithText( "Add" );
57 addManagedRepository( getProperty( "RELEASES_REPOSITORY" ), "Releases Repository",
58 new File( getBasedir(), "target/repository/releases" ).getPath(), "",
59 "Maven 2.x Repository", "0 0 * * * ?", "", "" );
60 assertTextPresent( "Releases Repository" );
62 String snapshotsRepo = getProperty( "SNAPSHOTS_REPOSITORY" );
65 "src/test/resources/snapshots/org/apache/maven/archiva/web/test/foo-bar/1.0-SNAPSHOT/foo-bar-1.0-SNAPSHOT.jar";
66 // TODO: do this differently as uploading doesn't work on browsers other than *chrome (below as well)
67 // upload a snapshot artifact to repository 'releases'
68 addArtifact( "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar", path, releasesRepo );
69 assertTextPresent( "Artifact 'archiva:archiva-webapp:1.0-SNAPSHOT' was successfully deployed to repository '"
70 + releasesRepo + "'" );
74 assertGroupsPage( "archiva/" );
75 assertArtifactsPage( "archiva-webapp/" );
76 assertArtifactInfoPage( "1.0-SNAPSHOT/", releasesRepo, "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar" );
78 // upload a snapshot artifact to repository 'snapshots'
79 addArtifact( "continuum", "continuum-core", "1.0-SNAPSHOT", "jar", path, snapshotsRepo );
80 assertTextPresent( "Artifact 'continuum:continuum-core:1.0-SNAPSHOT' was successfully deployed to repository '"
81 + snapshotsRepo + "'" );
85 assertGroupsPage( "continuum/" );
86 assertArtifactsPage( "continuum-core/" );
87 assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "continuum", "continuum-core", "1.0-SNAPSHOT", "jar" );
91 @Test( groups = { "requiresUpload" } )
92 public void testBuildNumberOfSnapshotArtifact()
94 String snapshotsRepo = getProperty( "SNAPSHOTS_REPOSITORY" );
97 "src/test/resources/snapshots/org/apache/maven/archiva/web/test/foo-bar/1.0-SNAPSHOT/foo-bar-1.0-SNAPSHOT.jar";
98 // TODO: do this differently as uploading doesn't work on browsers other than *chrome (below as well)
99 // upload a snapshot artifact to repository 'releases'
100 addArtifact( "archiva", "archiva-multiple-artifacts", "1.0-SNAPSHOT", "jar", path, snapshotsRepo );
101 assertTextPresent( "Artifact 'archiva:archiva-multiple-artifacts:1.0-SNAPSHOT' was successfully deployed to repository '"
102 + snapshotsRepo + "'" );
106 assertGroupsPage( "archiva/" );
107 assertArtifactsPage( "archiva-multiple-artifacts/" );
108 assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "archiva", "archiva-multiple-artifacts", "1.0-SNAPSHOT", "jar" );
111 addArtifact( "archiva", "archiva-multiple-artifacts", "1.0-SNAPSHOT", "jar", path, snapshotsRepo );
112 assertTextPresent( "Artifact 'archiva:archiva-multiple-artifacts:1.0-SNAPSHOT' was successfully deployed to repository '"
113 + snapshotsRepo + "'" );
117 assertGroupsPage( "archiva/" );
118 assertArtifactsPage( "archiva-multiple-artifacts/" );
119 assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "archiva", "archiva-multiple-artifacts", "1.0-SNAPSHOT", "jar" );
121 String firstSnapshotVersion = getText( "//div[@id='download']/div[@id='accordion']/p[2]/a/" );
122 Assert.assertTrue( firstSnapshotVersion.endsWith( "-1" ) );
124 String secondSnapshotVersion = getText( "//div[@id='download']/div[@id='accordion']/p[1]/a/" );
125 Assert.assertTrue( secondSnapshotVersion.endsWith( "-2" ) );
128 private void assertArtifactInfoPage( String version, String artifactInfoRepositoryId, String artifactInfoGroupId,
129 String artifactInfoArtifactId, String artifactInfoVersion,
130 String artifactInfoPackaging )
132 clickLinkWithText( version );
133 assertPage( "Apache Archiva \\ Browse Repository" );
134 assertTextPresent( artifactInfoRepositoryId );
135 assertTextPresent( artifactInfoGroupId );
136 assertTextPresent( artifactInfoArtifactId );
137 assertTextPresent( artifactInfoVersion );
138 assertTextPresent( artifactInfoPackaging );
141 private void assertArtifactsPage( String artifactId )
143 clickLinkWithText( artifactId );
144 assertPage( "Apache Archiva \\ Browse Repository" );
145 assertTextPresent( "Versions" );
148 private void assertGroupsPage( String groupId )
150 clickLinkWithText( groupId );
151 assertPage( "Apache Archiva \\ Browse Repository" );
152 assertTextPresent( "Artifacts" );