1 package org.apache.maven.index.creator;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23
24 import org.apache.maven.index.ArtifactContext;
25 import org.apache.maven.index.ArtifactInfo;
26 import org.apache.maven.index.context.IndexCreator;
27 import org.codehaus.plexus.PlexusTestCase;
28
29
30
31
32 public class JarFileContentsIndexCreatorTest
33 extends PlexusTestCase
34 {
35 protected IndexCreator indexCreator;
36
37 @Override
38 public void setUp()
39 throws Exception
40 {
41 super.setUp();
42
43 indexCreator = this.lookup( IndexCreator.class, "jarContent" );
44 }
45
46 public void test_nexus_2318_indexJarWithClasses()
47 throws Exception
48 {
49 File artifact = new File( getBasedir(), "src/test/nexus-2318/aopalliance/aopalliance/1.0/aopalliance-1.0.jar" );
50
51 File pom = new File( getBasedir(), "src/test/nexus-2318/aopalliance/aopalliance/1.0/aopalliance-1.0.pom" );
52
53 ArtifactInfo artifactInfo = new ArtifactInfo( "test", "aopalliance", "aopalliance", "1.0", null );
54
55 ArtifactContext artifactContext = new ArtifactContext( pom, artifact, null, artifactInfo, null );
56
57 indexCreator.populateArtifactInfo( artifactContext );
58
59 assertNotNull( "Classes should not be null", artifactContext.getArtifactInfo().classNames );
60 }
61
62 public void test_nexus_2318_indexJarWithSources()
63 throws Exception
64 {
65 File artifact =
66 new File( getBasedir(), "src/test/nexus-2318/aopalliance/aopalliance/1.0/aopalliance-1.0-sources.jar" );
67
68 File pom = new File( getBasedir(), "src/test/nexus-2318/aopalliance/aopalliance/1.0/aopalliance-1.0.pom" );
69
70 ArtifactInfo artifactInfo = new ArtifactInfo( "test", "aopalliance", "aopalliance", "1.0", null );
71
72 ArtifactContext artifactContext = new ArtifactContext( pom, artifact, null, artifactInfo, null );
73
74 indexCreator.populateArtifactInfo( artifactContext );
75
76 assertNull( "Classes should be null", artifactContext.getArtifactInfo().classNames );
77 }
78
79 public void testMindexer35ScanWar()
80 throws Exception
81 {
82 File artifact =
83 new File( getBasedir(),
84 "src/test/mindexer-35/org/apache/maven/indexer/test/sample-war/1.0-SNAPSHOT/sample-war-1.0-SNAPSHOT.war" );
85
86 File pom =
87 new File( getBasedir(),
88 "src/test/mindexer-35/org/apache/maven/indexer/test/sample-war/1.0-SNAPSHOT/sample-war-1.0-SNAPSHOT.pom" );
89
90 ArtifactInfo artifactInfo =
91 new ArtifactInfo( "test", "org.apache.maven.indexer.test", "sample-war", "1.0-SNAPSHOT", null );
92
93 ArtifactContext artifactContext = new ArtifactContext( pom, artifact, null, artifactInfo, null );
94
95 indexCreator.populateArtifactInfo( artifactContext );
96
97 assertTrue( "Classes should contain WebappClass",
98 artifactContext.getArtifactInfo().classNames.contains( "WebappClass" ) );
99 assertEquals( "WebappClass should have proper package",
100 "/org/apache/maven/indexer/samples/webapp/WebappClass", artifactContext.getArtifactInfo().classNames );
101 }
102 }