JAMES-1717 Integration test for html support

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

Branch: refs/heads/master
Commit: 0ae8736e7f7f1b87a2098001151b766547c78ec2
Parents: a8dd5d0
Author: Benoit Tellier <[email protected]>
Authored: Thu Jun 2 09:49:51 2016 +0700
Committer: Benoit Tellier <[email protected]>
Committed: Fri Jun 3 19:38:15 2016 +0700

----------------------------------------------------------------------
 .../james/jmap/VacationIntegrationTest.java     | 68 ++++++++++++++++++++
 1 file changed, 68 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/0ae8736e/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationIntegrationTest.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationIntegrationTest.java
 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationIntegrationTest.java
index 616c8c9..a720a7e 100644
--- 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationIntegrationTest.java
+++ 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationIntegrationTest.java
@@ -47,6 +47,7 @@ import com.jayway.restassured.http.ContentType;
 
 public abstract class VacationIntegrationTest {
 
+    private static final String NAME = "[0][0]";
     private static final String ARGUMENTS = "[0][1]";
     private static final String SECOND_NAME = "[1][0]";
     private static final String SECOND_ARGUMENTS = "[1][1]";
@@ -122,6 +123,24 @@ public abstract class VacationIntegrationTest {
     }
 
     @Test
+    public void jmapVacationShouldHaveSupportForHtmlMail() throws Exception {
+        // Given
+        AccessToken user1AccessToken = 
JmapAuthentication.authenticateJamesUser(USER_1, PASSWORD);
+        AccessToken user2AccessToken = 
JmapAuthentication.authenticateJamesUser(USER_2, PASSWORD);
+        setHtmlVacationResponse(user1AccessToken);
+
+        // When
+        String user2OutboxId = getOutboxId(user2AccessToken);
+        sendMail(user2AccessToken, user2OutboxId, "user|inbox|1");
+
+        // Then
+        calmlyAwait.atMost(10, TimeUnit.SECONDS)
+            .until(() -> isTextMessageReceived(user1AccessToken, 
getInboxId(user1AccessToken), ORIGINAL_MESSAGE_TEXT_BODY, USER_2, USER_1));
+        calmlyAwait.atMost(10, TimeUnit.SECONDS)
+            .until( () -> assertNotYetImplemented(user2AccessToken, 
getInboxId(user2AccessToken)));
+    }
+
+    @Test
     public void jmapVacationShouldNotGenerateAReplyWhenInactive() throws 
Exception {
         /* Test scenario :
             - User 2 [email protected] sends User 1 a mail
@@ -251,6 +270,30 @@ public abstract class VacationIntegrationTest {
             .statusCode(200);
     }
 
+    private void setHtmlVacationResponse(AccessToken user1AccessToken) {
+        String bodyRequest = "[[" +
+            "\"setVacationResponse\", " +
+            "{" +
+            "  \"update\":{" +
+            "    \"singleton\" : {" +
+            "      \"id\": \"singleton\"," +
+            "      \"isEnabled\": \"true\"," +
+            "      \"htmlBody\": \"<b>" + REASON + "</b>\"" +
+            "    }" +
+            "  }" +
+            "}, \"#0\"" +
+            "]]";
+        given()
+            .accept(ContentType.JSON)
+            .contentType(ContentType.JSON)
+            .header("Authorization", user1AccessToken.serialize())
+            .body(bodyRequest)
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200);
+    }
+
     private void sendMail(AccessToken user2AccessToken, String outboxId, 
String mailId) {
         String requestBody = "[" +
             "  [" +
@@ -333,6 +376,31 @@ public abstract class VacationIntegrationTest {
             .body(SECOND_ARGUMENTS + ".list[0].to.email[0]", 
equalTo(expectedTo));
     }
 
+    private boolean assertNotYetImplemented(AccessToken recipientToken, String 
mailboxId) {
+        try {
+            with()
+                .accept(ContentType.JSON)
+                .contentType(ContentType.JSON)
+                .header("Authorization", recipientToken.serialize())
+                .body("[[\"getMessageList\", " +
+                    "{" +
+                    "  \"fetchMessages\": true, " +
+                    "  \"fetchMessageProperties\": [\"textBody\", \"from\", 
\"to\", \"mailboxIds\"]," +
+                    "  \"filter\": {" +
+                    "    \"inMailboxes\":[\"" + mailboxId + "\"]" +
+                    "  }" +
+                    "}, \"#0\"]]")
+                .post("/jmap")
+            .then()
+                .statusCode(200)
+                .body(NAME, equalTo("error"))
+                .body(ARGUMENTS + ".type", equalTo("Not yet implemented"));
+            return true;
+        } catch (AssertionError e) {
+            return false;
+        }
+    }
+
     private String getOutboxId(AccessToken accessToken) {
         return getMailboxIdByRole(accessToken, "outbox");
     }


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

Reply via email to