JAMES-2525 implements Keystone v2 builders

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

Branch: refs/heads/master
Commit: 70a86f0b67eb4b3f6787e0129291917ee67dd50f
Parents: cc2cde1
Author: Jean Helou <j...@codamens.fr>
Authored: Fri Aug 31 15:15:49 2018 +0200
Committer: Benoit Tellier <btell...@linagora.com>
Committed: Fri Oct 5 18:11:43 2018 +0700

----------------------------------------------------------------------
 .../objectstorage/ObjectStorageBlobsDAO.java    |   5 +
 .../swift/SwiftKeystone2ObjectStorage.java      | 199 +++++++++++++++++++
 .../ObjectStorageBlobsDAOContract.java          |  31 ++-
 ...ystone2ObjectStorageBlobsDAOBuilderTest.java |  90 +++++++++
 ...Keystone2ObjectStorageConfigurationTest.java | 120 +++++++++++
 ...empAuthObjectStorageBlobsDAOBuilderTest.java |  19 +-
 ...tTempAuthObjectStorageConfigurationTest.java |   2 +
 7 files changed, 452 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/70a86f0b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAO.java
----------------------------------------------------------------------
diff --git 
a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAO.java
 
b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAO.java
index 6501978..478bb67 100644
--- 
a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAO.java
+++ 
b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAO.java
@@ -28,6 +28,7 @@ import org.apache.commons.io.IOUtils;
 import org.apache.james.blob.api.BlobId;
 import org.apache.james.blob.api.BlobStore;
 import org.apache.james.blob.api.ObjectStoreException;
+import org.apache.james.blob.objectstorage.swift.SwiftKeystone2ObjectStorage;
 import org.apache.james.blob.objectstorage.swift.SwiftTempAuthObjectStorage;
 import org.jclouds.blobstore.domain.Blob;
 import org.jclouds.blobstore.options.CopyOptions;
@@ -57,6 +58,10 @@ public class ObjectStorageBlobsDAO implements BlobStore {
         return SwiftTempAuthObjectStorage.daoBuilder(testConfig);
     }
 
