use of org.sonatype.aether.transfer.ArtifactTransferException 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());
}
use of org.sonatype.aether.transfer.ArtifactTransferException in project sonatype-aether by sonatype.
the class DefaultUpdateCheckManagerTest method testCheckArtifactUpdatePolicyNotRequired.
@Test
public void testCheckArtifactUpdatePolicyNotRequired() throws Exception {
UpdateCheck<Artifact, ArtifactTransferException> check = newArtifactCheck();
check.setItem(artifact);
check.setFile(artifact.getFile());
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
cal.add(Calendar.HOUR_OF_DAY, -1);
check.setLocalLastUpdated(cal.getTimeInMillis());
check.setPolicy(RepositoryPolicy.UPDATE_POLICY_NEVER);
manager.checkArtifact(session, check);
assertFalse(check.isRequired());
check.setPolicy(RepositoryPolicy.UPDATE_POLICY_DAILY);
manager.checkArtifact(session, check);
assertFalse(check.isRequired());
check.setPolicy(RepositoryPolicy.UPDATE_POLICY_INTERVAL + ":61");
manager.checkArtifact(session, check);
assertFalse(check.isRequired());
check.setPolicy("no particular policy");
manager.checkArtifact(session, check);
assertFalse(check.isRequired());
}
use of org.sonatype.aether.transfer.ArtifactTransferException in project sonatype-aether by sonatype.
the class DefaultUpdateCheckManagerTest method testCheckArtifact.
@Test
public void testCheckArtifact() throws Exception {
UpdateCheck<Artifact, ArtifactTransferException> check = newArtifactCheck();
long fifteenMinutes = new Date().getTime() - (15 * 60 * 1000);
check.getFile().setLastModified(fifteenMinutes);
// time is truncated on setLastModfied
fifteenMinutes = check.getFile().lastModified();
// never checked before
manager.checkArtifact(session, check);
assertEquals(true, check.isRequired());
// just checked
check.setLocalLastUpdated(0);
long lastUpdate = new Date().getTime();
check.getFile().setLastModified(lastUpdate);
lastUpdate = check.getFile().lastModified();
manager.checkArtifact(session, check);
assertEquals(false, check.isRequired());
// no local file, no repo timestamp
check.setLocalLastUpdated(0);
check.getFile().delete();
manager.checkArtifact(session, check);
assertEquals(true, check.isRequired());
}
use of org.sonatype.aether.transfer.ArtifactTransferException in project sonatype-aether by sonatype.
the class DefaultUpdateCheckManagerTest method testCheckArtifactErrorFromRepoCachingEnabled.
@Test
public void testCheckArtifactErrorFromRepoCachingEnabled() throws Exception {
artifact.getFile().delete();
UpdateCheck<Artifact, ArtifactTransferException> check = newArtifactCheck();
check.setPolicy(RepositoryPolicy.UPDATE_POLICY_DAILY);
check.setException(new ArtifactTransferException(artifact, repository, "some error"));
manager.touchArtifact(session, check);
resetSessionData(session);
// ! file.exists && ! updateRequired && previousError -> depends on transfer error caching
check = newArtifactCheck();
session.setTransferErrorCachingEnabled(true);
manager.checkArtifact(session, check);
assertEquals(false, check.isRequired());
assertTrue(check.getException() instanceof ArtifactTransferException);
}
use of org.sonatype.aether.transfer.ArtifactTransferException in project sonatype-aether by sonatype.
the class DefaultUpdateCheckManagerTest method testCheckArtifactNotFoundInRepoCachingEnabled.
@Test
public void testCheckArtifactNotFoundInRepoCachingEnabled() throws Exception {
artifact.getFile().delete();
session.setNotFoundCachingEnabled(true);
UpdateCheck<Artifact, ArtifactTransferException> check = newArtifactCheck();
check.setException(new ArtifactNotFoundException(artifact, repository));
manager.touchArtifact(session, check);
resetSessionData(session);
// ! file.exists && ! updateRequired -> artifact not found in remote repo
check = newArtifactCheck().setPolicy(RepositoryPolicy.UPDATE_POLICY_DAILY);
manager.checkArtifact(session, check);
assertEquals(false, check.isRequired());
assertTrue(check.getException() instanceof ArtifactNotFoundException);
}
Aggregations