### Question:
MavenArtifact { public static MavenArtifact fromCoordinate(String coordinate) { String[] parts = checkNotNull(coordinate, "coordinate").split(":"); if (parts.length==4) return new MavenArtifact(parts[0], parts[1], parts[2], parts[3]); if (parts.length==5) return new MavenArtifact(parts[0], parts[1], parts[2], parts[3], parts[4]); throw new IllegalArgumentException("Invalid maven coordinate '"+coordinate+"'"); } MavenArtifact(String groupId, String artifactId, String packaging, String classifier, String version);  MavenArtifact(String groupId, String artifactId, String packaging, String version); static MavenArtifact fromCoordinate(String coordinate); String getGroupId(); String getArtifactId(); String getVersion(); @Nullable String getClassifier(); String getPackaging(); boolean isSnapshot(); String getCustomFileNameAfterArtifactMarker(); void setCustomFileNameAfterArtifactMarker(String customFileNameMarker); String getClassifierFileNameMarker(); void setClassifierFileNameMarker(String classifierFileNameMarker); String getCoordinate(); String getFilename(); @Nullable String getExtension(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj);  }### Answer:
@Test public void testRetrieval() throws Exception { MavenArtifact m = MavenArtifact.fromCoordinate(MAVEN_JAR_PLUGIN_COORDINATE); String hostedUrl = new MavenRetriever().getHostedUrl(m); Assert.assertTrue(hostedUrl.startsWith("http: String localPath = new MavenRetriever().getLocalPath(m); Assert.assertTrue(localPath.endsWith( "/repository/org/apache/maven/plugins/maven-jar-plugin/2.6/maven-jar-plugin-2.6.jar"), localPath); }
@Test public void testRetrievalWithClassifier() throws Exception { MavenArtifact m = MavenArtifact.fromCoordinate(RELEASED_SOURCES_COORDINATE); String localPath = new MavenRetriever().getLocalPath(m); Assert.assertTrue(localPath.endsWith( "/repository/io/brooklyn/brooklyn-core/0.6.0/brooklyn-core-0.6.0-sources.jar"), localPath); }
@Test public void testRetrievalWithUnusualClassifier() throws Exception { MavenArtifact m = MavenArtifact.fromCoordinate(EXAMPLE_BZIP_COORDINATE); String localPath = new MavenRetriever().getLocalPath(m); Assert.assertTrue(localPath.endsWith( "/repository/com/example/example-artifact/2.0.1/example-artifact-2.0.1-server-windows.tar.bz2"), localPath); }
@Test(groups={"Integration","Broken"}) public void testRetrievalLocalIntegration() throws Exception { MavenArtifact m = MavenArtifact.fromCoordinate(MAVEN_JAR_PLUGIN_COORDINATE); String localPath = new MavenRetriever().getLocalPath(m); File f = new File(localPath); if (!f.exists()) Assert.fail("Could not load "+localPath+" when testing MavenRetriever: do a maven build with no integration tests first to ensure this is installed, then rerun"); checkValidMavenJarUrl(MavenRetriever.localUrl(m), "org/apache/maven/plugin/jar/JarMojo.class"); }
@Test(groups="Integration") public void testRetrievalHostedReleaseIntegration() throws Exception { MavenArtifact m = MavenArtifact.fromCoordinate(MAVEN_JAR_PLUGIN_COORDINATE); checkValidMavenJarUrl(new MavenRetriever().getHostedUrl(m), "org/apache/maven/plugin/jar/JarMojo.class"); }