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