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.Collection;
24  import java.util.Set;
25  
26  public class SubPathReindexTest
27      extends AbstractNexusIndexerTest
28  {
29      protected File repo = new File( getBasedir(), "src/test/repo" );
30  
31      @Override
32      protected void prepareNexusIndexer( NexusIndexer nexusIndexer )
33          throws Exception
34      {
35          context = nexusIndexer.addIndexingContext( "test-minimal", "test", repo, indexDir, null, null, MIN_CREATORS );
36  
37          nexusIndexer.scan( context, "/org/slf4j/slf4j-api", null, false );
38      }
39  
40      public void testRootGroups()
41          throws Exception
42      {
43          Set<String> rootGroups = context.getRootGroups();
44          assertEquals( rootGroups.toString(), 1, rootGroups.size() );
45  
46          assertGroup( 0, "com.adobe", context );
47          assertGroup( 0, "com.adobe.flexunit", context );
48  
49          assertGroup( 0, "qdox", context );
50  
51          assertGroup( 0, "proptest", context );
52  
53          assertGroup( 0, "junit", context );
54  
55          assertGroup( 0, "commons-logging", context );
56  
57          assertGroup( 0, "regexp", context );
58  
59          assertGroup( 0, "commons-cli", context );
60  
61          assertGroup( 4, "org", context );
62  
63          assertGroup( 4, "org.slf4j", context );
64  
65          assertGroup( 0, "org.testng", context );
66  
67          assertGroup( 0, "org.apache", context );
68  
69          assertGroup( 0, "org.apache.directory", context );
70          assertGroup( 0, "org.apache.directory.server", context );
71  
72          assertGroup( 0, "org.apache.maven", context );
73          assertGroup( 0, "org.apache.maven.plugins", context );
74          assertGroup( 0, "org.apache.maven.plugins.maven-core-it-plugin", context );
75      }
76  
77      public void testIdentify()
78          throws Exception
79      {
80          Collection<ArtifactInfo> ais;
81          File artifact;
82  
83          // Using a file: this one should be unknown
84          artifact = new File( repo, "qdox/qdox/1.5/qdox-1.5.jar" );
85  
86          ais = nexusIndexer.identify( artifact );
87  
88          assertTrue( "Should not be able to identify it!", ais.isEmpty() );
89  
90          // Using a file: this one should be known
91          artifact = new File( repo, "org/slf4j/slf4j-api/1.4.2/slf4j-api-1.4.2.jar" );
92  
93          ais = nexusIndexer.identify( artifact );
94  
95          assertEquals( "Should not be able to identify it!", 1, ais.size() );
96      }
97  
98  }