Author: bdekruijff at gmail.com
Date: Fri Nov 19 11:54:47 2010
New Revision: 432
Log:
AMDATU-176 Refactored to use ConfigAdmin for configuration
Modified:
trunk/amdatu-core/tenantstore-fs/src/main/java/org/amdatu/core/tenantstore/fs/internal/FSTenantIdList.java
trunk/amdatu-core/tenantstore-fs/src/main/java/org/amdatu/core/tenantstore/fs/internal/FSTenantStore.java
trunk/amdatu-core/tenantstore-fs/src/main/java/org/amdatu/core/tenantstore/fs/osgi/FSTenantStorageProviderActivator.java
trunk/amdatu-core/tenantstore-fs/src/main/java/org/amdatu/core/tenantstore/fs/service/FSTenantStorageProvider.java
trunk/amdatu-core/tenantstore-fs/src/test/java/org/amdatu/core/tenantstore/fs/osgi/FSTenantStorageProviderActivatorTest.java
trunk/amdatu-core/tenantstore-fs/src/test/java/org/amdatu/core/tenantstore/fs/service/FSTenantStorageProviderTest.java
Modified:
trunk/amdatu-core/tenantstore-fs/src/main/java/org/amdatu/core/tenantstore/fs/internal/FSTenantIdList.java
==============================================================================
---
trunk/amdatu-core/tenantstore-fs/src/main/java/org/amdatu/core/tenantstore/fs/internal/FSTenantIdList.java
(original)
+++
trunk/amdatu-core/tenantstore-fs/src/main/java/org/amdatu/core/tenantstore/fs/internal/FSTenantIdList.java
Fri Nov 19 11:54:47 2010
@@ -46,11 +46,11 @@
}
}
- public synchronized List<String> getAll() throws TenantStorageException {
+ public List<String> getAll() throws TenantStorageException {
return new LinkedList<String>(m_tenantIdList);
}
- public synchronized void addTenantId(final String entityId) throws
TenantStorageException {
+ public void addTenantId(final String entityId) throws
TenantStorageException {
try {
if (!m_tenantIdList.contains(entityId)) {
m_tenantIdList.add(entityId);
@@ -62,7 +62,7 @@
}
}
- public synchronized void removeTenantId(final String entityId) throws
TenantStorageException {
+ public void removeTenantId(final String entityId) throws
TenantStorageException {
try {
if (m_tenantIdList.contains(entityId)) {
m_tenantIdList.remove(entityId);
Modified:
trunk/amdatu-core/tenantstore-fs/src/main/java/org/amdatu/core/tenantstore/fs/internal/FSTenantStore.java
==============================================================================
---
trunk/amdatu-core/tenantstore-fs/src/main/java/org/amdatu/core/tenantstore/fs/internal/FSTenantStore.java
(original)
+++
trunk/amdatu-core/tenantstore-fs/src/main/java/org/amdatu/core/tenantstore/fs/internal/FSTenantStore.java
Fri Nov 19 11:54:47 2010
@@ -48,19 +48,19 @@
}
}
- public synchronized TenantEntity addEntity(final TenantEntity entity) {
+ public TenantEntity addEntity(final TenantEntity entity) {
return m_entities.put(entity.getId(), entity);
}
- public synchronized TenantEntity removeEntity(final String entityId) {
+ public TenantEntity removeEntity(final String entityId) {
return m_entities.remove(entityId);
}
- public synchronized TenantEntity getEntity(final String entityId) {
+ public TenantEntity getEntity(final String entityId) {
return m_entities.get(entityId);
}
- public synchronized void save() throws TenantStorageException {
+ public void save() throws TenantStorageException {
try {
writeEntities();
}
Modified:
trunk/amdatu-core/tenantstore-fs/src/main/java/org/amdatu/core/tenantstore/fs/osgi/FSTenantStorageProviderActivator.java
==============================================================================
---
trunk/amdatu-core/tenantstore-fs/src/main/java/org/amdatu/core/tenantstore/fs/osgi/FSTenantStorageProviderActivator.java
(original)
+++
trunk/amdatu-core/tenantstore-fs/src/main/java/org/amdatu/core/tenantstore/fs/osgi/FSTenantStorageProviderActivator.java
Fri Nov 19 11:54:47 2010
@@ -17,9 +17,6 @@
*/
package org.amdatu.core.tenantstore.fs.osgi;
-import java.io.File;
-
-import org.amdatu.core.tenant.TenantStorageException;
import org.amdatu.core.tenant.TenantStorageProvider;
import org.amdatu.core.tenantstore.fs.service.FSTenantStorageProvider;
import org.apache.felix.dm.DependencyActivatorBase;
@@ -28,35 +25,18 @@
import org.osgi.service.log.LogService;
/**
- * This class represents the OSGi activator for the tenant service fs storage
provider. By default it will use the
- * bundle storage, but can be configured to use an alternative directory by
setting the system property specified
- * by <code>FSTenantStorageProvider.STORAGEDIR_PROPERTYNAME</code>.
+ * This class represents the OSGi activator for the tenant service fs storage
provider.
*/
public final class FSTenantStorageProviderActivator extends
DependencyActivatorBase {
@Override
public void init(BundleContext context, DependencyManager manager) throws
Exception {
- File storageDirectory;
- String dirProperty =
System.getProperty(FSTenantStorageProvider.STORAGEDIR_PROPERTYNAME);
- if (dirProperty != null && !"".equals(dirProperty)) {
- storageDirectory = new File(dirProperty);
- }
- else {
- // Default bundle storage
- storageDirectory = context.getDataFile("");
- }
-
- // Check accessibility
- if (storageDirectory == null || !storageDirectory.exists() ||
!storageDirectory.canRead()
- || !storageDirectory.canWrite()) {
- throw new TenantStorageException("Unable to access storage
directory:" + storageDirectory.getAbsolutePath());
- }
-
manager.add(
createComponent()
- .setImplementation(new
FSTenantStorageProvider(storageDirectory))
+ .setImplementation(new FSTenantStorageProvider())
.setInterface(TenantStorageProvider.class.getName(), null)
+
.add(createConfigurationDependency().setPid(FSTenantStorageProvider.CONFIGURATION_PID))
.add(createServiceDependency().setService(LogService.class).setRequired(false)));
}
Modified:
trunk/amdatu-core/tenantstore-fs/src/main/java/org/amdatu/core/tenantstore/fs/service/FSTenantStorageProvider.java
==============================================================================
---
trunk/amdatu-core/tenantstore-fs/src/main/java/org/amdatu/core/tenantstore/fs/service/FSTenantStorageProvider.java
(original)
+++
trunk/amdatu-core/tenantstore-fs/src/main/java/org/amdatu/core/tenantstore/fs/service/FSTenantStorageProvider.java
Fri Nov 19 11:54:47 2010
@@ -17,6 +17,7 @@
package org.amdatu.core.tenantstore.fs.service;
import java.io.File;
+import java.util.Dictionary;
import java.util.LinkedList;
import java.util.List;
@@ -25,34 +26,99 @@
import org.amdatu.core.tenant.TenantStorageProvider;
import org.amdatu.core.tenantstore.fs.internal.FSTenantIdList;
import org.amdatu.core.tenantstore.fs.internal.FSTenantStore;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
+import org.osgi.service.log.LogService;
/**
* Filesystem backed implementation of the <code>TenantStorageProvider</code>
service interface.
*/
-public class FSTenantStorageProvider implements TenantStorageProvider {
+public class FSTenantStorageProvider implements TenantStorageProvider,
ManagedService {
- public static final String STORAGEDIR_PROPERTYNAME =
"org.amdatu.core.tenant.storagedir";
+ // The PID and configuration properties
+ public static final String CONFIGURATION_PID =
"org.amdatu.core.tenant.storagedir";
+ public final static String DATA_DIRECTORY = "datadir";
+ // File naming constants
private static final String ENTITYLIST_FILENAME = "tenantIdList.ser";
private static final String STORAGEFILE_PREFIX = "t_";
private static final String STORAGEFILE_POSTFIX = ".ser";
- private final FSTenantIdList m_fsSEntityIdList;
- private final File m_RootDirectory;
+ // DM injected (option)
+ private volatile LogService m_LogService;
- public FSTenantStorageProvider(final File rootDirectory) throws
TenantStorageException {
- if (!rootDirectory.isDirectory() || !rootDirectory.canRead() ||
!rootDirectory.canWrite()) {
- throw new TenantStorageException("Unable to access root
directory");
+ // Storage directory
+ private File m_DataDirectory;
+
+ // Collaborator
+ private FSTenantIdList m_TenantIdList;
+
+ /*
+ * Constructors
+ */
+
+ public FSTenantStorageProvider() {
+ }
+
+ /*
+ * Accessor methods
+ */
+
+ public synchronized File getDataDirectory() {
+ return m_DataDirectory;
+ }
+
+ public synchronized void setDataDirectory(final File dataDirectory) throws
ConfigurationException {
+ if (!((dataDirectory.exists() && dataDirectory.canRead() &&
dataDirectory.canWrite()) || dataDirectory
+ .mkdirs())) {
+ throw new ConfigurationException(DATA_DIRECTORY, "Unable to access
data directory: "
+ + dataDirectory.getAbsolutePath());
+ }
+ m_DataDirectory = dataDirectory;
+ }
+
+ /*
+ * Service lifecycle
+ */
+
+ public synchronized void start() throws TenantStorageException {
+ m_TenantIdList = new FSTenantIdList(new File(m_DataDirectory,
ENTITYLIST_FILENAME));
+ }
+
+ public synchronized void stop() {
+ m_TenantIdList = null;
+ }
+
+ /*
+ * ManagedService API
+ */
+
+ public synchronized void updated(Dictionary dictionary) throws
ConfigurationException {
+ File userDirectory = new File(System.getProperty("user.dir"));
+ if (dictionary != null) {
+ String dataDirectoryName = (String) dictionary.get(DATA_DIRECTORY);
+ if (dataDirectoryName == null || "".equals(dataDirectoryName)) {
+ throw new ConfigurationException(DATA_DIRECTORY, "Missing
mandatory data directory configuration");
+ }
+
+ File dataDirectory = new File(dataDirectoryName);
+ if (!dataDirectory.isAbsolute()) {
+ dataDirectory = new File(userDirectory, dataDirectoryName);
+
+ }
+ setDataDirectory(dataDirectory);
}
- m_RootDirectory = rootDirectory;
- m_fsSEntityIdList = new FSTenantIdList(new File(rootDirectory,
ENTITYLIST_FILENAME));
}
+ /*
+ * TenantStorageProvider API
+ */
+
public synchronized void store(final TenantEntity entity) throws
TenantStorageException {
FSTenantStore tenantStorageFile = getStorageFile(entity.getId());
TenantEntity storedEntity = tenantStorageFile.addEntity(entity);
if (storedEntity == null) {
- m_fsSEntityIdList.addTenantId(entity.getId());
+ m_TenantIdList.addTenantId(entity.getId());
}
tenantStorageFile.save();
}
@@ -61,7 +127,7 @@
FSTenantStore tenantStorageFile = getStorageFile(entity.getId());
TenantEntity storedEntity =
tenantStorageFile.removeEntity(entity.getId());
if (storedEntity != null) {
- m_fsSEntityIdList.removeTenantId(entity.getId());
+ m_TenantIdList.removeTenantId(entity.getId());
tenantStorageFile.save();
}
}
@@ -72,7 +138,7 @@
}
public synchronized List<TenantEntity> getAll() throws
TenantStorageException {
- final List<String> entityIdList = m_fsSEntityIdList.getAll();
+ final List<String> entityIdList = m_TenantIdList.getAll();
final List<TenantEntity> tenantEntityList = new
LinkedList<TenantEntity>();
for (String tenantEntityId : entityIdList) {
tenantEntityList.add(getById(tenantEntityId));
@@ -83,7 +149,7 @@
private FSTenantStore getStorageFile(final String entityId) throws
TenantStorageException {
final int hash = Math.abs(entityId.hashCode());
final String subdirName = "" + (hash % 50);
- final File subdirFile = new File(m_RootDirectory, subdirName);
+ final File subdirFile = new File(m_DataDirectory, subdirName);
if (!subdirFile.exists()) {
subdirFile.mkdir();
}
Modified:
trunk/amdatu-core/tenantstore-fs/src/test/java/org/amdatu/core/tenantstore/fs/osgi/FSTenantStorageProviderActivatorTest.java
==============================================================================
---
trunk/amdatu-core/tenantstore-fs/src/test/java/org/amdatu/core/tenantstore/fs/osgi/FSTenantStorageProviderActivatorTest.java
(original)
+++
trunk/amdatu-core/tenantstore-fs/src/test/java/org/amdatu/core/tenantstore/fs/osgi/FSTenantStorageProviderActivatorTest.java
Fri Nov 19 11:54:47 2010
@@ -17,21 +17,26 @@
package org.amdatu.core.tenantstore.fs.osgi;
import java.io.File;
+import java.util.Collection;
import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import junit.framework.Assert;
import org.amdatu.core.tenant.TenantEntity;
-import org.amdatu.core.tenant.TenantStorageException;
import org.amdatu.core.tenant.TenantStorageProvider;
import org.amdatu.core.tenantstore.fs.service.FSTenantStorageProvider;
import org.apache.felix.dm.ComponentDeclaration;
import org.apache.felix.dm.DependencyActivatorBase;
-import org.apache.felix.dm.impl.ComponentImpl;
+import org.hamcrest.Description;
import org.jmock.Expectations;
import org.jmock.Mockery;
+import org.jmock.api.Action;
+import org.jmock.api.Invocation;
+import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
@@ -39,12 +44,17 @@
import org.osgi.framework.BundleContext;
import org.osgi.framework.Filter;
import org.osgi.framework.ServiceListener;
+import org.osgi.service.cm.ManagedService;
import org.osgi.service.log.LogService;
public final class FSTenantStorageProviderActivatorTest {
private static final String JAVA_IO_TMPDIR =
System.getProperty("java.io.tmpdir");
- private static File m_rootDirectory;
+
+ private static File m_absoluteTestRootDirectory;
+ private static String m_relativeTestRootDirectory;
+
+ private List<Object> m_RegisteredServices;
@Rule
public TestName m_testName = new TestName();
@@ -53,25 +63,28 @@
public static void setUpOnce() {
Random rand = new Random();
int randomInt = 1 + Math.abs(rand.nextInt());
- m_rootDirectory =
- new File(JAVA_IO_TMPDIR + File.separator +
FSTenantStorageProviderActivatorTest.class.getSimpleName() + "_" + randomInt);
- if (!m_rootDirectory.exists()) {
- m_rootDirectory.mkdirs();
+ m_relativeTestRootDirectory =
FSTenantStorageProviderActivatorTest.class.getSimpleName() + "_" + randomInt;
+ m_absoluteTestRootDirectory =
+ new File(JAVA_IO_TMPDIR + File.separator +
m_relativeTestRootDirectory);
+ if (!m_absoluteTestRootDirectory.exists()) {
+ m_absoluteTestRootDirectory.mkdirs();
}
}
+ @Before
+ public void setUp() {
+ m_RegisteredServices = new LinkedList<Object>();
+ }
+
@Test
- public void testActivatorUsesBundleStorageDirectory() throws Exception {
+ public void testActivatorUsesAbsoluteStorageDirectory() throws Exception {
final Mockery mockContext = new Mockery();
final BundleContext bundleContext =
mockContext.mock(BundleContext.class);
- final File bundleStorageDir = new File(m_rootDirectory,
m_testName.getMethodName());
+ final File bundleStorageDir = new File(m_absoluteTestRootDirectory,
m_testName.getMethodName());
bundleStorageDir.mkdir();
- // make sure the configuration system property is not set
- System.setProperty(FSTenantStorageProvider.STORAGEDIR_PROPERTYNAME,
"");
-
mockContext.checking(new Expectations() {
{
// allowing all service registration calls to the bundleContext
@@ -87,16 +100,20 @@
allowing(bundleContext).getServiceReferences(with(LogService.class.getName()),
with(any(String.class)));
will(returnValue(null));
-
allowing(bundleContext).registerService(with(ComponentDeclaration.class.getName()),
+ // assert that DM registers a component and store it for
callback
+
one(bundleContext).registerService(with(ComponentDeclaration.class.getName()),
with(aNonNull(Object.class)), with(any(Dictionary.class)));
+ will(addRegisteredService());
- // assert that the bundleContext storage directory is
requested and return it
- one(bundleContext).getDataFile(with(aNonNull(String.class)));
- will(returnValue(bundleStorageDir));
+ // assert that DM registers a managed service and store it for
callback
+
one(bundleContext).registerService(with(ManagedService.class.getName()),
+ with(aNonNull(Object.class)), with(any(Dictionary.class)));
+ will(addRegisteredService());
- // assert that the TenantStorageProvider is registered at the
bundlecontext
+ // assert that the TenantStorageProvider is registered and
store it for callback
one(bundleContext).registerService(with(TenantStorageProvider.class.getName()),
with(aNonNull(FSTenantStorageProvider.class)),
with(any(Dictionary.class)));
+ will(addRegisteredService());
}
});
@@ -104,30 +121,33 @@
DependencyActivatorBase activatorBase = new
FSTenantStorageProviderActivator();
activatorBase.start(bundleContext);
- @SuppressWarnings(value="unchecked")
- List<Object> services =
activatorBase.getDependencyManager().getServices();
- ComponentImpl component = (ComponentImpl) services.get(0);
+ // simulate config admin callback
+ Dictionary<String, String> dict = new Hashtable<String, String>();
+ dict.put(FSTenantStorageProvider.DATA_DIRECTORY,
bundleStorageDir.getAbsolutePath());
+ ((ManagedService) m_RegisteredServices.get(1)).updated(dict);
- TenantStorageProvider provider = (TenantStorageProvider)
component.getService();
+ // invoke the storage provider to get it persist something
+ TenantStorageProvider provider = (TenantStorageProvider)
m_RegisteredServices.get(2);
provider.store(new TenantEntity("1", "Bram"));
// assert that the bundleContext storage directory was used
String[] files = bundleStorageDir.list();
Assert.assertTrue(files.length > 0);
+ // checkerdiecheck
mockContext.assertIsSatisfied();
}
@Test
- public void testActivatorUsesConfiguredStorageDirectory() throws Exception
{
+ public void testActivatorUsesRelativeStorageDirectory() throws Exception {
+
final Mockery mockContext = new Mockery();
final BundleContext bundleContext =
mockContext.mock(BundleContext.class);
- final File configuredStorageDir = new File(m_rootDirectory,
m_testName.getMethodName());
- configuredStorageDir.mkdir();
-
- // make sure the configuration system property is set
- System.setProperty(FSTenantStorageProvider.STORAGEDIR_PROPERTYNAME,
configuredStorageDir.getAbsolutePath());
+ final String relativeStorageDirectoryPath =
+ m_relativeTestRootDirectory + File.separator +
m_testName.getMethodName();
+ final File absolutebundleStorageDirectory = new
File(m_absoluteTestRootDirectory, m_testName.getMethodName());
+ absolutebundleStorageDirectory.mkdir();
mockContext.checking(new Expectations() {
{
@@ -144,12 +164,20 @@
allowing(bundleContext).getServiceReferences(with(LogService.class.getName()),
with(any(String.class)));
will(returnValue(null));
-
allowing(bundleContext).registerService(with(ComponentDeclaration.class.getName()),
+ // assert that DM registers a component and store it for
callback
+
one(bundleContext).registerService(with(ComponentDeclaration.class.getName()),
+ with(aNonNull(Object.class)), with(any(Dictionary.class)));
+ will(addRegisteredService());
+
+ // assert that DM registers a managed service and store it for
callback
+
one(bundleContext).registerService(with(ManagedService.class.getName()),
with(aNonNull(Object.class)), with(any(Dictionary.class)));
+ will(addRegisteredService());
- // assert that the TenantStorageProvider is registered at the
bundlecontext
+ // assert that the TenantStorageProvider is registered and
store it for callback
one(bundleContext).registerService(with(TenantStorageProvider.class.getName()),
with(aNonNull(FSTenantStorageProvider.class)),
with(any(Dictionary.class)));
+ will(addRegisteredService());
}
});
@@ -157,48 +185,46 @@
DependencyActivatorBase activatorBase = new
FSTenantStorageProviderActivator();
activatorBase.start(bundleContext);
- @SuppressWarnings(value="unchecked")
- List<Object> services =
activatorBase.getDependencyManager().getServices();
- ComponentImpl component = (ComponentImpl) services.get(0);
+ // simulate config admin callback with relative dir
+ System.setProperty("user.dir", JAVA_IO_TMPDIR);
+ Dictionary<String, String> dict = new Hashtable<String, String>();
+ dict.put(FSTenantStorageProvider.DATA_DIRECTORY,
relativeStorageDirectoryPath);
+ ((ManagedService) m_RegisteredServices.get(1)).updated(dict);
- TenantStorageProvider provider = (TenantStorageProvider)
component.getService();
+ // invoke the storage provider to get it persist something
+ TenantStorageProvider provider = (TenantStorageProvider)
m_RegisteredServices.get(2);
provider.store(new TenantEntity("1", "Bram"));
- // assert that the configured storage directory was used
- String[] files = configuredStorageDir.list();
+ // assert that the correct storage directory was actually used
+ Assert.assertEquals(((FSTenantStorageProvider)
provider).getDataDirectory().getAbsolutePath(),
+ absolutebundleStorageDirectory.getAbsolutePath());
+ String[] files = ((FSTenantStorageProvider)
provider).getDataDirectory().list();
Assert.assertTrue(files.length > 0);
+ // checkerdiecheck
mockContext.assertIsSatisfied();
}
- @Test(expected = TenantStorageException.class)
- public void testActivatorThrowsExcpetionOnNonExistingDirectory() throws
Exception {
- final Mockery mockContext = new Mockery();
- final BundleContext bundleContext =
mockContext.mock(BundleContext.class);
-
- final File configuredStorageDir = new File(m_rootDirectory,
m_testName.getMethodName());
-
- // make sure the configuration system property is set
- System.setProperty(FSTenantStorageProvider.STORAGEDIR_PROPERTYNAME,
configuredStorageDir.getAbsolutePath());
-
- mockContext.checking(new Expectations() {
- {
- // allowing all service registration calls to the bundleContext
-
allowing(bundleContext).addServiceListener(with(aNonNull(ServiceListener.class)),
- with(any(String.class)));
+ private <Object> Action addRegisteredService() {
+ return new AddElementsAction<Object>((Collection<Object>)
m_RegisteredServices);
+ }
+}
-
allowing(bundleContext).createFilter((with(aNonNull(String.class))));
- will(returnValue(mockContext.mock(Filter.class)));
+class AddElementsAction<T> implements Action {
+ private Collection<T> m_services;
-
allowing(bundleContext).getServiceReference(LogService.class.getName());
- will(returnValue(null));
- }
- });
-
- DependencyActivatorBase activatorBase = new
FSTenantStorageProviderActivator();
- activatorBase.start(bundleContext);
+ public AddElementsAction(Collection<T> services) {
+ m_services = services;
+ }
- mockContext.assertIsSatisfied();
+ public void describeTo(Description description) {
+ description.appendText("adds ")
+ .appendValueList("", ", ", "", m_services)
+ .appendText(" to a collection");
}
-}
+ public Object invoke(Invocation invocation) throws Throwable {
+ m_services.add((T) invocation.getParameter(1));
+ return null;
+ }
+}
\ No newline at end of file
Modified:
trunk/amdatu-core/tenantstore-fs/src/test/java/org/amdatu/core/tenantstore/fs/service/FSTenantStorageProviderTest.java
==============================================================================
---
trunk/amdatu-core/tenantstore-fs/src/test/java/org/amdatu/core/tenantstore/fs/service/FSTenantStorageProviderTest.java
(original)
+++
trunk/amdatu-core/tenantstore-fs/src/test/java/org/amdatu/core/tenantstore/fs/service/FSTenantStorageProviderTest.java
Fri Nov 19 11:54:47 2010
@@ -15,12 +15,15 @@
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
+import org.osgi.service.cm.ConfigurationException;
public class FSTenantStorageProviderTest {
private final static String JAVA_IO_TMPDIR =
System.getProperty("java.io.tmpdir");
- private static File m_rootDirectory;
+ private static File m_absoluteTestRootDirectory;
+ private static String m_relativeTestRootDirectory;
+
@Rule
public TestName m_testName = new TestName();
@@ -31,16 +34,19 @@
public static void setUpOnce() throws TenantStorageException {
Random rand = new Random();
int randomInt = 1 + Math.abs(rand.nextInt());
- m_rootDirectory =
- new File(JAVA_IO_TMPDIR + File.separator +
FSTenantStorageProviderActivatorTest.class.getSimpleName() + "_" + randomInt);
- m_rootDirectory.mkdirs();
+ m_relativeTestRootDirectory =
FSTenantStorageProviderActivatorTest.class.getSimpleName() + "_" + randomInt;
+ m_absoluteTestRootDirectory =
+ new File(JAVA_IO_TMPDIR + File.separator +
m_relativeTestRootDirectory);
+ m_absoluteTestRootDirectory.mkdirs();
}
@Before
- public void setUp() throws TenantStorageException {
- m_testDirectory = new File(m_rootDirectory,
m_testName.getMethodName());
+ public void setUp() throws TenantStorageException, ConfigurationException {
+ m_testDirectory = new File(m_absoluteTestRootDirectory,
m_testName.getMethodName());
m_testDirectory.mkdir();
- m_TenantBundleStorageProvider = new
FSTenantStorageProvider(m_testDirectory);
+ m_TenantBundleStorageProvider = new FSTenantStorageProvider();
+ m_TenantBundleStorageProvider.setDataDirectory(m_testDirectory);
+ m_TenantBundleStorageProvider.start();
}
/**