View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.index;
20  
21  import java.io.File;
22  import java.util.Collection;
23  import java.util.Set;
24  
25  import org.junit.Test;
26  
27  import static org.junit.Assert.assertEquals;
28  import static org.junit.Assert.assertTrue;
29  
30  public class Nexus4674GavPathReindexTest extends AbstractNexusIndexerTest {
31      protected File repo = new File(getBasedir(), "src/test/repo");
32  
33      @Override
34      protected void prepareNexusIndexer(NexusIndexer nexusIndexer) throws Exception {
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          nexusIndexer.scan(context, "/org/slf4j/slf4j-api/1.4.1", null, true);
39      }
40  
41      @Test
42      public void testRootGroups() throws Exception {
43          Set<String> rootGroups = context.getRootGroups();
44          assertEquals(rootGroups.toString(), 1, rootGroups.size());
45  
46          assertGroup(4, "org", context);
47  
48          assertGroup(4, "org.slf4j", context);
49      }
50  
51      @Test
52      public void testIdentify() throws Exception {
53          Collection<ArtifactInfo> ais;
54          File artifact;
55  
56          // Using a file: this one should be unknown
57          artifact = new File(repo, "qdox/qdox/1.5/qdox-1.5.jar");
58  
59          ais = nexusIndexer.identify(artifact);
60  
61          assertTrue("Should not be able to identify it!", ais.isEmpty());
62  
63          // Using a file: this one should be known
64          artifact = new File(repo, "org/slf4j/slf4j-api/1.4.2/slf4j-api-1.4.2.jar");
65  
66          ais = nexusIndexer.identify(artifact);
67  
68          assertEquals("Should not be able to identify it!", 1, ais.size());
69      }
70  }