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