View Javadoc

1   package org.apache.maven.index;
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  import java.util.ArrayList;
24  import java.util.Collection;
25  import java.util.List;
26  
27  import org.apache.lucene.search.Query;
28  
29  /** http://issues.sonatype.org/browse/NEXUS-13" target="alexandria_uri">http://issues.sonatype.org/browse/NEXUS-13 */
30  public class Nexus645NexusIndexerTest
31      extends AbstractNexusIndexerTest
32  {
33      protected File repo = new File( getBasedir(), "src/test/nexus-645" );
34  
35      @Override
36      protected void prepareNexusIndexer( NexusIndexer nexusIndexer )
37          throws Exception
38      {
39          context =
40              nexusIndexer.addIndexingContext( "nexus-645", "nexus-645", repo, indexDir, null, null, DEFAULT_CREATORS );
41          nexusIndexer.scan( context );
42      }
43  
44      public void testSearchFlat()
45          throws Exception
46      {
47          Query q = nexusIndexer.constructQuery( MAVEN.GROUP_ID, "org.codehaus.tycho", SearchType.SCORED );
48          FlatSearchResponse response = nexusIndexer.searchFlat( new FlatSearchRequest( q ) );
49          Collection<ArtifactInfo> r = response.getResults();
50  
51          assertEquals( 3, r.size() );
52  
53          List<ArtifactInfo> list = new ArrayList<ArtifactInfo>( r );
54  
55          ArtifactInfo ai = null;
56  
57          // g a v p c #1
58          ai = list.get( 0 );
59  
60          assertEquals( "org.codehaus.tycho", ai.groupId );
61          assertEquals( "tycho-distribution", ai.artifactId );
62          assertEquals( "0.3.0-SNAPSHOT", ai.version );
63          assertEquals( "pom", ai.packaging );
64          assertEquals( null, ai.classifier );
65          assertEquals( "nexus-645", ai.repository );
66          assertEquals( "pom", ai.fextension );
67  
68          // g a v p c #2
69          ai = list.get( 1 );
70  
71          assertEquals( "org.codehaus.tycho", ai.groupId );
72          assertEquals( "tycho-distribution", ai.artifactId );
73          assertEquals( "0.3.0-SNAPSHOT", ai.version );
74          assertEquals( "tar.gz", ai.packaging );
75          assertEquals( "bin", ai.classifier );
76          assertEquals( "nexus-645", ai.repository );
77          assertEquals( "tar.gz", ai.fextension );
78  
79          // g a v p c #3
80          ai = list.get( 2 );
81  
82          assertEquals( "org.codehaus.tycho", ai.groupId );
83          assertEquals( "tycho-distribution", ai.artifactId );
84          assertEquals( "0.3.0-SNAPSHOT", ai.version );
85          assertEquals( "zip", ai.packaging );
86          assertEquals( "bin", ai.classifier );
87          assertEquals( "nexus-645", ai.repository );
88          assertEquals( "zip", ai.fextension );
89      }
90  }