Package org.sonatype.nexus.proxy.registry

Examples of org.sonatype.nexus.proxy.registry.RepositoryRegistry


  @Test
  public void testDisposeInvoked()
      throws Exception
  {
    final RepositoryTypeRegistry repositoryTypeRegistry = lookup(RepositoryTypeRegistry.class);
    final RepositoryRegistry repositoryRegistry = lookup(RepositoryRegistry.class);
    final NexusConfiguration nexusConfiguration = lookup(NexusConfiguration.class);
    final TemplateManager templateManager = lookup(TemplateManager.class);

    // register this
    repositoryTypeRegistry.registerRepositoryTypeDescriptors(new RepositoryTypeDescriptor(Repository.class,
        Nexus4807RepositoryImpl.ID, "foo"));

    // load config
    nexusConfiguration.loadConfiguration();

    // assert we have peter not present
    try {
      repositoryRegistry.getRepository("peter");
      Assert.fail("Peter should not be present!");
    }
    catch (NoSuchRepositoryException e) {
      // good, it should be not present
    }

    // create this new repo type
    final RepositoryTemplate template =
        (RepositoryTemplate) templateManager.getTemplates().getTemplateById("nexus4807");
    template.getConfigurableRepository().setId("peter");
    template.getConfigurableRepository().setName("We all love Peter!");
    final Repository repository = template.create();

    // do some simple assertion
    assertThat(repository.getId(), equalTo("peter"));
    assertThat(repository.getName(), equalTo("We all love Peter!"));
    // assert peter is here simply, by having this below not throw any exception and returning non-null
    // note: by interface contract, this method never returns null: either returns value or throws exception
    assertThat(repositoryRegistry.getRepository("peter"), notNullValue());

    // now drop it
    nexusConfiguration.deleteRepository(repository.getId());

    // assert peter left the building
    try {
      repositoryRegistry.getRepository("peter");
      Assert.fail("Peter should not be present, he just left!");
    }
    catch (NoSuchRepositoryException e) {
      // good, he left of main entrance
    }
View Full Code Here


    try {
      // lookup nexus, this will do all sort of things, amongst them validate the config
      startNx();

      RepositoryRegistry repositoryRegistry = lookup(RepositoryRegistry.class);

      MavenGroupRepository publicGroup =
          repositoryRegistry.getRepositoryWithFacet("public", MavenGroupRepository.class);

      List<String> memberIds = new ArrayList<String>();
      for (Repository repo : publicGroup.getMemberRepositories()) {
        memberIds.add(repo.getId());
      }
View Full Code Here

  @Test
  public void shouldFailOnProxyRepositories()
      throws Exception
  {
    final RepositoryRegistry repositoryRegistry = mock(RepositoryRegistry.class);
    final TargetRegistry targetRegistry = mock(TargetRegistry.class);
    final Repository proxyRepository = mock(Repository.class);
    final RepositoryKind proxyRepositoryKind = mock(RepositoryKind.class);

    when(repositoryRegistry.getRepository(REPO_ID)).thenReturn(proxyRepository);
    when(proxyRepository.getRepositoryContentClass()).thenReturn(MAVEN_2_CONTENT_CLASS);
    when(proxyRepository.getLocalStatus()).thenReturn(LocalStatus.IN_SERVICE);
    when(proxyRepository.getRepositoryKind()).thenReturn(proxyRepositoryKind);
    when(proxyRepositoryKind.isFacetAvailable(ProxyRepository.class)).thenReturn(true);
View Full Code Here

  @Test
  public void shouldFailOnNonMaven2Repositories()
      throws Exception
  {
    final RepositoryRegistry repositoryRegistry = mock(RepositoryRegistry.class);
    final TargetRegistry targetRegistry = mock(TargetRegistry.class);
    final Repository repository = mock(Repository.class);

    when(repositoryRegistry.getRepository(REPO_ID)).thenReturn(repository);
    when(repository.getRepositoryContentClass()).thenReturn(MAVEN_1_CONTENT_CLASS);

    thrown.expect(IllegalArgumentException.class);
    new DefaultReleaseRemover(repositoryRegistry, targetRegistry, mock(Walker.class), MAVEN_2_CONTENT_CLASS)
        .removeReleases(new ReleaseRemovalRequest(REPO_ID, 1, null));
View Full Code Here

  @Test
  public void shouldFailOnOutOfServiceRepositories()
      throws Exception
  {
    final RepositoryRegistry repositoryRegistry = mock(RepositoryRegistry.class);
    final TargetRegistry targetRegistry = mock(TargetRegistry.class);

    final Repository repository = mock(Repository.class);

    when(repositoryRegistry.getRepository(REPO_ID)).thenReturn(repository);
    when(repository.getRepositoryContentClass()).thenReturn(MAVEN_2_CONTENT_CLASS);
    when(repository.getLocalStatus()).thenReturn(LocalStatus.OUT_OF_SERVICE);

    thrown.expect(IllegalArgumentException.class);
    new DefaultReleaseRemover(repositoryRegistry, targetRegistry, mock(Walker.class), MAVEN_2_CONTENT_CLASS)
View Full Code Here

  @Test
  public void shouldFailOnGroupRepositories()
      throws Exception
  {
    final RepositoryRegistry repositoryRegistry = mock(RepositoryRegistry.class);
    final TargetRegistry targetRegistry = mock(TargetRegistry.class);
    final Repository repository = mock(Repository.class);
    final RepositoryKind repositoryKind = mock(RepositoryKind.class);

    when(repositoryRegistry.getRepository(REPO_ID)).thenReturn(repository);
    when(repository.getRepositoryContentClass()).thenReturn(MAVEN_2_CONTENT_CLASS);
    when(repository.getLocalStatus()).thenReturn(LocalStatus.IN_SERVICE);
    when(repository.getRepositoryKind()).thenReturn(repositoryKind);
    when(repositoryKind.isFacetAvailable(GroupRepository.class)).thenReturn(true);
View Full Code Here

  @Test
  public void shouldFailOnSnapshotRepositories()
      throws Exception
  {
    final RepositoryRegistry repositoryRegistry = mock(RepositoryRegistry.class);
    final TargetRegistry targetRegistry = mock(TargetRegistry.class);
    final Repository repository = mock(Repository.class);
    final RepositoryKind repositoryKind = mock(RepositoryKind.class);
    final MavenRepository mavenRepository = mock(MavenRepository.class);

    when(repositoryRegistry.getRepository(REPO_ID)).thenReturn(repository);
    when(repository.getRepositoryContentClass()).thenReturn(MAVEN_2_CONTENT_CLASS);
    when(repository.getLocalStatus()).thenReturn(LocalStatus.IN_SERVICE);
    when(repository.getRepositoryKind()).thenReturn(repositoryKind);
    when(repositoryKind.isFacetAvailable(GroupRepository.class)).thenReturn(false);
    when(repository.adaptToFacet(MavenRepository.class)).thenReturn(mavenRepository);
View Full Code Here

  @Test
  public void shouldFailOnMixedRepositories()
      throws Exception
  {
    final RepositoryRegistry repositoryRegistry = mock(RepositoryRegistry.class);
    final TargetRegistry targetRegistry = mock(TargetRegistry.class);
    final Repository repository = mock(Repository.class);
    final RepositoryKind repositoryKind = mock(RepositoryKind.class);
    final MavenRepository mavenRepository = mock(MavenRepository.class);

    when(repositoryRegistry.getRepository(REPO_ID)).thenReturn(repository);
    when(repository.getRepositoryContentClass()).thenReturn(MAVEN_1_CONTENT_CLASS);
    when(repository.getLocalStatus()).thenReturn(LocalStatus.IN_SERVICE);
    when(repository.getRepositoryKind()).thenReturn(repositoryKind);
    when(repositoryKind.isFacetAvailable(GroupRepository.class)).thenReturn(false);
    when(repository.adaptToFacet(MavenRepository.class)).thenReturn(mavenRepository);
View Full Code Here

  @Test
  public void shouldFailOnMissingTarget()
      throws Exception
  {
    final RepositoryRegistry repositoryRegistry = mock(RepositoryRegistry.class);
    final TargetRegistry targetRegistry = mock(TargetRegistry.class);
    final Repository repository = mock(Repository.class);

    when(repositoryRegistry.getRepository(REPO_ID)).thenReturn(repository);
    when(targetRegistry.getRepositoryTarget(TARGET_ID)).thenReturn(null);

    thrown.expect(IllegalStateException.class);
    new DefaultReleaseRemover(repositoryRegistry, targetRegistry, mock(Walker.class), MAVEN_2_CONTENT_CLASS)
        .removeReleases(new ReleaseRemovalRequest(REPO_ID, 1, TARGET_ID));
View Full Code Here

  @Test
  public void testOnEmptyRepo()
      throws Exception
  {
    final RepositoryRegistry repositoryRegistry = mock(RepositoryRegistry.class);
    final TargetRegistry targetRegistry = mock(TargetRegistry.class);
    final Repository repository = mock(Repository.class);
    final RepositoryKind repositoryKind = mock(RepositoryKind.class);
    final MavenRepository mavenRepository = mock(MavenRepository.class);

    when(repositoryRegistry.getRepository(REPO_ID)).thenReturn(repository);
    when(targetRegistry.getRepositoryTarget(TARGET_ID)).thenReturn(null);
    when(repositoryRegistry.getRepository(REPO_ID)).thenReturn(repository);
    when(repository.getRepositoryContentClass()).thenReturn(MAVEN_2_CONTENT_CLASS);
    when(repository.getLocalStatus()).thenReturn(LocalStatus.IN_SERVICE);
    when(repository.getRepositoryKind()).thenReturn(repositoryKind);
    when(repositoryKind.isFacetAvailable(ProxyRepository.class)).thenReturn(false);
    when(repository.adaptToFacet(MavenRepository.class)).thenReturn(mavenRepository);
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.proxy.registry.RepositoryRegistry

Copyright © 2018 www.massapicom. 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.