Search in sources :

Example 16 with KnownRepositoryContentConsumer

use of org.apache.archiva.consumers.KnownRepositoryContentConsumer in project archiva by apache.

the class RepositoryScannerTest method testDefaultRepositoryArtifactScanner.

@Test
public void testDefaultRepositoryArtifactScanner() throws Exception {
    List<String> actualArtifactPaths = new ArrayList<>();
    actualArtifactPaths.add("invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar");
    actualArtifactPaths.add("invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar");
    actualArtifactPaths.add("invalid/invalid/1.0/invalid-1.0b.jar");
    actualArtifactPaths.add("invalid/invalid/1.0/invalid-2.0.jar");
    actualArtifactPaths.add("invalid/invalid-1.0.jar");
    actualArtifactPaths.add("org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar");
    actualArtifactPaths.add("org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar");
    actualArtifactPaths.add("org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar");
    actualArtifactPaths.add("org/apache/maven/A/1.0/A-1.0.war");
    actualArtifactPaths.add("org/apache/maven/A/1.0/A-1.0.pom");
    actualArtifactPaths.add("org/apache/maven/B/2.0/B-2.0.pom");
    actualArtifactPaths.add("org/apache/maven/B/1.0/B-1.0.pom");
    actualArtifactPaths.add("org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar");
    actualArtifactPaths.add("org/apache/maven/C/1.0/C-1.0.war");
    actualArtifactPaths.add("org/apache/maven/C/1.0/C-1.0.pom");
    actualArtifactPaths.add("org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom");
    actualArtifactPaths.add("org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar");
    actualArtifactPaths.add("org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom");
    actualArtifactPaths.add("org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar");
    actualArtifactPaths.add("org/apache/maven/discovery/1.0/discovery-1.0.pom");
    actualArtifactPaths.add("org/apache/maven/testing/1.0/testing-1.0-test-sources.jar");
    actualArtifactPaths.add("org/apache/maven/testing/1.0/testing-1.0.jar");
    actualArtifactPaths.add("org/apache/maven/testing/1.0/testing-1.0-sources.jar");
    actualArtifactPaths.add("org/apache/maven/testing/1.0/testing-1.0.zip");
    actualArtifactPaths.add("org/apache/maven/testing/1.0/testing-1.0.tar.gz");
    actualArtifactPaths.add("org/apache/maven/samplejar/2.0/samplejar-2.0.pom");
    actualArtifactPaths.add("org/apache/maven/samplejar/2.0/samplejar-2.0.jar");
    actualArtifactPaths.add("org/apache/maven/samplejar/1.0/samplejar-1.0.pom");
    actualArtifactPaths.add("org/apache/maven/samplejar/1.0/samplejar-1.0.jar");
    actualArtifactPaths.add("org/apache/testgroup/discovery/1.0/discovery-1.0.pom");
    actualArtifactPaths.add("javax/sql/jdbc/2.0/jdbc-2.0.jar");
    ManagedRepository repository = createDefaultRepository();
    List<KnownRepositoryContentConsumer> knownConsumers = new ArrayList<>();
    KnownScanConsumer consumer = new KnownScanConsumer();
    consumer.setIncludes(ARTIFACT_PATTERNS);
    knownConsumers.add(consumer);
    List<InvalidRepositoryContentConsumer> invalidConsumers = new ArrayList<>();
    InvalidScanConsumer badconsumer = new InvalidScanConsumer();
    invalidConsumers.add(badconsumer);
    RepositoryScanner scanner = lookupRepositoryScanner();
    RepositoryScanStatistics stats = scanner.scan(repository, knownConsumers, invalidConsumers, getIgnoreList(), RepositoryScanner.FRESH_SCAN);
    assertNotNull("Stats should not be null.", stats);
    assertMinimumHits("Stats.totalFileCount", actualArtifactPaths.size(), stats.getTotalFileCount());
    assertMinimumHits("Processed Count", actualArtifactPaths.size(), consumer.getProcessCount());
}
Also used : ManagedRepository(org.apache.archiva.repository.ManagedRepository) BasicManagedRepository(org.apache.archiva.repository.BasicManagedRepository) EditableManagedRepository(org.apache.archiva.repository.EditableManagedRepository) KnownRepositoryContentConsumer(org.apache.archiva.consumers.KnownRepositoryContentConsumer) ArrayList(java.util.ArrayList) InvalidRepositoryContentConsumer(org.apache.archiva.consumers.InvalidRepositoryContentConsumer) Test(org.junit.Test)

Example 17 with KnownRepositoryContentConsumer

use of org.apache.archiva.consumers.KnownRepositoryContentConsumer in project archiva by apache.

