]> source.dussan.org Git - archiva.git/blob
92b69fa05cfdf78a577896825468cc6a93647695
[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.annotations.Test;
26
27 @Test( groups = { "browse" }, dependsOnMethods = { "testAddArtifactNullValues" } )
28 public class BrowseTest 
29         extends AbstractBrowseTest
30 {
31         
32         public void testBrowseArtifact()
33         {
34                 goToBrowsePage();
35                 assertBrowsePage();
36         }
37         
38         public void testClickArtifactFromBrowse()
39         {
40                 goToBrowsePage();
41                 assertBrowsePage();
42                 clickLinkWithText( getProperty( "ARTIFACT_ARTIFACTID" ) + "/" );
43                 assertPage( "Apache Archiva \\ Browse Repository" );
44                 assertTextPresent( "Artifacts" );
45         }
46
47     // MRM-1278
48     @Test(groups = {"requiresUpload"})
49     public void testCorrectRepositoryInBrowse()
50     {
51         File artifact =
52             new File( getBasedir(),
53                       "/src/test/it-resources/snapshots/org/apache/maven/archiva/web/test/foo-bar/1.0-SNAPSHOT/foo-bar-1.0-SNAPSHOT.jar" );                     
54                 
55         String releasesRepo = getProperty( "RELEASES_REPOSITORY" );
56         
57         // create releases repository first
58         goToRepositoriesPage();
59         clickLinkWithText( "Add" );
60         addManagedRepository( getProperty( "RELEASES_REPOSITORY" ), "Releases Repository",
61                               new File( getBasedir(), "target/repository/releases" ).getPath(), "", "Maven 2.x Repository",
62                               "0 0 * * * ?", "", "" );        
63         assertTextPresent( "Releases Repository" );
64         
65         String snapshotsRepo = getProperty( "SNAPSHOTS_REPOSITORY" );
66
67         // TODO: do this differently as uploading doesn't work on browsers other than *chrome (below as well)
68         // upload a snapshot artifact to repository 'releases'        
69         addArtifact( "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar", artifact.getPath(),
70                      releasesRepo );
71         assertTextPresent( "Artifact 'archiva:archiva-webapp:1.0-SNAPSHOT' was successfully deployed to repository '" + releasesRepo + "'" );
72
73         goToBrowsePage();
74         assertBrowsePage();
75         assertGroupsPage( "archiva/" );
76         assertArtifactsPage( "archiva-webapp/" );
77         assertArtifactInfoPage( "1.0-SNAPSHOT/", releasesRepo, "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar" );
78
79         // upload a snapshot artifact to repository 'snapshots'        
80         addArtifact( "continuum", "continuum-core", "1.0-SNAPSHOT", "jar", artifact.getPath(),
81                      snapshotsRepo );
82         assertTextPresent( "Artifact 'continuum:continuum-core:1.0-SNAPSHOT' was successfully deployed to repository '" + snapshotsRepo + "'" );
83
84         goToBrowsePage();
85         assertBrowsePage();
86         assertGroupsPage( "continuum/" );
87         assertArtifactsPage( "continuum-core/" );
88         assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "continuum", "continuum-core", "1.0-SNAPSHOT", "jar" );
89     }
90
91     private void assertArtifactInfoPage( String version, String artifactInfoRepositoryId, String artifactInfoGroupId,
92                                          String artifactInfoArtifactId, String artifactInfoVersion, String artifactInfoPackaging )
93     {
94         clickLinkWithText( version );
95         assertPage( "Apache Archiva \\ Browse Repository" );
96         assertTextPresent( artifactInfoRepositoryId );
97         assertTextPresent( artifactInfoGroupId );
98         assertTextPresent( artifactInfoArtifactId );
99         assertTextPresent( artifactInfoVersion );
100         assertTextPresent( artifactInfoPackaging );
101     }
102
103     private void assertArtifactsPage( String artifactId )
104     {
105         clickLinkWithText( artifactId );
106         assertPage( "Apache Archiva \\ Browse Repository" );
107         assertTextPresent( "Versions" );
108     }
109
110     private void assertGroupsPage( String groupId )
111     {
112         clickLinkWithText( groupId );
113         assertPage( "Apache Archiva \\ Browse Repository" );
114         assertTextPresent( "Artifacts" );
115     }
116 }