예제 #1
0
  @Test
  public void testConvertNormalPath() throws InvalidMavenArtifactRequest {
    Assert.assertEquals(
        "groupId:artifactId:extension:version",
        servlet.convertToMavenUrl("groupId/artifactId/version/artifactId-version.extension"));
    Assert.assertEquals(
        "group.id:artifactId:extension:version",
        servlet.convertToMavenUrl("group/id/artifactId/version/artifactId-version.extension"));
    Assert.assertEquals(
        "group.id:artifact.id:extension:version",
        servlet.convertToMavenUrl("group/id/artifact.id/version/artifact.id-version.extension"));

    Assert.assertEquals(
        "group-id:artifactId:extension:version",
        servlet.convertToMavenUrl("group-id/artifactId/version/artifactId-version.extension"));
    Assert.assertEquals(
        "group-id:artifact-id:extension:version",
        servlet.convertToMavenUrl("group-id/artifact-id/version/artifact-id-version.extension"));
    Assert.assertEquals(
        "group-id:my-artifact-id:extension:version",
        servlet.convertToMavenUrl(
            "group-id/my-artifact-id/version/my-artifact-id-version.extension"));

    // Some real cases
    Assert.assertEquals(
        "org.apache.camel.karaf:apache-camel:jar:LATEST",
        servlet.convertToMavenUrl(
            "org/apache/camel/karaf/apache-camel/LATEST/apache-camel-LATEST.jar"));
    Assert.assertEquals(
        "org.apache.cxf.karaf:apache-cxf:jar:LATEST",
        servlet.convertToMavenUrl("org/apache/cxf/karaf/apache-cxf/LATEST/apache-cxf-LATEST.jar"));
    Assert.assertEquals(
        "org.fusesource.fabric:fuse-fabric:jar:LATEST",
        servlet.convertToMavenUrl(
            "org/fusesource/fabric/fuse-fabric/LATEST/fuse-fabric-LATEST.jar"));

    // Try extensions with a dot
    Assert.assertEquals(
        "org.fusesource.fabric:fuse-fabric:zip:LATEST",
        servlet.convertToMavenUrl(
            "org/fusesource/fabric/fuse-fabric/LATEST/fuse-fabric-LATEST.zip"));
  }
  @Test
  public void testConvertNormalPathWithClassifier() throws InvalidMavenArtifactRequest {
    assertEquals(
        "groupId:artifactId:extension:classifier:version",
        servlet.convertToMavenUrl(
            "groupId/artifactId/version/artifactId-version-classifier.extension"));
    assertEquals(
        "group.id:artifactId:extension:classifier:version",
        servlet.convertToMavenUrl(
            "group/id/artifactId/version/artifactId-version-classifier.extension"));
    assertEquals(
        "group.id:artifact.id:extension:classifier:version",
        servlet.convertToMavenUrl(
            "group/id/artifact.id/version/artifact.id-version-classifier.extension"));

    assertEquals(
        "group.id:artifact.id:extension.sha1:classifier:version",
        servlet.convertToMavenUrl(
            "group/id/artifact.id/version/artifact.id-version-classifier.extension.sha1"));
    assertEquals(
        "group.id:artifact.id:extension.md5:classifier:version",
        servlet.convertToMavenUrl(
            "group/id/artifact.id/version/artifact.id-version-classifier.extension.md5"));

    assertEquals(
        "group-id:artifactId:extension:classifier:version",
        servlet.convertToMavenUrl(
            "group-id/artifactId/version/artifactId-version-classifier.extension"));
    assertEquals(
        "group-id:artifact-id:extension:classifier:version",
        servlet.convertToMavenUrl(
            "group-id/artifact-id/version/artifact-id-version-classifier.extension"));
    assertEquals(
        "group-id:my-artifact-id:extension:classifier:version",
        servlet.convertToMavenUrl(
            "group-id/my-artifact-id/version/my-artifact-id-version-classifier.extension"));

    // Some real cases
    assertEquals(
        "org.apache.camel.karaf:apache-camel:xml:features:LATEST",
        servlet.convertToMavenUrl(
            "org/apache/camel/karaf/apache-camel/LATEST/apache-camel-LATEST-features.xml"));
    assertEquals(
        "org.apache.cxf.karaf:apache-cxf:xml:features:LATEST",
        servlet.convertToMavenUrl(
            "org/apache/cxf/karaf/apache-cxf/LATEST/apache-cxf-LATEST-features.xml"));
    assertEquals(
        "io.fabric8:fabric8-karaf:xml:features:LATEST",
        servlet.convertToMavenUrl(
            "io/fabric8/fabric8-karaf/LATEST/fabric8-karaf-LATEST-features.xml"));
    assertEquals(
        "io.fabric8:fabric8-karaf:xml:features:7-1-x-fuse-01",
        servlet.convertToMavenUrl(
            "io/fabric8/fabric8-karaf/7-1-x-fuse-01/fabric8-karaf-7-1-x-fuse-01-features.xml"));

    // Try extensions with a dot
    assertEquals(
        "io.fabric8:fabric8-karaf:zip:distro:LATEST",
        servlet.convertToMavenUrl(
            "io/fabric8/fabric8-karaf/LATEST/fabric8-karaf-LATEST-distro.zip"));
  }
 @Test(expected = InvalidMavenArtifactRequest.class)
 public void testConvertNullPath() throws InvalidMavenArtifactRequest {
   servlet.convertToMavenUrl(null);
 }