the class RepositoryScannerTest method testTimestampRepositoryScanner.

@Test
public void testTimestampRepositoryScanner() throws Exception {
    ManagedRepository repository = createSimpleRepository();
    List<KnownRepositoryContentConsumer> knownConsumers = new ArrayList<>();
    KnownScanConsumer consumer = new KnownScanConsumer();
    consumer.setIncludes(ARTIFACT_PATTERNS);
    knownConsumers.add(consumer);
    List<InvalidRepositoryContentConsumer> invalidConsumers = new ArrayList<>();
    InvalidScanConsumer badconsumer = new InvalidScanConsumer();
    invalidConsumers.add(badconsumer);
    RepositoryScanner scanner = lookupRepositoryScanner();
    RepositoryScanStatistics stats = scanner.scan(repository, knownConsumers, invalidConsumers, getIgnoreList(), getTimestampAsMillis("20061101.000000"));
    assertNotNull("Stats should not be null.", stats);
    assertEquals("Stats.totalFileCount", 4, stats.getTotalFileCount());
    assertEquals("Stats.newFileCount", 3, stats.getNewFileCount());
    assertEquals("Processed Count", 2, consumer.getProcessCount());
    assertEquals("Processed Count (of invalid items)", 1, badconsumer.getProcessCount());
}
Also used : ManagedRepository(org.apache.archiva.repository.ManagedRepository) BasicManagedRepository(org.apache.archiva.repository.BasicManagedRepository) EditableManagedRepository(org.apache.archiva.repository.EditableManagedRepository) KnownRepositoryContentConsumer(org.apache.archiva.consumers.KnownRepositoryContentConsumer) ArrayList(java.util.ArrayList) InvalidRepositoryContentConsumer(org.apache.archiva.consumers.InvalidRepositoryContentConsumer) Test(org.junit.Test)

Example 18 with KnownRepositoryContentConsumer

use of org.apache.archiva.consumers.KnownRepositoryContentConsumer in project archiva by apache.

the class RepositoryScannerTest method testDefaultRepositoryScanner.

@Test
public void testDefaultRepositoryScanner() throws Exception {
    ManagedRepository repository = createDefaultRepository();
    List<KnownRepositoryContentConsumer> knownConsumers = new ArrayList<>();
    KnownScanConsumer consumer = new KnownScanConsumer();
    consumer.setIncludes(new String[] { "**/*.jar", "**/*.war", "**/*.pom", "**/maven-metadata.xml", "**/*-site.xml", "**/*.zip", "**/*.tar.gz", "**/*.sha1", "**/*.md5" });
    knownConsumers.add(consumer);
    List<InvalidRepositoryContentConsumer> invalidConsumers = new ArrayList<>();
    InvalidScanConsumer badconsumer = new InvalidScanConsumer();
    invalidConsumers.add(badconsumer);
    RepositoryScanner scanner = lookupRepositoryScanner();
    RepositoryScanStatistics stats = scanner.scan(repository, knownConsumers, invalidConsumers, getIgnoreList(), RepositoryScanner.FRESH_SCAN);
    assertNotNull("Stats should not be null.", stats);
    assertMinimumHits("Stats.totalFileCount", 17, stats.getTotalFileCount());
    assertMinimumHits("Processed Count", 17, consumer.getProcessCount());
    assertEquals("Processed Count (of invalid items):" + badconsumer.getPaths(), 6, badconsumer.getProcessCount());
}
Also used : ManagedRepository(org.apache.archiva.repository.ManagedRepository) BasicManagedRepository(org.apache.archiva.repository.BasicManagedRepository) EditableManagedRepository(org.apache.archiva.repository.EditableManagedRepository) KnownRepositoryContentConsumer(org.apache.archiva.consumers.KnownRepositoryContentConsumer) ArrayList(java.util.ArrayList) InvalidRepositoryContentConsumer(org.apache.archiva.consumers.InvalidRepositoryContentConsumer) Test(org.junit.Test)

Example 19 with KnownRepositoryContentConsumer

use of org.apache.archiva.consumers.KnownRepositoryContentConsumer in project archiva by apache.

the class RepositoryScannerTest method testDefaultRepositoryProjectScanner.

@Test
public void testDefaultRepositoryProjectScanner() throws Exception {
    List<String> actualProjectPaths = new ArrayList<>();
    actualProjectPaths.add("org/apache/maven/A/1.0/A-1.0.pom");
    actualProjectPaths.add("org/apache/maven/B/2.0/B-2.0.pom");
    actualProjectPaths.add("org/apache/maven/B/1.0/B-1.0.pom");
    actualProjectPaths.add("org/apache/maven/C/1.0/C-1.0.pom");
    actualProjectPaths.add("org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom");
    actualProjectPaths.add("org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom");
    actualProjectPaths.add("org/apache/maven/discovery/1.0/discovery-1.0.pom");
    actualProjectPaths.add("org/apache/maven/samplejar/2.0/samplejar-2.0.pom");
    actualProjectPaths.add("org/apache/maven/samplejar/1.0/samplejar-1.0.pom");
    actualProjectPaths.add("org/apache/testgroup/discovery/1.0/discovery-1.0.pom");
    ManagedRepository repository = createDefaultRepository();
    List<KnownRepositoryContentConsumer> knownConsumers = new ArrayList<>();
    KnownScanConsumer consumer = new KnownScanConsumer();
    consumer.setIncludes(new String[] { "**/*.pom" });
    knownConsumers.add(consumer);
    List<InvalidRepositoryContentConsumer> invalidConsumers = new ArrayList<>();
    InvalidScanConsumer badconsumer = new InvalidScanConsumer();
    invalidConsumers.add(badconsumer);
    RepositoryScanner scanner = lookupRepositoryScanner();
    RepositoryScanStatistics stats = scanner.scan(repository, knownConsumers, invalidConsumers, getIgnoreList(), RepositoryScanner.FRESH_SCAN);
    assertNotNull("Stats should not be null.", stats);
    assertMinimumHits("Stats.totalFileCount", actualProjectPaths.size(), stats.getTotalFileCount());
    assertMinimumHits("Processed Count", actualProjectPaths.size(), consumer.getProcessCount());
}
Also used : ManagedRepository(org.apache.archiva.repository.ManagedRepository) BasicManagedRepository(org.apache.archiva.repository.BasicManagedRepository) EditableManagedRepository(org.apache.archiva.repository.EditableManagedRepository) KnownRepositoryContentConsumer(org.apache.archiva.consumers.KnownRepositoryContentConsumer) ArrayList(java.util.ArrayList) InvalidRepositoryContentConsumer(org.apache.archiva.consumers.InvalidRepositoryContentConsumer) Test(org.junit.Test)

Example 20 with KnownRepositoryContentConsumer

use of org.apache.archiva.consumers.KnownRepositoryContentConsumer in project archiva by apache.

the class RepositoryContentConsumersTest method testGetAvailableKnownList.

@Test
public void testGetAvailableKnownList() throws Exception {
    RepositoryContentConsumers consumerutil = lookupRepositoryConsumers();
    String[] expectedKnownIds = new String[] { "update-db-artifact", "create-missing-checksums", "update-db-repository-metadata", "validate-checksum", "index-content", "auto-remove", "auto-rename", "available-but-unselected" };
    List<KnownRepositoryContentConsumer> knownConsumers = consumerutil.getAvailableKnownConsumers();
    assertNotNull("known consumers should not be null.", knownConsumers);
    assertEquals("known consumers", expectedKnownIds.length, knownConsumers.size());
    List<String> expectedIds = Arrays.asList(expectedKnownIds);
    for (KnownRepositoryContentConsumer consumer : knownConsumers) {
        assertTrue("Consumer [" + consumer.getId() + "] returned by .getAvailableKnownConsumers() is unexpected.", expectedIds.contains(consumer.getId()));
    }
}
Also used : KnownRepositoryContentConsumer(org.apache.archiva.consumers.KnownRepositoryContentConsumer) Test(org.junit.Test)

Aggregations

KnownRepositoryContentConsumer (org.apache.archiva.consumers.KnownRepositoryContentConsumer)22 Test (org.junit.Test)15 InvalidRepositoryContentConsumer (org.apache.archiva.consumers.InvalidRepositoryContentConsumer)13 ArrayList (java.util.ArrayList)12 BasicManagedRepository (org.apache.archiva.repository.BasicManagedRepository)12 ManagedRepository (org.apache.archiva.repository.ManagedRepository)9 Path (java.nio.file.Path)8 EditableManagedRepository (org.apache.archiva.repository.EditableManagedRepository)8 ArtifactMetadata (org.apache.archiva.metadata.model.ArtifactMetadata)4 ArtifactCleanupFeature (org.apache.archiva.repository.features.ArtifactCleanupFeature)4 HashSet (java.util.HashSet)2 BaseFile (org.apache.archiva.common.utils.BaseFile)2 RepositoryContentConsumer (org.apache.archiva.consumers.RepositoryContentConsumer)2 ConsumerWantsFilePredicate (org.apache.archiva.consumers.functors.ConsumerWantsFilePredicate)2 RepositoryScannerException (org.apache.archiva.repository.scanner.RepositoryScannerException)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ArchivaConfiguration (org.apache.archiva.configuration.ArchivaConfiguration)1 FileType (org.apache.archiva.configuration.FileType)1