Skip to content

Commit

Permalink
fixed up test for maven module
Browse files Browse the repository at this point in the history
  • Loading branch information
hofmeister committed Feb 17, 2013
1 parent 0fae525 commit 55eaf01
Showing 1 changed file with 13 additions and 9 deletions.
Expand Up @@ -2,6 +2,7 @@

import org.junit.Test;
import org.sonatype.aether.artifact.Artifact;
import org.sonatype.aether.resolution.ArtifactResolutionException;
import org.sonatype.aether.util.artifact.DefaultArtifact;

import java.io.File;
Expand All @@ -16,9 +17,7 @@ public void testResolveArtifact() throws Exception {
Maven mvn = new Maven();
final Artifact artifact = mvn.resolveArtifact("com.hazelcast:hazelcast:2.5");

assertNotNull(artifact);
assertTrue(artifact.getFile().exists());

assertTrue("Got a jar file that exists",artifact.getFile().exists());
}


Expand All @@ -28,24 +27,29 @@ public void testResolveDependencies() throws Exception {

final List<Artifact> artifacts = mvn.resolveDependencies("org.springframework:spring-core:3.2.1.RELEASE");

assertTrue(artifacts.size() > 1);
assertTrue("Found more than 1 dependency (result includes itself)",artifacts.size() > 1);
}

@Test
public void testAddArtifact() throws Exception {
Maven mvn = new Maven();

boolean gotException = false;
try {
mvn.resolveArtifact("com.example:nothing:6.6.6");

} catch(ArtifactResolutionException ex) {
gotException = true;
}
assertTrue("Artifact could not be resolved",gotException);

Artifact artifact = new DefaultArtifact("com.example:nothing:6.6.6")
.setFile(new File("com/example/nothing-6.6.6.jar"));

mvn.addArtifact(artifact);

Artifact resolvedArtifact = mvn.resolveArtifact("com.example:nothing:6.6.6");

assertNotNull(resolvedArtifact);
}

private File file(String path) {
return new File(getClass().getResource(path).getFile());
assertNotNull("Artifact can now be resolved",resolvedArtifact);
}
}

0 comments on commit 55eaf01

Please sign in to comment.