Search in sources :

Example 26 with StorageAsset

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

the class AbstractStorageUtilTest method createTree.

protected StorageAsset createTree(int... levelElements) {
    StorageAsset root = createRootAsset();
    recurseSubTree(root, 0, levelElements);
    return root;
}
Also used : StorageAsset(org.apache.archiva.repository.storage.StorageAsset)

Example 27 with StorageAsset

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

the class AbstractStorageUtilTest method testWalkFromRootWithCondition.

@Test
void testWalkFromRootWithCondition() {
    StorageAsset root = createTree();
    StopVisitStatus status = new StopVisitStatus();
    status.setStopCondition(a -> a.getName().equals("001002003"));
    StorageUtil.walk(root, status);
    Assertions.assertEquals("001002003", status.getLast().getName());
    int expected = LEVEL2 * LEVEL3 + LEVEL2 + 2 * LEVEL3 + 1 + 1 + 1 + 4;
    Assertions.assertEquals(expected, status.size());
}
Also used : StorageAsset(org.apache.archiva.repository.storage.StorageAsset) Test(org.junit.jupiter.api.Test)

Example 28 with StorageAsset

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

the class AbstractStorageUtilTest method testStreamParallel.

@Test
void testStreamParallel() {
    StorageAsset root = createTree();
    List<StorageAsset> result;
    try (Stream<StorageAsset> stream = StorageUtil.newAssetStream(root, true)) {
        result = stream.filter(a -> a.getName().startsWith("001")).collect(Collectors.toList());
    }
    int expected = LEVEL2 * LEVEL3 + LEVEL2 + 1;
    Assertions.assertEquals(expected, result.size());
}
Also used : StorageAsset(org.apache.archiva.repository.storage.StorageAsset) Test(org.junit.jupiter.api.Test)

Example 29 with StorageAsset

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

the class AbstractStorageUtilTest method testCopyRecursive.

@Test
void testCopyRecursive() throws IOException {
    StorageAsset root = createTree();
    createStorage(root);
    StorageAsset destinationRoot = createRootAsset();
    RepositoryStorage destinationStorage = createStorage(destinationRoot);
    StorageAsset destination = destinationStorage.getAsset("");
    boolean result = StorageUtil.copyRecursively(root, destination, false);
    Assertions.assertTrue(result);
    Assertions.assertTrue(destination.exists());
    Assertions.assertTrue(destination.resolve("000/000000/000000000").exists());
    Assertions.assertTrue(destination.resolve("011/011000/011000000").exists());
    Assertions.assertTrue(destination.resolve("010/010000/010000000").exists());
    Assertions.assertTrue(destination.resolve("000/000000/000000000").exists());
}
Also used : RepositoryStorage(org.apache.archiva.repository.storage.RepositoryStorage) StorageAsset(org.apache.archiva.repository.storage.StorageAsset) Test(org.junit.jupiter.api.Test)

Example 30 with StorageAsset

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

the class AbstractStorageUtilTest method recurseSubTree.

private void recurseSubTree(StorageAsset parent, int level, int[] levelElements) {
    if (level < levelElements.length) {
        AssetType type = (level == levelElements.length - 1) ? AssetType.FILE : AssetType.CONTAINER;
        for (int k = 0; k < levelElements[level]; k++) {
            String name = parent.getName() + String.format("%03d", k);
            StorageAsset asset = createAsset(parent, name, type);
            recurseSubTree(asset, level + 1, levelElements);
        }
    }
}
Also used : AssetType(org.apache.archiva.repository.storage.AssetType) StorageAsset(org.apache.archiva.repository.storage.StorageAsset)

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