Package org.sonatype.nexus.proxy.maven.routing

Examples of org.sonatype.nexus.proxy.maven.routing.Manager


  {
    // all is settled now, proxy should have prefix file pulled from remote AND merged with cache content
    final MavenProxyRepository proxyRepository =
        getRepositoryRegistry().getRepositoryWithFacet(PROXY_REPO_ID, MavenProxyRepository.class);

    final Manager routingManager = lookup(Manager.class);
    final PrefixSource proxyPrefixSource = routingManager.getPrefixSourceFor(proxyRepository);

    assertThat("Prefix file for proxy repository should exists", proxyPrefixSource.exists());
    assertThat("Prefix file for proxy repository should be discovered", proxyPrefixSource.supported());
    assertThat("Prefix file should be instanceof FilePrefixSource", proxyPrefixSource instanceof FilePrefixSource);
View Full Code Here


  @Test
  public void contentUponBoot()
      throws Exception
  {
    final Manager wm = lookup(Manager.class);
    waitForRoutingBackgroundUpdates();

    // after boot, we should have group WL exist (as all 2 member WLs should exist)
    // group1 WL should be union of the 2 proxy member WLs
    {
      final PrefixSource groupPrefixSource =
          wm.getPrefixSourceFor(getRepositoryRegistry().getRepositoryWithFacet(GROUP1_REPO_ID,
              MavenRepository.class));

      assertThat("Group1 should have WL", groupPrefixSource.supported());

      final List<String> groupEntries = groupPrefixSource.readEntries();
      assertThat(groupEntries, hasSize(3));
      assertThat(groupEntries, hasItem("/com/sonatype"));
      assertThat(groupEntries, hasItem("/org/sonatype"));
      assertThat(groupEntries, hasItem("/org/apache"));
    }
    // group2 WL should be same as group1 (is only member)
    {
      final PrefixSource groupPrefixSource =
          wm.getPrefixSourceFor(getRepositoryRegistry().getRepositoryWithFacet(GROUP2_REPO_ID,
              MavenRepository.class));

      assertThat("Group2 should have WL", groupPrefixSource.supported());

      final List<String> groupEntries = groupPrefixSource.readEntries();
View Full Code Here

    // remove the proxy2 from group
    getRepositoryRegistry().getRepositoryWithFacet(GROUP1_REPO_ID, MavenGroupRepository.class).removeMemberRepositoryId(
        PROXY2_REPO_ID);
    getApplicationConfiguration().saveConfiguration();

    final Manager wm = lookup(Manager.class);
    waitForRoutingBackgroundUpdates();

    // group1 WL should have only proxy1 WL
    {
      final PrefixSource groupPrefixSource =
          wm.getPrefixSourceFor(getRepositoryRegistry().getRepositoryWithFacet(GROUP1_REPO_ID,
              MavenRepository.class));

      assertThat("Group1 should have WL", groupPrefixSource.supported());

      final List<String> groupEntries = groupPrefixSource.readEntries();
      assertThat(groupEntries, hasSize(1));
      assertThat(groupEntries, hasItem("/org/apache"));
    }
    // group2 WL should be same as group1 (is only member)
    {
      final PrefixSource groupPrefixSource =
          wm.getPrefixSourceFor(getRepositoryRegistry().getRepositoryWithFacet(GROUP2_REPO_ID,
              MavenRepository.class));

      assertThat("Group2 should have WL", groupPrefixSource.supported());

      final List<String> groupEntries = groupPrefixSource.readEntries();
View Full Code Here

    // add the proxy3 to group
    getRepositoryRegistry().getRepositoryWithFacet(GROUP1_REPO_ID, MavenGroupRepository.class).addMemberRepositoryId(
        PROXY3_REPO_ID);
    getApplicationConfiguration().saveConfiguration();

    final Manager wm = lookup(Manager.class);
    waitForRoutingBackgroundUpdates();

    // after member addition, we should have all 3 WLs member in group
    // group1 WL should be union of the 3 proxy member WLs
    {
      final PrefixSource groupPrefixSource =
          wm.getPrefixSourceFor(getRepositoryRegistry().getRepositoryWithFacet(GROUP1_REPO_ID,
              MavenRepository.class));

      assertThat("Group1 should have WL", groupPrefixSource.supported());

      final List<String> groupEntries = groupPrefixSource.readEntries();
      assertThat(groupEntries, hasSize(4));
      assertThat(groupEntries, hasItem("/com/sonatype"));
      assertThat(groupEntries, hasItem("/org/sonatype"));
      assertThat(groupEntries, hasItem("/org/apache"));
      assertThat(groupEntries, hasItem("/eu/flatwhite"));
    }
    // group2 WL should be same as group1 (is only member)
    {
      final PrefixSource groupPrefixSource =
          wm.getPrefixSourceFor(getRepositoryRegistry().getRepositoryWithFacet(GROUP2_REPO_ID,
              MavenRepository.class));

      assertThat("Group2 should have WL", groupPrefixSource.supported());

      final List<String> groupEntries = groupPrefixSource.readEntries();
View Full Code Here

        PROXY2_REPO_ID);
    getRepositoryRegistry().getRepositoryWithFacet(GROUP1_REPO_ID, MavenGroupRepository.class).addMemberRepositoryId(
        PROXY3_REPO_ID);
    getApplicationConfiguration().saveConfiguration();

    final Manager wm = lookup(Manager.class);
    waitForRoutingBackgroundUpdates();

    // after member addition and removal, group1 should have proxy1 and proxt3 WL in group
    {
      final PrefixSource groupPrefixSource =
          wm.getPrefixSourceFor(getRepositoryRegistry().getRepositoryWithFacet(GROUP1_REPO_ID,
              MavenRepository.class));

      assertThat("Group1 should have WL", groupPrefixSource.supported());

      final List<String> groupEntries = groupPrefixSource.readEntries();
      assertThat(groupEntries, hasSize(2));
      assertThat(groupEntries, hasItem("/org/apache"));
      assertThat(groupEntries, hasItem("/eu/flatwhite"));
    }
    // group2 WL should be same as group1 (is only member)
    {
      final PrefixSource groupPrefixSource =
          wm.getPrefixSourceFor(getRepositoryRegistry().getRepositoryWithFacet(GROUP2_REPO_ID,
              MavenRepository.class));

      assertThat("Group2 should have WL", groupPrefixSource.supported());

      final List<String> groupEntries = groupPrefixSource.readEntries();
View Full Code Here

    // add the proxy3 to group2
    getRepositoryRegistry().getRepositoryWithFacet(GROUP2_REPO_ID, MavenGroupRepository.class).addMemberRepositoryId(
        PROXY3_REPO_ID);
    getApplicationConfiguration().saveConfiguration();

    final Manager wm = lookup(Manager.class);
    waitForRoutingBackgroundUpdates();

    // after member removal, group1 should have proxy1 WL in group
    {
      final PrefixSource groupPrefixSource =
          wm.getPrefixSourceFor(getRepositoryRegistry().getRepositoryWithFacet(GROUP1_REPO_ID,
              MavenRepository.class));

      assertThat("Group1 should have WL", groupPrefixSource.supported());

      final List<String> groupEntries = groupPrefixSource.readEntries();
      assertThat(groupEntries, hasSize(1));
      assertThat(groupEntries, hasItem("/org/apache"));
    }
    // after member addition and removal (from member group1), group2 should have proxy1 and proxt3 WL in group
    {
      final PrefixSource groupPrefixSource =
          wm.getPrefixSourceFor(getRepositoryRegistry().getRepositoryWithFacet(GROUP2_REPO_ID,
              MavenRepository.class));

      assertThat("Group2 should have WL", groupPrefixSource.supported());

      final List<String> groupEntries = groupPrefixSource.readEntries();
View Full Code Here

    // add the proxy3 to group2
    getRepositoryRegistry().getRepositoryWithFacet(GROUP2_REPO_ID, MavenGroupRepository.class).addMemberRepositoryId(
        PROXY3_REPO_ID);
    getApplicationConfiguration().saveConfiguration();

    final Manager wm = lookup(Manager.class);
    waitForRoutingBackgroundUpdates();

    // after member change, group1 should have proxy1, proxy2 and proxy3 WL in group
    {
      final PrefixSource groupPrefixSource =
          wm.getPrefixSourceFor(getRepositoryRegistry().getRepositoryWithFacet(GROUP1_REPO_ID,
              MavenRepository.class));

      assertThat("Group1 should have WL", groupPrefixSource.supported());

      final List<String> groupEntries = groupPrefixSource.readEntries();
      assertThat(groupEntries, hasSize(4));
      assertThat(groupEntries, hasItem("/org/apache"));
      assertThat(groupEntries, hasItem("/org/sonatype"));
      assertThat(groupEntries, hasItem("/com/sonatype"));
      assertThat(groupEntries, hasItem("/eu/flatwhite"));
    }
    // after member change, group2 should have g1+p3 but is same as g1 (since p3 is member of g1 too) -- (WL is
    // kept unique)
    {
      final PrefixSource groupPrefixSource =
          wm.getPrefixSourceFor(getRepositoryRegistry().getRepositoryWithFacet(GROUP2_REPO_ID,
              MavenRepository.class));

      assertThat("Group2 should have WL", groupPrefixSource.supported());

      final List<String> groupEntries = groupPrefixSource.readEntries();
View Full Code Here

  @Test
  public void outOfServiceRepositoryDoesNotAffectWLInitialization()
      throws Exception
  {
    // at this point, NexusStartedEvent was fired, and hence, WL's should be inited
    final Manager wm = lookup(Manager.class);
    final MavenProxyRepository proxy1 =
        getRepositoryRegistry().getRepositoryWithFacet(PROXY1_REPO_ID, MavenProxyRepository.class);

    assertThat(proxy1.getLocalStatus(), equalTo(LocalStatus.OUT_OF_SERVICE));
    waitForRoutingBackgroundUpdates();

    // let's check states

    {
      // proxy1
      final RoutingStatus proxy1status = wm.getStatusFor(proxy1);
      // this repo is Out of Service
      assertThat(proxy1status.getPublishingStatus().getStatus(), equalTo(PStatus.NOT_PUBLISHED));
      assertThat(proxy1status.getDiscoveryStatus().getStatus(), equalTo(DStatus.ENABLED_NOT_POSSIBLE));
      assertThat(proxy1status.getDiscoveryStatus().getLastDiscoveryStrategy(), is("none"));
      // Remark: the combination of those three above simply means "discovery never tried against it"
      // yet.
    }

    {
      // proxy2
      final RoutingStatus proxy2status =
          wm.getStatusFor(getRepositoryRegistry().getRepositoryWithFacet(PROXY2_REPO_ID,
              MavenProxyRepository.class));
      // this repo should be good
      assertThat(proxy2status.getPublishingStatus().getStatus(), equalTo(PStatus.PUBLISHED));
      assertThat(proxy2status.getDiscoveryStatus().getStatus(), equalTo(DStatus.SUCCESSFUL));
    }

    {
      // hosted
      final RoutingStatus hostedStatus =
          wm.getStatusFor(getRepositoryRegistry().getRepositoryWithFacet(HOSTED_REPO_ID,
              MavenHostedRepository.class));
      // this repo should be good
      assertThat(hostedStatus.getPublishingStatus().getStatus(), equalTo(PStatus.PUBLISHED));
      assertThat(hostedStatus.getDiscoveryStatus().getStatus(), equalTo(DStatus.NOT_A_PROXY));
    }

    {
      // group
      final RoutingStatus groupStatus =
          wm.getStatusFor(getRepositoryRegistry().getRepositoryWithFacet(GROUP_REPO_ID,
              MavenGroupRepository.class));
      // not all members have WL, unpublished
      assertThat(groupStatus.getPublishingStatus().getStatus(), equalTo(PStatus.PUBLISHED));
      assertThat(groupStatus.getDiscoveryStatus().getStatus(), equalTo(DStatus.NOT_A_PROXY));
    }
View Full Code Here

  @Test
  public void flippingLocalStatusUpdatesWL()
      throws Exception
  {
    // at this point, NexusStartedEvent was fired, and hence, WL's should be inited
    final Manager wm = lookup(Manager.class);
    final MavenProxyRepository proxy1 =
        getRepositoryRegistry().getRepositoryWithFacet(PROXY1_REPO_ID, MavenProxyRepository.class);

    assertThat(proxy1.getLocalStatus(), equalTo(LocalStatus.OUT_OF_SERVICE));
    waitForRoutingBackgroundUpdates();

    // let's check states
    {
      // proxy1
      final RoutingStatus proxy1status = wm.getStatusFor(proxy1);
      // this repo is Out of Service
      assertThat(proxy1status.getPublishingStatus().getStatus(), equalTo(PStatus.NOT_PUBLISHED));
      assertThat(proxy1status.getDiscoveryStatus().getStatus(), equalTo(DStatus.ENABLED_NOT_POSSIBLE));
      assertThat(proxy1status.getDiscoveryStatus().getLastDiscoveryStrategy(), is("none"));
      // Remark: the combination of those three above simply means "discovery never tried against it"
      // yet.
    }
    {
      // group
      final RoutingStatus groupStatus =
          wm.getStatusFor(getRepositoryRegistry().getRepositoryWithFacet(GROUP_REPO_ID,
              MavenGroupRepository.class));
      // not all members have WL, unpublished
      assertThat(groupStatus.getPublishingStatus().getStatus(), equalTo(PStatus.PUBLISHED));
      assertThat(groupStatus.getDiscoveryStatus().getStatus(), equalTo(DStatus.NOT_A_PROXY));
    }

    {
      // let's flip proxy1 now
      proxy1.setLocalStatus(LocalStatus.IN_SERVICE);
      getApplicationConfiguration().saveConfiguration();
      wairForAsyncEventsToCalmDown();
      waitForRoutingBackgroundUpdates();
    }

    // let's check states again, now with enabled proxy1

    {
      // proxy1
      final RoutingStatus proxy1status =
          wm.getStatusFor(getRepositoryRegistry().getRepositoryWithFacet(PROXY1_REPO_ID,
              MavenProxyRepository.class));
      // this repo is Out of Service
      assertThat(proxy1status.getPublishingStatus().getStatus(), equalTo(PStatus.PUBLISHED));
      assertThat(proxy1status.getDiscoveryStatus().getStatus(), equalTo(DStatus.SUCCESSFUL));
      assertThat(proxy1status.getDiscoveryStatus().getLastDiscoveryStrategy(), is(RemotePrefixFileStrategy.ID));
    }
    {
      // group
      final RoutingStatus groupStatus =
          wm.getStatusFor(getRepositoryRegistry().getRepositoryWithFacet(GROUP_REPO_ID,
              MavenGroupRepository.class));
      // not all members have WL, unpublisged
      assertThat(groupStatus.getPublishingStatus().getStatus(), equalTo(PStatus.PUBLISHED));
      assertThat(groupStatus.getDiscoveryStatus().getStatus(), equalTo(DStatus.NOT_A_PROXY));
    }

    {
      // let's flip proxy1 now back
      proxy1.setLocalStatus(LocalStatus.OUT_OF_SERVICE);
      getApplicationConfiguration().saveConfiguration();
      wairForAsyncEventsToCalmDown();
      waitForRoutingBackgroundUpdates();
    }

    // let's check states again, now with enabled proxy1

    {
      // proxy1
      final RoutingStatus proxy1status =
          wm.getStatusFor(getRepositoryRegistry().getRepositoryWithFacet(PROXY1_REPO_ID,
              MavenProxyRepository.class));
      // this repo is Out of Service
      assertThat(proxy1status.getPublishingStatus().getStatus(), equalTo(PStatus.NOT_PUBLISHED));
      assertThat(proxy1status.getDiscoveryStatus().getStatus(), equalTo(DStatus.ENABLED_NOT_POSSIBLE));
      assertThat(proxy1status.getDiscoveryStatus().getLastDiscoveryStrategy(), is("none"));
    }
    {
      // group
      final RoutingStatus groupStatus =
          wm.getStatusFor(getRepositoryRegistry().getRepositoryWithFacet(GROUP_REPO_ID,
              MavenGroupRepository.class));
      // not all members have WL, unpublished
      assertThat(groupStatus.getPublishingStatus().getStatus(), equalTo(PStatus.PUBLISHED));
      assertThat(groupStatus.getDiscoveryStatus().getStatus(), equalTo(DStatus.NOT_A_PROXY));
    }
View Full Code Here

  @Test
  public void noPrefixFilesServed()
      throws Exception
  {
    try {
      final Manager wm = lookup(Manager.class);
      {
        final PrefixSource proxy1EntrySource =
            wm.getPrefixSourceFor(getRepositoryRegistry().getRepositoryWithFacet(PROXY1_REPO_ID,
                MavenRepository.class));
        final PrefixSource proxy2EntrySource =
            wm.getPrefixSourceFor(getRepositoryRegistry().getRepositoryWithFacet(PROXY2_REPO_ID,
                MavenRepository.class));
        final PrefixSource groupEntrySource =
            wm.getPrefixSourceFor(getRepositoryRegistry().getRepositoryWithFacet(GROUP_REPO_ID,
                MavenRepository.class));

        assertThat("Proxy1 should not have ES", !proxy1EntrySource.supported()); // we served noscrape file
        assertThat("Proxy2 should not have ES", !proxy2EntrySource.supported()); // we served noscrape file
        assertThat("Group cannot have ES", !groupEntrySource.supported()); // as proxy member are disabled
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.proxy.maven.routing.Manager

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.