]> git.argeo.org Git - gpl/argeo-jcr.git/blob - org.argeo.slc.repo/ext/test/org/argeo/slc/repo/internal/AetherUtilsTest.java
Releasing
[gpl/argeo-jcr.git] / org.argeo.slc.repo / ext / test / org / argeo / slc / repo / internal / AetherUtilsTest.java
1 package org.argeo.slc.repo.internal;
2
3
4 import junit.framework.TestCase;
5
6 import org.argeo.slc.repo.maven.AetherUtils;
7 import org.eclipse.aether.artifact.Artifact;
8 import org.eclipse.aether.artifact.DefaultArtifact;
9
10 public class AetherUtilsTest extends TestCase {
11 public void testConvertPathToArtifact() throws Exception {
12 checkPathConversion("my.group.id:my-artifactId:pom:1.2.3",
13 "/my/group/id/my-artifactId/1.2.3/my-artifactId-1.2.3.pom");
14 checkPathConversion("my.group.id:my-artifactId:pom:1.2.3-SNAPSHOT",
15 "/my/group/id/my-artifactId/1.2.3-SNAPSHOT/my-artifactId-1.2.3-SNAPSHOT.pom");
16 checkPathConversion("my.group.id:my-artifactId:pom:myClassifier:1.2.3",
17 "/my/group/id/my-artifactId/1.2.3/my-artifactId-1.2.3-myClassifier.pom");
18 checkPathConversion(
19 "my.group.id:my-artifactId:pom:myClassifier:1.2.3-SNAPSHOT",
20 "/my/group/id/my-artifactId/1.2.3-SNAPSHOT/my-artifactId-1.2.3-SNAPSHOT-myClassifier.pom");
21 checkPathConversion(
22 "my.group.id:my-artifactId:pom:myClassifier:20110828.223836-2",
23 "/my/group/id/my-artifactId/1.2.3-SNAPSHOT/my-artifactId-20110828.223836-2-myClassifier.pom");
24 }
25
26 public void testConvertPathToArtifactRealLife() throws Exception {
27 checkPathConversion(
28 "org.apache.maven.plugins:maven-antrun-plugin:pom:1.1",
29 "org/apache/maven/plugins/maven-antrun-plugin/1.1/maven-antrun-plugin-1.1.pom");
30 checkPathConversion(
31 "org.apache.maven.plugins:maven-plugin-parent:pom:2.0.1",
32 "org/apache/maven/plugins/maven-plugin-parent/2.0.1/maven-plugin-parent-2.0.1.pom");
33 checkPathConversion(
34 "org.apache.avalon.framework:avalon-framework-impl:pom:4.3.1",
35 "org/apache/avalon/framework/avalon-framework-impl/4.3.1/avalon-framework-impl-4.3.1.pom");
36 checkPathConversion(
37 "org.apache.maven.shared:maven-dependency-tree:pom:1.2",
38 "org/apache/maven/shared/maven-dependency-tree/1.2/maven-dependency-tree-1.2.pom");
39 checkPathConversion(
40 "org.argeo.maven.plugins:maven-argeo-osgi-plugin:pom:1.0.33",
41 "org/argeo/maven/plugins/maven-argeo-osgi-plugin/1.0.33/maven-argeo-osgi-plugin-1.0.33.pom");
42 checkPathConversion(
43 "org.apache.maven.plugins:maven-clean-plugin:pom:2.4.1",
44 "org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom");
45 }
46
47 protected void checkPathConversion(String expectedArtifact, String path) {
48 Artifact artifact = AetherUtils.convertPathToArtifact(path, null);
49 if (expectedArtifact == null)
50 assertNull(artifact);
51 else
52 assertEquals(new DefaultArtifact(expectedArtifact), artifact);
53 }
54 }