Repository: james-project
Updated Branches:
  refs/heads/master 3f82e7b8e -> 466a4f461


JAMES-2589 Rely on a single `blobstore.properties` configuration file


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/5015c7e5
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/5015c7e5
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/5015c7e5

Branch: refs/heads/master
Commit: 5015c7e54f8284b29c6b7a02a689d1ce58ae25c2
Parents: 3f82e7b
Author: Benoit Tellier <[email protected]>
Authored: Fri Nov 16 10:19:29 2018 +0700
Committer: Benoit Tellier <[email protected]>
Committed: Wed Nov 21 09:47:34 2018 +0700

----------------------------------------------------------------------
 .../destination/conf/blobstore.properties       |  13 ++
 .../destination/conf/objectstorage.properties   |  11 --
 .../destination/conf/objectstore.properties     |   1 -
 .../modules/mailbox/ConfigurationComponent.java |  24 ++++
 .../guice/blob-objectstorage-guice/pom.xml      |   4 +
 .../ObjectStorageDependenciesModule.java        |   6 +-
 .../guice/cassandra-rabbitmq-guice/pom.xml      |   5 +
 .../james/CassandraRabbitMQJamesServerMain.java |   2 +-
 .../BlobStoreChoosingConfiguration.java         | 115 ++++++++++++++++
 .../blobstore/BlobStoreChoosingModule.java      |  90 ++++++++++++
 .../BlobStoreChoosingConfiguration.java         |  91 -------------
 .../objectstore/BlobStoreChoosingModule.java    |  82 -----------
 .../BlobStoreChoosingConfigurationTest.java     | 127 +++++++++++++++++
 .../blobstore/BlobStoreChoosingModuleTest.java  | 136 +++++++++++++++++++
 .../BlobStoreChoosingConfigurationTest.java     | 119 ----------------
 .../BlobStoreChoosingModuleTest.java            | 118 ----------------
 16 files changed, 518 insertions(+), 426 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/5015c7e5/dockerfiles/run/guice/cassandra-rabbitmq/destination/conf/blobstore.properties
----------------------------------------------------------------------
diff --git 
a/dockerfiles/run/guice/cassandra-rabbitmq/destination/conf/blobstore.properties
 
b/dockerfiles/run/guice/cassandra-rabbitmq/destination/conf/blobstore.properties
new file mode 100644
index 0000000..a7b3ee8
--- /dev/null
+++ 
b/dockerfiles/run/guice/cassandra-rabbitmq/destination/conf/blobstore.properties
@@ -0,0 +1,13 @@
+implementation=objectstorage
+
+# Configuration for swift BlobStore
+objectstorage.payload.codec=DEFAULT
+objectstorage.provider=swift
+objectstorage.namespace=james
+objectstorage.swift.authapi=tmpauth
+objectstorage.swift.endpoint=http://swift:8080/auth/v1.0
+objectstorage.swift.credentials=testing
+objectstorage.swift.tempauth.username=tester
+objectstorage.swift.tempauth.tenantname=test
+objectstorage.swift.tempauth.passheadername=X-Storage-Pass
+objectstorage.swift.tempauth.userheadername=X-Storage-User
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/5015c7e5/dockerfiles/run/guice/cassandra-rabbitmq/destination/conf/objectstorage.properties
----------------------------------------------------------------------
diff --git 
a/dockerfiles/run/guice/cassandra-rabbitmq/destination/conf/objectstorage.properties
 
b/dockerfiles/run/guice/cassandra-rabbitmq/destination/conf/objectstorage.properties
deleted file mode 100644
index 9ab4beb..0000000
--- 
a/dockerfiles/run/guice/cassandra-rabbitmq/destination/conf/objectstorage.properties
+++ /dev/null
@@ -1,11 +0,0 @@
-# Configuration for swift BlobStore
-objectstorage.payload.codec=DEFAULT
-objectstorage.provider=swift
-objectstorage.namespace=james
-objectstorage.swift.authapi=tmpauth
-objectstorage.swift.endpoint=http://swift:8080/auth/v1.0
-objectstorage.swift.credentials=testing
-objectstorage.swift.tempauth.username=tester
-objectstorage.swift.tempauth.tenantname=test
-objectstorage.swift.tempauth.passheadername=X-Storage-Pass
-objectstorage.swift.tempauth.userheadername=X-Storage-User
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/5015c7e5/dockerfiles/run/guice/cassandra-rabbitmq/destination/conf/objectstore.properties
----------------------------------------------------------------------
diff --git 
a/dockerfiles/run/guice/cassandra-rabbitmq/destination/conf/objectstore.properties
 
b/dockerfiles/run/guice/cassandra-rabbitmq/destination/conf/objectstore.properties
deleted file mode 100644
index 4f1cb0c..0000000
--- 
a/dockerfiles/run/guice/cassandra-rabbitmq/destination/conf/objectstore.properties
+++ /dev/null
@@ -1 +0,0 @@
-objectstore.implementation=swift
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/5015c7e5/server/container/guice/blob-api-guice/src/main/java/org/apache/james/modules/mailbox/ConfigurationComponent.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/blob-api-guice/src/main/java/org/apache/james/modules/mailbox/ConfigurationComponent.java
 
