Debian Codegraph @

src/test/java/org/apache/maven/shared/jar/identification/exposers/EmbeddedMavenModelExposerTest.java

raw
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
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 * Test Case for Embedded Maven Model Taxon Data.
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 // TODO test others
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 // TODO test others
86 }
87 }