1 package org.apache.maven.shared.jar.identification;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.shared.jar.AbstractJarAnalyzerTestCase;
23 import org.apache.maven.shared.jar.JarAnalyzer;
24
25 import java.io.File;
26
27
28
29
30
31
32
33 public class JarIdentificationAnalyzerTest
34 extends AbstractJarAnalyzerTestCase
35 {
36 private JarIdentification getJarTaxon( String filename )
37 throws Exception
38 {
39 File jarfile = getSampleJar( filename );
40
41 JarIdentificationAnalysis analyzer =
42 (JarIdentificationAnalysis) lookup( JarIdentificationAnalysis.class.getName() );
43 JarIdentification taxon = analyzer.analyze( new JarAnalyzer( jarfile ) );
44 assertNotNull( "JarIdentification", taxon );
45
46 return taxon;
47 }
48
49 public void testTaxonAnalyzerWithJXR()
50 throws Exception
51 {
52 JarIdentification taxon = getJarTaxon( "jxr.jar" );
53
54 assertEquals( "identification.groupId", "org.apache.maven", taxon.getGroupId() );
55 assertEquals( "identification.artifactId", "maven-jxr", taxon.getArtifactId() );
56 assertEquals( "identification.version", "1.1-SNAPSHOT", taxon.getVersion() );
57 assertEquals( "identification.name", "Maven JXR", taxon.getName() );
58 assertEquals( "identification.vendor", "Apache Software Foundation", taxon.getVendor() );
59
60
61 }
62
63
64
65
66
67
68 public void testTaxonAnalyzerWithCODEC()
69 throws Exception
70 {
71 JarIdentification taxon = getJarTaxon( "codec.jar" );
72
73 assertEquals( "identification.groupId", "org.apache.commons.codec", taxon.getGroupId() );
74 assertEquals( "identification.artifactId", "codec", taxon.getArtifactId() );
75
76
77 assertEquals( "identification.version", "20030519", taxon.getVersion() );
78 assertEquals( "identification.name", "codec", taxon.getName() );
79 assertNull( "identification.vendor", taxon.getVendor() );
80
81
82 }
83
84 public void testTaxonAnalyzerWithANT()
85 throws Exception
86 {
87 JarIdentification taxon = getJarTaxon( "ant.jar" );
88
89 assertEquals( "identification.groupId", "org.apache.tools.ant", taxon.getGroupId() );
90 assertEquals( "identification.artifactId", "ant", taxon.getArtifactId() );
91 assertEquals( "identification.version", "1.6.5", taxon.getVersion() );
92
93
94 assertEquals( "identification.vendor", "Apache Software Foundation", taxon.getVendor() );
95
96
97 }
98 }