use of org.apache.archiva.repository.storage.fs.FilesystemAsset in project archiva by apache.
the class FilesystemAssetTest method storeDataFile.
@Test
public void storeDataFile() throws IOException {
FilesystemAsset asset = new FilesystemAsset(filesystemStorage, "/test1234", assetPathFile);
Path dataFile = Files.createTempFile("testdata", "dat");
try (OutputStream os = Files.newOutputStream(dataFile)) {
IOUtils.write("testkdkdkd", os, "ASCII");
}
asset.replaceDataFromFile(dataFile);
Assert.assertEquals("testkdkdkd", IOUtils.toString(assetPathFile.toUri().toURL(), "ASCII"));
}
use of org.apache.archiva.repository.storage.fs.FilesystemAsset in project archiva by apache.
the class FilesystemAssetTest method getPath.
@Test
public void getPath() {
FilesystemAsset asset = new FilesystemAsset(filesystemStorage, assetPathFile.getFileName().toString(), assetPathFile);
Assert.assertEquals("/" + assetPathFile.getFileName().toString(), asset.getPath());
}
use of org.apache.archiva.repository.storage.fs.FilesystemAsset in project archiva by apache.
the class FilesystemAssetTest method writeDataAppend.
@Test
public void writeDataAppend() throws IOException {
FilesystemAsset asset = new FilesystemAsset(filesystemStorage, "/test1234", assetPathFile);
Files.write(assetPathFile, "abcdef".getBytes("ASCII"));
try (OutputStream os = asset.getWriteStream(false)) {
IOUtils.write("test12345", os, "ASCII");
}
Assert.assertEquals("abcdeftest12345", IOUtils.toString(assetPathFile.toUri().toURL(), "ASCII"));
}
use of org.apache.archiva.repository.storage.fs.FilesystemAsset in project archiva by apache.
the class FilesystemAssetTest method getData.
@Test
public void getData() throws IOException {
FilesystemAsset asset = new FilesystemAsset(filesystemStorage, "/test1234", assetPathFile);
Files.write(assetPathFile, "abcdef".getBytes("ASCII"));
try (InputStream is = asset.getReadStream()) {
Assert.assertEquals("abcdef", IOUtils.toString(is, "ASCII"));
}
}
use of org.apache.archiva.repository.storage.fs.FilesystemAsset in project archiva by apache.
the class FilesystemAssetTest method getDataExceptionOnDir.
@Test
public void getDataExceptionOnDir() throws IOException {
FilesystemAsset asset = new FilesystemAsset(filesystemStorage, "/test1234", assetPathDir);
Files.write(assetPathFile, "abcdef".getBytes("ASCII"));
try {
InputStream is = asset.getReadStream();
Assert.assertFalse("Exception expected for data on dir", true);
} catch (IOException e) {
// fine
}
}
Aggregations