@Test
  public void testOneRun() throws Exception {
    fillInRepo();

    final int countTotalBefore =
        countFiles(snapshots, new String[] {"**/maven-metadata.xml"}, new String[] {".nexus/**"});

    RebuildMavenMetadataTask task =
        nexusScheduler.createTaskInstance( //
            RebuildMavenMetadataTask.class);

    task.setRepositoryId(snapshots.getId());

    ScheduledTask<Object> handle = nexusScheduler.submit("task", task);

    // block until it finishes
    handle.get();

    // count it again
    final int countTotalAfter =
        countFiles(snapshots, new String[] {"**/maven-metadata.xml"}, new String[] {".nexus/**"});

    // assert
    assertTrue(
        "We should have more md's after rebuilding them, since we have some of them missing!",
        countTotalBefore < countTotalAfter);
  }
Exemplo n.º 2
0
  public void mirror(boolean force) {
    UpdateSiteMirrorTask task = scheduler.createTaskInstance(UpdateSiteMirrorTask.class);

    task.setRepositoryId(this.getId());
    task.setForce(force);

    scheduler.submit("Eclipse Update Site Mirror (" + this.getId() + ")", task);
  }
Exemplo n.º 3
0
  /** Empty the wastebasket. */
  @Override
  @DELETE
  @ResourceMethodSignature()
  public void delete(Context context, Request request, Response response) throws ResourceException {
    EmptyTrashTask task = nexusScheduler.createTaskInstance(EmptyTrashTask.class);

    nexusScheduler.submit("Internal", task);

    response.setStatus(Status.SUCCESS_NO_CONTENT);
  }
  @Test
  public void testOneRunWithSubpath() throws Exception {
    fillInRepo();

    // we will initiate a task with "subpath" of /org/sonatype, so we count the files of total and
    // the processed and
    // non-processed set
    // to be able to perform checks at the end
    final int countTotalBefore =
        countFiles(snapshots, new String[] {"**/maven-metadata.xml"}, new String[] {".nexus/**"});
    final int countNonProcessedSubBefore =
        countFiles(
            snapshots,
            new String[] {"**/maven-metadata.xml"},
            new String[] {".nexus/**", "org/sonatype/**/maven-metadata.xml"});
    final int countProcessedSubBefore =
        countFiles(
            snapshots,
            new String[] {"org/sonatype/**/maven-metadata.xml"},
            new String[] {".nexus/**"});

    RebuildMavenMetadataTask task =
        nexusScheduler.createTaskInstance( //
            RebuildMavenMetadataTask.class);

    task.setRepositoryId(snapshots.getId());
    task.setResourceStorePath("/org/sonatype");

    ScheduledTask<Object> handle = nexusScheduler.submit("task", task);

    // block until it finishes
    handle.get();

    // count it again
    final int countTotalAfter =
        countFiles(snapshots, new String[] {"**/maven-metadata.xml"}, new String[] {".nexus/**"});
    final int countNonProcessedSubAfter =
        countFiles(
            snapshots,
            new String[] {"**/maven-metadata.xml"},
            new String[] {".nexus/**", "org/sonatype/**/maven-metadata.xml"});
    final int countProcessedSubAfter =
        countFiles(
            snapshots,
            new String[] {"org/sonatype/**/maven-metadata.xml"},
            new String[] {".nexus/**"});

    // assert
    assertTrue(
        String.format(
            "We should have more md's after rebuilding them, since we have some of them missing! (%s, %s)",
            new Object[] {countTotalBefore, countTotalAfter}),
        countTotalBefore < countTotalAfter);
    assertTrue(
        String.format(
            "We should have same count of md's after rebuilding them for non-processed ones! (%s, %s)",
            new Object[] {countNonProcessedSubBefore, countNonProcessedSubAfter}),
        countNonProcessedSubBefore == countNonProcessedSubAfter);
    assertTrue(
        String.format(
            "We should have more md's after rebuilding them for processed ones, since we have some of them missing! (%s, %s)",
            new Object[] {countProcessedSubBefore, countProcessedSubAfter}),
        countProcessedSubBefore < countProcessedSubAfter);

    // the total change has to equals to processed change
    assertTrue(
        "We should have same change on total level as we have on processed ones, since we have some of them missing!",
        (countTotalAfter - countTotalBefore) == (countProcessedSubAfter - countProcessedSubBefore));
  }