+    public static ObjectStorageBlobsDAOBuilder 
builder(SwiftKeystone2ObjectStorage.Configuration testConfig) {
+        return SwiftKeystone2ObjectStorage.daoBuilder(testConfig);
+    }
+
     @Override
     public CompletableFuture<BlobId> save(byte[] data) {
         return save(new ByteArrayInputStream(data));

http://git-wip-us.apache.org/repos/asf/james-project/blob/70a86f0b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone2ObjectStorage.java
----------------------------------------------------------------------
diff --git 
a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone2ObjectStorage.java
 
b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone2ObjectStorage.java
new file mode 100644
index 0000000..1d26c9c
--- /dev/null
+++ 
b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone2ObjectStorage.java
@@ -0,0 +1,199 @@
+/****************************************************************
+ * 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.blob.objectstorage.swift;
+
+import java.net.URI;
+import java.util.Optional;
+import java.util.Properties;
+import java.util.function.Supplier;
+
+import org.apache.james.blob.objectstorage.ObjectStorageBlobsDAOBuilder;
+import org.jclouds.ContextBuilder;
+import org.jclouds.blobstore.BlobStore;
+import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
+import org.jclouds.openstack.keystone.config.KeystoneProperties;
+import org.jclouds.openstack.swift.v1.blobstore.RegionScopedBlobStoreContext;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Module;
+
+public class SwiftKeystone2ObjectStorage {
+    private static final Iterable<Module> JCLOUDS_MODULES =
+        ImmutableSet.of(new SLF4JLoggingModule());
+
+    public static ObjectStorageBlobsDAOBuilder daoBuilder(Configuration 
testConfig) {
+        return new ObjectStorageBlobsDAOBuilder(new 
BlobStoreBuilder(testConfig));
+    }
+
+    public static Configuration.Builder configBuilder() {
+        return new Configuration.Builder();
+    }
+
+    public static class BlobStoreBuilder implements Supplier<BlobStore> {
+        private final Configuration testConfig;
+
+        private BlobStoreBuilder(Configuration testConfig) {
+            this.testConfig = testConfig;
+        }
+
+        @Override
+        public BlobStore get() {
+            RegionScopedBlobStoreContext blobStoreContext = contextBuilder()
+                .endpoint(testConfig.getEndpoint().toString())
+                .credentials(testConfig.getIdentity().asString(), 
testConfig.getCredentials().value())
+                .overrides(testConfig.getOverrides())
+                .modules(JCLOUDS_MODULES)
+                .buildView(RegionScopedBlobStoreContext.class);
+
+            return testConfig.getRegion()
+                .map(Region::value)
+                .map(blobStoreContext::getBlobStore)
+                .orElseGet(blobStoreContext::getBlobStore);
+        }
+
+        private ContextBuilder contextBuilder() {
+            return ContextBuilder.newBuilder("openstack-swift");
+        }
+    }
+
+    public static final class Configuration {
+        public static class Builder {
+            private URI endpoint;
+            private UserName userName;
+            private TenantName tenantName;
+            private Credentials credentials;
+            private Optional<Region> region;
+
+            private Builder() {
+                region = Optional.empty();
+            }
+
+            public Builder endpoint(URI endpoint) {
+                this.endpoint = endpoint;
+                return this;
+            }
+
+            public Builder identity(Identity identity) {
+                this.tenantName = identity.getTenant();
+                this.userName = identity.getUserName();
+                return this;
+            }
+
+            public Builder tenantName(TenantName tenantName) {
+                this.tenantName = tenantName;
+                return this;
+            }
+
+            public Builder userName(UserName username) {
+                this.userName = username;
+                return this;
+            }
+
+            public Builder credentials(Credentials credentials) {
+                this.credentials = credentials;
+                return this;
+            }
+
+            public Builder region(Region region) {
+                this.region = Optional.of(region);
+                return this;
+            }
+
+            public Configuration build() {
+                Preconditions.checkState(endpoint != null);
+                Preconditions.checkState(tenantName != null);
+                Preconditions.checkState(userName != null);
+                Preconditions.checkState(credentials != null);
+                Identity identity = Identity.of(tenantName, userName);
+                return new Configuration(endpoint, identity, credentials, 
region);
+            }
+        }
+
+        private final URI endpoint;
+        private final Identity identity;
+        private final Optional<Region> region;
+        private final Credentials credentials;
+
+        private Configuration(URI endpoint,
+                              Identity identity,
+                              Credentials credentials,
+                              Optional<Region> region) {
+            this.endpoint = endpoint;
+            this.identity = identity;
+            this.region = region;
+            this.credentials = credentials;
+        }
+
+        public URI getEndpoint() {
+            return endpoint;
+        }
+
+        public Identity getIdentity() {
+            return identity;
+        }
+
+        public Credentials getCredentials() {
+            return credentials;
+        }
+
+        public Properties getOverrides() {
+            Properties properties = new Properties();
+            properties.setProperty(KeystoneProperties.KEYSTONE_VERSION, "2");
+            return properties;
+        }
+
+        public Optional<Region> getRegion() {
+            return region;
+        }
+
+        @Override
+        public boolean equals(Object o) {
+            if (this == o) {
+                return true;
+            }
+            if (o == null || getClass() != o.getClass()) {
+                return false;
+            }
+            Configuration that = (Configuration) o;
+            return Objects.equal(endpoint, that.endpoint) &&
+                Objects.equal(identity, that.identity) &&
+                Objects.equal(region, that.region) &&
+                Objects.equal(credentials, that.credentials);
+        }
+
+        @Override
+        public int hashCode() {
+            return Objects.hashCode(endpoint, identity, region, credentials);
+        }
+
+        @Override
+        public String toString() {
+            return MoreObjects.toStringHelper(this)
+                .add("endpoint", endpoint)
+                .add("identity", identity)
+                .add("region", region)
+                .add("credentials", credentials)
+                .toString();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/70a86f0b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOContract.java
----------------------------------------------------------------------
diff --git 
a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOContract.java
 
b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOContract.java
index 9b9d86d..07da03b 100644
--- 
a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOContract.java
+++ 
b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOContract.java
@@ -19,10 +19,37 @@
 
 package org.apache.james.blob.objectstorage;
 
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.james.blob.api.BlobId;
 import org.jclouds.blobstore.BlobStore;
+import org.jclouds.domain.Location;
+import org.junit.jupiter.api.Test;
 
 public interface ObjectStorageBlobsDAOContract {
-    default BlobStore buildBlobStore(ObjectStorageBlobsDAOBuilder 
objectStorageBlobsDAOBuilder){
-        return objectStorageBlobsDAOBuilder.getSupplier().get();
+
+    ObjectStorageBlobsDAOBuilder builder();
+
+    Location DEFAULT_LOCATION = null;
+
+    ContainerName containerName();
+
+    @Test
+    default void builtBlobsDAOCanStoreAndRetrieve() throws Exception {
+        ObjectStorageBlobsDAOBuilder builder = builder();
+
+        BlobStore blobStore = builder.getSupplier().get();
+        blobStore.createContainerInLocation(DEFAULT_LOCATION, 
containerName().value());
+        ObjectStorageBlobsDAO dao = builder.build();
+        byte[] bytes = "content".getBytes(StandardCharsets.UTF_8);
+        CompletableFuture<BlobId> save = dao.save(bytes);
+        InputStream inputStream = save.thenApply(dao::read).get(10, 
TimeUnit.SECONDS);
+        assertThat(inputStream).hasSameContentAs(new 
ByteArrayInputStream(bytes));
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/70a86f0b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone2ObjectStorageBlobsDAOBuilderTest.java
----------------------------------------------------------------------
diff --git 
a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone2ObjectStorageBlobsDAOBuilderTest.java
 
b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone2ObjectStorageBlobsDAOBuilderTest.java
new file mode 100644
index 0000000..8821d31
--- /dev/null
+++ 
b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone2ObjectStorageBlobsDAOBuilderTest.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.blob.objectstorage.swift;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.net.URI;
+import java.util.UUID;
+
+import org.apache.james.blob.api.HashBlobId;
+import org.apache.james.blob.objectstorage.ContainerName;
+import org.apache.james.blob.objectstorage.DockerSwift;
+import org.apache.james.blob.objectstorage.DockerSwiftExtension;
+import org.apache.james.blob.objectstorage.ObjectStorageBlobsDAO;
+import org.apache.james.blob.objectstorage.ObjectStorageBlobsDAOBuilder;
+import org.apache.james.blob.objectstorage.ObjectStorageBlobsDAOContract;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+@ExtendWith(DockerSwiftExtension.class)
+class SwiftKeystone2ObjectStorageBlobsDAOBuilderTest implements 
ObjectStorageBlobsDAOContract {
+
+    private static final TenantName TENANT_NAME = TenantName.of("test");
+    private static final UserName USER_NAME = UserName.of("demo");
+    private static final Credentials PASSWORD = Credentials.of("demo");
+    private static final Identity SWIFT_IDENTITY = Identity.of(TENANT_NAME, 
USER_NAME);
+    private ContainerName containerName;
+    private URI endpoint;
+    private SwiftKeystone2ObjectStorage.Configuration testConfig;
+
+    @BeforeEach
+    void setUp(DockerSwift dockerSwift) throws Exception {
+        containerName = ContainerName.of(UUID.randomUUID().toString());
+        endpoint = dockerSwift.keystoneV2Endpoint();
+        testConfig = SwiftKeystone2ObjectStorage.configBuilder()
+            .endpoint(endpoint)
+            .identity(SWIFT_IDENTITY)
+            .credentials(PASSWORD)
+            .build();
+    }
+
+    @Override
+    public ObjectStorageBlobsDAOBuilder builder() {
+        return ObjectStorageBlobsDAO
+            .builder(testConfig)
+            .container(containerName)
+            .blobIdFactory(new HashBlobId.Factory());
+    }
+
+    @Override
+    public ContainerName containerName() {
+        return containerName;
+    }
+
+    @Test
+    void containerNameIsMandatoryToBuildBlobsDAO() throws Exception {
+        ObjectStorageBlobsDAOBuilder builder = ObjectStorageBlobsDAO
+            .builder(testConfig)
+            .blobIdFactory(new HashBlobId.Factory());
+
+        
assertThatThrownBy(builder::build).isInstanceOf(IllegalStateException.class);
+    }
+
+    @Test
+    void blobIdFactoryIsMandatoryToBuildBlobsDAO() throws Exception {
+        ObjectStorageBlobsDAOBuilder builder = ObjectStorageBlobsDAO
+            .builder(testConfig)
+            .container(containerName);
+
+        
assertThatThrownBy(builder::build).isInstanceOf(IllegalStateException.class);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/70a86f0b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone2ObjectStorageConfigurationTest.java
----------------------------------------------------------------------
diff --git 
a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone2ObjectStorageConfigurationTest.java
 
b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone2ObjectStorageConfigurationTest.java
new file mode 100644
index 0000000..12cdb5b
--- /dev/null
+++ 
b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone2ObjectStorageConfigurationTest.java
@@ -0,0 +1,120 @@
+/****************************************************************
+ * 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.blob.objectstorage.swift;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.net.URI;
+
+import org.jclouds.openstack.keystone.config.KeystoneProperties;
+import org.junit.jupiter.api.Test;
+
+import nl.jqno.equalsverifier.EqualsVerifier;
+
+class SwiftKeystone2ObjectStorageConfigurationTest {
+
+    private static final TenantName TENANT_NAME = TenantName.of("fake");
+    private static final UserName USER_NAME = UserName.of("fake");
+    private static URI ENDPOINT = URI.create("http://example.com";);
+    private static Credentials CREDENTIALS = Credentials.of("fake");
+    private static Identity SWIFT_IDENTITY = 
Identity.of(TenantName.of("fake"), UserName.of("fake"));
+
+    @Test
+    void enpointIsMandatoryToBuildConfiguration() throws Exception {
+        SwiftKeystone2ObjectStorage.Configuration.Builder builder =
+            SwiftKeystone2ObjectStorage.configBuilder()
+            .tenantName(TENANT_NAME)
+            .userName(USER_NAME)
+            .credentials(CREDENTIALS);
+
+        
assertThatThrownBy(builder::build).isInstanceOf(IllegalStateException.class);
+    }
+
+    @Test
+    void tenantNameIsMandatoryToBuildConfiguration() throws Exception {
+        SwiftKeystone2ObjectStorage.Configuration.Builder builder =
+            SwiftKeystone2ObjectStorage.configBuilder()
+            .endpoint(ENDPOINT)
+            .userName(USER_NAME)
+            .credentials(CREDENTIALS);
+
+        
assertThatThrownBy(builder::build).isInstanceOf(IllegalStateException.class);
+    }
+
+    @Test
+    void userNameIsMandatoryToBuildConfiguration() throws Exception {
+        SwiftKeystone2ObjectStorage.Configuration.Builder builder =
+            SwiftKeystone2ObjectStorage.configBuilder()
+            .endpoint(ENDPOINT)
+            .tenantName(TENANT_NAME)
+            .credentials(CREDENTIALS);
+
+        
assertThatThrownBy(builder::build).isInstanceOf(IllegalStateException.class);
+    }
+
+    @Test
+    void credentialsIsMandatoryToBuildConfiguration() throws Exception {
+        SwiftKeystone2ObjectStorage.Configuration.Builder builder =
+            SwiftKeystone2ObjectStorage.configBuilder()
+            .endpoint(ENDPOINT)
+            .tenantName(TENANT_NAME)
+            .userName(USER_NAME);
+
+        
assertThatThrownBy(builder::build).isInstanceOf(IllegalStateException.class);
+    }
+
+    @Test
+    void configurationIsBuiltWhenAllMandatoryParamsAreProvided() throws 
Exception {
+        SwiftKeystone2ObjectStorage.Configuration.Builder builder =
+            SwiftKeystone2ObjectStorage.configBuilder()
+            .endpoint(ENDPOINT)
+            .tenantName(TENANT_NAME)
+            .userName(USER_NAME)
+            .credentials(CREDENTIALS);
+
+        SwiftKeystone2ObjectStorage.Configuration build = builder.build();
+
+        assertThat(build.getEndpoint()).isEqualTo(ENDPOINT);
+        assertThat(build.getIdentity()).isEqualTo(SWIFT_IDENTITY);
+        assertThat(build.getCredentials()).isEqualTo(CREDENTIALS);
+        
assertThat(build.getOverrides().getProperty(KeystoneProperties.KEYSTONE_VERSION)).isEqualTo("2");
+    }
+
+    @Test
+    void identityCanReplaceTenantAndUserName() throws Exception {
+        SwiftKeystone2ObjectStorage.Configuration.Builder builder =
+            SwiftKeystone2ObjectStorage.configBuilder()
+            .endpoint(ENDPOINT)
+            .identity(SWIFT_IDENTITY)
+            .credentials(CREDENTIALS);
+
+        SwiftKeystone2ObjectStorage.Configuration build = builder.build();
+
+        assertThat(build.getEndpoint()).isEqualTo(ENDPOINT);
+        assertThat(build.getIdentity()).isEqualTo(SWIFT_IDENTITY);
+        assertThat(build.getCredentials()).isEqualTo(CREDENTIALS);
+    }
+
+    @Test
+    void configurationShouldEnforceBeanContract() {
+        
EqualsVerifier.forClass(SwiftKeystone2ObjectStorage.Configuration.class);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/70a86f0b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/swift/SwiftTempAuthObjectStorageBlobsDAOBuilderTest.java
----------------------------------------------------------------------
diff --git 
a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/swift/SwiftTempAuthObjectStorageBlobsDAOBuilderTest.java
 
b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/swift/SwiftTempAuthObjectStorageBlobsDAOBuilderTest.java
index 6ebdae4..c44c1ad 100644
--- 
a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/swift/SwiftTempAuthObjectStorageBlobsDAOBuilderTest.java
+++ 
b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/swift/SwiftTempAuthObjectStorageBlobsDAOBuilderTest.java
@@ -38,7 +38,6 @@ import 
org.apache.james.blob.objectstorage.DockerSwiftExtension;
 import org.apache.james.blob.objectstorage.ObjectStorageBlobsDAO;
 import org.apache.james.blob.objectstorage.ObjectStorageBlobsDAOBuilder;
 import org.apache.james.blob.objectstorage.ObjectStorageBlobsDAOContract;
-import org.jclouds.blobstore.BlobStore;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
@@ -85,20 +84,16 @@ class SwiftTempAuthObjectStorageBlobsDAOBuilderTest 
implements ObjectStorageBlob
         
assertThatThrownBy(builder::build).isInstanceOf(IllegalStateException.class);
     }
 
-    @Test
-    void builtBlobsDAOCanStoreAndRetrieve() throws Exception {
-        ObjectStorageBlobsDAOBuilder builder = ObjectStorageBlobsDAO
+    @Override
+    public ObjectStorageBlobsDAOBuilder builder() {
+        return ObjectStorageBlobsDAO
             .builder(testConfig)
             .container(containerName)
             .blobIdFactory(new HashBlobId.Factory());
-
-        BlobStore blobStore = buildBlobStore(builder);
-        blobStore.createContainerInLocation(null, containerName.value());
-        ObjectStorageBlobsDAO dao = builder.build();
-        byte[] bytes = "content".getBytes(StandardCharsets.UTF_8);
-        CompletableFuture<BlobId> save = dao.save(bytes);
-        InputStream inputStream = save.thenApply(dao::read).get(10, 
TimeUnit.SECONDS);
-        assertThat(inputStream).hasSameContentAs(new 
ByteArrayInputStream(bytes));
     }
 
+    @Override
+    public ContainerName containerName() {
+        return containerName;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/70a86f0b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/swift/SwiftTempAuthObjectStorageConfigurationTest.java
----------------------------------------------------------------------
diff --git 
a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/swift/SwiftTempAuthObjectStorageConfigurationTest.java
 
b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/swift/SwiftTempAuthObjectStorageConfigurationTest.java
index 75a3824..850db15 100644
--- 
a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/swift/SwiftTempAuthObjectStorageConfigurationTest.java
+++ 
b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/swift/SwiftTempAuthObjectStorageConfigurationTest.java
@@ -24,6 +24,7 @@ import static 
org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import java.net.URI;
 
+import org.jclouds.openstack.keystone.config.KeystoneProperties;
 import org.junit.jupiter.api.Test;
 
 import nl.jqno.equalsverifier.EqualsVerifier;
@@ -95,6 +96,7 @@ class SwiftTempAuthObjectStorageConfigurationTest {
         assertThat(build.getEndpoint()).isEqualTo(ENDPOINT);
         assertThat(build.getIdentity()).isEqualTo(SWIFT_IDENTITY);
         assertThat(build.getCredentials()).isEqualTo(CREDENTIALS);
+        
assertThat(build.getOverrides().getProperty(KeystoneProperties.CREDENTIAL_TYPE)).isEqualTo("tempAuthCredentials");
     }
 
     @Test


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to