1
2
3
4
5
6
7
8
9
10
11
12
13
14 package org.basepom.mojo.duplicatefinder.artifact;
15
16 import org.apache.maven.artifact.Artifact;
17 import org.apache.maven.artifact.DefaultArtifact;
18 import org.apache.maven.artifact.handler.ArtifactHandler;
19 import org.apache.maven.artifact.handler.DefaultArtifactHandler;
20 import org.junit.Test;
21
22 import static org.junit.Assert.assertEquals;
23
24 public class TestArtifactFileResolver {
25
26 private final ArtifactHandler handler = new DefaultArtifactHandler();
27
28 @Test
29 public void testCanonicalization() {
30 final Artifact jarArtifact = new DefaultArtifact("foo.group", "foo-id", "1.0", "compile", "jar", null, handler);
31
32 assertEquals(jarArtifact, ArtifactFileResolver.canonicalizeArtifact(jarArtifact));
33
34 final Artifact testJarArtifact = new DefaultArtifact("foo.group", "foo-id", "1.0", "compile", "jar", "tests", handler);
35 assertEquals(testJarArtifact, ArtifactFileResolver.canonicalizeArtifact(testJarArtifact));
36 assertEquals(testJarArtifact,
37 ArtifactFileResolver.canonicalizeArtifact(new DefaultArtifact("foo.group", "foo-id", "1.0", "compile", "test-jar", null, handler)));
38 assertEquals(testJarArtifact,
39 ArtifactFileResolver.canonicalizeArtifact(new DefaultArtifact("foo.group", "foo-id", "1.0", "compile", "test-jar", "tests", handler)));
40
41 final Artifact testArtifact = new DefaultArtifact("foo.group", "foo-id", "1.0", "compile", "zip", "tests", handler);
42 assertEquals(testArtifact, ArtifactFileResolver.canonicalizeArtifact(testArtifact));
43
44 final Artifact testClassifiedJarArtifact = new DefaultArtifact("foo.group", "foo-id", "1.0", "compile", "test-jar", "special", handler);
45 assertEquals(testClassifiedJarArtifact, ArtifactFileResolver.canonicalizeArtifact(testClassifiedJarArtifact));
46 }
47 }