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
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 public void testClickArtifactFromBrowse()
57 clickLinkWithText( getProperty( "ARTIFACT_ARTIFACTID" ) + "/" );
58 assertPage( "Apache Archiva \\ Browse Repository" );
59 assertTextPresent( "Artifacts" );
63 @Test( groups = { "requiresUpload" } )
64 public void testCorrectRepositoryInBrowse()
66 String releasesRepo = getProperty( "RELEASES_REPOSITORY" );
68 // create releases repository first
69 goToRepositoriesPage();
70 clickLinkWithText( "Add" );
71 addManagedRepository( getProperty( "RELEASES_REPOSITORY" ), "Releases Repository",
72 new File( getBasedir(), "target/repository/releases" ).getPath(), "",
73 "Maven 2.x Repository", "0 0 * * * ?", "", "" );
74 assertTextPresent( "Releases Repository" );
76 String snapshotsRepo = getProperty( "SNAPSHOTS_REPOSITORY" );
79 "src/test/resources/snapshots/org/apache/maven/archiva/web/test/foo-bar/1.0-SNAPSHOT/foo-bar-1.0-SNAPSHOT.jar";
80 // TODO: do this differently as uploading doesn't work on browsers other than *chrome (below as well)
81 // upload a snapshot artifact to repository 'releases'
82 addArtifact( "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar", path, releasesRepo );
83 assertTextPresent( "Artifact 'archiva:archiva-webapp:1.0-SNAPSHOT' was successfully deployed to repository '"
84 + releasesRepo + "'" );
88 assertGroupsPage( "archiva/" );
89 assertArtifactsPage( "archiva-webapp/" );
90 assertArtifactInfoPage( "1.0-SNAPSHOT/", releasesRepo, "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar" );
92 // upload a snapshot artifact to repository 'snapshots'
93 addArtifact( "continuum", "continuum-core", "1.0-SNAPSHOT", "jar", path, snapshotsRepo );
94 assertTextPresent( "Artifact 'continuum:continuum-core:1.0-SNAPSHOT' was successfully deployed to repository '"
95 + snapshotsRepo + "'" );
99 assertGroupsPage( "continuum/" );
100 assertArtifactsPage( "continuum-core/" );
101 assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "continuum", "continuum-core", "1.0-SNAPSHOT", "jar" );
105 @Test( groups = { "requiresUpload" } )
106 public void testBuildNumberOfSnapshotArtifact()
108 String snapshotsRepo = getProperty( "SNAPSHOTS_REPOSITORY" );
111 "src/test/resources/snapshots/org/apache/maven/archiva/web/test/foo-bar/1.0-SNAPSHOT/foo-bar-1.0-SNAPSHOT.jar";
112 // TODO: do this differently as uploading doesn't work on browsers other than *chrome (below as well)
113 // upload a snapshot artifact to repository 'releases'
114 addArtifact( "archiva", "archiva-multiple-artifacts", "1.0-SNAPSHOT", "jar", path, snapshotsRepo );
115 assertTextPresent( "Artifact 'archiva:archiva-multiple-artifacts:1.0-SNAPSHOT' was successfully deployed to repository '"
116 + snapshotsRepo + "'" );
120 assertGroupsPage( "archiva/" );
121 assertArtifactsPage( "archiva-multiple-artifacts/" );
122 assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "archiva", "archiva-multiple-artifacts", "1.0-SNAPSHOT", "jar" );
125 addArtifact( "archiva", "archiva-multiple-artifacts", "1.0-SNAPSHOT", "jar", path, snapshotsRepo );
126 assertTextPresent( "Artifact 'archiva:archiva-multiple-artifacts:1.0-SNAPSHOT' was successfully deployed to repository '"
127 + snapshotsRepo + "'" );
131 assertGroupsPage( "archiva/" );
132 assertArtifactsPage( "archiva-multiple-artifacts/" );
133 assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "archiva", "archiva-multiple-artifacts", "1.0-SNAPSHOT", "jar" );
135 String firstSnapshotVersion = getText( "//div[@id='download']/div[@id='accordion']/p[2]/a/" );
136 Assert.assertTrue( firstSnapshotVersion.endsWith( "-1" ) );
138 String secondSnapshotVersion = getText( "//div[@id='download']/div[@id='accordion']/p[1]/a/" );
139 Assert.assertTrue( secondSnapshotVersion.endsWith( "-2" ) );
142 private void assertArtifactInfoPage( String version, String artifactInfoRepositoryId, String artifactInfoGroupId,
143 String artifactInfoArtifactId, String artifactInfoVersion,
144 String artifactInfoPackaging )
146 clickLinkWithText( version );
147 assertPage( "Apache Archiva \\ Browse Repository" );
148 assertTextPresent( artifactInfoRepositoryId );
149 assertTextPresent( artifactInfoGroupId );
150 assertTextPresent( artifactInfoArtifactId );
151 assertTextPresent( artifactInfoVersion );
152 assertTextPresent( artifactInfoPackaging );
155 private void assertArtifactsPage( String artifactId )
157 clickLinkWithText( artifactId );
158 assertPage( "Apache Archiva \\ Browse Repository" );
159 assertTextPresent( "Versions" );
162 private void assertGroupsPage( String groupId )
164 clickLinkWithText( groupId );
165 assertPage( "Apache Archiva \\ Browse Repository" );
166 assertTextPresent( "Artifacts" );