assertThat("File timestamp did not change, first pass", mdFile.lastModified(), not(equalTo(fileTimestamp)));
fileTimestamp = mdFile.lastModified();
// We need to wait a bit to avoid the check that last remote check = current time
Thread.sleep(500);
final StorageItem item = repository.retrieveItem(new ResourceStoreRequest(path, false));
getLogger().info(
path + " -> BEFORE assert 1 requestCount=" + expectedHits[0] + " at (" + System.currentTimeMillis() + ")");
assertThat("Remote hits count fail after first request at (" + System.currentTimeMillis() + ")",
ch.getRequestCount(), equalTo(expectedHits[0]));
getLogger().info(
path + " -> AFTER assert 1 requestCount=" + expectedHits[0] + " at (" + System.currentTimeMillis() + ")");
for (int i = 0; i < 10 && !mdFile.setLastModified(System.currentTimeMillis() - (2L * A_DAY)); i++) {
System.gc(); // helps with FS sync'ing on Windows
Thread.sleep(500); // wait for FS
}
assertThat("File timestamp did not change, second pass", mdFile.lastModified(), not(equalTo(fileTimestamp)));
fileTimestamp = mdFile.lastModified();
// We need to wait a bit to avoid the check that last remote check = current time
Thread.sleep(500);
// this goes remote depending on age setting
repository.retrieveItem(new ResourceStoreRequest(path, false));
getLogger().info(
path + " -> BEFORE assert 2 requestCount=" + expectedHits[1] + " at (" + System.currentTimeMillis() + ")");
assertThat("Remote hits count fail after second request at (" + System.currentTimeMillis() + ")",
ch.getRequestCount(), equalTo(expectedHits[1]));
getLogger().info(
path + " -> AFTER assert 2 requestCount=" + expectedHits[1] + " at (" + System.currentTimeMillis() + ")");
for (int i = 0; i < 10 && !mdFile.setLastModified(System.currentTimeMillis() - (1L * A_DAY)); i++) {
System.gc(); // helps with FS sync'ing on Windows
Thread.sleep(500); // wait for FS
}
assertThat("File timestamp did not change, third pass", mdFile.lastModified(), not(equalTo(fileTimestamp)));
fileTimestamp = mdFile.lastModified();
// set up last checked timestamp so that nexus should go remote
final RepositoryItemUid uid = item.getRepositoryItemUid();
final AttributeStorage storage = uid.getRepository().getAttributesHandler().getAttributeStorage();
final Attributes attributes = item.getRepositoryItemAttributes();
attributes.setCheckedRemotely(System.currentTimeMillis() - ((Math.abs(age) + 1) * 60 * 1000));
storage.putAttributes(uid, attributes);
// We need to wait a bit to avoid the check that last remote check = current time
Thread.sleep(500);