use of org.sonatype.aether.repository.LocalMetadataRequest 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.LocalMetadataRequest in project sonatype-aether by sonatype.
the class EnhancedLocalRepositoryManagerTest method testFindLocalMetadataNoVersion.
@Test
public void testFindLocalMetadataNoVersion() throws Exception {
addMetadata(noVerMetadata, null);
LocalMetadataRequest request = new LocalMetadataRequest(noVerMetadata, null, testContext);
LocalMetadataResult result = manager.find(session, request);
assertNotNull(result.getFile());
}
use of org.sonatype.aether.repository.LocalMetadataRequest in project sonatype-aether by sonatype.
the class EnhancedLocalRepositoryManagerTest method testDoNotFindRemoteMetadataDifferentContext.
@Test
public void testDoNotFindRemoteMetadataDifferentContext() throws Exception {
addMetadata(noVerMetadata, repository);
addMetadata(metadata, repository);
LocalMetadataRequest request = new LocalMetadataRequest(noVerMetadata, repository, "different");
LocalMetadataResult result = manager.find(session, request);
assertNull(result.getFile());
request = new LocalMetadataRequest(metadata, repository, "different");
result = manager.find(session, request);
assertNull(result.getFile());
}
Aggregations