Package org.apache.maven.index.updater

Examples of org.apache.maven.index.updater.IndexUpdater


  protected void prepare(final IOException failure)
      throws Exception
  {
    // faking IndexUpdater that will fail with given exception for given "failing" repository
    final IndexUpdater realUpdater = lookup(IndexUpdater.class);
    // predicate to match invocation when the arguments are for the failingRepository
    final Predicate<Object[]> fetchAndUpdateIndexMethodArgumentsPredicate = new Predicate<Object[]>()
    {
      @Override
      public boolean apply(@Nullable Object[] input) {
        if (input != null) {
          final IndexUpdateRequest req = (IndexUpdateRequest) input[0];
          if (req != null) {
            return req.getIndexingContext().getId().startsWith(failingRepository.getId());
          }
        }
        return false;
      }
    };
    // method we want to fail and count
    final Method fetchAndUpdateIndexMethod =
        IndexUpdater.class.getMethod("fetchAndUpdateIndex", new Class[]{IndexUpdateRequest.class});
    fetchFailingInvocationHandler =
        new FailingInvocationHandler(new PassThruInvocationHandler(realUpdater), fetchAndUpdateIndexMethod,
            fetchAndUpdateIndexMethodArgumentsPredicate, failure);
    fetchCountingInvocationHandler =
        new CountingInvocationHandler(fetchFailingInvocationHandler, fetchAndUpdateIndexMethod);
    final IndexUpdater fakeUpdater =
        (IndexUpdater) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{IndexUpdater.class},
            fetchCountingInvocationHandler);

    final Scanner fakeScanner = new Scanner()
    {
View Full Code Here

TOP

Related Classes of org.apache.maven.index.updater.IndexUpdater

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.