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 Nexus658NexusIndexerTest
31      extends AbstractNexusIndexerTest
32  {
33      protected File repo = new File( getBasedir(), "src/test/nexus-658" );
34  
35      @Override
36      protected void prepareNexusIndexer( NexusIndexer nexusIndexer )
37          throws Exception
38      {
39          context =
40              nexusIndexer.addIndexingContext( "nexus-658", "nexus-658", 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.sonatype.nexus", SearchType.SCORED );
48          FlatSearchResponse response = nexusIndexer.searchFlat( new FlatSearchRequest( q ) );
49          Collection<ArtifactInfo> r = response.getResults();
50          assertEquals( r.toString(), 4, r.size() );
51  
52          List<ArtifactInfo> list = new ArrayList<ArtifactInfo>( r );
53  
54          // g a v p c #1
55          ArtifactInfo ai1 = list.get( 0 );
56          assertEquals( "org.sonatype.nexus", ai1.groupId );
57          assertEquals( "nexus-webapp", ai1.artifactId );
58          assertEquals( "1.0.0-SNAPSHOT", ai1.version );
59          assertEquals( "jar", ai1.packaging );
60          assertEquals( null, ai1.classifier );
61          assertEquals( ArtifactAvailablility.PRESENT, ai1.sourcesExists );
62          assertEquals( "nexus-658", ai1.repository );
63  
64          // g a v p c #2
65          ArtifactInfo ai2 = list.get( 1 );
66          assertEquals( "org.sonatype.nexus", ai2.groupId );
67          assertEquals( "nexus-webapp", ai2.artifactId );
68          assertEquals( "1.0.0-SNAPSHOT", ai2.version );
69          assertEquals( "tar.gz", ai2.packaging );
70          assertEquals( "bundle", ai2.classifier );
71          assertEquals( ArtifactAvailablility.NOT_AVAILABLE, ai2.sourcesExists );
72          assertEquals( "nexus-658", ai2.repository );
73  
74          // g a v p c #3
75          ArtifactInfo ai3 = list.get( 2 );
76          assertEquals( "org.sonatype.nexus", ai3.groupId );
77          assertEquals( "nexus-webapp", ai3.artifactId );
78          assertEquals( "1.0.0-SNAPSHOT", ai3.version );
79          assertEquals( "zip", ai3.packaging );
80          assertEquals( "bundle", ai3.classifier );
81          assertEquals( ArtifactAvailablility.NOT_AVAILABLE, ai3.sourcesExists );
82          assertEquals( "nexus-658", ai3.repository );
83  
84          // g a v p c #3
85          ArtifactInfo ai4 = list.get( 3 );
86          assertEquals( "org.sonatype.nexus", ai4.groupId );
87          assertEquals( "nexus-webapp", ai4.artifactId );
88          assertEquals( "1.0.0-SNAPSHOT", ai4.version );
89          assertEquals( "jar", ai4.packaging );
90          assertEquals( "sources", ai4.classifier );
91          assertEquals( ArtifactAvailablility.NOT_AVAILABLE, ai4.sourcesExists );
92          assertEquals( "nexus-658", ai4.repository );
93      }
94  
95  }