@Test public void validateP2ProxyMaxAgeConfig() throws Exception { RepositoryProxyResource p2repo = new RepositoryProxyResource(); p2repo.setRepoType("proxy"); p2repo.setId("p2proxy"); p2repo.setName("p2proxy"); p2repo.setBrowseable(true); p2repo.setIndexable(false); p2repo.setNotFoundCacheTTL(1440); p2repo.setArtifactMaxAge(100); p2repo.setMetadataMaxAge(200); p2repo.setRepoPolicy("RELEASE"); p2repo.setProvider("p2"); p2repo.setProviderRole("org.sonatype.nexus.proxy.repository.Repository"); p2repo.setOverrideLocalStorageUrl(null); p2repo.setDefaultLocalStorageUrl(null); p2repo.setDownloadRemoteIndexes(false); p2repo.setExposed(true); p2repo.setChecksumPolicy("WARN"); final RepositoryResourceRemoteStorage p2proxyRemoteStorage = new RepositoryResourceRemoteStorage(); p2proxyRemoteStorage.setRemoteStorageUrl("http://p2proxy"); p2proxyRemoteStorage.setAuthentication(null); p2proxyRemoteStorage.setConnectionSettings(null); p2proxyRemoteStorage.setHttpProxySettings(null); p2repo.setRemoteStorage(p2proxyRemoteStorage); p2repo = (RepositoryProxyResource) repoUtil.createRepository(p2repo, false); p2repo = (RepositoryProxyResource) repoUtil.getRepository(p2repo.getId()); assertThat(p2repo.getArtifactMaxAge(), is(100)); assertThat(p2repo.getMetadataMaxAge(), is(200)); // now do an update p2repo.setArtifactMaxAge(300); p2repo.setMetadataMaxAge(400); repoUtil.updateRepo(p2repo, false); p2repo = (RepositoryProxyResource) repoUtil.getRepository(p2repo.getId()); assertThat(p2repo.getArtifactMaxAge(), is(300)); assertThat(p2repo.getMetadataMaxAge(), is(400)); }
@Test public void updateRepoTest() throws Exception { // change the name of the test repo RepositoryMessageUtil repoUtil = new RepositoryMessageUtil( this.getXMLXStream(), MediaType.APPLICATION_XML, getRepositoryTypeRegistry()); RepositoryBaseResource repo = repoUtil.getRepository(this.getTestRepositoryId()); String oldName = repo.getName(); String newName = repo.getName() + "-new"; repo.setName(newName); repoUtil.updateRepo(repo); TaskScheduleUtil.waitForAllTasksToStop(); final SyndFeed feed = FeedUtil.getFeed("systemChanges"); this.validateLinksInFeeds(feed); Assert.assertTrue( "Update repo feed not found\r\n\r\n" + feed, findFeedEntry(feed, "Configuration change", new String[] {newName, oldName})); }
@Test public void testIndexTree() throws Exception { String repoId = this.getTestRepositoryId(); // get the index tree Response response = RequestFacade.doGetRequest( RequestFacade.SERVICE_LOCAL + "repositories/" + repoId + "/index_content/"); Assert.assertEquals(200, response.getStatus().getCode()); RepositoryMessageUtil repoUtil = new RepositoryMessageUtil(this, this.getXMLXStream(), MediaType.APPLICATION_XML); RepositoryResource resource = (RepositoryResource) repoUtil.getRepository(repoId); resource.setIndexable(false); repoUtil.updateRepo(resource); // get the index tree response = RequestFacade.doGetRequest( RequestFacade.SERVICE_LOCAL + "repositories/" + repoId + "/index_content/"); Assert.assertEquals(404, response.getStatus().getCode()); }