use of org.apache.archiva.repository.storage.fs.FilesystemAsset in project archiva by apache.
the class ArtifactContentEntriesTests method readArtifactContentEntriesDirectoryAndFiles.
@Test
public void readArtifactContentEntriesDirectoryAndFiles() throws Exception {
FilesystemStorage filesystemStorage = new FilesystemStorage(Paths.get(getBasedir()), new DefaultFileLockManager());
Path file = Paths.get(getBasedir(), "src/test/repo-with-osgi/commons-logging/commons-logging/1.1/commons-logging-1.1.jar");
List<ArtifactContentEntry> artifactContentEntries = browseService.readFileEntries(new FilesystemAsset(filesystemStorage, file.toString(), file), "org/apache/commons/logging/", "foo");
log.info("artifactContentEntries: {}", artifactContentEntries);
assertThat(artifactContentEntries).isNotNull().isNotEmpty().hasSize(10).contains(new ArtifactContentEntry("org/apache/commons/logging/impl", false, 4, "foo"), new ArtifactContentEntry("org/apache/commons/logging/LogSource.class", true, 4, "foo"));
}
use of org.apache.archiva.repository.storage.fs.FilesystemAsset in project archiva by apache.
the class ArtifactContentEntriesTests method readArtifactContentEntriesOnlyFiles.
@Test
public void readArtifactContentEntriesOnlyFiles() throws Exception {
FilesystemStorage filesystemStorage = new FilesystemStorage(Paths.get(getBasedir()), new DefaultFileLockManager());
Path file = Paths.get(getBasedir(), "src/test/repo-with-osgi/commons-logging/commons-logging/1.1/commons-logging-1.1.jar");
List<ArtifactContentEntry> artifactContentEntries = browseService.readFileEntries(new FilesystemAsset(filesystemStorage, file.toString(), file), "org/apache/commons/logging/impl/", "foo");
log.info("artifactContentEntries: {}", artifactContentEntries);
assertThat(artifactContentEntries).isNotNull().isNotEmpty().hasSize(16).contains(new ArtifactContentEntry("org/apache/commons/logging/impl/AvalonLogger.class", true, 5, "foo"));
}
use of org.apache.archiva.repository.storage.fs.FilesystemAsset in project archiva by apache.
the class ArtifactContentEntriesTests method readArtifactContentEntriesRootPathEmpty.
@Test
public void readArtifactContentEntriesRootPathEmpty() throws Exception {
FilesystemStorage filesystemStorage = new FilesystemStorage(Paths.get(getBasedir()), new DefaultFileLockManager());
Path file = Paths.get(getBasedir(), "src/test/repo-with-osgi/commons-logging/commons-logging/1.1/commons-logging-1.1.jar");
List<ArtifactContentEntry> artifactContentEntries = browseService.readFileEntries(new FilesystemAsset(filesystemStorage, file.toString(), file), "", "foo");
log.info("artifactContentEntries: {}", artifactContentEntries);
assertThat(artifactContentEntries).isNotNull().isNotEmpty().hasSize(2).contains(new ArtifactContentEntry("org", false, 0, "foo"), new ArtifactContentEntry("META-INF", false, 0, "foo"));
}
use of org.apache.archiva.repository.storage.fs.FilesystemAsset in project archiva by apache.
the class FilesystemAssetTest method list.
@Test
public void list() throws IOException {
FilesystemAsset asset = new FilesystemAsset(filesystemStorage, "/test1234", assetPathFile);
Assert.assertEquals(0, asset.list().size());
FilesystemAsset asset2 = new FilesystemAsset(filesystemStorage, "/test1235", assetPathDir);
Assert.assertEquals(1, asset2.list().size());
Path f1 = Files.createTempFile(assetPathDir, "testfile", "dat");
Path f2 = Files.createTempFile(assetPathDir, "testfile", "dat");
Path d1 = Files.createTempDirectory(assetPathDir, "testdir");
Assert.assertEquals(4, asset2.list().size());
Assert.assertTrue(asset2.list().stream().anyMatch(p -> p.getName().equals(f1.getFileName().toString())));
Assert.assertTrue(asset2.list().stream().anyMatch(p -> p.getName().equals(f2.getFileName().toString())));
Assert.assertTrue(asset2.list().stream().anyMatch(p -> p.getName().equals(d1.getFileName().toString())));
Files.deleteIfExists(f1);
Files.deleteIfExists(f2);
Files.deleteIfExists(d1);
}
use of org.apache.archiva.repository.storage.fs.FilesystemAsset in project archiva by apache.
the class FilesystemAssetTest method writeDataExceptionOnDir.
@Test
public void writeDataExceptionOnDir() throws IOException {
FilesystemAsset asset = new FilesystemAsset(filesystemStorage, "/test1234", assetPathDir);
try {
OutputStream os = asset.getWriteStream(true);
Assert.assertTrue("Writing to a directory should throw a IOException", false);
} catch (IOException e) {
// Fine
}
}
Aggregations