JAMES-1965 Add an integration test for a difficult to preview e-mail
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/9715af0f Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/9715af0f Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/9715af0f Branch: refs/heads/master Commit: 9715af0fefc6f3fb0e3c768b9d306ac0402a0680 Parents: b64c3ed Author: Raphael Ouazana <[email protected]> Authored: Fri Mar 24 17:59:06 2017 +0100 Committer: Raphael Ouazana <[email protected]> Committed: Fri Mar 24 18:05:36 2017 +0100 ---------------------------------------------------------------------- .../cucumber/GetMessagesMethodStepdefs.java | 11 ++ .../test/resources/cucumber/GetMessages.feature | 7 ++ .../resources/eml/htmlBodyWithManyEmptyTags.eml | 105 +++++++++++++++++++ 3 files changed, 123 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/9715af0f/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java index 620328e..c097957 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java @@ -213,6 +213,11 @@ public class GetMessagesMethodStepdefs { appendMessage(messageName, "eml/mailWithInlinedAttachmentButNoCid.eml"); } + @Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with HTML body with many empty tags$") + public void appendMessageWithNoPreview(String messageName, String mailbox) throws Throwable { + appendMessage(messageName, "eml/htmlBodyWithManyEmptyTags.eml"); + } + private void appendMessage(String messageName, String emlFileName) throws Exception { ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z"); MessageId id = mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).appendMessage(userStepdefs.lastConnectedUser, @@ -405,6 +410,12 @@ public class GetMessagesMethodStepdefs { assertThat(actual).isEqualToIgnoringWhitespace(StringEscapeUtils.unescapeJava(preview)); } + @Then("^the preview of the message is not empty$") + public void assertPreviewOfTheFirstMessageIsNotEmpty() throws Throwable { + String actual = jsonPath.<String>read(FIRST_MESSAGE + ".preview").replace("\n", " ").trim(); + assertThat(actual).isNotEmpty(); + } + @Then("^the headers of the message contains:$") public void assertHeadersOfTheFirstMessage(DataTable headers) throws Throwable { assertThat(jsonPath.<Map<String, String>>read(FIRST_MESSAGE + ".headers")).containsAllEntriesOf(headers.asMap(String.class, String.class)); http://git-wip-us.apache.org/repos/asf/james-project/blob/9715af0f/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature index 7a27e6d..5a860ee 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature @@ -261,3 +261,10 @@ Feature: GetMessages method |type |"application/pdf" | |cid |null | |isInline |true | + + Scenario: Preview should be computed even when HTML body contains many tags without content + Given the user has a message "m1" in "INBOX" mailbox with HTML body with many empty tags + When the user ask for messages "m1" + Then no error is returned + And the list should contain 1 message + And the preview of the message is not empty http://git-wip-us.apache.org/repos/asf/james-project/blob/9715af0f/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/htmlBodyWithManyEmptyTags.eml ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/htmlBodyWithManyEmptyTags.eml b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/htmlBodyWithManyEmptyTags.eml new file mode 100644 index 0000000..70739a4 --- /dev/null +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/htmlBodyWithManyEmptyTags.eml @@ -0,0 +1,105 @@ +From: User1 <[email protected]> +Content-Type: multipart/alternative; + boundary="Apple-Mail=_D2911C08-3A5E-42E0-8425-66C5B77B4CFB" +Message-Id: <[email protected]> +Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) +X-Smtp-Server: 0977CE5E-80CD-4915-A107-FAFEC09C4749 +Subject: Re: Subject +Date: Thu, 2 Mar 2017 17:45:51 +0100 +X-Universally-Unique-Identifier: A41C9129-282B-42B3-ABE2-4FA16E75C536 +References: <[email protected]> <[email protected]> <[email protected]> <[email protected]> <[email protected]> <[email protected]> +To: User2 <[email protected]> +In-Reply-To: <[email protected]> + + +--Apple-Mail=_D2911C08-3A5E-42E0-8425-66C5B77B4CFB +Content-Transfer-Encoding: quoted-printable +Content-Type: text/plain; + charset=windows-1252 + + +-- +Signature + + + +> On 02 Mar 2017, at 17:36, User2 = +<[email protected]> wrote: +>=20 +> Hi,=20 +> Test. +>=20 + + +--Apple-Mail=_D2911C08-3A5E-42E0-8425-66C5B77B4CFB +Content-Type: multipart/mixed; + boundary="Apple-Mail=_B0F07404-D743-4428-AC87-850B66EAB0FF" + + +--Apple-Mail=_B0F07404-D743-4428-AC87-850B66EAB0FF +Content-Transfer-Encoding: 7bit +Content-Type: text/html; + charset=windows-1252 + +<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""></body></html> +--Apple-Mail=_B0F07404-D743-4428-AC87-850B66EAB0FF +Content-Disposition: attachment; + filename*0="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL"; + filename*1="MNOPQRSTUVW.rtf" +Content-Type: text/rtf; + name="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZA" +Content-Transfer-Encoding: quoted-printable + +{= +\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1036{\fonttbl{\f0\fswiss\fc= +harset0 Arial;}{\f1\froman\fcharset0 Times New Roman;}}=0D +{\colortbl = +;\red255\green0\blue255;\red255\green0\blue0;\red155\green0\blue211;\red25= +5\green255\blue0;\red192\green192\blue192;\red0\green255\blue255;\red0\gre= +en176\blue80;}=0D +}=0D +=00= + +--Apple-Mail=_B0F07404-D743-4428-AC87-850B66EAB0FF +Content-Transfer-Encoding: quoted-printable +Content-Type: text/html; + charset=windows-1252 + +<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html = +charset=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; = +-webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" = +class=3D""><br class=3D""><div class=3D""> +<div style=3D"color: rgb(0, 0, 0); letter-spacing: normal; orphans: = +auto; text-align: start; text-indent: 0px; text-transform: none; = +white-space: normal; widows: auto; word-spacing: 0px; = +-webkit-text-stroke-width: 0px; word-wrap: break-word; = +-webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" = +class=3D""><div class=3D"">--</div><div class=3D"">User1 = +User1</div><div class=3D"">Signature</div><div = +class=3D"">Signature</div><div class=3D""><br class=3D""></div></div><br= + class=3D"Apple-interchange-newline"><br = +class=3D"Apple-interchange-newline"> + +</div> +<br class=3D""><div style=3D""><blockquote type=3D"cite" class=3D""><div = +class=3D"">On 02 Mar 2017, at 17:36, User2 <<a = +href=3D"mailto:[email protected]" = +class=3D"">[email protected]</a>> wrote:</div><br = +class=3D"Apple-interchange-newline"><div class=3D""> + =20 + <meta content=3D"text/html; charset=3Dwindows-1252" = +http-equiv=3D"Content-Type" class=3D""> + =20 + <div bgcolor=3D"#FFFFFF" text=3D"#000066" class=3D""><p = +class=3D"">Hi, <br class=3D""> + </p><p class=3D"">Test.</p> +<p class=3D"">Test<br = +class=3D""> + </p> + </div> + +</div></blockquote></div><br class=3D""></body></html>= + +--Apple-Mail=_B0F07404-D743-4428-AC87-850B66EAB0FF-- + +--Apple-Mail=_D2911C08-3A5E-42E0-8425-66C5B77B4CFB-- --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
