import org.apache.archiva.consumers.functors.ConsumerWantsFilePredicate;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.apache.commons.lang.StringUtils;
-import org.apache.maven.index.NexusIndexer;
-import org.apache.maven.index.context.IndexingContext;
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import javax.inject.Inject;
-
import java.nio.file.Path;
import java.nio.file.Paths;
@Inject
ArchivaConfiguration archivaConfiguration;
- @Inject
- protected NexusIndexer nexusIndexer;
-
@Before
public void setUp()
repoLocation = Paths.get( "target/test-" + getName() + "/test-repo" );
}
- @After
- public void tearDown()
- throws Exception
- {
- for ( IndexingContext indexingContext : nexusIndexer.getIndexingContexts().values() )
- {
- nexusIndexer.removeIndexingContext( indexingContext, false );
- }
- }
-
@Test
public void testConsumption()
@Inject
protected ApplicationContext applicationContext;
- @Inject
- protected NexusIndexer nexusIndexer;
-
@Before
public void setUp()
throws Exception
{
- removeMavenIndexes();
-
listenerControl = EasyMock.createControl();
listener = listenerControl.createMock( RepositoryListener.class );
public void tearDown()
throws Exception
{
- removeMavenIndexes();
config = null;
repo = null;
}
- protected void removeMavenIndexes()
- throws Exception
- {
- for ( IndexingContext indexingContext : nexusIndexer.getIndexingContexts().values() )
- {
- nexusIndexer.removeIndexingContext( indexingContext, false );
- }
- }
protected static String fixPath( String path )
{
protected String prepareTestRepos()
throws Exception
{
- removeMavenIndexes();
Path testDir = Paths.get( AbstractRepositoryPurgeTest.fixPath( getTestRepoRoot().toAbsolutePath().toString() ) );
org.apache.archiva.common.utils.FileUtils.deleteDirectory( testDir );
Path sourceDir = Paths.get( Paths.get( "target/test-classes/" + TEST_REPO_ID ).toAbsolutePath().toString() );
( (DefaultManagedRepositoryAdmin) applicationContext.getBean(
ManagedRepositoryAdmin.class ) ).setArchivaConfiguration( archivaConfiguration );
- removeMavenIndexes();
}
@Test
throws Exception
{
RepositoryRegistry repositoryRegistry = applicationContext.getBean( RepositoryRegistry.class );
- ManagedRepository managedRepository = repositoryRegistry.getManagedRepository( TEST_REPO_ID );
repositoryRegistry.removeRepository( TEST_REPO_ID );
repositoryRegistry.putRepository(
getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ));