Search in sources :

Example 1 with TestLocalRepositoryManager

use of org.sonatype.aether.test.impl.TestLocalRepositoryManager in project sonatype-aether by sonatype.

the class DefaultMetadataResolverTest method testResolve.

@Test
public void testResolve() throws IOException {
    connector.setExpectGet(metadata);
    // prepare "download"
    File file = new File(session.getLocalRepository().getBasedir(), session.getLocalRepositoryManager().getPathForRemoteMetadata(metadata, repository, ""));
    TestFileUtils.write(file.getAbsolutePath(), file);
    MetadataRequest request = new MetadataRequest(metadata, repository, "");
    List<MetadataResult> results = resolver.resolveMetadata(session, Arrays.asList(request));
    assertEquals(1, results.size());
    MetadataResult result = results.get(0);
    assertSame(request, result.getRequest());
    assertNull(result.getException());
    assertNotNull(result.getMetadata());
    assertNotNull(result.getMetadata().getFile());
    assertEquals(file, result.getMetadata().getFile());
    assertEquals(metadata, result.getMetadata().setFile(null));
    connector.assertSeenExpected();
    Set<Metadata> metadataRegistration = ((TestLocalRepositoryManager) session.getLocalRepositoryManager()).getMetadataRegistration();
    assertTrue(metadataRegistration.contains(metadata));
    assertEquals(1, metadataRegistration.size());
}
Also used : TestLocalRepositoryManager(org.sonatype.aether.test.impl.TestLocalRepositoryManager) MetadataRequest(org.sonatype.aether.resolution.MetadataRequest) StubMetadata(org.sonatype.aether.test.util.impl.StubMetadata) Metadata(org.sonatype.aether.metadata.Metadata) File(java.io.File) MetadataResult(org.sonatype.aether.resolution.MetadataResult) Test(org.junit.Test)

Aggregations

File (java.io.File)1 Test (org.junit.Test)1 Metadata (org.sonatype.aether.metadata.Metadata)1 MetadataRequest (org.sonatype.aether.resolution.MetadataRequest)1 MetadataResult (org.sonatype.aether.resolution.MetadataResult)1 TestLocalRepositoryManager (org.sonatype.aether.test.impl.TestLocalRepositoryManager)1 StubMetadata (org.sonatype.aether.test.util.impl.StubMetadata)1