Search in sources :

Example 6 with FilesystemAsset

use of org.apache.archiva.repository.storage.fs.FilesystemAsset in project archiva by apache.

the class FilesystemAssetTest method writeData.

@Test
public void writeData() throws IOException {
    FilesystemAsset asset = new FilesystemAsset(filesystemStorage, "/test1234", assetPathFile);
    Files.write(assetPathFile, "abcdef".getBytes("ASCII"));
    try (OutputStream os = asset.getWriteStream(true)) {
        IOUtils.write("test12345", os, "ASCII");
    }
    Assert.assertEquals("test12345", IOUtils.toString(assetPathFile.toUri().toURL(), "ASCII"));
}
Also used : OutputStream(java.io.OutputStream) FilesystemAsset(org.apache.archiva.repository.storage.fs.FilesystemAsset) Test(org.junit.Test)

Example 7 with FilesystemAsset

use of org.apache.archiva.repository.storage.fs.FilesystemAsset in project archiva by apache.

the class FilesystemAssetTest method getFilePath.

@Test
public void getFilePath() {
    FilesystemAsset asset = new FilesystemAsset(filesystemStorage, "/test1234", assetPathFile);
    Assert.assertEquals(assetPathFile, asset.getFilePath());
}
Also used : FilesystemAsset(org.apache.archiva.repository.storage.fs.FilesystemAsset) Test(org.junit.Test)

Example 8 with FilesystemAsset

use of org.apache.archiva.repository.storage.fs.FilesystemAsset in project archiva by apache.

the class FilesystemAssetTest method getModificationTime.

@Test
public void getModificationTime() throws IOException {
    Instant modTime = Files.getLastModifiedTime(assetPathFile).toInstant();
    FilesystemAsset asset = new FilesystemAsset(filesystemStorage, "/test123", assetPathFile);
    Assert.assertTrue(modTime.equals(asset.getModificationTime()));
}
Also used : Instant(java.time.Instant) FilesystemAsset(org.apache.archiva.repository.storage.fs.FilesystemAsset) Test(org.junit.Test)

Example 9 with FilesystemAsset

use of org.apache.archiva.repository.storage.fs.FilesystemAsset in project archiva by apache.

the class FilesystemAssetTest method exists.

@Test
public void exists() {
    FilesystemAsset asset = new FilesystemAsset(filesystemStorage, "/test1234", assetPathFile);
    Assert.assertTrue(asset.exists());
    FilesystemAsset asset2 = new FilesystemAsset(filesystemStorage, "/test1234", Paths.get("abcdefgkdkdk"));
    Assert.assertFalse(asset2.exists());
}
Also used : FilesystemAsset(org.apache.archiva.repository.storage.fs.FilesystemAsset) Test(org.junit.Test)

Example 10 with FilesystemAsset

use of org.apache.archiva.repository.storage.fs.FilesystemAsset in project archiva by apache.

the class ArtifactContentEntriesTests method readArtifactContentEntriesRootSlash.

@Test
public void readArtifactContentEntriesRootSlash() 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"));
}
Also used : Path(java.nio.file.Path) FilesystemStorage(org.apache.archiva.repository.storage.fs.FilesystemStorage) ArtifactContentEntry(org.apache.archiva.rest.api.model.ArtifactContentEntry) FilesystemAsset(org.apache.archiva.repository.storage.fs.FilesystemAsset) DefaultFileLockManager(org.apache.archiva.common.filelock.DefaultFileLockManager) Test(org.junit.Test)

Aggregations

FilesystemAsset (org.apache.archiva.repository.storage.fs.FilesystemAsset)26 Test (org.junit.Test)20 Path (java.nio.file.Path)13 DefaultFileLockManager (org.apache.archiva.common.filelock.DefaultFileLockManager)13 FilesystemStorage (org.apache.archiva.repository.storage.fs.FilesystemStorage)13 ArtifactContentEntry (org.apache.archiva.rest.api.model.ArtifactContentEntry)6 OutputStream (java.io.OutputStream)5 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 URI (java.net.URI)3 IndexCreationFeature (org.apache.archiva.repository.features.IndexCreationFeature)3 Instant (java.time.Instant)2 Before (org.junit.Before)2 Files (java.nio.file.Files)1 Paths (java.nio.file.Paths)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 TimeZone (java.util.TimeZone)1 Configuration (org.apache.archiva.configuration.model.Configuration)1