Examples of GroupRepository


Examples of org.sonatype.nexus.proxy.repository.GroupRepository

  public void testGroupReindex()
      throws Exception
  {
    fillInRepo();

    GroupRepository group = (GroupRepository) repositoryRegistry.getRepository("public");

    File groupRoot = new File(new URL(group.getLocalUrl()).toURI());
    File index = new File(groupRoot, ".index");

    File indexFile = new File(index, "nexus-maven-repository-index.gz");
    File incrementalIndexFile = new File(index, "nexus-maven-repository-index.1.gz");

    assertFalse("No index .gz file should exist.", indexFile.exists());
    assertFalse("No incremental chunk should exists.", incrementalIndexFile.exists());

    indexerManager.reindexRepository(null, group.getId(), true);

    assertTrue("Index .gz file should exist.", indexFile.exists());
    assertFalse("No incremental chunk should exists.", incrementalIndexFile.exists());

    // copy some _new_ stuff, not found in any of the members
    File sourceApacheSnapshotsRoot = new File(getBasedir(), "src/test/resources/reposes/apache-snapshots-2");
    File snapshotsRoot = new File(new URL(snapshots.getLocalUrl()).toURI());
    copyDirectory(sourceApacheSnapshotsRoot, snapshotsRoot);
    indexerManager.reindexRepository(null, group.getId(), false);

    assertTrue("Index .gz file should exist.", indexFile.exists());
    assertTrue("Incremental chunk should exists.", incrementalIndexFile.exists());

    assertTrue("We expected less than 300 bytes but got " + incrementalIndexFile.length(),
View Full Code Here

Examples of org.sonatype.nexus.proxy.repository.GroupRepository

    // add repo content
    fillInRepo();

    // our patient
    final GroupRepository group = (GroupRepository) repositoryRegistry.getRepository("public");

    // reindex
    indexerManager.reindexAllRepositories(null, true);

    // Note: public by default contains snapshots repository as member
    // Snapshots repository is the only one that contains GroupID "org.sonatype.plexus".
    // Meaning, the presence of this search (is in result set or not) is used
    // to validate the group member changes.
    // Similarly, Apache Snapshots repository by default is NOT member of
    // Public, and it is the only one having artifact with groupID "org.sonatype.test-evict".

    // assure context does exists (if Igor comments out few lines or so, as MI will plainly swallow targeted search
    // against nonexistent context!)
    Assert.assertNotNull(((DefaultIndexerManager) indexerManager).getRepositoryIndexContext(group));

    // do searches
    searchFor("org.sonatype.plexus", 1, "snapshots"); // is in this repo
    searchFor("org.sonatype.plexus", 1, group.getId()); // snapshots is member of public
    searchFor("org.sonatype.test-evict", 1, "apache-snapshots"); // is in this repo
    searchFor("org.sonatype.test-evict", 0, group.getId()); // apache-snapshots not a member

    // reconfigure group: remove snapshots
    group.removeMemberRepositoryId(snapshots.getId());
    nexusConfiguration().saveConfiguration();
    waitForTasksToStop();
    wairForAsyncEventsToCalmDown();

    // assure context does exists (if Igor comments out few lines or so, as MI will plainly swallow targeted search
    // against nonexistent context!)
    Assert.assertNotNull(((DefaultIndexerManager) indexerManager).getRepositoryIndexContext(group));

    // do searches
    searchFor("org.sonatype.plexus", 1, "snapshots"); // is in this repo
    searchFor("org.sonatype.plexus", 0, group.getId()); // snapshots is not member of public
    searchFor("org.sonatype.test-evict", 1, "apache-snapshots"); // is in this repo
    searchFor("org.sonatype.test-evict", 0, group.getId()); // apache-snapshots not a member

    // reconfigure group: add apache-snapshots
    group.addMemberRepositoryId(apacheSnapshots.getId());
    nexusConfiguration().saveConfiguration();
    waitForTasksToStop();
    wairForAsyncEventsToCalmDown();

    // assure context does exists (if Igor comments out few lines or so, as MI will plainly swallow targeted search
    // against nonexistent context!)
    Assert.assertNotNull(((DefaultIndexerManager) indexerManager).getRepositoryIndexContext(group));

    // do searches
    searchFor("org.sonatype.plexus", 1, "snapshots"); // is in this repo
    searchFor("org.sonatype.plexus", 0, group.getId()); // snapshots is not member of public
    searchFor("org.sonatype.test-evict", 1, "apache-snapshots"); // is in this repo
    searchFor("org.sonatype.test-evict", 1, group.getId()); // apache-snapshots is a member of public
  }
View Full Code Here

Examples of org.sonatype.nexus.proxy.repository.GroupRepository

  {
    // add repo content
    fillInRepo();

    // our patients, group and one member
    final GroupRepository group = (GroupRepository) repositoryRegistry.getRepository("public");
    final Repository member = repositoryRegistry.getRepository("snapshots");

    // reindex
    indexerManager.reindexAllRepositories(null, true);

    // Note: public by default contains snapshots repository as member
    // Snapshots repository is the only one that contains GroupID "org.sonatype.plexus".
    // Meaning, the presence of this search (is in result set or not) is used
    // to validate the group member changes.

    // assure context does exists (if Igor comments out few lines or so, as MI will plainly swallow targeted search
    // against nonexistent context!)
    Assert.assertNotNull(((DefaultIndexerManager) indexerManager).getRepositoryIndexContext(group));
    Assert.assertNotNull(((DefaultIndexerManager) indexerManager).getRepositoryIndexContext(member));

    // do searches
    searchFor("org.sonatype.plexus", 1, member.getId()); // is in this repo
    searchFor("org.sonatype.plexus", 1, group.getId()); // snapshots is member of public

    // reconfigure group member: make it non-indexable
    member.setSearchable(false);
    member.setIndexable(false);
    nexusConfiguration().saveConfiguration();
    waitForTasksToStop();
    wairForAsyncEventsToCalmDown();

    // assure context does exists (if Igor comments out few lines or so, as MI will plainly swallow targeted search
    // against nonexistent context!)
    Assert.assertNotNull(((DefaultIndexerManager) indexerManager).getRepositoryIndexContext(group));
    Assert.assertNull(((DefaultIndexerManager) indexerManager).getRepositoryIndexContext(member));

    // do searches
    searchFor("org.sonatype.plexus", 0, member.getId()); // is in this repo
    searchFor("org.sonatype.plexus", 0, group.getId()); // snapshots is not member of public

    // reconfigure group: add apache-snapshots
    member.setSearchable(true);
    member.setIndexable(true);
    nexusConfiguration().saveConfiguration();
    waitForTasksToStop();
    wairForAsyncEventsToCalmDown();

    // assure context does exists (if Igor comments out few lines or so, as MI will plainly swallow targeted search
    // against nonexistent context!)
    Assert.assertNotNull(((DefaultIndexerManager) indexerManager).getRepositoryIndexContext(group));
    Assert.assertNotNull(((DefaultIndexerManager) indexerManager).getRepositoryIndexContext(member));

    // do searches
    searchFor("org.sonatype.plexus", 1, member.getId()); // is in this repo
    searchFor("org.sonatype.plexus", 1, group.getId()); // snapshots is not member of public
  }
View Full Code Here

Examples of org.sonatype.nexus.proxy.repository.GroupRepository

  @Override
  public void onHandle(final Repository repository, final ResourceStoreRequest request, final Action action)
      throws ItemNotFoundException
  {
    GroupRepository groupRepository = repository.adaptToFacet(GroupRepository.class);
    final String requestPath = request.getRequestPath();
    if (Action.read.equals(action) && requestPath.endsWith(PATH_OF_REPOMD_XML) && groupRepository != null) {
      Yum yum = yumRegistry.get(groupRepository.getId());
      if (yum != null && yum instanceof YumGroup) {
        for (Repository member : groupRepository.getMemberRepositories()) {
          if (member.getRepositoryKind().isFacetAvailable(ProxyRepository.class)) {
            try {
              log.debug("Fetching {}:{} member of {}", member.getId(), PATH_OF_REPOMD_XML, groupRepository.getId());
              member.retrieveItem(new ResourceStoreRequest(PATH_OF_REPOMD_XML));
            }
            catch (ItemNotFoundException e) {
              // proxy repo is not a yum repository, go on
            }
            catch (Exception e) {
              log.debug(
                  "Could not retrieve {} from {}, member of yum enabled group {}. Ignoring.",
                  PATH_OF_REPOMD_XML, member.getId(), groupRepository.getId(), e
              );
            }
          }
        }
        try {
View Full Code Here

Examples of org.sonatype.nexus.proxy.repository.GroupRepository

    }

    central.setLocalStatus(LocalStatus.OUT_OF_SERVICE);
    nexusConfiguration().saveConfiguration();

    GroupRepository group = repositoryRegistry.getRepositoryWithFacet("public", GroupRepository.class);
    group.expireCaches(new ResourceStoreRequest("/"));
  }
View Full Code Here

Examples of org.sonatype.nexus.proxy.repository.GroupRepository

      throws Exception
  {
    final Maven2ContentClass maven2ContentClass = new Maven2ContentClass();
    final RepositoryRegistry repositoryRegistry = mock(RepositoryRegistry.class);
    final Repository proxyRepository = mock(Repository.class);
    final GroupRepository groupRepository = mock(GroupRepository.class);
    final RepositoryKind groupRepositoryKind = mock(RepositoryKind.class);
    final RepositoryKind proxyRepositoryKind = mock(RepositoryKind.class);

    when(repositoryRegistry.getRepository("foo-group")).thenReturn(groupRepository);
    when(groupRepository.getRepositoryContentClass()).thenReturn(maven2ContentClass);
    when(proxyRepository.getRepositoryContentClass()).thenReturn(maven2ContentClass);
    when(groupRepository.getLocalStatus()).thenReturn(LocalStatus.IN_SERVICE);
    when(proxyRepository.getLocalStatus()).thenReturn(LocalStatus.IN_SERVICE);
    when(groupRepository.getRepositoryKind()).thenReturn(groupRepositoryKind);
    when(proxyRepository.getRepositoryKind()).thenReturn(proxyRepositoryKind);
    when(groupRepositoryKind.isFacetAvailable(GroupRepository.class)).thenReturn(true);
    when(proxyRepositoryKind.isFacetAvailable(ProxyRepository.class)).thenReturn(true);
    when(groupRepository.adaptToFacet(GroupRepository.class)).thenReturn(groupRepository);
    when(groupRepository.getMemberRepositories()).thenReturn(Arrays.asList(proxyRepository));

    final SnapshotRemovalResult result =
        new DefaultSnapshotRemover(repositoryRegistry, mock(Walker.class), maven2ContentClass)
        {
          @Override
View Full Code Here

Examples of org.sonatype.nexus.proxy.repository.GroupRepository

    assertEquals("A", repoMembers.get(0).getId());
    assertEquals("B", repoMembers.get(1).getId());
    assertEquals("C", repoMembers.get(2).getId());

    // recheck the group
    GroupRepository group = repositoryRegistry.getRepositoryWithFacet("ALL", GroupRepository.class);

    assertEquals(3, group.getMemberRepositories().size());

    // and remove them all
    List<? extends Repository> repositories = repositoryRegistry.getRepositoriesWithFacet(HostedRepository.class);

    for (Repository repo : repositories) {
      repositoryRegistry.removeRepository(repo.getId());
    }

    try {
      repoMembers =
          repositoryRegistry.getRepositoryWithFacet("ALL", GroupRepository.class).getMemberRepositories();

      assertEquals(0, repoMembers.size());
    }
    catch (NoSuchRepositoryException e) {
      fail("Repo group should remain as empty group!");
    }

    repoMembers = repositoryRegistry.getRepositories();

    assertEquals(1, repoMembers.size());

    // the group is there alone, recheck it again
    group = repositoryRegistry.getRepositoryWithFacet("ALL", GroupRepository.class);

    assertEquals(0, group.getMemberRepositories().size());
  }
View Full Code Here

Examples of org.sonatype.nexus.proxy.repository.GroupRepository

      throws Exception
  {
    final MergeMetadataTask task = new MergeMetadataTask(
        mock(EventBus.class), mock(YumRegistry.class), mock(CommandLineExecutor.class)
    );
    final GroupRepository group = mock(GroupRepository.class);
    when(group.getId()).thenReturn(GROUP_ID_1);
    task.setGroupRepository(group);
    assertThat(task.allowConcurrentExecution(createRunningTaskForGroups(group)), is(false));
  }
View Full Code Here

Examples of org.sonatype.nexus.proxy.repository.GroupRepository

      throws Exception
  {
    final MergeMetadataTask task = new MergeMetadataTask(
        mock(EventBus.class), mock(YumRegistry.class), mock(CommandLineExecutor.class)
    );
    final GroupRepository group1 = mock(GroupRepository.class);
    when(group1.getId()).thenReturn(GROUP_ID_1);
    final GroupRepository group2 = mock(GroupRepository.class);
    when(group2.getId()).thenReturn(GROUP_ID_2);
    task.setGroupRepository(group1);
    assertThat(task.allowConcurrentExecution(createRunningTaskForGroups(group2)), is(true));
  }
View Full Code Here

Examples of org.sonatype.nexus.proxy.repository.GroupRepository

        {
            // do not exists, creating it!
            Repository repo = createFlexmojosRepository();
            if ( repo != null )
            {
                GroupRepository group = setupPublicGroup( repo );
                if ( group != null )
                {
                    setupRouting( group, repo );
                }
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.