more log for MRM-1832

This commit is contained in:
Olivier Lamy 2014-04-22 22:52:25 +10:00
parent 9a09994c8c
commit 6611fc497b
2 changed files with 17 additions and 11 deletions

View File

@ -23,6 +23,8 @@ import org.apache.archiva.admin.model.beans.ManagedRepository;
import org.apache.archiva.consumers.AbstractMonitoredConsumer; import org.apache.archiva.consumers.AbstractMonitoredConsumer;
import org.apache.archiva.consumers.ConsumerException; import org.apache.archiva.consumers.ConsumerException;
import org.apache.archiva.consumers.InvalidRepositoryContentConsumer; import org.apache.archiva.consumers.InvalidRepositoryContentConsumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -42,6 +44,8 @@ public class InvalidScanConsumer
* default-value="unset-id" * default-value="unset-id"
*/ */
private String id = "unset-id"; private String id = "unset-id";
private Logger logger = LoggerFactory.getLogger( getClass() );
private int processCount = 0; private int processCount = 0;
@ -87,6 +91,7 @@ public class InvalidScanConsumer
public void processFile( String path ) public void processFile( String path )
throws ConsumerException throws ConsumerException
{ {
logger.info( "processFile: {}", path );
processCount++; processCount++;
} }

View File

@ -22,9 +22,10 @@ package org.apache.archiva.repository.scanner;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.admin.model.beans.ManagedRepository;
import org.apache.archiva.admin.model.beans.RemoteRepository; import org.apache.archiva.admin.model.beans.RemoteRepository;
import org.apache.commons.io.FileUtils;
import org.apache.archiva.consumers.InvalidRepositoryContentConsumer; import org.apache.archiva.consumers.InvalidRepositoryContentConsumer;
import org.apache.archiva.consumers.KnownRepositoryContentConsumer; import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.apache.commons.io.FileUtils;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
@ -33,6 +34,7 @@ import org.springframework.test.context.ContextConfiguration;
import javax.inject.Inject; import javax.inject.Inject;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Paths;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
@ -40,15 +42,12 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.TimeZone; import java.util.TimeZone;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
/** /**
* RepositoryScannerTest * RepositoryScannerTest
*
*
*/ */
@RunWith( ArchivaSpringJUnit4ClassRunner.class ) @RunWith(ArchivaSpringJUnit4ClassRunner.class)
@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml" } ) @ContextConfiguration(locations = { "classpath*:/META-INF/spring-context.xml" })
public class RepositoryScannerTest public class RepositoryScannerTest
extends TestCase extends TestCase
{ {
@ -79,7 +78,8 @@ public class RepositoryScannerTest
private ManagedRepository createDefaultRepository() private ManagedRepository createDefaultRepository()
{ {
File repoDir = new File( "src/test/repositories/default-repository" ); File repoDir =
Paths.get( System.getProperty( "basedir" ), "src/test/repositories/default-repository" ).toFile();
assertTrue( "Default Test Repository should exist.", repoDir.exists() && repoDir.isDirectory() ); assertTrue( "Default Test Repository should exist.", repoDir.exists() && repoDir.isDirectory() );
@ -89,9 +89,9 @@ public class RepositoryScannerTest
private ManagedRepository createSimpleRepository() private ManagedRepository createSimpleRepository()
throws IOException, ParseException throws IOException, ParseException
{ {
File srcDir = new File( "src/test/repositories/simple-repository" ); File srcDir = Paths.get( System.getProperty( "basedir" ), "src/test/repositories/simple-repository" ).toFile();
File repoDir = new File( "target/test-repos/simple-repository" ); File repoDir = Paths.get( System.getProperty( "basedir" ), "target/test-repos/simple-repository" ).toFile();
FileUtils.deleteDirectory( repoDir ); FileUtils.deleteDirectory( repoDir );
@ -116,7 +116,7 @@ public class RepositoryScannerTest
private ManagedRepository createLegacyRepository() private ManagedRepository createLegacyRepository()
{ {
File repoDir = new File( "src/test/repositories/legacy-repository" ); File repoDir = Paths.get( System.getProperty( "basedir" ), "src/test/repositories/legacy-repository" ).toFile();
assertTrue( "Legacy Test Repository should exist.", repoDir.exists() && repoDir.isDirectory() ); assertTrue( "Legacy Test Repository should exist.", repoDir.exists() && repoDir.isDirectory() );
@ -238,7 +238,8 @@ public class RepositoryScannerTest
KnownScanConsumer consumer = new KnownScanConsumer(); KnownScanConsumer consumer = new KnownScanConsumer();
consumer.setIncludes( consumer.setIncludes(
new String[]{ "**/*.jar", "**/*.war", "**/*.pom", "**/maven-metadata.xml", "**/*-site.xml", "**/*.zip", new String[]{ "**/*.jar", "**/*.war", "**/*.pom", "**/maven-metadata.xml", "**/*-site.xml", "**/*.zip",
"**/*.tar.gz", "**/*.sha1", "**/*.md5" } ); "**/*.tar.gz", "**/*.sha1", "**/*.md5" }
);
knownConsumers.add( consumer ); knownConsumers.add( consumer );
List<InvalidRepositoryContentConsumer> invalidConsumers = new ArrayList<>(); List<InvalidRepositoryContentConsumer> invalidConsumers = new ArrayList<>();