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(), "", "Maven 2.x Repository",
59 "0 0 * * * ?", "", "" );
60 assertTextPresent( "Releases Repository" );
62 String snapshotsRepo = getProperty( "SNAPSHOTS_REPOSITORY" );
64 String path = "src/test/it-resources/snapshots/org/apache/maven/archiva/web/test/foo-bar/1.0-SNAPSHOT/foo-bar-1.0-SNAPSHOT.jar";
65 // TODO: do this differently as uploading doesn't work on browsers other than *chrome (below as well)
66 // upload a snapshot artifact to repository 'releases'
67 addArtifact( "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar", path, releasesRepo );
68 assertTextPresent( "Artifact 'archiva:archiva-webapp:1.0-SNAPSHOT' was successfully deployed to repository '" + releasesRepo + "'" );
72 assertGroupsPage( "archiva/" );
73 assertArtifactsPage( "archiva-webapp/" );
74 assertArtifactInfoPage( "1.0-SNAPSHOT/", releasesRepo, "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar" );
76 // upload a snapshot artifact to repository 'snapshots'
77 addArtifact( "continuum", "continuum-core", "1.0-SNAPSHOT", "jar", path, snapshotsRepo );
78 assertTextPresent( "Artifact 'continuum:continuum-core:1.0-SNAPSHOT' was successfully deployed to repository '" + snapshotsRepo + "'" );
82 assertGroupsPage( "continuum/" );
83 assertArtifactsPage( "continuum-core/" );
84 assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "continuum", "continuum-core", "1.0-SNAPSHOT", "jar" );
88 @Test( groups = { "requiresUpload" } )
89 public void testBuildNumberOfSnapshotArtifact()
91 String snapshotsRepo = getProperty( "SNAPSHOTS_REPOSITORY" );
93 String path = "src/test/it-resources/snapshots/org/apache/maven/archiva/web/test/foo-bar/1.0-SNAPSHOT/foo-bar-1.0-SNAPSHOT.jar";
94 // TODO: do this differently as uploading doesn't work on browsers other than *chrome (below as well)
95 // upload a snapshot artifact to repository 'releases'
96 addArtifact( "archiva", "archiva-multiple-artifacts", "1.0-SNAPSHOT", "jar", path, snapshotsRepo );
97 assertTextPresent( "Artifact 'archiva:archiva-multiple-artifacts:1.0-SNAPSHOT' was successfully deployed to repository '"
98 + snapshotsRepo + "'" );
102 assertGroupsPage( "archiva/" );
103 assertArtifactsPage( "archiva-multiple-artifacts/" );
104 assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "archiva", "archiva-multiple-artifacts", "1.0-SNAPSHOT", "jar" );
107 addArtifact( "archiva", "archiva-multiple-artifacts", "1.0-SNAPSHOT", "jar", path, snapshotsRepo );
108 assertTextPresent( "Artifact 'archiva:archiva-multiple-artifacts:1.0-SNAPSHOT' was successfully deployed to repository '"
109 + snapshotsRepo + "'" );
113 assertGroupsPage( "archiva/" );
114 assertArtifactsPage( "archiva-multiple-artifacts/" );
115 assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "archiva", "archiva-multiple-artifacts", "1.0-SNAPSHOT", "jar" );
117 String firstSnapshotVersion = getText( "//div[@id='tabArea']/table[@class='infoTable']/tbody/tr[6]/td/a[1]" );
118 Assert.assertTrue( firstSnapshotVersion.endsWith( "-1" ) );
120 String secondSnapshotVersion = getText( "//div[@id='tabArea']/table[@class='infoTable']/tbody/tr[6]/td/a[2]" );
121 Assert.assertTrue( secondSnapshotVersion.endsWith( "-2" ) );
124 private void assertArtifactInfoPage( String version, String artifactInfoRepositoryId, String artifactInfoGroupId,
125 String artifactInfoArtifactId, String artifactInfoVersion, String artifactInfoPackaging )
127 clickLinkWithText( version );
128 assertPage( "Apache Archiva \\ Browse Repository" );
129 assertTextPresent( artifactInfoRepositoryId );
130 assertTextPresent( artifactInfoGroupId );
131 assertTextPresent( artifactInfoArtifactId );
132 assertTextPresent( artifactInfoVersion );
133 assertTextPresent( artifactInfoPackaging );
136 private void assertArtifactsPage( String artifactId )
138 clickLinkWithText( artifactId );
139 assertPage( "Apache Archiva \\ Browse Repository" );
140 assertTextPresent( "Versions" );
143 private void assertGroupsPage( String groupId )
145 clickLinkWithText( groupId );
146 assertPage( "Apache Archiva \\ Browse Repository" );
147 assertTextPresent( "Artifacts" );