Search in sources :

Example 6 with Artifact

use of org.sonatype.aether.artifact.Artifact in project sonatype-aether by sonatype.

the class GetTest method testDownloadArtifactChecksumFailure.

@Test
public void testDownloadArtifactChecksumFailure() throws Exception {
    addDelivery("gid/aid/version/aid-version-classifier.extension", "artifact");
    addDelivery("gid/aid/version/aid-version-classifier.extension.sha1", "foo");
    addDelivery("gid/aid/version/aid-version-classifier.extension.md5", "bar");
    File f = TestFileUtils.createTempFile("");
    Artifact a = artifact("bla");
    ArtifactDownload down = new ArtifactDownload(a, null, f, RepositoryPolicy.CHECKSUM_POLICY_FAIL);
    Collection<? extends ArtifactDownload> downs = Arrays.asList(down);
    connector().get(downs, null);
    assertNotNull(down.getException());
}
Also used : ArtifactDownload(org.sonatype.aether.spi.connector.ArtifactDownload) File(java.io.File) Artifact(org.sonatype.aether.artifact.Artifact) Test(org.junit.Test)

Example 7 with Artifact

use of org.sonatype.aether.artifact.Artifact in project sonatype-aether by sonatype.

the class GetTest method testDownloadArtifactNoChecksumAvailable.

@Test
public void testDownloadArtifactNoChecksumAvailable() throws Exception {
    addDelivery("gid/aid/version/aid-version-classifier.extension", "artifact");
    File f = TestFileUtils.createTempFile("");
    Artifact a = artifact("foo");
    ArtifactDownload down = new ArtifactDownload(a, null, f, RepositoryPolicy.CHECKSUM_POLICY_FAIL);
    Collection<? extends ArtifactDownload> downs = Arrays.asList(down);
    connector().get(downs, null);
    TestFileUtils.assertContent("", f);
    assertNotNull(down.getException());
}
Also used : ArtifactDownload(org.sonatype.aether.spi.connector.ArtifactDownload) File(java.io.File) Artifact(org.sonatype.aether.artifact.Artifact) Test(org.junit.Test)

Example 8 with Artifact

use of org.sonatype.aether.artifact.Artifact in project sonatype-aether by sonatype.

the class GetTest method testClosedGet.

@Test(expected = IllegalStateException.class)
public void testClosedGet() throws Exception {
    connector().close();
    File f = TestFileUtils.createTempFile("");
    Artifact a = artifact("foo");
    ArtifactDownload down = new ArtifactDownload(a, null, f, RepositoryPolicy.CHECKSUM_POLICY_FAIL);
    Collection<? extends ArtifactDownload> downs = Arrays.asList(down);
    connector().get(downs, null);
}
Also used : ArtifactDownload(org.sonatype.aether.spi.connector.ArtifactDownload) File(java.io.File) Artifact(org.sonatype.aether.artifact.Artifact) Test(org.junit.Test)

Example 9 with Artifact

use of org.sonatype.aether.artifact.Artifact in project sonatype-aether by sonatype.

the class UnsolvableVersionConflictException method toPath.

private static String toPath(List<DependencyNode> path) {
    StringBuilder buffer = new StringBuilder(256);
    for (Iterator<DependencyNode> it = path.iterator(); it.hasNext(); ) {
        DependencyNode node = it.next();
        if (node.getDependency() == null) {
            continue;
        }
        Artifact artifact = node.getDependency().getArtifact();
        buffer.append(artifact.getGroupId());
        buffer.append(':').append(artifact.getArtifactId());
        buffer.append(':').append(artifact.getExtension());
        if (artifact.getClassifier().length() > 0) {
            buffer.append(':').append(artifact.getClassifier());
        }
        buffer.append(':').append(node.getVersionConstraint());
        if (it.hasNext()) {
            buffer.append(" -> ");
        }
    }
    return buffer.toString();
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) Artifact(org.sonatype.aether.artifact.Artifact)

Example 10 with Artifact

use of org.sonatype.aether.artifact.Artifact in project sonatype-aether by sonatype.

the class DefaultUpdateCheckManagerTest method testCheckArtifactUpdatePolicyRequired.

@Test
public void testCheckArtifactUpdatePolicyRequired() throws Exception {
    UpdateCheck<Artifact, ArtifactTransferException> check = newArtifactCheck();
    check.setItem(artifact);
    check.setFile(artifact.getFile());
    Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
    cal.add(Calendar.DATE, -1);
    long lastUpdate = cal.getTimeInMillis();
    artifact.getFile().setLastModified(lastUpdate);
    check.setLocalLastUpdated(lastUpdate);
    check.setPolicy(RepositoryPolicy.UPDATE_POLICY_ALWAYS);
    manager.checkArtifact(session, check);
    assertNull(check.getException());
    assertTrue(check.isRequired());
    check.setPolicy(RepositoryPolicy.UPDATE_POLICY_DAILY);
    manager.checkArtifact(session, check);
    assertNull(check.getException());
    assertTrue(check.isRequired());
    check.setPolicy(RepositoryPolicy.UPDATE_POLICY_INTERVAL + ":60");
    manager.checkArtifact(session, check);
    assertNull(check.getException());
    assertTrue(check.isRequired());
}
Also used : ArtifactTransferException(org.sonatype.aether.transfer.ArtifactTransferException) Calendar(java.util.Calendar) StubArtifact(org.sonatype.aether.test.util.impl.StubArtifact) Artifact(org.sonatype.aether.artifact.Artifact) Test(org.junit.Test)

Aggregations

Artifact (org.sonatype.aether.artifact.Artifact)116 Test (org.junit.Test)63 File (java.io.File)33 RemoteRepository (org.sonatype.aether.repository.RemoteRepository)30 StubArtifact (org.sonatype.aether.test.util.impl.StubArtifact)28 DefaultArtifact (org.sonatype.aether.util.artifact.DefaultArtifact)27 Dependency (org.sonatype.aether.graph.Dependency)22 ArtifactResult (org.sonatype.aether.resolution.ArtifactResult)17 ArtifactDownload (org.sonatype.aether.spi.connector.ArtifactDownload)16 LocalArtifactRequest (org.sonatype.aether.repository.LocalArtifactRequest)15 LocalArtifactResult (org.sonatype.aether.repository.LocalArtifactResult)15 ArtifactRequest (org.sonatype.aether.resolution.ArtifactRequest)14 RepositorySystemSession (org.sonatype.aether.RepositorySystemSession)13 SubArtifact (org.sonatype.aether.util.artifact.SubArtifact)13 ArrayList (java.util.ArrayList)12 ArtifactTransferException (org.sonatype.aether.transfer.ArtifactTransferException)12 Metadata (org.sonatype.aether.metadata.Metadata)10 RepositorySystem (org.sonatype.aether.RepositorySystem)9 IOException (java.io.IOException)8 HashMap (java.util.HashMap)8