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.exposers;
20
21 import java.io.File;
22
23 import org.apache.maven.shared.jar.AbstractJarAnalyzerTestCase;
24 import org.apache.maven.shared.jar.JarAnalyzer;
25 import org.apache.maven.shared.jar.identification.JarIdentification;
26 import org.junit.jupiter.api.Test;
27
28 import static org.junit.jupiter.api.Assertions.assertEquals;
29 import static org.junit.jupiter.api.Assertions.assertFalse;
30 import static org.junit.jupiter.api.Assertions.assertTrue;
31
32
33
34
35 class EmbeddedMavenModelExposerTest extends AbstractJarAnalyzerTestCase {
36
37 @Test
38 void testExposerWithParent() throws Exception {
39 File file = getSampleJar("test1.jar");
40
41 JarIdentification identification = new JarIdentification();
42
43 EmbeddedMavenModelExposer exposer = new EmbeddedMavenModelExposer();
44 exposer.expose(identification, new JarAnalyzer(file));
45
46 assertEquals(1, identification.getPotentialGroupIds().size());
47 assertEquals("test", identification.getPotentialGroupIds().get(0));
48
49 assertEquals(1, identification.getPotentialArtifactIds().size());
50 assertEquals("test1", identification.getPotentialArtifactIds().get(0));
51
52 assertEquals(1, identification.getPotentialVersions().size());
53 assertEquals("1.1-SNAPSHOT", identification.getPotentialVersions().get(0));
54 }
55
56 @Test
57 void testExposerWithJXR() throws Exception {
58 File file = getSampleJar("jxr.jar");
59
60 JarIdentification identification = new JarIdentification();
61
62 EmbeddedMavenModelExposer exposer = new EmbeddedMavenModelExposer();
63 exposer.expose(identification, new JarAnalyzer(file));
64
65 assertFalse(identification.getPotentialGroupIds().isEmpty(), "exposer.groupIds");
66 assertFalse(identification.getPotentialArtifactIds().isEmpty(), "exposer.artifactIds");
67 assertFalse(identification.getPotentialVersions().isEmpty(), "exposer.versions");
68
69
70 }
71
72 @Test
73 void testExposerWithANT() throws Exception {
74 File file = getSampleJar("ant.jar");
75
76 JarIdentification identification = new JarIdentification();
77
78 EmbeddedMavenModelExposer exposer = new EmbeddedMavenModelExposer();
79 exposer.expose(identification, new JarAnalyzer(file));
80
81 assertTrue(identification.getPotentialGroupIds().isEmpty(), "exposer.groupIds");
82 assertTrue(identification.getPotentialArtifactIds().isEmpty(), "exposer.artifactIds");
83 assertTrue(identification.getPotentialVersions().isEmpty(), "exposer.versions");
84
85
86 }
87 }