@Test
public void validateUpdateSiteMaxAgeConfig()
throws Exception
{
RepositoryProxyResource updatesiterepo = new RepositoryProxyResource();
updatesiterepo.setRepoType("proxy");
updatesiterepo.setId("updatesite");
updatesiterepo.setName("updatesite");
updatesiterepo.setBrowseable(true);
updatesiterepo.setIndexable(false);
updatesiterepo.setNotFoundCacheTTL(1440);
updatesiterepo.setArtifactMaxAge(100);
updatesiterepo.setMetadataMaxAge(200);
updatesiterepo.setRepoPolicy("RELEASE");
updatesiterepo.setProvider("eclipse-update-site");
updatesiterepo.setProviderRole("org.sonatype.nexus.proxy.repository.Repository");
updatesiterepo.setOverrideLocalStorageUrl(null);
updatesiterepo.setDefaultLocalStorageUrl(null);
updatesiterepo.setDownloadRemoteIndexes(false);
updatesiterepo.setExposed(true);
updatesiterepo.setChecksumPolicy("WARN");
final RepositoryResourceRemoteStorage p2proxyRemoteStorage = new RepositoryResourceRemoteStorage();
p2proxyRemoteStorage.setRemoteStorageUrl("http://updatesite");
p2proxyRemoteStorage.setAuthentication(null);
p2proxyRemoteStorage.setConnectionSettings(null);
updatesiterepo.setRemoteStorage(p2proxyRemoteStorage);
updatesiterepo = (RepositoryProxyResource) repoUtil.createRepository(updatesiterepo, false);
updatesiterepo = (RepositoryProxyResource) repoUtil.getRepository(updatesiterepo.getId());
assertThat(updatesiterepo.getArtifactMaxAge(), is(100));
assertThat(updatesiterepo.getMetadataMaxAge(), is(200));
// now do an update
updatesiterepo.setArtifactMaxAge(300);
updatesiterepo.setMetadataMaxAge(400);
repoUtil.updateRepo(updatesiterepo, false);
updatesiterepo = (RepositoryProxyResource) repoUtil.getRepository(updatesiterepo.getId());
assertThat(updatesiterepo.getArtifactMaxAge(), is(300));
assertThat(updatesiterepo.getMetadataMaxAge(), is(400));
}