Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
UT helped debugging the problem.
Browse files Browse the repository at this point in the history
but it's disabled as it really scrapes the spring repo
  • Loading branch information
cstamas committed Apr 25, 2013
1 parent 8777c5c commit 028f241
Showing 1 changed file with 71 additions and 0 deletions.
@@ -0,0 +1,71 @@
/*
* Sonatype Nexus (TM) Open Source Version
* Copyright (c) 2007-2012 Sonatype, Inc.
* All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
*
* This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
* which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
*
* Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
* of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
* Eclipse Foundation. All other trademarks are the property of their respective owners.
*/
package org.sonatype.nexus.proxy.maven.routing.internal.scrape;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.mockito.Mockito.when;

import java.util.List;

import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mock;
import org.sonatype.nexus.proxy.maven.MavenProxyRepository;
import org.sonatype.sisu.litmus.testsupport.TestSupport;

@Ignore( "This test really goes remotely and would try to scrape Springsource external repository." )
public class AmazonS3LiveIndexScraperTest
extends TestSupport
{
@Mock
private MavenProxyRepository mavenProxyRepository;

private AmazonS3IndexScraper s3scraper;

@Before
public void prepare()
throws Exception
{
s3scraper = new AmazonS3IndexScraper();
}

/**
* This test will go remote for true and scrape Springsource External bundles repository, that should take about 20+
* "paged" request (every page is 1000 entries limited by S3), and will take about a minute to execute.
*
* @throws Exception
*/
@Test
public void springExternalRepository()
throws Exception
{
final HttpClient httpClient = new DefaultHttpClient();
final String repoRoot = "http://repository.springsource.com/maven/bundles/external/";
when( mavenProxyRepository.getRemoteUrl() ).thenReturn( repoRoot );
final ScrapeContext context = new ScrapeContext( mavenProxyRepository, httpClient, 2 );
final Page page = Page.getPageFor( context, repoRoot );
s3scraper.scrape( context, page );
assertThat( context.isStopped(), is( true ) );
assertThat( context.isSuccessful(), is( true ) );
assertThat( context.getPrefixSource(), notNullValue() );
final List<String> entries = context.getPrefixSource().readEntries();
assertThat( entries, notNullValue() );
assertThat( entries.size(), equalTo( 152 ) );
}
}

0 comments on commit 028f241

Please sign in to comment.