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());
}
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());
}
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);
}
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();
}
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());
}
Aggregations