]> source.dussan.org Git - archiva.git/blob
7d9c27f94c6547c7e90c9f862f348a6ab278a978
[archiva.git] /
1 package org.apache.archiva.web.test;
2
3 /*
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
11  *
12  *   http://www.apache.org/licenses/LICENSE-2.0
13  *
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
19  * under the License.
20  */
21
22 import java.io.File;
23
24 import org.apache.archiva.web.test.parent.AbstractBrowseTest;
25 import org.testng.Assert;
26 import org.testng.annotations.Test;
27
28 @Test( groups = { "browse" }, dependsOnMethods = { "testAddArtifactNullValues" } )
29 public class BrowseTest 
30         extends AbstractBrowseTest
31 {
32         
33         public void testBrowseArtifact()
34         {
35                 goToBrowsePage();
36                 assertBrowsePage();
37         }
38         
39         public void testClickArtifactFromBrowse()
40         {
41                 goToBrowsePage();
42                 assertBrowsePage();
43                 clickLinkWithText( getProperty( "ARTIFACT_ARTIFACTID" ) + "/" );
44                 assertPage( "Apache Archiva \\ Browse Repository" );
45                 assertTextPresent( "Artifacts" );
46         }
47
48     // MRM-1278
49     @Test(groups = {"requiresUpload"})
50     public void testCorrectRepositoryInBrowse()
51     {
52         String releasesRepo = getProperty( "RELEASES_REPOSITORY" );
53         
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" );
61         
62         String snapshotsRepo = getProperty( "SNAPSHOTS_REPOSITORY" );
63
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 + "'" );
69
70         goToBrowsePage();
71         assertBrowsePage();
72         assertGroupsPage( "archiva/" );
73         assertArtifactsPage( "archiva-webapp/" );
74         assertArtifactInfoPage( "1.0-SNAPSHOT/", releasesRepo, "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar" );
75
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 + "'" );
79
80         goToBrowsePage();
81         assertBrowsePage();
82         assertGroupsPage( "continuum/" );
83         assertArtifactsPage( "continuum-core/" );
84         assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "continuum", "continuum-core", "1.0-SNAPSHOT", "jar" );
85     }
86
87     // MRM-1353
88     @Test( groups = { "requiresUpload" } )
89     public void testBuildNumberOfSnapshotArtifact()
90     {
91         String snapshotsRepo = getProperty( "SNAPSHOTS_REPOSITORY" );
92
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 + "'" );
99
100         goToBrowsePage();
101         assertBrowsePage();
102         assertGroupsPage( "archiva/" );
103         assertArtifactsPage( "archiva-multiple-artifacts/" );
104         assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "archiva", "archiva-multiple-artifacts", "1.0-SNAPSHOT", "jar" );
105
106
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 + "'" );
110
111         goToBrowsePage();
112         assertBrowsePage();
113         assertGroupsPage( "archiva/" );
114         assertArtifactsPage( "archiva-multiple-artifacts/" );
115         assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "archiva", "archiva-multiple-artifacts", "1.0-SNAPSHOT", "jar" );
116
117         String firstSnapshotVersion = getText( "//div[@id='tabArea']/table[@class='infoTable']/tbody/tr[6]/td/a[1]" );
118         Assert.assertTrue( firstSnapshotVersion.endsWith( "-1" ) );
119
120         String secondSnapshotVersion = getText( "//div[@id='tabArea']/table[@class='infoTable']/tbody/tr[6]/td/a[2]" );
121         Assert.assertTrue( secondSnapshotVersion.endsWith( "-2" ) );
122     }
123
124     private void assertArtifactInfoPage( String version, String artifactInfoRepositoryId, String artifactInfoGroupId,
125                                          String artifactInfoArtifactId, String artifactInfoVersion, String artifactInfoPackaging )
126     {
127         clickLinkWithText( version );
128         assertPage( "Apache Archiva \\ Browse Repository" );
129         assertTextPresent( artifactInfoRepositoryId );
130         assertTextPresent( artifactInfoGroupId );
131         assertTextPresent( artifactInfoArtifactId );
132         assertTextPresent( artifactInfoVersion );
133         assertTextPresent( artifactInfoPackaging );
134     }
135
136     private void assertArtifactsPage( String artifactId )
137     {
138         clickLinkWithText( artifactId );
139         assertPage( "Apache Archiva \\ Browse Repository" );
140         assertTextPresent( "Versions" );
141     }
142
143     private void assertGroupsPage( String groupId )
144     {
145         clickLinkWithText( groupId );
146         assertPage( "Apache Archiva \\ Browse Repository" );
147         assertTextPresent( "Artifacts" );
148     }
149 }