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  /**
30   * @author Juven Xu http://issues.sonatype.org/browse/NEXUS-687
31   */
32  public class Nexus687NexusIndexerTest
33      extends AbstractNexusIndexerTest
34  {
35      protected File repo = new File( getBasedir(), "src/test/nexus-687" );
36  
37      @Override
38      protected void prepareNexusIndexer( NexusIndexer nexusIndexer )
39          throws Exception
40      {
41          context =
42              nexusIndexer.addIndexingContext( "nexus-687", "nexus-687", repo, indexDir, null, null, DEFAULT_CREATORS );
43          nexusIndexer.scan( context );
44      }
45  
46      public void testSearchFlat()
47          throws Exception
48      {
49          Query q = nexusIndexer.constructQuery( MAVEN.GROUP_ID, "xstream", SearchType.SCORED );
50  
51          FlatSearchResponse response = nexusIndexer.searchFlat( new FlatSearchRequest( q ) );
52  
53          Collection<ArtifactInfo> r = response.getResults();
54  
55          assertEquals( 1, r.size() );
56  
57          List<ArtifactInfo> list = new ArrayList<ArtifactInfo>( r );
58  
59          assertEquals( 1, list.size() );
60  
61          ArtifactInfo ai = list.get( 0 );
62  
63          assertEquals( "xstream", ai.groupId );
64  
65          assertEquals( "xstream", ai.artifactId );
66  
67          assertEquals( "1.2.2", ai.version );
68  
69          assertNull( ai.packaging );
70      }
71  }