b/server/container/guice/blob-api-guice/src/main/java/org/apache/james/modules/mailbox/ConfigurationComponent.java
new file mode 100644
index 0000000..4613f15
--- /dev/null
+++ 
b/server/container/guice/blob-api-guice/src/main/java/org/apache/james/modules/mailbox/ConfigurationComponent.java
@@ -0,0 +1,24 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.modules.mailbox;
+
+public interface ConfigurationComponent {
+    String NAME = "blobstore";
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/5015c7e5/server/container/guice/blob-objectstorage-guice/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/blob-objectstorage-guice/pom.xml 
b/server/container/guice/blob-objectstorage-guice/pom.xml
index 782d06b..af39f09 100644
--- a/server/container/guice/blob-objectstorage-guice/pom.xml
+++ b/server/container/guice/blob-objectstorage-guice/pom.xml
@@ -37,6 +37,10 @@
     <dependencies>
         <dependency>
             <groupId>${james.groupId}</groupId>
+            <artifactId>blob-api-guice</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${james.groupId}</groupId>
             <artifactId>blob-objectstorage</artifactId>
         </dependency>
         <dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/5015c7e5/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/ObjectStorageDependenciesModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/ObjectStorageDependenciesModule.java
 
b/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/ObjectStorageDependenciesModule.java
index 0c975f2..4577159 100644
--- 
a/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/ObjectStorageDependenciesModule.java
+++ 
b/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/ObjectStorageDependenciesModule.java
@@ -36,6 +36,7 @@ import org.apache.james.blob.objectstorage.PayloadCodec;
 import org.apache.james.blob.objectstorage.swift.SwiftKeystone2ObjectStorage;
 import org.apache.james.blob.objectstorage.swift.SwiftKeystone3ObjectStorage;
 import org.apache.james.blob.objectstorage.swift.SwiftTempAuthObjectStorage;
+import org.apache.james.modules.mailbox.ConfigurationComponent;
 import org.apache.james.utils.PropertiesProvider;
 
 import com.google.inject.AbstractModule;
@@ -44,7 +45,6 @@ import com.google.inject.Scopes;
 
 public class ObjectStorageDependenciesModule extends AbstractModule {
 
-    private static final String OBJECTSTORAGE_CONFIGURATION_NAME = 
"objectstorage";
     private static final String OBJECTSTORAGE_PROVIDER_SWIFT = "swift";
 
     @Override
@@ -62,10 +62,10 @@ public class ObjectStorageDependenciesModule extends 
AbstractModule {
     @Singleton
     private ObjectStorageBlobConfiguration 
getObjectStorageConfiguration(PropertiesProvider propertiesProvider) throws 
ConfigurationException {
         try {
-            Configuration configuration = 
propertiesProvider.getConfiguration(OBJECTSTORAGE_CONFIGURATION_NAME);
+            Configuration configuration = 
propertiesProvider.getConfiguration(ConfigurationComponent.NAME);
             return ObjectStorageBlobConfiguration.from(configuration);
         } catch (FileNotFoundException e) {
-            throw new ConfigurationException(OBJECTSTORAGE_CONFIGURATION_NAME 
+ " configuration was not found");
+            throw new ConfigurationException(ConfigurationComponent.NAME + " 
configuration was not found");
         }
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/5015c7e5/server/container/guice/cassandra-rabbitmq-guice/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-rabbitmq-guice/pom.xml 
b/server/container/guice/cassandra-rabbitmq-guice/pom.xml
index a207f77..d079dd7 100644
--- a/server/container/guice/cassandra-rabbitmq-guice/pom.xml
+++ b/server/container/guice/cassandra-rabbitmq-guice/pom.xml
@@ -148,6 +148,11 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>nl.jqno.equalsverifier</groupId>
+            <artifactId>equalsverifier</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>org.apache.pdfbox</groupId>
             <artifactId>pdfbox</artifactId>
             <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/james-project/blob/5015c7e5/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/CassandraRabbitMQJamesServerMain.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/CassandraRabbitMQJamesServerMain.java
 
b/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/CassandraRabbitMQJamesServerMain.java
index 21cee59..8bcf444 100644
--- 
a/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/CassandraRabbitMQJamesServerMain.java
+++ 
b/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/CassandraRabbitMQJamesServerMain.java
@@ -21,7 +21,7 @@ package org.apache.james;
 
 import static 
org.apache.james.CassandraJamesServerMain.ALL_BUT_JMX_CASSANDRA_MODULE;
 
-import org.apache.james.modules.objectstore.BlobStoreChoosingModule;
+import org.apache.james.modules.blobstore.BlobStoreChoosingModule;
 import org.apache.james.modules.rabbitmq.RabbitMQModule;
 import org.apache.james.modules.server.JMXServerModule;
 import org.apache.james.server.core.configuration.Configuration;

http://git-wip-us.apache.org/repos/asf/james-project/blob/5015c7e5/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/modules/blobstore/BlobStoreChoosingConfiguration.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/modules/blobstore/BlobStoreChoosingConfiguration.java
 
b/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/modules/blobstore/BlobStoreChoosingConfiguration.java
new file mode 100644
index 0000000..10ea54f
--- /dev/null
+++ 
b/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/modules/blobstore/BlobStoreChoosingConfiguration.java
@@ -0,0 +1,115 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.modules.blobstore;
+
+import java.util.Objects;
+import java.util.Optional;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.lang3.StringUtils;
+
+import com.google.common.base.MoreObjects;
+
+public class BlobStoreChoosingConfiguration {
+
+    public enum BlobStoreImplName {
+        CASSANDRA("cassandra"),
+        OBJECTSTORAGE("objectstorage");
+
+        static String supportedImplNames() {
+            return Stream.of(BlobStoreImplName.values())
+                .map(BlobStoreImplName::getName)
+                .collect(Collectors.joining(", "));
+        }
+
+        static BlobStoreImplName from(String name) {
+            return Stream.of(values())
+                .filter(blobName -> blobName.getName().equalsIgnoreCase(name))
+                .findFirst()
+                .orElseThrow(() -> new 
IllegalArgumentException(String.format("%s is not a valid name of BlobStores, " 
+
+                    "please use one of supported values in: %s", name, 
supportedImplNames())));
+        }
+
+        private final String name;
+
+        BlobStoreImplName(String name) {
+            this.name = name;
+        }
+
+        public String getName() {
+            return name;
+        }
+    }
+
+    static final String BLOBSTORE_IMPLEMENTATION_PROPERTY = "implementation";
+
+    static BlobStoreChoosingConfiguration from(Configuration configuration) {
+        BlobStoreImplName blobStoreImplName = 
Optional.ofNullable(configuration.getString(BLOBSTORE_IMPLEMENTATION_PROPERTY))
+            .filter(StringUtils::isNotBlank)
+            .map(StringUtils::trim)
+            .map(BlobStoreImplName::from)
+            .orElseThrow(() -> new IllegalStateException(String.format("%s 
property is missing please use one of " +
+                "supported values in: %s", BLOBSTORE_IMPLEMENTATION_PROPERTY, 
BlobStoreImplName.supportedImplNames())));
+
+        return new BlobStoreChoosingConfiguration(blobStoreImplName);
+    }
+
+    public static BlobStoreChoosingConfiguration cassandra() {
+        return new BlobStoreChoosingConfiguration(BlobStoreImplName.CASSANDRA);
+    }
+
+    public static BlobStoreChoosingConfiguration objectStorage() {
+        return new 
BlobStoreChoosingConfiguration(BlobStoreImplName.OBJECTSTORAGE);
+    }
+
+    private final BlobStoreImplName implementation;
+
+    BlobStoreChoosingConfiguration(BlobStoreImplName implementation) {
+        this.implementation = implementation;
+    }
+
+    BlobStoreImplName getImplementation() {
+        return implementation;
+    }
+
+    @Override
+    public final boolean equals(Object o) {
+        if (o instanceof BlobStoreChoosingConfiguration) {
+            BlobStoreChoosingConfiguration that = 
(BlobStoreChoosingConfiguration) o;
+
+            return Objects.equals(this.implementation, that.implementation);
+        }
+        return false;
+    }
+
+    @Override
+    public final int hashCode() {
+        return Objects.hash(implementation);
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(this)
+            .add("implementation", implementation)
+            .toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/5015c7e5/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/modules/blobstore/BlobStoreChoosingModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/modules/blobstore/BlobStoreChoosingModule.java
 
b/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/modules/blobstore/BlobStoreChoosingModule.java
new file mode 100644
index 0000000..20e04b1
--- /dev/null
+++ 
b/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/modules/blobstore/BlobStoreChoosingModule.java
@@ -0,0 +1,90 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.modules.blobstore;
+
+import java.io.FileNotFoundException;
+
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.james.backends.cassandra.components.CassandraModule;
+import org.apache.james.blob.api.BlobStore;
+import org.apache.james.blob.cassandra.CassandraBlobModule;
+import org.apache.james.blob.cassandra.CassandraBlobsDAO;
+import org.apache.james.blob.objectstorage.ObjectStorageBlobsDAO;
+import org.apache.james.modules.mailbox.ConfigurationComponent;
+import org.apache.james.modules.objectstorage.ObjectStorageDependenciesModule;
+import org.apache.james.utils.PropertiesProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+import com.google.inject.multibindings.Multibinder;
+
+public class BlobStoreChoosingModule extends AbstractModule {
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(BlobStoreChoosingModule.class);
+
+    @VisibleForTesting
+    static final String BLOB_STORE_CONFIGURATION_FILE = "blobstore";
+
+    @Override
+    protected void configure() {
+        install(new ObjectStorageDependenciesModule());
+
+        Multibinder<CassandraModule> cassandraDataDefinitions = 
Multibinder.newSetBinder(binder(), CassandraModule.class);
+        
cassandraDataDefinitions.addBinding().toInstance(CassandraBlobModule.MODULE);
+    }
+
+    @VisibleForTesting
+    @Provides
+    @Singleton
+    BlobStoreChoosingConfiguration 
provideChoosingConfiguration(PropertiesProvider propertiesProvider) throws 
ConfigurationException {
+        try {
+            Configuration configuration = 
propertiesProvider.getConfiguration(ConfigurationComponent.NAME);
+            return BlobStoreChoosingConfiguration.from(configuration);
+        } catch (FileNotFoundException e) {
+            LOGGER.warn("Could not find " + ConfigurationComponent.NAME + " 
configuration file, using cassandra blobstore as the default");
+            return BlobStoreChoosingConfiguration.cassandra();
+        }
+    }
+
+    @VisibleForTesting
+    @Provides
+    @Singleton
+    BlobStore provideBlobStore(BlobStoreChoosingConfiguration 
choosingConfiguration,
+                               Provider<CassandraBlobsDAO> 
cassandraBlobStoreProvider,
+                               Provider<ObjectStorageBlobsDAO> 
swiftBlobStoreProvider) {
+
+        switch (choosingConfiguration.getImplementation()) {
+            case OBJECTSTORAGE:
+                return swiftBlobStoreProvider.get();
+            case CASSANDRA:
+                return cassandraBlobStoreProvider.get();
+            default:
+                throw new RuntimeException(String.format("can not get the 
right blobstore provider with configuration %s",
+                    choosingConfiguration.toString()));
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/5015c7e5/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/modules/objectstore/BlobStoreChoosingConfiguration.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/modules/objectstore/BlobStoreChoosingConfiguration.java
 
b/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/modules/objectstore/BlobStoreChoosingConfiguration.java
deleted file mode 100644
index f980530..0000000
--- 
a/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/modules/objectstore/BlobStoreChoosingConfiguration.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.modules.objectstore;
-
-import java.util.Optional;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import org.apache.commons.configuration.Configuration;
-import org.apache.commons.lang3.StringUtils;
-
-import com.google.common.base.MoreObjects;
-
-public class BlobStoreChoosingConfiguration {
-
-    public enum BlobStoreImplName {
-        CASSANDRA("cassandra"),
-        SWIFT("swift");
-
-        static String supportedImplNames() {
-            return Stream.of(BlobStoreImplName.values())
-                .map(BlobStoreImplName::getName)
-                .collect(Collectors.joining(", "));
-        }
-
-        static BlobStoreImplName from(String name) {
-            return Stream.of(values())
-                .filter(blobName -> blobName.getName().equalsIgnoreCase(name))
-                .findFirst()
-                .orElseThrow(() -> new 
IllegalArgumentException(String.format("%s is not a valid name of BlobStores, " 
+
-                    "please use one of supported values in: %s", name, 
supportedImplNames())));
-        }
-
-        private final String name;
-
-        BlobStoreImplName(String name) {
-            this.name = name;
-        }
-
-        public String getName() {
-            return name;
-        }
-    }
-
-    static final String BLOBSTORE_IMPLEMENTATION_PROPERTY = 
"objectstore.implementation";
-
-    static BlobStoreChoosingConfiguration from(Configuration configuration) {
-        BlobStoreImplName blobStoreImplName = 
Optional.ofNullable(configuration.getString(BLOBSTORE_IMPLEMENTATION_PROPERTY))
-            .filter(StringUtils::isNotBlank)
-            .map(StringUtils::trim)
-            .map(BlobStoreImplName::from)
-            .orElseThrow(() -> new IllegalStateException(String.format("%s 
property is missing please use one of " +
-                "supported values in: %s", BLOBSTORE_IMPLEMENTATION_PROPERTY, 
BlobStoreImplName.supportedImplNames())));
-
-        return new BlobStoreChoosingConfiguration(blobStoreImplName);
-    }
-
-    private final BlobStoreImplName implementation;
-
-    BlobStoreChoosingConfiguration(BlobStoreImplName implementation) {
-        this.implementation = implementation;
-    }
-
-    BlobStoreImplName getImplementation() {
-        return implementation;
-    }
-
-    @Override
-    public String toString() {
-        return MoreObjects.toStringHelper(this)
-            .add("implementation", implementation)
-            .toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/5015c7e5/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/modules/objectstore/BlobStoreChoosingModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/modules/objectstore/BlobStoreChoosingModule.java
 
b/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/modules/objectstore/BlobStoreChoosingModule.java
deleted file mode 100644
index 510cee1..0000000
--- 
a/server/container/guice/cassandra-rabbitmq-guice/src/main/java/org/apache/james/modules/objectstore/BlobStoreChoosingModule.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.modules.objectstore;
-
-import java.io.FileNotFoundException;
-
-import javax.inject.Provider;
-import javax.inject.Singleton;
-
-import org.apache.commons.configuration.Configuration;
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.james.backends.cassandra.components.CassandraModule;
-import org.apache.james.blob.api.BlobStore;
-import org.apache.james.blob.cassandra.CassandraBlobModule;
-import org.apache.james.blob.cassandra.CassandraBlobsDAO;
-import org.apache.james.blob.objectstorage.ObjectStorageBlobsDAO;
-import org.apache.james.modules.objectstorage.ObjectStorageDependenciesModule;
-import org.apache.james.utils.PropertiesProvider;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.inject.AbstractModule;
-import com.google.inject.Provides;
-import com.google.inject.multibindings.Multibinder;
-
-public class BlobStoreChoosingModule extends AbstractModule {
-
-    private static final Logger LOGGER = 
LoggerFactory.getLogger(BlobStoreChoosingModule.class);
-
-    static final String BLOBSTORE_CONFIGURATION_NAME = "objectstore";
-
-    @Override
-    protected void configure() {
-        install(new ObjectStorageDependenciesModule());
-
-        Multibinder<CassandraModule> cassandraDataDefinitions = 
Multibinder.newSetBinder(binder(), CassandraModule.class);
-        
cassandraDataDefinitions.addBinding().toInstance(CassandraBlobModule.MODULE);
-    }
-
-    @VisibleForTesting
-    @Provides
-    @Singleton
-    BlobStore provideBlobStore(PropertiesProvider propertiesProvider,
-                               Provider<CassandraBlobsDAO> 
cassandraBlobStoreProvider,
-                               Provider<ObjectStorageBlobsDAO> 
swiftBlobStoreProvider) throws ConfigurationException {
-        try {
-            Configuration configuration = 
propertiesProvider.getConfiguration(BLOBSTORE_CONFIGURATION_NAME);
-            BlobStoreChoosingConfiguration choosingConfiguration = 
BlobStoreChoosingConfiguration.from(configuration);
-            switch (choosingConfiguration.getImplementation()) {
-                case SWIFT:
-                    return swiftBlobStoreProvider.get();
-                case CASSANDRA:
-                    return cassandraBlobStoreProvider.get();
-                default:
-                    throw new RuntimeException(String.format("can not get the 
right blobstore provider with configuration %s",
-                        choosingConfiguration.toString()));
-            }
-        } catch (FileNotFoundException e) {
-            LOGGER.warn("Could not find " + BLOBSTORE_CONFIGURATION_NAME + " 
configuration file, using cassandra blobstore as the default");
-            return cassandraBlobStoreProvider.get();
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/5015c7e5/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/modules/blobstore/BlobStoreChoosingConfigurationTest.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/modules/blobstore/BlobStoreChoosingConfigurationTest.java
 
b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/modules/blobstore/BlobStoreChoosingConfigurationTest.java
new file mode 100644
index 0000000..b97f5ad
--- /dev/null
+++ 
b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/modules/blobstore/BlobStoreChoosingConfigurationTest.java
@@ -0,0 +1,127 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.modules.blobstore;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.junit.jupiter.api.Test;
+
+import nl.jqno.equalsverifier.EqualsVerifier;
+
+class BlobStoreChoosingConfigurationTest {
+
+    private static final String OBJECT_STORAGE = "objectstorage";
+    private static final String CASSANDRA = "cassandra";
+
+    @Test
+    void shouldMatchBeanContract() {
+        EqualsVerifier.forClass(BlobStoreChoosingConfiguration.class)
+            .verify();
+    }
+
+    @Test
+    void fromShouldThrowWhenBlobStoreImplIsMissing() {
+        PropertiesConfiguration configuration = new PropertiesConfiguration();
+
+        assertThatThrownBy(() -> 
BlobStoreChoosingConfiguration.from(configuration))
+            .isInstanceOf(IllegalStateException.class)
+            .hasMessage("implementation property is missing please use one of 
supported values in: cassandra, objectstorage");
+    }
+
+    @Test
+    void fromShouldThrowWhenBlobStoreImplIsNull() {
+        PropertiesConfiguration configuration = new PropertiesConfiguration();
+        configuration.addProperty("implementation", null);
+
+        assertThatThrownBy(() -> 
BlobStoreChoosingConfiguration.from(configuration))
+            .isInstanceOf(IllegalStateException.class)
+            .hasMessage("implementation property is missing please use one of 
supported values in: cassandra, objectstorage");
+    }
+
+    @Test
+    void fromShouldThrowWhenBlobStoreImplIsEmpty() {
+        PropertiesConfiguration configuration = new PropertiesConfiguration();
+        configuration.addProperty("implementation", "");
+
+        assertThatThrownBy(() -> 
BlobStoreChoosingConfiguration.from(configuration))
+            .isInstanceOf(IllegalStateException.class)
+            .hasMessage("implementation property is missing please use one of 
supported values in: cassandra, objectstorage");
+    }
+
+    @Test
+    void fromShouldThrowWhenBlobStoreImplIsNotInSupportedList() {
+        PropertiesConfiguration configuration = new PropertiesConfiguration();
+        configuration.addProperty("implementation", "un_supported");
+
+        assertThatThrownBy(() -> 
BlobStoreChoosingConfiguration.from(configuration))
+            .isInstanceOf(IllegalArgumentException.class)
+            .hasMessage("un_supported is not a valid name of BlobStores, 
please use one of supported values in: cassandra, objectstorage");
+    }
+
+    @Test
+    void fromShouldReturnConfigurationWhenBlobStoreImplIsCassandra() {
+        PropertiesConfiguration configuration = new PropertiesConfiguration();
+        configuration.addProperty("implementation", CASSANDRA);
+
+        assertThat(
+            BlobStoreChoosingConfiguration.from(configuration)
+                .getImplementation()
+                .getName())
+            .isEqualTo(CASSANDRA);
+    }
+
+    @Test
+    void fromShouldReturnConfigurationWhenBlobStoreImplIsSwift() {
+        PropertiesConfiguration configuration = new PropertiesConfiguration();
+        configuration.addProperty("implementation", OBJECT_STORAGE);
+
+        assertThat(
+            BlobStoreChoosingConfiguration.from(configuration)
+                .getImplementation()
+                .getName())
+            .isEqualTo(OBJECT_STORAGE);
+    }
+
+    @Test
+    void 
fromShouldReturnConfigurationWhenBlobStoreImplIsSupportedAndCaseInsensitive() {
+        PropertiesConfiguration configuration = new PropertiesConfiguration();
+        configuration.addProperty("implementation", "OBjecTStorAGE");
+
+        assertThat(
+            BlobStoreChoosingConfiguration.from(configuration)
+                .getImplementation()
+                .getName())
+            .isEqualTo(OBJECT_STORAGE);
+    }
+
+    @Test
+    void 
fromShouldReturnConfigurationWhenBlobStoreImplIsSupportedAndHasExtraSpaces() {
+        PropertiesConfiguration configuration = new PropertiesConfiguration();
+        configuration.addProperty("implementation", " cassandra ");
+
+        assertThat(
+            BlobStoreChoosingConfiguration.from(configuration)
+                .getImplementation()
+                .getName())
+            .isEqualTo(CASSANDRA);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/5015c7e5/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/modules/blobstore/BlobStoreChoosingModuleTest.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/modules/blobstore/BlobStoreChoosingModuleTest.java
 
b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/modules/blobstore/BlobStoreChoosingModuleTest.java
new file mode 100644
index 0000000..c881cf3
--- /dev/null
+++ 
b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/modules/blobstore/BlobStoreChoosingModuleTest.java
@@ -0,0 +1,136 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.modules.blobstore;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.mockito.Mockito.mock;
+
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.james.blob.cassandra.CassandraBlobsDAO;
+import org.apache.james.blob.objectstorage.ObjectStorageBlobsDAO;
+import 
org.apache.james.modules.blobstore.BlobStoreChoosingConfiguration.BlobStoreImplName;
+import org.apache.james.modules.mailbox.ConfigurationComponent;
+import org.apache.james.modules.objectstorage.FakePropertiesProvider;
+import org.junit.jupiter.api.Test;
+
+import com.google.inject.Provider;
+
+class BlobStoreChoosingModuleTest {
+
+    private static CassandraBlobsDAO CASSANDRA_BLOBSTORE = 
mock(CassandraBlobsDAO.class);
+    private static Provider<CassandraBlobsDAO> CASSANDRA_BLOBSTORE_PROVIDER = 
() -> CASSANDRA_BLOBSTORE;
+    private static ObjectStorageBlobsDAO SWIFT_BLOBSTORE = 
mock(ObjectStorageBlobsDAO.class);
+    private static Provider<ObjectStorageBlobsDAO> SWIFT_BLOBSTORE_PROVIDER = 
() -> SWIFT_BLOBSTORE;
+
+    @Test
+    void provideChoosingConfigurationShouldThrowWhenMissingPropertyField() {
+        BlobStoreChoosingModule module = new BlobStoreChoosingModule();
+        PropertiesConfiguration configuration = new PropertiesConfiguration();
+        configuration.addProperty("implementation", "");
+        FakePropertiesProvider propertyProvider = 
FakePropertiesProvider.builder()
+            .register(ConfigurationComponent.NAME, configuration)
+            .build();
+
+        assertThatThrownBy(() -> 
module.provideChoosingConfiguration(propertyProvider))
+            .isInstanceOf(IllegalStateException.class);
+    }
+
+    @Test
+    void provideChoosingConfigurationShouldThrowWhenEmptyPropertyField() 
throws Exception {
+        BlobStoreChoosingModule module = new BlobStoreChoosingModule();
+        PropertiesConfiguration configuration = new PropertiesConfiguration();
+        configuration.addProperty("implementation", "");
+        FakePropertiesProvider propertyProvider = 
FakePropertiesProvider.builder()
+            .register(ConfigurationComponent.NAME, configuration)
+            .build();
+
+        assertThatThrownBy(() -> 
module.provideChoosingConfiguration(propertyProvider))
+            .isInstanceOf(IllegalStateException.class);
+    }
+
+    @Test
+    void 
provideChoosingConfigurationShouldThrowWhenPropertyFieldIsNotInSupportedList() 
throws Exception {
+        BlobStoreChoosingModule module = new BlobStoreChoosingModule();
+        PropertiesConfiguration configuration = new PropertiesConfiguration();
+        configuration.addProperty("implementation", "gabouzomeuh");
+        FakePropertiesProvider propertyProvider = 
FakePropertiesProvider.builder()
+            .register(ConfigurationComponent.NAME, configuration)
+            .build();
+
+        assertThatThrownBy(() -> 
module.provideChoosingConfiguration(propertyProvider))
+            .isInstanceOf(IllegalArgumentException.class);
+    }
+
+    @Test
+    void provideChoosingConfigurationShouldReturnCassandraWhenNoFile() throws 
Exception {
+        BlobStoreChoosingModule module = new BlobStoreChoosingModule();
+        FakePropertiesProvider propertyProvider = 
FakePropertiesProvider.builder()
+            .register("other_configuration_file", new 
PropertiesConfiguration())
+            .build();
+
+        assertThat(module.provideChoosingConfiguration(propertyProvider))
+            .isEqualTo(BlobStoreChoosingConfiguration.cassandra());
+    }
+
+    @Test
+    void 
provideChoosingConfigurationShouldReturnSwiftFactoryWhenConfigurationImplIsSwift()
 throws Exception {
+        BlobStoreChoosingModule module = new BlobStoreChoosingModule();
+        PropertiesConfiguration configuration = new PropertiesConfiguration();
+        configuration.addProperty("implementation", 
BlobStoreImplName.OBJECTSTORAGE.getName());
+        FakePropertiesProvider propertyProvider = 
FakePropertiesProvider.builder()
+            .register(ConfigurationComponent.NAME, configuration)
+            .build();
+
+        assertThat(module.provideChoosingConfiguration(propertyProvider))
+            .isEqualTo(BlobStoreChoosingConfiguration.objectStorage());
+    }
+
+    @Test
+    void 
provideChoosingConfigurationShouldReturnCassandraFactoryWhenConfigurationImplIsCassandra()
 throws Exception {
+        BlobStoreChoosingModule module = new BlobStoreChoosingModule();
+        PropertiesConfiguration configuration = new PropertiesConfiguration();
+        configuration.addProperty("implementation", 
BlobStoreImplName.CASSANDRA.getName());
+        FakePropertiesProvider propertyProvider = 
FakePropertiesProvider.builder()
+            .register(ConfigurationComponent.NAME, configuration)
+            .build();
+
+        assertThat(module.provideChoosingConfiguration(propertyProvider))
+            .isEqualTo(BlobStoreChoosingConfiguration.cassandra());
+    }
+
+    @Test
+    void 
provideBlobStoreShouldReturnCassandraBlobStoreWhenCassandraConfigured() {
+        BlobStoreChoosingModule module = new BlobStoreChoosingModule();
+
+        
assertThat(module.provideBlobStore(BlobStoreChoosingConfiguration.cassandra(),
+            CASSANDRA_BLOBSTORE_PROVIDER, SWIFT_BLOBSTORE_PROVIDER))
+            .isEqualTo(CASSANDRA_BLOBSTORE);
+    }
+
+    @Test
+    void provideBlobStoreShouldReturnSwiftBlobStoreWhenSwiftConfigured() {
+        BlobStoreChoosingModule module = new BlobStoreChoosingModule();
+
+        
assertThat(module.provideBlobStore(BlobStoreChoosingConfiguration.cassandra(),
+            CASSANDRA_BLOBSTORE_PROVIDER, SWIFT_BLOBSTORE_PROVIDER))
+            .isEqualTo(CASSANDRA_BLOBSTORE);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/5015c7e5/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/modules/objectstore/BlobStoreChoosingConfigurationTest.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/modules/objectstore/BlobStoreChoosingConfigurationTest.java
 
b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/modules/objectstore/BlobStoreChoosingConfigurationTest.java
deleted file mode 100644
index a32fba8..0000000
--- 
a/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/modules/objectstore/BlobStoreChoosingConfigurationTest.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.modules.objectstore;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-import org.apache.commons.configuration.PropertiesConfiguration;
-import org.junit.jupiter.api.Test;
-
-class BlobStoreChoosingConfigurationTest {
-
-    private static final String SWIFT = "swift";
-    private static final String CASSANDRA = "cassandra";
-
-    @Test
-    void fromShouldThrowWhenBlobStoreImplIsMissing() {
-        PropertiesConfiguration configuration = new PropertiesConfiguration();
-
-        assertThatThrownBy(() -> 
BlobStoreChoosingConfiguration.from(configuration))
-            .isInstanceOf(IllegalStateException.class)
-            .hasMessage("objectstore.implementation property is missing please 
use one of supported values in: cassandra, swift");
-    }
-
-    @Test
-    void fromShouldThrowWhenBlobStoreImplIsNull() {
-        PropertiesConfiguration configuration = new PropertiesConfiguration();
-        configuration.addProperty("objectstore.implementation", null);
-
-        assertThatThrownBy(() -> 
BlobStoreChoosingConfiguration.from(configuration))
-            .isInstanceOf(IllegalStateException.class)
-            .hasMessage("objectstore.implementation property is missing please 
use one of supported values in: cassandra, swift");
-    }
-
-    @Test
-    void fromShouldThrowWhenBlobStoreImplIsEmpty() {
-        PropertiesConfiguration configuration = new PropertiesConfiguration();
-        configuration.addProperty("objectstore.implementation", "");
-
-        assertThatThrownBy(() -> 
BlobStoreChoosingConfiguration.from(configuration))
-            .isInstanceOf(IllegalStateException.class)
-            .hasMessage("objectstore.implementation property is missing please 
use one of supported values in: cassandra, swift");
-    }
-
-    @Test
-    void fromShouldThrowWhenBlobStoreImplIsNotInSupportedList() {
-        PropertiesConfiguration configuration = new PropertiesConfiguration();
-        configuration.addProperty("objectstore.implementation", 
"un_supported");
-
-        assertThatThrownBy(() -> 
BlobStoreChoosingConfiguration.from(configuration))
-            .isInstanceOf(IllegalArgumentException.class)
-            .hasMessage("un_supported is not a valid name of BlobStores, 
please use one of supported values in: cassandra, swift");
-    }
-
-    @Test
-    void fromShouldReturnConfigurationWhenBlobStoreImplIsCassandra() {
-        PropertiesConfiguration configuration = new PropertiesConfiguration();
-        configuration.addProperty("objectstore.implementation", CASSANDRA);
-
-        assertThat(
-            BlobStoreChoosingConfiguration.from(configuration)
-                .getImplementation()
-                .getName())
-            .isEqualTo(CASSANDRA);
-    }
-
-    @Test
-    void fromShouldReturnConfigurationWhenBlobStoreImplIsSwift() {
-        PropertiesConfiguration configuration = new PropertiesConfiguration();
-        configuration.addProperty("objectstore.implementation", SWIFT);
-
-        assertThat(
-            BlobStoreChoosingConfiguration.from(configuration)
-                .getImplementation()
-                .getName())
-            .isEqualTo(SWIFT);
-    }
-
-    @Test
-    void 
fromShouldReturnConfigurationWhenBlobStoreImplIsSupportedAndCaseInsensitive() {
-        PropertiesConfiguration configuration = new PropertiesConfiguration();
-        configuration.addProperty("objectstore.implementation", "SWifT");
-
-        assertThat(
-            BlobStoreChoosingConfiguration.from(configuration)
-                .getImplementation()
-                .getName())
-            .isEqualTo(SWIFT);
-    }
-
-    @Test
-    void 
fromShouldReturnConfigurationWhenBlobStoreImplIsSupportedAndHasExtraSpaces() {
-        PropertiesConfiguration configuration = new PropertiesConfiguration();
-        configuration.addProperty("objectstore.implementation", " cassandra ");
-
-        assertThat(
-            BlobStoreChoosingConfiguration.from(configuration)
-                .getImplementation()
-                .getName())
-            .isEqualTo(CASSANDRA);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/5015c7e5/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/modules/objectstore/BlobStoreChoosingModuleTest.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/modules/objectstore/BlobStoreChoosingModuleTest.java
 
b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/modules/objectstore/BlobStoreChoosingModuleTest.java
deleted file mode 100644
index 0fb619c..0000000
--- 
a/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/modules/objectstore/BlobStoreChoosingModuleTest.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.modules.objectstore;
-
-import static 
org.apache.james.modules.objectstore.BlobStoreChoosingModule.BLOBSTORE_CONFIGURATION_NAME;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.mockito.Mockito.mock;
-
-import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.james.blob.cassandra.CassandraBlobsDAO;
-import org.apache.james.blob.objectstorage.ObjectStorageBlobsDAO;
-import org.apache.james.modules.objectstorage.FakePropertiesProvider;
-import 
org.apache.james.modules.objectstore.BlobStoreChoosingConfiguration.BlobStoreImplName;
-import org.junit.jupiter.api.Test;
-
-import com.google.inject.Provider;
-
-class BlobStoreChoosingModuleTest {
-
-    private static CassandraBlobsDAO CASSANDRA_BLOBSTORE = 
mock(CassandraBlobsDAO.class);
-    private static Provider<CassandraBlobsDAO> CASSANDRA_BLOBSTORE_PROVIDER = 
() -> CASSANDRA_BLOBSTORE;
-    private static ObjectStorageBlobsDAO SWIFT_BLOBSTORE = 
mock(ObjectStorageBlobsDAO.class);
-    private static Provider<ObjectStorageBlobsDAO> SWIFT_BLOBSTORE_PROVIDER = 
() -> SWIFT_BLOBSTORE;
-
-    @Test
-    void provideBlobStoreFactoryShouldThrowWhenMissingPropertyField() throws 
Exception {
-        BlobStoreChoosingModule module = new BlobStoreChoosingModule();
-        PropertiesConfiguration configuration = new PropertiesConfiguration();
-        configuration.addProperty("objectstore.implementation", "");
-        FakePropertiesProvider propertyProvider = 
FakePropertiesProvider.builder()
-            .register(BLOBSTORE_CONFIGURATION_NAME, configuration)
-            .build();
-
-        assertThatThrownBy(() -> module.provideBlobStore(propertyProvider, 
CASSANDRA_BLOBSTORE_PROVIDER, SWIFT_BLOBSTORE_PROVIDER))
-            .isInstanceOf(IllegalStateException.class);
-    }
-
-    @Test
-    void provideBlobStoreFactoryShouldThrowWhenEmptyPropertyField() throws 
Exception {
-        BlobStoreChoosingModule module = new BlobStoreChoosingModule();
-        PropertiesConfiguration configuration = new PropertiesConfiguration();
-        configuration.addProperty("objectstore.implementation", "");
-        FakePropertiesProvider propertyProvider = 
FakePropertiesProvider.builder()
-            .register(BLOBSTORE_CONFIGURATION_NAME, configuration)
-            .build();
-
-        assertThatThrownBy(() -> module.provideBlobStore(propertyProvider, 
CASSANDRA_BLOBSTORE_PROVIDER, SWIFT_BLOBSTORE_PROVIDER))
-            .isInstanceOf(IllegalStateException.class);
-    }
-
-    @Test
-    void 
provideBlobStoreFactoryShouldThrowWhenPropertyFieldIsNotInSupportedList() 
throws Exception {
-        BlobStoreChoosingModule module = new BlobStoreChoosingModule();
-        PropertiesConfiguration configuration = new PropertiesConfiguration();
-        configuration.addProperty("objectstore.implementation", "gabouzomeuh");
-        FakePropertiesProvider propertyProvider = 
FakePropertiesProvider.builder()
-            .register(BLOBSTORE_CONFIGURATION_NAME, configuration)
-            .build();
-
-        assertThatThrownBy(() -> module.provideBlobStore(propertyProvider, 
CASSANDRA_BLOBSTORE_PROVIDER, SWIFT_BLOBSTORE_PROVIDER))
-            .isInstanceOf(IllegalArgumentException.class);
-    }
-
-    @Test
-    void provideBlobStoreFactoryShouldReturnCassandraWhenNoFile() throws 
Exception {
-        BlobStoreChoosingModule module = new BlobStoreChoosingModule();
-        FakePropertiesProvider propertyProvider = 
FakePropertiesProvider.builder()
-            .register("other_configuration_file", new 
PropertiesConfiguration())
-            .build();
-
-        assertThat(module.provideBlobStore(propertyProvider, 
CASSANDRA_BLOBSTORE_PROVIDER, SWIFT_BLOBSTORE_PROVIDER))
-            .isEqualTo(CASSANDRA_BLOBSTORE);
-    }
-
-    @Test
-    void 
provideBlobStoreFactoryShouldReturnSwiftFactoryWhenConfigurationImplIsSwift() 
throws Exception {
-        BlobStoreChoosingModule module = new BlobStoreChoosingModule();
-        PropertiesConfiguration configuration = new PropertiesConfiguration();
-        configuration.addProperty("objectstore.implementation", 
BlobStoreImplName.SWIFT.getName());
-        FakePropertiesProvider propertyProvider = 
FakePropertiesProvider.builder()
-            .register(BLOBSTORE_CONFIGURATION_NAME, configuration)
-            .build();
-
-        assertThat(module.provideBlobStore(propertyProvider, 
CASSANDRA_BLOBSTORE_PROVIDER, SWIFT_BLOBSTORE_PROVIDER))
-            .isEqualTo(SWIFT_BLOBSTORE);
-    }
-
-    @Test
-    void 
provideBlobStoreFactoryShouldReturnCassandraFactoryWhenConfigurationImplIsCassandra()
 throws Exception {
-        BlobStoreChoosingModule module = new BlobStoreChoosingModule();
-        PropertiesConfiguration configuration = new PropertiesConfiguration();
-        configuration.addProperty("objectstore.implementation", 
BlobStoreImplName.CASSANDRA.getName());
-        FakePropertiesProvider propertyProvider = 
FakePropertiesProvider.builder()
-            .register(BLOBSTORE_CONFIGURATION_NAME, configuration)
-            .build();
-
-        assertThat(module.provideBlobStore(propertyProvider, 
CASSANDRA_BLOBSTORE_PROVIDER, SWIFT_BLOBSTORE_PROVIDER))
-            .isEqualTo(CASSANDRA_BLOBSTORE);
-    }
-}
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to