Examples of PrefixSource


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

      final Manager wm = lookup(Manager.class);
      wm.updatePrefixFile(getRepositoryRegistry().getRepositoryWithFacet(PROXY1_REPO_ID, MavenRepository.class));
      wm.updatePrefixFile(getRepositoryRegistry().getRepositoryWithFacet(PROXY2_REPO_ID, MavenRepository.class));
      waitForRoutingBackgroundUpdates();
      {
        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 have ES", proxy1EntrySource.supported()); // we served prefix file
        assertThat("Proxy2 should not have ES", !proxy2EntrySource.supported()); // we served invalid prefix file
        assertThat("Group should not have ES", !groupEntrySource.supported()); // both proxies have it

        final RoutingStatus status =
            wm.getStatusFor(getRepositoryRegistry().getRepositoryWithFacet(PROXY2_REPO_ID,
                MavenRepository.class));
        final String message = status.getDiscoveryStatus().getLastDiscoveryMessage();
View Full Code Here

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

          subject.discover(getRepositoryRegistry().getRepositoryWithFacet(PROXY_REPO_ID,
              MavenProxyRepository.class));
      assertThat(result.getMessage(),
          equalTo("Remote publishes prefix file (is less than a day old), using it."));

      final PrefixSource entrySource = result.getPrefixSource();
      assertThat(entrySource.supported(), is(true));
      assertThat(entrySource.readEntries(), contains("/org/apache/maven", "/org/sonatype", "/eu/flatwhite"));
      assertThat(entrySource.readEntries().size(), equalTo(3));
    }
    finally {
      server.stop();
    }
  }
View Full Code Here

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

          subject.discover(getRepositoryRegistry().getRepositoryWithFacet(PROXY_REPO_ID,
              MavenProxyRepository.class));
      assertThat(result.getMessage(),
          equalTo("Remote publishes prefix file (is less than a day old), using it."));

      final PrefixSource entrySource = result.getPrefixSource();
      assertThat(entrySource.supported(), is(true));
      assertThat(entrySource.readEntries(), contains("/org/apache/maven", "/org/sonatype", "/eu/flatwhite"));
      assertThat(entrySource.readEntries().size(), equalTo(3));
    }
    finally {
      server.stop();
    }
  }
View Full Code Here

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

      final RemoteStrategy subject = lookup(RemoteStrategy.class, RemotePrefixFileStrategy.ID);
      final StrategyResult result = subject.discover(mavenProxyRepository);
      assertThat(result.getMessage(),
          equalTo("Remote publishes prefix file (is less than a day old), using it."));

      final PrefixSource entrySource = result.getPrefixSource();
      assertThat(entrySource.supported(), is(true));
      assertThat(entrySource.readEntries(), contains("/org/apache/maven", "/org/sonatype", "/eu/flatwhite"));
      assertThat(entrySource.readEntries().size(), equalTo(3));
    }
    finally {
      server.stop();
    }
  }
View Full Code Here

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

          localContentDiscoverer.discoverLocalContent(mavenRepository);
      assertThat(result, notNullValue());
      assertThat(result.isSuccessful(), is(true));
      assertThat(result.getLastResult().getStrategyId(), equalTo("local"));
      assertThat(result.getLastResult().getMessage(), notNullValue());
      final PrefixSource entrySource = result.getPrefixSource();
      assertThat(
          entrySource.readEntries(),
          hasItems("/archetype-catalog.xml", "/archetype-catalog.xml.sha1", "/archetype-catalog.xml.md5",
              "/org/sonatype", "/org/apache"));
      assertThat(entrySource.readEntries(), not(hasItems("/com/sonatype")));
      assertThat(entrySource.readEntries().size(), equalTo(5));
    }

    addSomeContent(mavenRepository, PATHS2);

    {
      final DiscoveryResult<MavenRepository> result =
          localContentDiscoverer.discoverLocalContent(mavenRepository);
      assertThat(result, notNullValue());
      assertThat(result.isSuccessful(), is(true));
      assertThat(result.getLastResult().getStrategyId(), equalTo("local"));
      assertThat(result.getLastResult().getMessage(), notNullValue());
      final PrefixSource entrySource = result.getPrefixSource();
      assertThat(
          entrySource.readEntries(),
          hasItems("/archetype-catalog.xml", "/archetype-catalog.xml.sha1", "/archetype-catalog.xml.md5",
              "/org/sonatype", "/com/sonatype", "/org/apache"));
      assertThat(entrySource.readEntries().size(), equalTo(6));
    }

    removeSomeContent(mavenRepository, PATHS3);

    {
      final DiscoveryResult<MavenRepository> result =
          localContentDiscoverer.discoverLocalContent(mavenRepository);
      assertThat(result, notNullValue());
      assertThat(result.isSuccessful(), is(true));
      assertThat(result.getLastResult().getStrategyId(), equalTo("local"));
      assertThat(result.getLastResult().getMessage(), notNullValue());
      final PrefixSource entrySource = result.getPrefixSource();
      assertThat(
          entrySource.readEntries(),
          hasItems("/archetype-catalog.xml", "/archetype-catalog.xml.sha1", "/archetype-catalog.xml.md5",
              "/com/sonatype", "/org/apache"));
      // NEXUS-6485: Not true anymore, we do include empty directories due to "depth" optimization
      // see LocalContentDiscovererImpl
      // assertThat(entrySource.readEntries(), not(hasItems("/org/sonatype")));
      assertThat(entrySource.readEntries().size(), equalTo(6)); // was 5
    }
  }
