1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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 SubPathReindexTest 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 }
39
40 @Test
41 public void testRootGroups() throws Exception {
42 Set<String> rootGroups = context.getRootGroups();
43 assertEquals(rootGroups.toString(), 1, rootGroups.size());
44
45 assertGroup(0, "com.adobe", context);
46 assertGroup(0, "com.adobe.flexunit", context);
47
48 assertGroup(0, "qdox", context);
49
50 assertGroup(0, "proptest", context);
51
52 assertGroup(0, "junit", context);
53
54 assertGroup(0, "commons-logging", context);
55
56 assertGroup(0, "regexp", context);
57
58 assertGroup(0, "commons-cli", context);
59
60 assertGroup(4, "org", context);
61
62 assertGroup(4, "org.slf4j", context);
63
64 assertGroup(0, "org.testng", context);
65
66 assertGroup(0, "org.apache", context);
67
68 assertGroup(0, "org.apache.directory", context);
69 assertGroup(0, "org.apache.directory.server", context);
70
71 assertGroup(0, "org.apache.maven", context);
72 assertGroup(0, "org.apache.maven.plugins", context);
73 assertGroup(0, "org.apache.maven.plugins.maven-core-it-plugin", context);
74 }
75
76 @Test
77 public void testIdentify() throws Exception {
78 Collection<ArtifactInfo> ais;
79 File artifact;
80
81
82 artifact = new File(repo, "qdox/qdox/1.5/qdox-1.5.jar");
83
84 ais = nexusIndexer.identify(artifact);
85
86 assertTrue("Should not be able to identify it!", ais.isEmpty());
87
88
89 artifact = new File(repo, "org/slf4j/slf4j-api/1.4.2/slf4j-api-1.4.2.jar");
90
91 ais = nexusIndexer.identify(artifact);
92
93 assertEquals("Should not be able to identify it!", 1, ais.size());
94 }
95 }