]> source.dussan.org Git - archiva.git/blob
ea60aaee6d9390500ca9141313e223df9d65c630
[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(), "",
59                               "Maven 2.x Repository", "0 0 * * * ?", "", "" );
60         assertTextPresent( "Releases Repository" );
61
62         String snapshotsRepo = getProperty( "SNAPSHOTS_REPOSITORY" );
63
64         String path =
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 + "'" );
71
72         goToBrowsePage();
73         assertBrowsePage();
74         assertGroupsPage( "archiva/" );
75         assertArtifactsPage( "archiva-webapp/" );
76         assertArtifactInfoPage( "1.0-SNAPSHOT/", releasesRepo, "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar" );
77
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 + "'" );
82
83         goToBrowsePage();
84         assertBrowsePage();
85         assertGroupsPage( "continuum/" );
86         assertArtifactsPage( "continuum-core/" );
87         assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "continuum", "continuum-core", "1.0-SNAPSHOT", "jar" );
88     }
89
90     // MRM-1353
91     @Test( groups = { "requiresUpload" } )
92     public void testBuildNumberOfSnapshotArtifact()
93     {
94         String snapshotsRepo = getProperty( "SNAPSHOTS_REPOSITORY" );
95
96         String path =
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 + "'" );
103
104         goToBrowsePage();
105         assertBrowsePage();
106         assertGroupsPage( "archiva/" );
107         assertArtifactsPage( "archiva-multiple-artifacts/" );
108         assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "archiva", "archiva-multiple-artifacts", "1.0-SNAPSHOT", "jar" );
109
110
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 + "'" );
114
115         goToBrowsePage();
116         assertBrowsePage();
117         assertGroupsPage( "archiva/" );
118         assertArtifactsPage( "archiva-multiple-artifacts/" );
119         assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "archiva", "archiva-multiple-artifacts", "1.0-SNAPSHOT", "jar" );
120
121         String firstSnapshotVersion = getText( "//div[@id='download']/div[@id='accordion']/p[2]/a/" );
122         Assert.assertTrue( firstSnapshotVersion.endsWith( "-1" ) );
123
124         String secondSnapshotVersion = getText( "//div[@id='download']/div[@id='accordion']/p[1]/a/" );
125         Assert.assertTrue( secondSnapshotVersion.endsWith( "-2" ) );
126     }
127
128     private void assertArtifactInfoPage( String version, String artifactInfoRepositoryId, String artifactInfoGroupId,
129                                          String artifactInfoArtifactId, String artifactInfoVersion,
130                                          String artifactInfoPackaging )
131     {
132         clickLinkWithText( version );
133         assertPage( "Apache Archiva \\ Browse Repository" );
134         assertTextPresent( artifactInfoRepositoryId );
135         assertTextPresent( artifactInfoGroupId );
136         assertTextPresent( artifactInfoArtifactId );
137         assertTextPresent( artifactInfoVersion );
138         assertTextPresent( artifactInfoPackaging );
139     }
140
141     private void assertArtifactsPage( String artifactId )
142     {
143         clickLinkWithText( artifactId );
144         assertPage( "Apache Archiva \\ Browse Repository" );
145         assertTextPresent( "Versions" );
146     }
147
148     private void assertGroupsPage( String groupId )
149     {
150         clickLinkWithText( groupId );
151         assertPage( "Apache Archiva \\ Browse Repository" );
152         assertTextPresent( "Artifacts" );
153     }
154 }