View Full Code Here

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

  }

  protected List<String> getEntriesOf(final MavenRepository mavenRepository)
      throws IOException
  {
    final PrefixSource entrySource = manager.getPrefixSourceFor(mavenRepository);
    final ArrayList<String> result = new ArrayList<String>(entrySource.readEntries());
    Collections.sort(result);
    return result;
  }
View Full Code Here

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

          new ByteArrayInputStream("Some fluke content".getBytes()), null);
    }

    {
      try {
        final PrefixSource hostedEntrySource =
            wm.getPrefixSourceFor(getRepositoryRegistry().getRepositoryWithFacet(HOSTED_REPO_ID,
                MavenRepository.class));
        final PrefixSource proxyEntrySource =
            wm.getPrefixSourceFor(getRepositoryRegistry().getRepositoryWithFacet(PROXY_REPO_ID,
                MavenRepository.class));
        final PrefixSource groupEntrySource =
            wm.getPrefixSourceFor(getRepositoryRegistry().getRepositoryWithFacet(GROUP_REPO_ID,
                MavenRepository.class));

        assertThat("Hosted should have ES", hostedEntrySource.supported());
        assertThat("Proxy should not have ES", !proxyEntrySource.supported()); // as we serve noscrape prefix
        // file
        assertThat("Group cannot have ES", !groupEntrySource.supported()); // as proxy member does not have WL
      }
      finally {
        server.stop();
      }
    }

    {
      server =
          Server.withPort(remoteServerPort).serve("/.meta/prefixes.txt").withBehaviours(
              Behaviours.content(prefixFile1(true)));
      try {
        server.start();
        final MavenProxyRepository mavenProxyRepository =
            getRepositoryRegistry().getRepositoryWithFacet(PROXY_REPO_ID, MavenProxyRepository.class);
        wm.updatePrefixFile(mavenProxyRepository);
        waitForRoutingBackgroundUpdates();

        final PrefixSource hostedEntrySource =
            wm.getPrefixSourceFor(getRepositoryRegistry().getRepositoryWithFacet(HOSTED_REPO_ID,
                MavenRepository.class));
        final PrefixSource proxyEntrySource =
            wm.getPrefixSourceFor(getRepositoryRegistry().getRepositoryWithFacet(PROXY_REPO_ID,
                MavenRepository.class));
        final PrefixSource groupEntrySource =
            wm.getPrefixSourceFor(getRepositoryRegistry().getRepositoryWithFacet(GROUP_REPO_ID,
                MavenRepository.class));

        assertThat("Hosted should have ES", hostedEntrySource.supported());
        assertThat("Proxy should have ES", proxyEntrySource.supported()); // as we did serve file ok
        assertThat("Group should have ES", groupEntrySource.supported()); // as all member should have it

        // GROUP wl must have 4 entries: 1 from hosted (/com/sonatype) + 3 from proxied prefix file
        final List<String> groupEntries = groupEntrySource.readEntries();
        assertThat(groupEntries.size(), equalTo(4));
        assertThat(groupEntries, hasItem("/com/sonatype"));
        assertThat(groupEntries, hasItem("/org/sonatype"));
        assertThat(groupEntries, hasItem("/org/apache/maven"));
        assertThat(groupEntries, hasItem("/eu/flatwhite"));
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.