]> source.dussan.org Git - archiva.git/blob
5226f78e2960cd36c30b07a2c08da630079ced98
[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     public void testBrowseArtifactPageTabs()
33     {
34         goToBrowsePage();
35         clickLinkWithText( getProperty( "ARTIFACT_GROUPID" ) + "/" );
36         clickLinkWithText( getProperty( "ARTIFACT_ARTIFACTID" ) + "/" );
37         clickLinkWithText( getProperty( "ARTIFACT_VERSION" ) + "/" );
38         
39         assertTextPresent( "Info" );
40         assertTextPresent( "Dependencies" );
41         assertTextPresent( "Dependency Tree" );
42         assertTextPresent( "Used By" );
43         assertTextPresent( "Mailing Lists" );
44         assertTextPresent( "Metadata" );
45     }
46
47     public void testBrowseArtifact()
48     {
49         goToBrowsePage();
50         assertBrowsePage();
51     }
52
53     public void testClickArtifactFromBrowse()
54     {
55         goToBrowsePage();
56         assertBrowsePage();
57         clickLinkWithText( getProperty( "ARTIFACT_ARTIFACTID" ) + "/" );
58         assertPage( "Apache Archiva \\ Browse Repository" );
59         assertTextPresent( "Artifacts" );
60     }
61
62     // MRM-1278
63     @Test( groups = { "requiresUpload" } )
64     public void testCorrectRepositoryInBrowse()
65     {
66         String releasesRepo = getProperty( "RELEASES_REPOSITORY" );
67
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" );
75
76         String snapshotsRepo = getProperty( "SNAPSHOTS_REPOSITORY" );
77
78         String path =
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 + "'" );
85
86         goToBrowsePage();
87         assertBrowsePage();
88         assertGroupsPage( "archiva/" );
89         assertArtifactsPage( "archiva-webapp/" );
90         assertArtifactInfoPage( "1.0-SNAPSHOT/", releasesRepo, "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar" );
91
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 + "'" );
96
97         goToBrowsePage();
98         assertBrowsePage();
99         assertGroupsPage( "continuum/" );
100         assertArtifactsPage( "continuum-core/" );
101         assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "continuum", "continuum-core", "1.0-SNAPSHOT", "jar" );
102     }
103
104     // MRM-1353
105     @Test( groups = { "requiresUpload" } )
106     public void testBuildNumberOfSnapshotArtifact()
107     {
108         String snapshotsRepo = getProperty( "SNAPSHOTS_REPOSITORY" );
109
110         String path =
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 + "'" );
117
118         goToBrowsePage();
119         assertBrowsePage();
120         assertGroupsPage( "archiva/" );
121         assertArtifactsPage( "archiva-multiple-artifacts/" );
122         assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "archiva", "archiva-multiple-artifacts", "1.0-SNAPSHOT", "jar" );
123
124
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 + "'" );
128
129         goToBrowsePage();
130         assertBrowsePage();
131         assertGroupsPage( "archiva/" );
132         assertArtifactsPage( "archiva-multiple-artifacts/" );
133         assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "archiva", "archiva-multiple-artifacts", "1.0-SNAPSHOT", "jar" );
134
135         String firstSnapshotVersion = getText( "//div[@id='download']/div[@id='accordion']/p[2]/a/" );
136         Assert.assertTrue( firstSnapshotVersion.endsWith( "-1" ) );
137
138         String secondSnapshotVersion = getText( "//div[@id='download']/div[@id='accordion']/p[1]/a/" );
139         Assert.assertTrue( secondSnapshotVersion.endsWith( "-2" ) );
140     }
141
142     private void assertArtifactInfoPage( String version, String artifactInfoRepositoryId, String artifactInfoGroupId,
143                                          String artifactInfoArtifactId, String artifactInfoVersion,
144                                          String artifactInfoPackaging )
145     {
146         clickLinkWithText( version );
147         assertPage( "Apache Archiva \\ Browse Repository" );
148         assertTextPresent( artifactInfoRepositoryId );
149         assertTextPresent( artifactInfoGroupId );
150         assertTextPresent( artifactInfoArtifactId );
151         assertTextPresent( artifactInfoVersion );
152         assertTextPresent( artifactInfoPackaging );
153     }
154
155     private void assertArtifactsPage( String artifactId )
156     {
157         clickLinkWithText( artifactId );
158         assertPage( "Apache Archiva \\ Browse Repository" );
159         assertTextPresent( "Versions" );
160     }
161
162     private void assertGroupsPage( String groupId )
163     {
164         clickLinkWithText( groupId );
165         assertPage( "Apache Archiva \\ Browse Repository" );
166         assertTextPresent( "Artifacts" );
167     }
168 }