@Before public void deploySnapshotArtifacts() throws Exception { initFolders(); File oldSnapshot = getTestFile("repo"); // Copying to keep an old timestamp FileUtils.copyDirectory(oldSnapshot, repositoryPath); RepositoryMessageUtil.updateIndexes("nexus-test-harness-snapshot-repo"); }
@Test public void testSnapRepoDeployFilesRunTaskDeleteIFRelease() throws IOException, Exception { // create a snapshot repository createSnapshotRepo(snapRepoId); // add some artifacts copyToSnapRepo(snapRepoId); TaskScheduleUtil.waitForAllTasksToStop(); // update indexes for search RepositoryMessageUtil.updateIndexes(snapRepoId); TaskScheduleUtil.waitForAllTasksToStop(); // set Remover task parameters 2 latest version snapshots should be left over ScheduledServicePropertyResource keepSnapshotsProp = new ScheduledServicePropertyResource(); keepSnapshotsProp.setKey(IVYSnapshotRemovalTaskDescriptor.MIN_TO_KEEP_FIELD_ID); keepSnapshotsProp.setValue(String.valueOf(2)); ScheduledServicePropertyResource ageProp = new ScheduledServicePropertyResource(); ageProp.setKey(IVYSnapshotRemovalTaskDescriptor.KEEP_DAYS_FIELD_ID); ageProp.setValue(String.valueOf(0)); // and if a release version exists it should be removed too ScheduledServicePropertyResource relProp = new ScheduledServicePropertyResource(); relProp.setKey(IVYSnapshotRemovalTaskDescriptor.REMOVE_WHEN_RELEASED_FIELD_ID); relProp.setValue(Boolean.toString(true)); ScheduledServicePropertyResource repos = new ScheduledServicePropertyResource(); repos.setKey("IvyRepositoryId"); repos.setValue(snapRepoId); TaskScheduleUtil.runTask( "IvySnapshotRemoval", IVYSnapshotRemovalTaskDescriptor.ID, repos, keepSnapshotsProp, ageProp, relProp); TaskScheduleUtil.waitForAllTasksToStop(); getEventInspectorsUtil().waitForCalmPeriod(); // firstly assert that there is the artifact "auth-api" version "0.8-102" left over with // ".source.jar" and ".jar" Gav gav = GavUtil.newGav("ivyRemover", "auth-api", "0.8-102"); List<NexusArtifact> result = getSearchMessageUtil().searchForGav(gav, snapRepoId); Assert.assertEquals( result.size(), 2, "Results: \n" + XStreamFactory.getXmlXStream().toXML(result)); // secondly assert that there is the artifact "auth-api" version "0.8-103" left over with // ".source.jar" and ".jar" gav = GavUtil.newGav("ivyRemover", "auth-api", "0.8-103"); result = getSearchMessageUtil().searchForGav(gav, snapRepoId); Assert.assertEquals( result.size(), 2, "Results: \n" + XStreamFactory.getXmlXStream().toXML(result)); // thirdly assert that there isn't the artifact "auth-mod" version "0.8-102" left over gav = GavUtil.newGav("ivyRemover", "auth-mod", "1.0-102"); result = getSearchMessageUtil().searchForGav(gav, snapRepoId); Assert.assertEquals( result.size(), 0, "Results: \n" + XStreamFactory.getXmlXStream().toXML(result)); // fourthly assert that there isn't the artifact "auth-api" version "0.8-103" left over gav = GavUtil.newGav("ivyRemover", "auth-mod", "1.0-103"); result = getSearchMessageUtil().searchForGav(gav, snapRepoId); Assert.assertEquals( result.size(), 0, "Results: \n" + XStreamFactory.getXmlXStream().toXML(result)); // fifthly assert that there are at least 2 of 8 snapshots with 2 jar files in the whole test // group, 6 removed result = getSearchMessageUtil().searchFor(Collections.singletonMap("q", "ivyRemover"), snapRepoId); Assert.assertEquals( result.size(), 4, "Results: \n" + XStreamFactory.getXmlXStream().toXML(result)); }