mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-03 17:49:40 +00:00
added unit tests for file storage
This commit is contained in:
1 parent
745cc2bdac
commit
096251015e
9 files changed
+73
-18
No files matched your search
@@ -0,0 +1,35 @@
|
||||
package com.sap.sse.filestorage.test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sse.filestorage.FileStorageService;
|
||||
import com.sap.sse.filestorage.impl.AmazonS3FileStorageServiceImpl;
|
||||
|
||||
public class AmazonS3Test {
|
||||
private final String teamImageFile = "Bundesliga2014_Regatta6_eventteaser.jpg";
|
||||
private final FileStorageService storageService = new AmazonS3FileStorageServiceImpl();
|
||||
|
||||
@Test
|
||||
public void testStoreAndRemoveFileTest() throws URISyntaxException, IOException {
|
||||
URL fileUrl = getClass().getResource("/" + teamImageFile);
|
||||
URI fileUri = new URI(fileUrl.toString());
|
||||
long length = new File(fileUri).length();
|
||||
InputStream stream = getClass().getResourceAsStream("/" + teamImageFile);
|
||||
|
||||
URI uri = storageService.storeFile(stream, teamImageFile, length);
|
||||
|
||||
InputStream downloadStream = uri.toURL().openStream();
|
||||
stream = getClass().getResourceAsStream("/" + teamImageFile);
|
||||
IOUtils.contentEquals(downloadStream, stream);
|
||||
|
||||
storageService.removeFile(uri);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user