This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
     new 572c4d76bf Upgrade EmailSubmissionSetMethodFutureReleaseTest for 
distributed test (#1635)
572c4d76bf is described below

commit 572c4d76bf86b9fe9691379b0a5052fb09cfe0c8
Author: vtbui <87489927+thanhbv200...@users.noreply.github.com>
AuthorDate: Mon Jul 10 10:45:55 2023 +0700

    Upgrade EmailSubmissionSetMethodFutureReleaseTest for distributed test 
(#1635)
---
 ...dEmailSubmissionSetMethodFutureReleaseTest.java |  96 +++++++++++++++++++
 ...lSubmissionSetMethodFutureReleaseContract.scala | 105 ++++++++++++++++-----
 2 files changed, 175 insertions(+), 26 deletions(-)

diff --git 
a/server/protocols/jmap-rfc-8621-integration-tests/distributed-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/distributed/DistributedEmailSubmissionSetMethodFutureReleaseTest.java
 
b/server/protocols/jmap-rfc-8621-integration-tests/distributed-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/distributed/DistributedEmailSubmissionSetMethodFutureReleaseTest.java
new file mode 100644
index 0000000000..1c67d4b24b
--- /dev/null
+++ 
b/server/protocols/jmap-rfc-8621-integration-tests/distributed-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/distributed/DistributedEmailSubmissionSetMethodFutureReleaseTest.java
@@ -0,0 +1,96 @@
+/****************************************************************
+ * 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.jmap.rfc8621.distributed;
+
+import org.apache.james.CassandraExtension;
+import org.apache.james.CassandraRabbitMQJamesConfiguration;
+import org.apache.james.CassandraRabbitMQJamesServerMain;
+import org.apache.james.ClockExtension;
+import org.apache.james.DockerOpenSearchExtension;
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.JamesServerBuilder;
+import org.apache.james.JamesServerExtension;
+import org.apache.james.SearchConfiguration;
+import 
org.apache.james.jmap.rfc8621.contract.EmailSubmissionSetMethodFutureReleaseContract;
+import org.apache.james.jmap.rfc8621.contract.probe.DelegationProbeModule;
+import org.apache.james.mailbox.cassandra.ids.CassandraMessageId;
+import org.apache.james.mailbox.model.MessageId;
+import org.apache.james.modules.AwsS3BlobStoreExtension;
+import org.apache.james.modules.RabbitMQExtension;
+import org.apache.james.modules.TestJMAPServerModule;
+import org.apache.james.modules.blobstore.BlobStoreConfiguration;
+import org.apache.james.utils.UpdatableTickingClock;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import com.datastax.oss.driver.api.core.uuid.Uuids;
+import com.google.inject.name.Names;
+
+public class DistributedEmailSubmissionSetMethodFutureReleaseTest implements 
EmailSubmissionSetMethodFutureReleaseContract {
+    public static final CassandraMessageId.Factory MESSAGE_ID_FACTORY = new 
CassandraMessageId.Factory();
+
+    @RegisterExtension
+    static JamesServerExtension testExtension = new 
JamesServerBuilder<CassandraRabbitMQJamesConfiguration>(tmpDir ->
+        CassandraRabbitMQJamesConfiguration.builder()
+            .workingDirectory(tmpDir)
+            .configurationFromClasspath()
+            .enableJMAP()
+            .blobStore(BlobStoreConfiguration.builder()
+                .s3()
+                .disableCache()
+                .deduplication()
+                .noCryptoConfig())
+            .searchConfiguration(SearchConfiguration.openSearch())
+            .build())
+        .extension(new DockerOpenSearchExtension())
+        .extension(new CassandraExtension())
+        .extension(new RabbitMQExtension())
+        .extension(new AwsS3BlobStoreExtension())
+        .extension(new ClockExtension())
+        .server(configuration -> 
CassandraRabbitMQJamesServerMain.createServer(configuration)
+            .overrideWith(new TestJMAPServerModule(), new 
DelegationProbeModule()))
+        .overrideServerModule(binder -> 
binder.bind(Boolean.class).annotatedWith(Names.named("supportsDelaySends")).toInstance(true))
+        .build();
+
+    @Override
+    public MessageId randomMessageId() {
+        return MESSAGE_ID_FACTORY.of(Uuids.timeBased());
+    }
+
+    @Disabled("Not work for distributed test")
+    @Override
+    public void 
emailSubmissionSetCreateShouldDeliverEmailWhenHoldForExpired(GuiceJamesServer 
server, UpdatableTickingClock updatableTickingClock){
+    }
+
+    @Disabled("Not work for distributed test")
+    @Override
+    public void 
emailSubmissionSetCreateShouldDeliverEmailWhenHoldUntilExpired(GuiceJamesServer 
server, UpdatableTickingClock updatableTickingClock){
+    }
+
+    @Disabled("Not work for distributed test")
+    @Override
+    public void 
emailSubmissionSetCreateShouldDelayEmailWithHoldFor(GuiceJamesServer server, 
UpdatableTickingClock updatableTickingClock){
+    }
+
+    @Disabled("Not work for distributed test")
+    @Override
+    public void 
emailSubmissionSetCreateShouldDelayEmailWithHoldUntil(GuiceJamesServer server, 
UpdatableTickingClock updatableTickingClock){
+    }
+}
\ No newline at end of file
diff --git 
a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailSubmissionSetMethodFutureReleaseContract.scala
 
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailSubmissionSetMethodFutureReleaseContract.scala
index ab20631020..864d223609 100644
--- 
a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailSubmissionSetMethodFutureReleaseContract.scala
+++ 
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailSubmissionSetMethodFutureReleaseContract.scala
@@ -40,8 +40,10 @@ import org.apache.james.mailbox.model.{MailboxId, 
MailboxPath, MessageId}
 import org.apache.james.mime4j.dom.Message
 import org.apache.james.modules.MailboxProbeImpl
 import org.apache.james.utils.{DataProbeImpl, UpdatableTickingClock}
+import org.assertj.core.api.Assertions
 import org.awaitility.Awaitility
 import org.awaitility.Durations.ONE_HUNDRED_MILLISECONDS
+import org.awaitility.core.ConditionTimeoutException
 import org.hamcrest.text.CharSequenceLength
 import org.hamcrest.{Matcher, Matchers}
 import org.junit.jupiter.api.{BeforeEach, Tag, Test}
@@ -297,8 +299,7 @@ trait EmailSubmissionSetMethodFutureReleaseContract {
       .body(request)
       .post
 
-    // Wait one second
-    updatableTickingClock.setInstant(DATE.plusSeconds(1))
+    Thread.sleep(1000)
 
     // Ensure Andre did not receive the email
     val requestAndre =
@@ -312,24 +313,27 @@ trait EmailSubmissionSetMethodFutureReleaseContract {
          |    },
          |    "c1"]]
          |}""".stripMargin
-    val response = `given`(
-      baseRequestSpecBuilder(server)
-        .setAuth(authScheme(UserCredential(ANDRE, ANDRE_PASSWORD)))
-        .addHeader(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
-        .setBody(requestAndre)
-        .build, new ResponseSpecBuilder().build)
-      .post
-      .`then`
-      .statusCode(SC_OK)
-      .contentType(JSON)
-      .extract
-      .body
-      .asString
-
-    assertThatJson(response)
-      .inPath("methodResponses[0][1].ids")
-      .isArray
-      .hasSize(0)
+
+    awaitAtMostTenSeconds.untilAsserted { () =>
+      val response = `given`(
+        baseRequestSpecBuilder(server)
+          .setAuth(authScheme(UserCredential(ANDRE, ANDRE_PASSWORD)))
+          .addHeader(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
+          .setBody(requestAndre)
+          .build, new ResponseSpecBuilder().build)
+          .post
+        .`then`
+          .statusCode(SC_OK)
+          .contentType(JSON)
+          .extract
+          .body
+          .asString
+
+      assertThatJson(response)
+        .inPath("methodResponses[0][1].ids")
+        .isArray
+        .hasSize(0)
+    }
   }
 
   @Test
@@ -382,8 +386,6 @@ trait EmailSubmissionSetMethodFutureReleaseContract {
       .body(request)
       .post
 
-    updatableTickingClock.setInstant(DATE.plusSeconds(20000))
-
     val requestAndre =
       s"""{
          |  "using": ["urn:ietf:params:jmap:core","urn:ietf:params:jmap:mail"],
@@ -395,6 +397,33 @@ trait EmailSubmissionSetMethodFutureReleaseContract {
          |    },
          |    "c1"]]
          |}""".stripMargin
+
+    Assertions.assertThatThrownBy(() => {
+      calmlyAwait.atMost(1, TimeUnit.SECONDS).untilAsserted { () =>
+        val response = `given`(
+          baseRequestSpecBuilder(server)
+            .setAuth(authScheme(UserCredential(ANDRE, ANDRE_PASSWORD)))
+            .addHeader(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
+            .setBody(requestAndre)
+            .build, new ResponseSpecBuilder().build)
+            .post
+          .`then`
+            .statusCode(SC_OK)
+            .contentType(JSON)
+            .extract
+            .body
+            .asString
+
+        assertThatJson(response)
+          .inPath("methodResponses[0][1].ids")
+          .isArray
+          .hasSizeGreaterThan(0)
+      }
+    })
+      .isInstanceOf(classOf[ConditionTimeoutException])
+
+    updatableTickingClock.setInstant(DATE.plusSeconds(20000))
+
     awaitAtMostTenSeconds.untilAsserted { () =>
       val response = `given`(
         baseRequestSpecBuilder(server)
@@ -712,7 +741,7 @@ trait EmailSubmissionSetMethodFutureReleaseContract {
       .body(request)
       .post
 
-    updatableTickingClock.setInstant(DATE.plusSeconds(1))
+    Thread.sleep(1000)
 
     // Ensure Andre did not receive the email
     val requestAndre =
@@ -798,8 +827,6 @@ trait EmailSubmissionSetMethodFutureReleaseContract {
       .body(request)
       .post
 
-    updatableTickingClock.setInstant(DATE.plusSeconds(18000))
-
     val requestAndre =
       s"""{
          |  "using": ["urn:ietf:params:jmap:core","urn:ietf:params:jmap:mail"],
@@ -811,6 +838,32 @@ trait EmailSubmissionSetMethodFutureReleaseContract {
          |    },
          |    "c1"]]
          |}""".stripMargin
+
+    Assertions.assertThatThrownBy(() => {
+      calmlyAwait.atMost(1, TimeUnit.SECONDS).untilAsserted { () =>
+        val response = `given`(
+          baseRequestSpecBuilder(server)
+            .setAuth(authScheme(UserCredential(ANDRE, ANDRE_PASSWORD)))
+            .addHeader(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
+            .setBody(requestAndre)
+            .build, new ResponseSpecBuilder().build)
+            .post
+          .`then`
+            .statusCode(SC_OK)
+            .contentType(JSON)
+            .extract
+            .body
+            .asString
+
+        assertThatJson(response)
+          .inPath("methodResponses[0][1].ids")
+          .isArray
+          .hasSizeGreaterThan(0)
+      }
+    })
+      .isInstanceOf(classOf[ConditionTimeoutException])
+
+    updatableTickingClock.setInstant(DATE.plusSeconds(18000))
     awaitAtMostTenSeconds.untilAsserted { () =>
       val response = `given`(
         baseRequestSpecBuilder(server)
@@ -1368,7 +1421,7 @@ trait EmailSubmissionSetMethodFutureReleaseContract {
   }
 
   @Test
-  def emailShouldNotBeSentWhenHoldForIsNull(server: GuiceJamesServer): Unit = {
+  def emailShouldBeSentImmediatelyWhenHoldForIsNull(server: GuiceJamesServer): 
Unit = {
     val message: Message = Message.Builder
       .of
       .setSubject("test")


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

Reply via email to