}
public void testConfigureValidDatabaseConsumer()
throws Exception
{
DatabaseScanningConfiguration dbScanning = new DatabaseScanningConfiguration();
dbScanning.addCleanupConsumer( "cleanup-index" );
dbScanning.addCleanupConsumer( "cleanup-database" );
dbScanning.addUnprocessedConsumer( "process-artifact" );
recordDbConsumers();
// test enable "process-pom" db consumer
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
configControl.expectAndReturn( config.getDatabaseScanning(), dbScanning );
config.setDatabaseScanning( dbScanning );
configControl.setMatcher( MockControl.ALWAYS_MATCHER );
configControl.setVoidCallable();
archivaConfig.save( config );
archivaConfigControl.setVoidCallable();
dbConsumersUtilControl.replay();
cleanupConsumersControl.replay();
unprocessedConsumersControl.replay();
archivaConfigControl.replay();
configControl.replay();
try
{
boolean success = service.configureDatabaseConsumer( "process-pom", true );
assertTrue( success );
}
catch ( Exception e )
{
fail( "An exception should not have been thrown." );
}
dbConsumersUtilControl.verify();
cleanupConsumersControl.verify();
unprocessedConsumersControl.verify();
archivaConfigControl.verify();
configControl.verify();
// test disable "process-pom" db consumer
dbConsumersUtilControl.reset();
cleanupConsumersControl.reset();
unprocessedConsumersControl.reset();
archivaConfigControl.reset();
configControl.reset();
dbScanning.addUnprocessedConsumer( "process-pom" );
recordDbConsumers();
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
configControl.expectAndReturn( config.getDatabaseScanning(), dbScanning );