VIVO-848 Move the FileStorage system behind an interface
Add it to the Application framework, and do some cleanup.
This commit is contained in:
parent
c751ecdc6d
commit
6e5bbaeef8
24 changed files with 232 additions and 260 deletions
|
@ -12,7 +12,6 @@ import stubs.edu.cornell.mannlib.vitro.webapp.config.ConfigurationPropertiesStub
|
|||
import stubs.javax.servlet.ServletContextStub;
|
||||
import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||
import edu.cornell.mannlib.vitro.webapp.filestorage.backend.FileStorageSetup;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -35,7 +34,7 @@ public class FileServingHelperTest extends AbstractTestClass {
|
|||
ctx = new ServletContextStub();
|
||||
|
||||
ConfigurationPropertiesStub props = new ConfigurationPropertiesStub();
|
||||
props.setProperty(FileStorageSetup.PROPERTY_DEFAULT_NAMESPACE,
|
||||
props.setProperty(FileServingHelper.PROPERTY_DEFAULT_NAMESPACE,
|
||||
DEFAULT_NAMESPACE);
|
||||
props.setBean(ctx);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.filestorage.backend;
|
||||
package edu.cornell.mannlib.vitro.webapp.filestorage.impl;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
@ -1,7 +1,9 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.filestorage.backend;
|
||||
package edu.cornell.mannlib.vitro.webapp.filestorage.impl;
|
||||
|
||||
import static edu.cornell.mannlib.vitro.webapp.filestorage.impl.FileStorageImpl.FILE_STORAGE_NAMESPACES_PROPERTIES;
|
||||
import static edu.cornell.mannlib.vitro.webapp.filestorage.impl.FileStorageImpl.FILE_STORAGE_ROOT;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
@ -26,6 +28,7 @@ import org.junit.BeforeClass;
|
|||
import org.junit.Test;
|
||||
|
||||
import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.modules.fileStorage.FileAlreadyExistsException;
|
||||
|
||||
/**
|
||||
* Test the FileStorage methods. The zero-argument constructor was tested in
|
||||
|
@ -55,26 +58,29 @@ public class FileStorageImplTest extends AbstractTestClass {
|
|||
// tests
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void baseDirDoesntExist() throws IOException {
|
||||
File baseDir = new File(tempDir, "doesntExist");
|
||||
new FileStorageImpl(baseDir, EMPTY_NAMESPACES);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void partialInitializationRoot() throws IOException {
|
||||
File baseDir = new File(tempDir, "partialWithRoot");
|
||||
baseDir.mkdir();
|
||||
new File(baseDir, FileStorage.FILE_STORAGE_ROOT).mkdir();
|
||||
new File(baseDir, FILE_STORAGE_ROOT).mkdir();
|
||||
|
||||
new FileStorageImpl(baseDir, EMPTY_NAMESPACES);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void partialInitializationNamespaces() throws IOException {
|
||||
File baseDir = new File(tempDir, "partialWithNamespaces");
|
||||
baseDir.mkdir();
|
||||
new File(baseDir, FileStorage.FILE_STORAGE_NAMESPACES_PROPERTIES)
|
||||
new File(baseDir, FILE_STORAGE_NAMESPACES_PROPERTIES)
|
||||
.createNewFile();
|
||||
|
||||
new FileStorageImpl(baseDir, EMPTY_NAMESPACES);
|
||||
|
@ -276,7 +282,7 @@ public class FileStorageImplTest extends AbstractTestClass {
|
|||
*/
|
||||
private void assertFileContents(FileStorageImpl fs, String id,
|
||||
String filename, String expectedContents) throws IOException {
|
||||
File rootDir = new File(fs.getBaseDir(), FileStorage.FILE_STORAGE_ROOT);
|
||||
File rootDir = new File(fs.getBaseDir(), FILE_STORAGE_ROOT);
|
||||
File path = FileStorageHelper.getFullPath(rootDir, id, filename,
|
||||
fs.getNamespaces());
|
||||
|
|
@ -8,6 +8,7 @@ import javax.servlet.ServletContext;
|
|||
|
||||
import edu.cornell.mannlib.vitro.webapp.application.ApplicationUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.modules.Application;
|
||||
import edu.cornell.mannlib.vitro.webapp.modules.fileStorage.FileStorage;
|
||||
import edu.cornell.mannlib.vitro.webapp.modules.imageProcessor.ImageProcessor;
|
||||
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchEngine;
|
||||
|
||||
|
@ -66,4 +67,11 @@ public class ApplicationStub implements Application {
|
|||
"ApplicationStub.getImageProcessor() not implemented.");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileStorage getFileStorage() {
|
||||
throw new RuntimeException(
|
||||
"ApplicationStub.getFileStorage() not implemented.");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue