Search in sources :

Example 21 with StorageAsset

use of org.apache.archiva.repository.storage.StorageAsset in project archiva by apache.

the class AssetSpliteratorTest method trySplit.

@Test
void trySplit() {
    StorageAsset root = createTree();
    AssetSpliterator spliterator = new AssetSpliterator(root);
    final ConsumeVisitStatus status1 = new ConsumeVisitStatus();
    final ConsumeVisitStatus status2 = new ConsumeVisitStatus();
    Spliterator<StorageAsset> newSpliterator = spliterator.trySplit();
    assertNotNull(newSpliterator);
    newSpliterator.forEachRemaining(status1);
    spliterator.forEachRemaining(status2);
    int sum = LEVEL1 * LEVEL2 * LEVEL3 + LEVEL1 * LEVEL2 + LEVEL1 + 1;
    int expected1 = sum / 2;
    int expected2 = sum / 2 + 1;
    assertEquals(expected1, status1.size());
    assertEquals(expected2, status2.size());
}
Also used : StorageAsset(org.apache.archiva.repository.storage.StorageAsset) Test(org.junit.jupiter.api.Test)

Example 22 with StorageAsset

use of org.apache.archiva.repository.storage.StorageAsset in project archiva by apache.

the class FilesystemStorageTest method addAsset.

@Test
public void addAsset() {
    StorageAsset newAsset = fsStorage.addAsset("dir2/test", false);
    Assert.assertNotNull(newAsset);
    Assert.assertFalse(newAsset.isContainer());
    Assert.assertFalse(newAsset.exists());
    StorageAsset newDirAsset = fsStorage.addAsset("/dir2/testdir2", true);
    Assert.assertNotNull(newDirAsset);
    Assert.assertTrue(newDirAsset.isContainer());
    Assert.assertFalse(newDirAsset.exists());
}
Also used : StorageAsset(org.apache.archiva.repository.storage.StorageAsset) Test(org.junit.Test)

Example 23 with StorageAsset

use of org.apache.archiva.repository.storage.StorageAsset in project archiva by apache.

the class AssetSpliterator method tryAdvance.

@Override
public boolean tryAdvance(Consumer<? super StorageAsset> action) {
    try {
        StorageAsset asset = workList.getLast();
        consumeAsset(action, asset);
        return true;
    } catch (NoSuchElementException e) {
        return false;
    }
}
Also used : StorageAsset(org.apache.archiva.repository.storage.StorageAsset) NoSuchElementException(java.util.NoSuchElementException)

Example 24 with StorageAsset

use of org.apache.archiva.repository.storage.StorageAsset in project archiva by apache.

the class MockAsset method resolve.

@Override
public StorageAsset resolve(String toPath) {
    if (children.containsKey(toPath)) {
        return children.get(toPath);
    } else {
        if (toPath.startsWith("/")) {
            toPath = StringUtils.removeStart(toPath, "/");
        }
        if ("".equals(toPath)) {
            return this;
        }
        String[] destPath = toPath.split("/");
        StringBuilder destPathStr = new StringBuilder();
        MockAsset destParent = this;
        for (int i = 0; i < destPath.length; i++) {
            destPathStr.append("/").append(destPath[i]);
            StorageAsset child = storage.getAsset(destPathStr.toString());
            if (child != null) {
                destParent = (MockAsset) child;
            } else {
                System.out.println("Resolve " + destParent.getPath() + " -- " + destPath[i]);
                destParent = new MockAsset(destParent, destPath[i]);
            }
        }
        return destParent;
    }
}
Also used : StorageAsset(org.apache.archiva.repository.storage.StorageAsset)

Example 25 with StorageAsset

use of org.apache.archiva.repository.storage.StorageAsset in project archiva by apache.

the class AbstractStorageUtilTest method testWalkFromChild.

@Test
void testWalkFromChild() {
    StorageAsset root = createTree();
    ConsumeVisitStatus status = new ConsumeVisitStatus();
    StorageAsset testRoot = root.list().get(3);
    StorageUtil.walk(testRoot, status);
    int expected = LEVEL2 * LEVEL3 + LEVEL2 + 1;
    Assertions.assertEquals(expected, status.size());
    StorageAsset first = root.list().get(3).list().get(0).list().get(0);
    Assertions.assertEquals(first, status.getFirst());
    Assertions.assertEquals(testRoot, status.getLast());
}
Also used : StorageAsset(org.apache.archiva.repository.storage.StorageAsset) Test(org.junit.jupiter.api.Test)

Aggregations

StorageAsset (org.apache.archiva.repository.storage.StorageAsset)191 Path (java.nio.file.Path)91 BaseRepositoryContentLayout (org.apache.archiva.repository.content.BaseRepositoryContentLayout)61 IOException (java.io.IOException)59 Test (org.junit.Test)59 Artifact (org.apache.archiva.repository.content.Artifact)54 ManagedRepository (org.apache.archiva.repository.ManagedRepository)27 ArchivaIndexingContext (org.apache.archiva.indexer.ArchivaIndexingContext)22 ArchivaRepositoryMetadata (org.apache.archiva.model.ArchivaRepositoryMetadata)22 List (java.util.List)20 Inject (javax.inject.Inject)20 RepositoryMetadataException (org.apache.archiva.repository.metadata.RepositoryMetadataException)20 Collectors (java.util.stream.Collectors)19 RemoteRepository (org.apache.archiva.repository.RemoteRepository)19 IndexingContext (org.apache.maven.index.context.IndexingContext)19 FilesystemStorage (org.apache.archiva.repository.storage.fs.FilesystemStorage)18 StringUtils (org.apache.commons.lang3.StringUtils)18 Logger (org.slf4j.Logger)18 LoggerFactory (org.slf4j.LoggerFactory)18 Map (java.util.Map)17