NIHVIVO-160 Remove the maximum file size - no need for it at this level.
This commit is contained in:
parent
fe89b1f7e9
commit
b86ec9e7b2
5 changed files with 6 additions and 136 deletions
|
@ -3,7 +3,6 @@
|
|||
package edu.cornell.mannlib.vitro.webapp.utils.filestorage;
|
||||
|
||||
import static edu.cornell.mannlib.vitro.webapp.utils.filestorage.FileStorageFactory.PROPERTY_IMPLEMETATION_CLASSNAME;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
|
@ -64,7 +63,7 @@ public class FileStorageFactoryTest extends AbstractTestClass {
|
|||
@Test
|
||||
public void createDefaultImplementation() throws IOException {
|
||||
setConfigurationProperties(tempDir.getPath(),
|
||||
"http://vivo.myDomain.edu/individual/", "50M");
|
||||
"http://vivo.myDomain.edu/individual/");
|
||||
FileStorage fs = FileStorageFactory.getFileStorage();
|
||||
assertEquals("implementation class", FileStorageImpl.class, fs
|
||||
.getClass());
|
||||
|
@ -82,20 +81,13 @@ public class FileStorageFactoryTest extends AbstractTestClass {
|
|||
@Test(expected = IllegalArgumentException.class)
|
||||
public void baseDirectoryDoesntExist() throws IOException {
|
||||
setConfigurationProperties("/bogus/Directory",
|
||||
"http://vivo.myDomain.edu/individual/", "50M");
|
||||
"http://vivo.myDomain.edu/individual/");
|
||||
FileStorageFactory.getFileStorage();
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void defaultNamespaceIsBogus() throws IOException {
|
||||
setConfigurationProperties(tempDir.getPath(), "namespace", "50M");
|
||||
FileStorageFactory.getFileStorage();
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void invalidMaximumFileSize() throws IOException {
|
||||
setConfigurationProperties(tempDir.getPath(),
|
||||
"http://vivo.myDomain.edu/individual/", "50X");
|
||||
setConfigurationProperties(tempDir.getPath(), "namespace");
|
||||
FileStorageFactory.getFileStorage();
|
||||
}
|
||||
|
||||
|
@ -124,11 +116,10 @@ public class FileStorageFactoryTest extends AbstractTestClass {
|
|||
// ----------------------------------------------------------------------
|
||||
|
||||
private void setConfigurationProperties(String baseDir,
|
||||
String defaultNamespace, String maxFileSize) {
|
||||
String defaultNamespace) {
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
map.put(FileStorage.PROPERTY_FILE_STORAGE_BASE_DIR, baseDir);
|
||||
map.put(FileStorage.PROPERTY_DEFAULT_NAMESPACE, defaultNamespace);
|
||||
map.put(FileStorage.PROPERTY_FILE_MAXIMUM_SIZE, maxFileSize);
|
||||
|
||||
try {
|
||||
Field f = ConfigurationProperties.class.getDeclaredField("theMap");
|
||||
|
|
|
@ -199,41 +199,4 @@ public class FileStorageHelperTest {
|
|||
assertEquals("fullPath", FULL_RESULT_PATH, actual);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// parseMaximumFileSize
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@Test
|
||||
public void parseMaximumFileSizeBare() {
|
||||
long size = FileStorageHelper.parseMaximumFileSize("1467898");
|
||||
assertEquals("", 1467898, size);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseMaximumFileSizeWithSuffixes() {
|
||||
long size = FileStorageHelper.parseMaximumFileSize("152K");
|
||||
assertEquals("", 152L * 1024L, size);
|
||||
|
||||
size = FileStorageHelper.parseMaximumFileSize("47M");
|
||||
assertEquals("", 47L * 1024L * 1024L, size);
|
||||
|
||||
size = FileStorageHelper.parseMaximumFileSize("3G");
|
||||
assertEquals("", 3L * 1024L * 1024L * 1024L, size);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void parseMaximumFileSizeInvalidSuffix() {
|
||||
FileStorageHelper.parseMaximumFileSize("152X");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void parseMaximumFileSizeNegativeNumber() {
|
||||
FileStorageHelper.parseMaximumFileSize("-3K");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void parseMaximumFileSizeEmbeddedBadCharacter() {
|
||||
FileStorageHelper.parseMaximumFileSize("1G52K");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue