1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.index.creator;
20
21 import java.io.File;
22 import java.util.ArrayList;
23 import java.util.List;
24
25 import org.apache.maven.index.AbstractTestSupport;
26 import org.apache.maven.index.ArtifactContext;
27 import org.apache.maven.index.ArtifactInfo;
28 import org.apache.maven.index.context.IndexCreator;
29 import org.junit.Test;
30
31 import static org.junit.Assert.assertEquals;
32
33
34
35
36 public class MavenPluginArtifactInfoIndexCreatorTest extends AbstractTestSupport {
37 protected IndexCreator indexCreator;
38
39 @Override
40 public void setUp() throws Exception {
41 super.setUp();
42
43 indexCreator = this.lookup(IndexCreator.class, MavenPluginArtifactInfoIndexCreator.ID);
44 }
45
46 @Test
47 public void testMavenPluginInfo() throws Exception {
48 File artifact = new File(
49 getBasedir(),
50 "src/test/repo-creator/org/apache/maven/plugins/maven-dependency-plugin/2.0/maven-dependency-plugin-2.0.jar");
51
52 File pom = new File(
53 getBasedir(),
54 "src/test/repo-creator/org/apache/maven/plugins/maven-dependency-plugin/2.0/maven-dependency-plugin-2.0.pom");
55
56 ArtifactInfo artifactInfo =
57 new ArtifactInfo("test", "org.apache.maven.plugins", "maven-dependency-plugin", "2.0", null, "jar");
58
59 artifactInfo.setPackaging("maven-plugin");
60 artifactInfo.setFileExtension("jar");
61
62 ArtifactContext artifactContext = new ArtifactContext(pom, artifact, null, artifactInfo, null);
63
64 indexCreator.populateArtifactInfo(artifactContext);
65
66 assertEquals("dependency", artifactContext.getArtifactInfo().getPrefix());
67
68 List<String> goals = new ArrayList<>(16);
69 goals.add("analyze-dep-mgt");
70 goals.add("analyze");
71 goals.add("analyze-only");
72 goals.add("analyze-report");
73 goals.add("build-classpath");
74 goals.add("copy-dependencies");
75 goals.add("copy");
76 goals.add("unpack");
77 goals.add("list");
78 goals.add("purge-local-repository");
79 goals.add("go-offline");
80 goals.add("resolve");
81 goals.add("sources");
82 goals.add("resolve-plugins");
83 goals.add("tree");
84 goals.add("unpack-dependencies");
85
86 assertEquals(goals, artifactContext.getArtifactInfo().getGoals());
87 }
88 }