use of org.sonatype.aether.repository.LocalArtifactRequest in project sonatype-aether by sonatype.
the class DefaultArtifactResolverTest method testLocalArtifactAvailable.
@Test
public void testLocalArtifactAvailable() throws ArtifactResolutionException {
session.setLocalRepositoryManager(new LocalRepositoryManager() {
public LocalRepository getRepository() {
return null;
}
public String getPathForRemoteMetadata(Metadata metadata, RemoteRepository repository, String context) {
return null;
}
public String getPathForRemoteArtifact(Artifact artifact, RemoteRepository repository, String context) {
return null;
}
public String getPathForLocalMetadata(Metadata metadata) {
return null;
}
public String getPathForLocalArtifact(Artifact artifact) {
return null;
}
public LocalArtifactResult find(RepositorySystemSession session, LocalArtifactRequest request) {
LocalArtifactResult result = new LocalArtifactResult(request);
result.setAvailable(true);
try {
result.setFile(TestFileUtils.createTempFile(""));
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
public void add(RepositorySystemSession session, LocalArtifactRegistration request) {
}
public LocalMetadataResult find(RepositorySystemSession session, LocalMetadataRequest request) {
LocalMetadataResult result = new LocalMetadataResult(request);
try {
result.setFile(TestFileUtils.createTempFile(""));
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
public void add(RepositorySystemSession session, LocalMetadataRegistration request) {
}
});
ArtifactRequest request = new ArtifactRequest(artifact, null, "");
request.addRepository(new RemoteRepository("id", "default", "file:///"));
ArtifactResult result = resolver.resolveArtifact(session, request);
assertTrue(result.getExceptions().isEmpty());
Artifact resolved = result.getArtifact();
assertNotNull(resolved.getFile());
resolved = resolved.setFile(null);
assertEquals(artifact, resolved);
}
use of org.sonatype.aether.repository.LocalArtifactRequest in project sonatype-aether by sonatype.
the class SimpleLocalRepositoryManagerTest method testFindArtifactUsesTimestampedVersion.
@Test
public void testFindArtifactUsesTimestampedVersion() throws Exception {
Artifact artifact = new DefaultArtifact("g.i.d:a.i.d:1.0-SNAPSHOT");
File file = new File(basedir, manager.getPathForLocalArtifact(artifact));
TestFileUtils.write("test", file);
artifact = artifact.setVersion("1.0-20110329.221805-4");
LocalArtifactRequest request = new LocalArtifactRequest();
request.setArtifact(artifact);
LocalArtifactResult result = manager.find(session, request);
assertNull(result.toString(), result.getFile());
assertFalse(result.toString(), result.isAvailable());
}
use of org.sonatype.aether.repository.LocalArtifactRequest in project sonatype-aether by sonatype.
the class EnhancedLocalRepositoryManagerTest method testDoNotFindDifferentContext.
@Test
public void testDoNotFindDifferentContext() throws Exception {
addRemoteArtifact(artifact);
LocalArtifactRequest request = new LocalArtifactRequest(artifact, Arrays.asList(repository), "different");
LocalArtifactResult result = manager.find(session, request);
assertFalse(result.isAvailable());
}
use of org.sonatype.aether.repository.LocalArtifactRequest in project sonatype-aether by sonatype.
the class EnhancedLocalRepositoryManagerTest method testDoNotFindNullFile.
@Test
public void testDoNotFindNullFile() throws Exception {
artifact = artifact.setFile(null);
addLocalArtifact(artifact);
LocalArtifactRequest request = new LocalArtifactRequest(artifact, Arrays.asList(repository), testContext);
LocalArtifactResult result = manager.find(session, request);
assertFalse(result.isAvailable());
}
use of org.sonatype.aether.repository.LocalArtifactRequest in project sonatype-aether by sonatype.
the class EnhancedLocalRepositoryManagerTest method testFindArtifactUsesTimestampedVersion.
@Test
public void testFindArtifactUsesTimestampedVersion() throws Exception {
Artifact artifact = new DefaultArtifact("g.i.d:a.i.d:1.0-SNAPSHOT");
File file = new File(basedir, manager.getPathForLocalArtifact(artifact));
TestFileUtils.write("test", file);
addLocalArtifact(artifact);
artifact = artifact.setVersion("1.0-20110329.221805-4");
LocalArtifactRequest request = new LocalArtifactRequest();
request.setArtifact(artifact);
LocalArtifactResult result = manager.find(session, request);
assertNull(result.toString(), result.getFile());
assertFalse(result.toString(), result.isAvailable());
}
Aggregations