1 package org.apache.maven.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
22 public class SearchTest
23 extends AbstractArchivaTestCase
25 private static int PAGE_LOAD_WAIT = 1500;
27 public void testSearchNonExistingArtifact()
29 searchForArtifact( "asdf" );
31 waitPage( PAGE_LOAD_WAIT );
33 assertTextPresent( "No results found" );
36 public void testSearchExistingArtifact()
38 searchForArtifact( "artifact-a" );
40 waitPage( PAGE_LOAD_WAIT );
42 assertPage( "Search Results" );
44 assertTextPresent( "artifact-a" );
47 public void testViewSearchedArtifact()
49 // test viewing artifact (header link) listed in search results
51 searchForArtifact( "artifact-a" );
53 waitPage( PAGE_LOAD_WAIT );
55 getSelenium().click( "link=artifact-a" );
57 waitPage( PAGE_LOAD_WAIT );
59 assertPage( "Browse Repository" );
61 assertTextPresent( "artifact-a" );
63 //test viewing artifact listed in search results
65 searchForArtifact( "artifact-a" );
67 waitPage( PAGE_LOAD_WAIT );
69 clickLinkWithText( "1.0" );
71 waitPage( PAGE_LOAD_WAIT );
73 assertPage( "Browse Repository" );
75 assertTextPresent( "Artifact ID" );
77 assertTextPresent( "artifact-a" );
79 assertTextPresent( "Version" );
81 assertTextPresent( "1.0" );
84 public void testBrowseSearchedArtifact()
86 // test viewing artifact listed in search results
88 searchForArtifact( "artifact-a" );
90 waitPage( PAGE_LOAD_WAIT );
92 getSelenium().click("//p[1]/span/a[1]");
94 waitPage( PAGE_LOAD_WAIT );
96 assertPage( "Browse Repository" );
98 assertTextPresent( "artifact-a" );
101 public void testBrowseRepoFromSearchResults()
103 searchForArtifact( "artifact-a" );
105 waitPage( PAGE_LOAD_WAIT );
107 clickLinkWithText( "[top]" );
109 waitPage( PAGE_LOAD_WAIT );
111 assertPage( "Browse Repository" );
114 private void searchForArtifact( String artifactId )
116 if ( !"Maven Archiva :: Quick Search".equals( getSelenium().getTitle() ) )
118 clickLinkWithText( "Search" );
120 waitPage( PAGE_LOAD_WAIT );
122 assertPage( "Quick Search" );
125 setFieldValue( "quickSearch_q", artifactId );
127 clickButtonWithValue( "Submit" );