You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ro...@apache.org on 2019/05/13 12:38:11 UTC
[james-project] 02/07: JAMES-2725 Split object storage tests per
implementation
This is an automated email from the ASF dual-hosted git repository.
rouazana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 9473aac521f91aabd86ce31754f48bac8c1f5670
Author: Antoine Duprat <ad...@linagora.com>
AuthorDate: Tue Apr 16 11:03:29 2019 +0200
JAMES-2725 Split object storage tests per implementation
---
.../james/CassandraRabbitMQJamesServerFixture.java | 43 +++++
.../james/CassandraRabbitMQJamesServerTest.java | 184 ---------------------
.../apache/james/MailsShouldBeWellReceived.java | 67 ++++++++
.../org/apache/james/WithCassandraBlobStore.java | 68 ++++++++
.../apache/james/WithCassandraBlobStoreTest.java | 26 +++
.../apache/james/WithDefaultAwsS3Extension.java | 71 ++++++++
.../org/apache/james/WithDefaultAwsS3Test.java | 41 +++++
.../apache/james/WithDefaultSwiftExtension.java | 71 ++++++++
.../org/apache/james/WithDefaultSwiftTest.java | 41 +++++
.../apache/james/WithEncryptedAwsS3Extension.java | 72 ++++++++
.../org/apache/james/WithEncryptedAwsS3Test.java | 41 +++++
.../apache/james/WithEncryptedSwiftExtension.java | 72 ++++++++
.../org/apache/james/WithEncryptedSwiftTest.java | 42 +++++
.../org/apache/james/JamesServerExtension.java | 5 +
14 files changed, 660 insertions(+), 184 deletions(-)
diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/CassandraRabbitMQJamesServerFixture.java b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/CassandraRabbitMQJamesServerFixture.java
new file mode 100644
index 0000000..bc5836c
--- /dev/null
+++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/CassandraRabbitMQJamesServerFixture.java
@@ -0,0 +1,43 @@
+/*
+ * 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;
+
+import org.apache.james.modules.RabbitMQExtension;
+import org.apache.james.modules.TestJMAPServerModule;
+
+public class CassandraRabbitMQJamesServerFixture {
+
+ private static final int LIMIT_TO_10_MESSAGES = 10;
+
+ private static final JamesServerBuilder.ServerProvider CONFIGURATION_BUILDER =
+ configuration -> GuiceJamesServer
+ .forConfiguration(configuration)
+ .combineWith(CassandraRabbitMQJamesServerMain.MODULES)
+ .overrideWith(new TestJMAPServerModule(LIMIT_TO_10_MESSAGES))
+ .overrideWith(JmapJamesServerContract.DOMAIN_LIST_CONFIGURATION_MODULE);
+
+ public static JamesServerBuilder baseExtensionBuilder() {
+ return new JamesServerBuilder()
+ .extension(new DockerElasticSearchExtension())
+ .extension(new CassandraExtension())
+ .extension(new RabbitMQExtension())
+ .server(CONFIGURATION_BUILDER);
+ }
+}
diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/CassandraRabbitMQJamesServerTest.java b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/CassandraRabbitMQJamesServerTest.java
deleted file mode 100644
index 631c93a..0000000
--- a/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/CassandraRabbitMQJamesServerTest.java
+++ /dev/null
@@ -1,184 +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;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.awaitility.Duration.ONE_HUNDRED_MILLISECONDS;
-import static org.junit.jupiter.api.TestInstance.Lifecycle;
-
-import org.apache.james.blob.objectstorage.AESPayloadCodec;
-import org.apache.james.blob.objectstorage.DefaultPayloadCodec;
-import org.apache.james.blob.objectstorage.PayloadCodec;
-import org.apache.james.core.Domain;
-import org.apache.james.modules.AwsS3BlobStoreExtension;
-import org.apache.james.modules.RabbitMQExtension;
-import org.apache.james.modules.SwiftBlobStoreExtension;
-import org.apache.james.modules.TestJMAPServerModule;
-import org.apache.james.modules.objectstorage.PayloadCodecFactory;
-import org.apache.james.modules.objectstorage.aws.s3.DockerAwsS3TestRule;
-import org.apache.james.modules.objectstorage.swift.DockerSwiftTestRule;
-import org.apache.james.modules.protocols.ImapGuiceProbe;
-import org.apache.james.modules.protocols.SmtpGuiceProbe;
-import org.apache.james.utils.DataProbeImpl;
-import org.apache.james.utils.IMAPMessageReader;
-import org.apache.james.utils.SMTPMessageSender;
-import org.apache.james.utils.SpoolerProbe;
-import org.awaitility.Awaitility;
-import org.awaitility.core.ConditionFactory;
-import org.junit.jupiter.api.Nested;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.TestInstance;
-import org.junit.jupiter.api.extension.RegisterExtension;
-
-class CassandraRabbitMQJamesServerTest {
-
- interface MailsShouldBeWellReceived {
- String JAMES_SERVER_HOST = "127.0.0.1";
-
- @Test
- default void mailsShouldBeWellReceived(GuiceJamesServer server) throws Exception {
- server.getProbe(DataProbeImpl.class).fluent()
- .addDomain(DOMAIN)
- .addUser(JAMES_USER, PASSWORD);
-
- try (SMTPMessageSender sender = new SMTPMessageSender(Domain.LOCALHOST.asString())) {
- sender.connect(JAMES_SERVER_HOST, server.getProbe(SmtpGuiceProbe.class).getSmtpPort())
- .sendMessage("bob@any.com", JAMES_USER);
- }
-
- CALMLY_AWAIT.until(() -> server.getProbe(SpoolerProbe.class).processingFinished());
-
- try (IMAPMessageReader reader = new IMAPMessageReader()) {
- reader.connect(JAMES_SERVER_HOST, server.getProbe(ImapGuiceProbe.class).getImapPort())
- .login(JAMES_USER, PASSWORD)
- .select(IMAPMessageReader.INBOX)
- .awaitMessage(CALMLY_AWAIT);
- }
- }
- }
-
- interface ContractSuite extends JmapJamesServerContract, MailsShouldBeWellReceived, JamesServerContract {}
-
- private static final String DOMAIN = "domain";
- private static final String JAMES_USER = "james-user@" + DOMAIN;
- private static final String PASSWORD = "secret";
- private static final int LIMIT_TO_10_MESSAGES = 10;
-
- private static final ConditionFactory CALMLY_AWAIT = Awaitility
- .with().pollInterval(ONE_HUNDRED_MILLISECONDS)
- .and().pollDelay(ONE_HUNDRED_MILLISECONDS)
- .await();
-
- private static final JamesServerBuilder.ServerProvider CONFIGURATION_BUILDER =
- configuration -> GuiceJamesServer
- .forConfiguration(configuration)
- .combineWith(CassandraRabbitMQJamesServerMain.MODULES)
- .overrideWith(new TestJMAPServerModule(LIMIT_TO_10_MESSAGES))
- .overrideWith(JmapJamesServerContract.DOMAIN_LIST_CONFIGURATION_MODULE);
-
- @Nested
- @TestInstance(Lifecycle.PER_CLASS)
- class WithEncryptedSwift implements ContractSuite {
- @RegisterExtension
- JamesServerExtension testExtension = baseExtensionBuilder()
- .extension(new SwiftBlobStoreExtension(PayloadCodecFactory.AES256))
- .server(CONFIGURATION_BUILDER)
- .build();
-
- @Test
- void encryptedPayloadShouldBeConfiguredWhenProvidingEncryptedPayloadConfiguration(GuiceJamesServer jamesServer) {
- PayloadCodec payloadCodec = jamesServer.getProbe(DockerSwiftTestRule.TestSwiftBlobStoreProbe.class)
- .getSwiftPayloadCodec();
-
- assertThat(payloadCodec)
- .isInstanceOf(AESPayloadCodec.class);
- }
- }
-
- @Nested
- @TestInstance(Lifecycle.PER_CLASS)
- class WithDefaultSwift implements ContractSuite {
- @RegisterExtension
- JamesServerExtension testExtension = baseExtensionBuilder()
- .extension(new SwiftBlobStoreExtension())
- .build();
-
- @Test
- void defaultPayloadShouldBeByDefault(GuiceJamesServer jamesServer) {
- PayloadCodec payloadCodec = jamesServer.getProbe(DockerSwiftTestRule.TestSwiftBlobStoreProbe.class)
- .getSwiftPayloadCodec();
-
- assertThat(payloadCodec)
- .isInstanceOf(DefaultPayloadCodec.class);
- }
- }
-
- @Nested
- @TestInstance(Lifecycle.PER_CLASS)
- class WithoutSwiftOrAwsS3 implements ContractSuite {
- @RegisterExtension
- JamesServerExtension testExtension = baseExtensionBuilder().build();
- }
-
- @Nested
- @TestInstance(Lifecycle.PER_CLASS)
- class WithEncryptedAwsS3 implements ContractSuite {
- @RegisterExtension
- JamesServerExtension testExtension = baseExtensionBuilder()
- .extension(new AwsS3BlobStoreExtension(PayloadCodecFactory.AES256))
- .server(CONFIGURATION_BUILDER)
- .build();
-
- @Test
- void encryptedPayloadShouldBeConfiguredWhenProvidingEncryptedPayloadConfiguration(GuiceJamesServer jamesServer) {
- PayloadCodec payloadCodec = jamesServer.getProbe(DockerAwsS3TestRule.TestAwsS3BlobStoreProbe.class)
- .getAwsS3PayloadCodec();
-
- assertThat(payloadCodec)
- .isInstanceOf(AESPayloadCodec.class);
- }
- }
-
- @Nested
- @TestInstance(Lifecycle.PER_CLASS)
- class WithDefaultAwsS3 implements ContractSuite {
- @RegisterExtension
- JamesServerExtension testExtension = baseExtensionBuilder()
- .extension(new AwsS3BlobStoreExtension())
- .build();
-
- @Test
- void defaultPayloadShouldBeByDefault(GuiceJamesServer jamesServer) {
- PayloadCodec payloadCodec = jamesServer.getProbe(DockerAwsS3TestRule.TestAwsS3BlobStoreProbe.class)
- .getAwsS3PayloadCodec();
-
- assertThat(payloadCodec)
- .isInstanceOf(DefaultPayloadCodec.class);
- }
- }
-
- private static JamesServerBuilder baseExtensionBuilder() {
- return new JamesServerBuilder()
- .extension(new DockerElasticSearchExtension())
- .extension(new CassandraExtension())
- .extension(new RabbitMQExtension())
- .server(CONFIGURATION_BUILDER);
- }
-}
diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/MailsShouldBeWellReceived.java b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/MailsShouldBeWellReceived.java
new file mode 100644
index 0000000..16d3f54
--- /dev/null
+++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/MailsShouldBeWellReceived.java
@@ -0,0 +1,67 @@
+/*
+ * 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;
+
+import static org.awaitility.Duration.ONE_HUNDRED_MILLISECONDS;
+
+import org.apache.james.core.Domain;
+import org.apache.james.modules.protocols.ImapGuiceProbe;
+import org.apache.james.modules.protocols.SmtpGuiceProbe;
+import org.apache.james.utils.DataProbeImpl;
+import org.apache.james.utils.IMAPMessageReader;
+import org.apache.james.utils.SMTPMessageSender;
+import org.apache.james.utils.SpoolerProbe;
+import org.awaitility.Awaitility;
+import org.awaitility.core.ConditionFactory;
+import org.junit.jupiter.api.Test;
+
+interface MailsShouldBeWellReceived {
+
+ String JAMES_SERVER_HOST = "127.0.0.1";
+ String DOMAIN = "domain";
+ String JAMES_USER = "james-user@" + DOMAIN;
+ String PASSWORD = "secret";
+ ConditionFactory CALMLY_AWAIT = Awaitility
+ .with().pollInterval(ONE_HUNDRED_MILLISECONDS)
+ .and().pollDelay(ONE_HUNDRED_MILLISECONDS)
+ .await();
+
+
+ @Test
+ default void mailsShouldBeWellReceived(GuiceJamesServer server) throws Exception {
+ server.getProbe(DataProbeImpl.class).fluent()
+ .addDomain(DOMAIN)
+ .addUser(JAMES_USER, PASSWORD);
+
+ try (SMTPMessageSender sender = new SMTPMessageSender(Domain.LOCALHOST.asString())) {
+ sender.connect(JAMES_SERVER_HOST, server.getProbe(SmtpGuiceProbe.class).getSmtpPort())
+ .sendMessage("bob@any.com", JAMES_USER);
+ }
+
+ CALMLY_AWAIT.until(() -> server.getProbe(SpoolerProbe.class).processingFinished());
+
+ try (IMAPMessageReader reader = new IMAPMessageReader()) {
+ reader.connect(JAMES_SERVER_HOST, server.getProbe(ImapGuiceProbe.class).getImapPort())
+ .login(JAMES_USER, PASSWORD)
+ .select(IMAPMessageReader.INBOX)
+ .awaitMessage(CALMLY_AWAIT);
+ }
+ }
+}
diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/WithCassandraBlobStore.java b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/WithCassandraBlobStore.java
new file mode 100644
index 0000000..808c47e
--- /dev/null
+++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/WithCassandraBlobStore.java
@@ -0,0 +1,68 @@
+/*
+ * 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;
+
+import org.junit.jupiter.api.extension.AfterAllCallback;
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.BeforeAllCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.extension.ParameterContext;
+import org.junit.jupiter.api.extension.ParameterResolutionException;
+import org.junit.jupiter.api.extension.ParameterResolver;
+
+public class WithCassandraBlobStore implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback, ParameterResolver {
+
+ private final JamesServerExtension jamesServerExtension;
+
+ WithCassandraBlobStore() {
+ jamesServerExtension = CassandraRabbitMQJamesServerFixture.baseExtensionBuilder().build();
+ }
+
+ @Override
+ public void beforeAll(ExtensionContext context) throws Exception {
+ jamesServerExtension.beforeAll(context);
+ }
+
+ @Override
+ public void afterAll(ExtensionContext context) throws Exception {
+ jamesServerExtension.afterAll(context);
+ }
+
+ @Override
+ public void beforeEach(ExtensionContext context) throws Exception {
+ jamesServerExtension.beforeEach(context);
+ }
+
+ @Override
+ public void afterEach(ExtensionContext context) throws Exception {
+ jamesServerExtension.afterEach(context);
+ }
+
+ @Override
+ public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
+ return (parameterContext.getParameter().getType() == GuiceJamesServer.class);
+ }
+
+ @Override
+ public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
+ return jamesServerExtension.getGuiceJamesServer();
+ }
+}
diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/WithCassandraBlobStoreTest.java b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/WithCassandraBlobStoreTest.java
new file mode 100644
index 0000000..135d2ae
--- /dev/null
+++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/WithCassandraBlobStoreTest.java
@@ -0,0 +1,26 @@
+/*
+ * 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;
+
+import org.junit.jupiter.api.extension.ExtendWith;
+
+@ExtendWith(WithCassandraBlobStore.class)
+public class WithCassandraBlobStoreTest implements JmapJamesServerContract, MailsShouldBeWellReceived, JamesServerContract {
+}
diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/WithDefaultAwsS3Extension.java b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/WithDefaultAwsS3Extension.java
new file mode 100644
index 0000000..03a035e
--- /dev/null
+++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/WithDefaultAwsS3Extension.java
@@ -0,0 +1,71 @@
+/*
+ * 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;
+
+import org.apache.james.modules.AwsS3BlobStoreExtension;
+import org.junit.jupiter.api.extension.AfterAllCallback;
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.BeforeAllCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.extension.ParameterContext;
+import org.junit.jupiter.api.extension.ParameterResolutionException;
+import org.junit.jupiter.api.extension.ParameterResolver;
+
+public class WithDefaultAwsS3Extension implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback, ParameterResolver {
+
+ private final JamesServerExtension jamesServerExtension;
+
+ WithDefaultAwsS3Extension() {
+ jamesServerExtension = CassandraRabbitMQJamesServerFixture.baseExtensionBuilder()
+ .extension(new AwsS3BlobStoreExtension())
+ .build();
+ }
+
+ @Override
+ public void beforeAll(ExtensionContext context) throws Exception {
+ jamesServerExtension.beforeAll(context);
+ }
+
+ @Override
+ public void afterAll(ExtensionContext context) throws Exception {
+ jamesServerExtension.afterAll(context);
+ }
+
+ @Override
+ public void beforeEach(ExtensionContext context) throws Exception {
+ jamesServerExtension.beforeEach(context);
+ }
+
+ @Override
+ public void afterEach(ExtensionContext context) throws Exception {
+ jamesServerExtension.afterEach(context);
+ }
+
+ @Override
+ public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
+ return (parameterContext.getParameter().getType() == GuiceJamesServer.class);
+ }
+
+ @Override
+ public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
+ return jamesServerExtension.getGuiceJamesServer();
+ }
+}
diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/WithDefaultAwsS3Test.java b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/WithDefaultAwsS3Test.java
new file mode 100644
index 0000000..99af818
--- /dev/null
+++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/WithDefaultAwsS3Test.java
@@ -0,0 +1,41 @@
+/*
+ * 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;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.james.blob.objectstorage.DefaultPayloadCodec;
+import org.apache.james.blob.objectstorage.PayloadCodec;
+import org.apache.james.modules.objectstorage.aws.s3.DockerAwsS3TestRule;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+@ExtendWith(WithDefaultAwsS3Extension.class)
+public class WithDefaultAwsS3Test implements JmapJamesServerContract, MailsShouldBeWellReceived, JamesServerContract {
+
+ @Test
+ void defaultPayloadShouldBeByDefault(GuiceJamesServer jamesServer) {
+ PayloadCodec payloadCodec = jamesServer.getProbe(DockerAwsS3TestRule.TestAwsS3BlobStoreProbe.class)
+ .getAwsS3PayloadCodec();
+
+ assertThat(payloadCodec)
+ .isInstanceOf(DefaultPayloadCodec.class);
+ }
+}
diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/WithDefaultSwiftExtension.java b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/WithDefaultSwiftExtension.java
new file mode 100644
index 0000000..3e867aa
--- /dev/null
+++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/WithDefaultSwiftExtension.java
@@ -0,0 +1,71 @@
+/*
+ * 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;
+
+import org.apache.james.modules.SwiftBlobStoreExtension;
+import org.junit.jupiter.api.extension.AfterAllCallback;
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.BeforeAllCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.extension.ParameterContext;
+import org.junit.jupiter.api.extension.ParameterResolutionException;
+import org.junit.jupiter.api.extension.ParameterResolver;
+
+public class WithDefaultSwiftExtension implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback, ParameterResolver {
+
+ private final JamesServerExtension jamesServerExtension;
+
+ WithDefaultSwiftExtension() {
+ jamesServerExtension = CassandraRabbitMQJamesServerFixture.baseExtensionBuilder()
+ .extension(new SwiftBlobStoreExtension())
+ .build();
+ }
+
+ @Override
+ public void beforeAll(ExtensionContext context) throws Exception {
+ jamesServerExtension.beforeAll(context);
+ }
+
+ @Override
+ public void afterAll(ExtensionContext context) throws Exception {
+ jamesServerExtension.afterAll(context);
+ }
+
+ @Override
+ public void beforeEach(ExtensionContext context) throws Exception {
+ jamesServerExtension.beforeEach(context);
+ }
+
+ @Override
+ public void afterEach(ExtensionContext context) throws Exception {
+ jamesServerExtension.afterEach(context);
+ }
+
+ @Override
+ public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
+ return (parameterContext.getParameter().getType() == GuiceJamesServer.class);
+ }
+
+ @Override
+ public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
+ return jamesServerExtension.getGuiceJamesServer();
+ }
+}
diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/WithDefaultSwiftTest.java b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/WithDefaultSwiftTest.java
new file mode 100644
index 0000000..a385484
--- /dev/null
+++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/WithDefaultSwiftTest.java
@@ -0,0 +1,41 @@
+/*
+ * 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;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.james.blob.objectstorage.DefaultPayloadCodec;
+import org.apache.james.blob.objectstorage.PayloadCodec;
+import org.apache.james.modules.objectstorage.swift.DockerSwiftTestRule;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+@ExtendWith(WithDefaultSwiftExtension.class)
+public class WithDefaultSwiftTest implements JmapJamesServerContract, MailsShouldBeWellReceived, JamesServerContract {
+
+ @Test
+ void defaultPayloadShouldBeByDefault(GuiceJamesServer jamesServer) {
+ PayloadCodec payloadCodec = jamesServer.getProbe(DockerSwiftTestRule.TestSwiftBlobStoreProbe.class)
+ .getSwiftPayloadCodec();
+
+ assertThat(payloadCodec)
+ .isInstanceOf(DefaultPayloadCodec.class);
+ }
+}
diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/WithEncryptedAwsS3Extension.java b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/WithEncryptedAwsS3Extension.java
new file mode 100644
index 0000000..c4927a2
--- /dev/null
+++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/WithEncryptedAwsS3Extension.java
@@ -0,0 +1,72 @@
+/*
+ * 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;
+
+import org.apache.james.modules.AwsS3BlobStoreExtension;
+import org.apache.james.modules.objectstorage.PayloadCodecFactory;
+import org.junit.jupiter.api.extension.AfterAllCallback;
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.BeforeAllCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.extension.ParameterContext;
+import org.junit.jupiter.api.extension.ParameterResolutionException;
+import org.junit.jupiter.api.extension.ParameterResolver;
+
+public class WithEncryptedAwsS3Extension implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback, ParameterResolver {
+
+ private final JamesServerExtension jamesServerExtension;
+
+ WithEncryptedAwsS3Extension() {
+ jamesServerExtension = CassandraRabbitMQJamesServerFixture.baseExtensionBuilder()
+ .extension(new AwsS3BlobStoreExtension(PayloadCodecFactory.AES256))
+ .build();
+ }
+
+ @Override
+ public void beforeAll(ExtensionContext context) throws Exception {
+ jamesServerExtension.beforeAll(context);
+ }
+
+ @Override
+ public void afterAll(ExtensionContext context) throws Exception {
+ jamesServerExtension.afterAll(context);
+ }
+
+ @Override
+ public void beforeEach(ExtensionContext context) throws Exception {
+ jamesServerExtension.beforeEach(context);
+ }
+
+ @Override
+ public void afterEach(ExtensionContext context) throws Exception {
+ jamesServerExtension.afterEach(context);
+ }
+
+ @Override
+ public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
+ return (parameterContext.getParameter().getType() == GuiceJamesServer.class);
+ }
+
+ @Override
+ public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
+ return jamesServerExtension.getGuiceJamesServer();
+ }
+}
diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/WithEncryptedAwsS3Test.java b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/WithEncryptedAwsS3Test.java
new file mode 100644
index 0000000..312a8e0
--- /dev/null
+++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/WithEncryptedAwsS3Test.java
@@ -0,0 +1,41 @@
+/*
+ * 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;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.james.blob.objectstorage.AESPayloadCodec;
+import org.apache.james.blob.objectstorage.PayloadCodec;
+import org.apache.james.modules.objectstorage.aws.s3.DockerAwsS3TestRule;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+@ExtendWith(WithEncryptedAwsS3Extension.class)
+public class WithEncryptedAwsS3Test implements JmapJamesServerContract, MailsShouldBeWellReceived, JamesServerContract {
+
+ @Test
+ void encryptedPayloadShouldBeConfiguredWhenProvidingEncryptedPayloadConfiguration(GuiceJamesServer jamesServer) {
+ PayloadCodec payloadCodec = jamesServer.getProbe(DockerAwsS3TestRule.TestAwsS3BlobStoreProbe.class)
+ .getAwsS3PayloadCodec();
+
+ assertThat(payloadCodec)
+ .isInstanceOf(AESPayloadCodec.class);
+ }
+}
diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/WithEncryptedSwiftExtension.java b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/WithEncryptedSwiftExtension.java
new file mode 100644
index 0000000..422a281
--- /dev/null
+++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/WithEncryptedSwiftExtension.java
@@ -0,0 +1,72 @@
+/*
+ * 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;
+
+import org.apache.james.modules.SwiftBlobStoreExtension;
+import org.apache.james.modules.objectstorage.PayloadCodecFactory;
+import org.junit.jupiter.api.extension.AfterAllCallback;
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.BeforeAllCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.extension.ParameterContext;
+import org.junit.jupiter.api.extension.ParameterResolutionException;
+import org.junit.jupiter.api.extension.ParameterResolver;
+
+public class WithEncryptedSwiftExtension implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback, ParameterResolver {
+
+ private final JamesServerExtension jamesServerExtension;
+
+ WithEncryptedSwiftExtension() {
+ jamesServerExtension = CassandraRabbitMQJamesServerFixture.baseExtensionBuilder()
+ .extension(new SwiftBlobStoreExtension(PayloadCodecFactory.AES256))
+ .build();
+ }
+
+ @Override
+ public void beforeAll(ExtensionContext context) throws Exception {
+ jamesServerExtension.beforeAll(context);
+ }
+
+ @Override
+ public void afterAll(ExtensionContext context) throws Exception {
+ jamesServerExtension.afterAll(context);
+ }
+
+ @Override
+ public void beforeEach(ExtensionContext context) throws Exception {
+ jamesServerExtension.beforeEach(context);
+ }
+
+ @Override
+ public void afterEach(ExtensionContext context) throws Exception {
+ jamesServerExtension.afterEach(context);
+ }
+
+ @Override
+ public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
+ return (parameterContext.getParameter().getType() == GuiceJamesServer.class);
+ }
+
+ @Override
+ public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
+ return jamesServerExtension.getGuiceJamesServer();
+ }
+}
diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/WithEncryptedSwiftTest.java b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/WithEncryptedSwiftTest.java
new file mode 100644
index 0000000..74b1fd2
--- /dev/null
+++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/WithEncryptedSwiftTest.java
@@ -0,0 +1,42 @@
+/*
+ * 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;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.james.blob.objectstorage.AESPayloadCodec;
+import org.apache.james.blob.objectstorage.PayloadCodec;
+import org.apache.james.modules.objectstorage.swift.DockerSwiftTestRule;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+@ExtendWith(WithEncryptedSwiftExtension.class)
+public class WithEncryptedSwiftTest implements JmapJamesServerContract, MailsShouldBeWellReceived, JamesServerContract {
+
+ @Test
+ void encryptedPayloadShouldBeConfiguredWhenProvidingEncryptedPayloadConfiguration(GuiceJamesServer jamesServer) {
+ PayloadCodec payloadCodec = jamesServer.getProbe(DockerSwiftTestRule.TestSwiftBlobStoreProbe.class)
+ .getSwiftPayloadCodec();
+
+ assertThat(payloadCodec)
+ .isInstanceOf(AESPayloadCodec.class);
+ }
+
+}
diff --git a/server/container/guice/guice-common/src/test/java/org/apache/james/JamesServerExtension.java b/server/container/guice/guice-common/src/test/java/org/apache/james/JamesServerExtension.java
index 99c42b2..3469871 100644
--- a/server/container/guice/guice-common/src/test/java/org/apache/james/JamesServerExtension.java
+++ b/server/container/guice/guice-common/src/test/java/org/apache/james/JamesServerExtension.java
@@ -47,6 +47,7 @@ public class JamesServerExtension implements BeforeAllCallback, BeforeEachCallba
private final RegistrableExtension registrableExtension;
private final boolean autoStart;
private final AwaitCondition awaitCondition;
+
private GuiceJamesServer guiceJamesServer;
JamesServerExtension(RegistrableExtension registrableExtension, ThrowingFunction<File, GuiceJamesServer> serverSupplier,
@@ -58,6 +59,10 @@ public class JamesServerExtension implements BeforeAllCallback, BeforeEachCallba
this.awaitCondition = awaitCondition;
}
+ public GuiceJamesServer getGuiceJamesServer() {
+ return guiceJamesServer;
+ }
+
@Override
public void beforeAll(ExtensionContext extensionContext) throws Exception {
registrableExtension.beforeAll(extensionContext);
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org