1 package org.apache.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 import org.apache.archiva.web.test.parent.AbstractSearchTest;
23 import org.testng.annotations.Test;
25 @Test( groups = { "search" }, dependsOnGroups = { "about" }, sequential = true )
26 public class SearchTest
27 extends AbstractSearchTest
30 @Test( alwaysRun = true )
31 public void testSearchNonExistingArtifact()
34 searchForArtifact( getProperty( "SEARCH_BAD_ARTIFACT" ) );
35 assertTextPresent( "No results found" );
38 // TODO: make search tests more robust especially when comparing/asserting number of hits
39 @Test( alwaysRun = true )
40 public void testSearchExistingArtifact()
42 searchForArtifact( "artifactId:" + getProperty( "ARTIFACT_ARTIFACTID" ) );
43 //assertTextPresent( "Results" );
44 assertElementPresent( "resultsBox" );
45 assertTextPresent( "1 to 1 of 1" );
46 assertLinkPresent( "test" );
49 @Test( alwaysRun = true )
50 public void testViewSearchedArtifact()
52 searchForArtifact( getProperty( "ARTIFACT_ARTIFACTID" ) );
53 clickLinkWithLocator( "//span[@class=\"artifact-title\"]/a[text()='" + getProperty( "ARTIFACT_ARTIFACTID" ) + "']" );
54 assertPage( "Apache Archiva \\ Browse Repository" );
55 assertTextPresent( getProperty( "ARTIFACT_ARTIFACTID" ) );
56 clickLinkWithText( getProperty( "ARTIFACT_VERSION" ) + "/" );
57 assertPage( "Apache Archiva \\ Browse Repository" );
60 @Test( alwaysRun = true )
61 public void testSearchWithMultipleKeywords()
63 String groupId = getProperty( "ADD_REMOVE_GROUPID" );
64 String version = getProperty( "SNAPSHOT_VERSION" );
65 String packaging = getProperty( "SNAPSHOT_PACKAGING" );
66 String filePath = getProperty( "SNAPSHOT_ARTIFACTFILEPATH" );
67 String repoId = getProperty( "SNAPSHOT_REPOSITORYID" );
69 String existingArtifactId = getProperty( "ADD_REMOVE_ARTIFACTID" );
70 String multiKeywords = existingArtifactId.replace( "-", " " );
72 addArtifact( groupId, existingArtifactId, version, packaging, filePath, repoId, true );
74 // verify artifact is existing
75 searchForArtifact( existingArtifactId );
76 assertTextPresent( "Results" );
77 assertTextPresent( "Hits: 1 to 1 of 1" );
78 assertLinkPresent( existingArtifactId );
80 // search for existing artifact using multiple keywords
81 searchForArtifact( multiKeywords );
82 assertTextPresent( "Results" );
83 assertTextPresent( "Hits: 1 to 1 of 1" );
84 assertLinkPresent( existingArtifactId );
87 @Test( alwaysRun = true )
88 public void testSearchNonExistingArtifactInAdvancedSearch()
90 searchForArtifactAdvancedSearch( null, getProperty( "SEARCH_BAD_ARTIFACT" ), null, null, null, null );
91 assertTextPresent( "No results found" );
94 @Test( alwaysRun = true )
95 public void testSearchNoSearchCriteriaSpecifiedInAdvancedSearch()
97 searchForArtifactAdvancedSearch( null, null, null, null, null, null );
98 assertTextPresent( "Advanced Search - At least one search criteria must be provided." );
101 @Test( alwaysRun = true )
102 public void testSearchExistingArtifactUsingAdvancedSearchArtifactId()
104 searchForArtifactAdvancedSearch( null, getProperty( "ARTIFACT_ARTIFACTID" ), null,
105 getProperty( "REPOSITORYID" ), null, null );
106 assertTextPresent( "Results" );
107 assertTextPresent( "Hits: 1 to 1 of 1" );
108 assertLinkPresent( "test" );
111 @Test( alwaysRun = true )
112 public void testSearchExistingArtifactUsingAdvancedSearchGroupId()
114 searchForArtifactAdvancedSearch( getProperty( "GROUPID" ), null, null, getProperty( "REPOSITORYID" ), null,
116 assertTextPresent( "Results" );
117 assertTextPresent( "Hits: 1 to 1 of 1" );
118 assertLinkPresent( "test" );
121 @Test( alwaysRun = true )
122 public void testSearchExistingArtifactAllCriteriaSpecifiedInAdvancedSearch()
124 searchForArtifactAdvancedSearch( getProperty( "GROUPID" ), getProperty( "ARTIFACT_ARTIFACTID" ),
125 getProperty( "ARTIFACT_VERSION" ), getProperty( "REPOSITORYID" ),
126 getProperty( "ARTIFACT_CLASSNAME" ), null );
127 assertTextPresent( "Results" );
128 assertTextPresent( "Hits: 1 to 1 of 1" );
129 assertLinkPresent( "test" );
132 @Test( alwaysRun = true )
133 public void testSearchExistingArtifactUsingAdvancedSearchNotInRepository()
135 searchForArtifactAdvancedSearch( null, getProperty( "ARTIFACT_ARTIFACTID" ), null, "snapshots", null, null );
136 assertTextPresent( "No results found" );
137 assertTextNotPresent( "Results" );
138 assertTextNotPresent( "Hits: 1 to 1 of 1" );
139 assertLinkNotPresent( "test" );