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 bt...@apache.org on 2017/05/15 01:13:18 UTC
[4/5] james-project git commit: JAMES-2019 Add integration testing
JAMES-2019 Add integration testing
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/ae36fda5
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/ae36fda5
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/ae36fda5
Branch: refs/heads/master
Commit: ae36fda5b33ad6d493f4953df865e87a1f63ee9e
Parents: 6573fc8
Author: quynhn <qn...@linagora.com>
Authored: Mon May 8 14:45:00 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Mon May 15 08:10:48 2017 +0700
----------------------------------------------------------------------
.../cucumber/GetMessagesMethodStepdefs.java | 18 +-
.../test/resources/cucumber/GetMessages.feature | 10 +-
.../eml/htmlWithLongAndComplicatedContent.eml | 1995 ++++++++++++++++++
3 files changed, 2021 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/ae36fda5/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 a88c824..bde6f87 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
@@ -37,10 +37,12 @@ import javax.inject.Inject;
import javax.mail.Flags;
import org.apache.commons.lang3.StringEscapeUtils;
+import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.client.fluent.Request;
import org.apache.james.jmap.DefaultMailboxes;
import org.apache.james.jmap.methods.integration.cucumber.util.TableRow;
+import org.apache.james.jmap.model.MessagePreviewGenerator;
import org.apache.james.mailbox.model.MailboxConstants;
import org.apache.james.mailbox.model.MailboxId;
import org.apache.james.mailbox.model.MailboxPath;
@@ -228,6 +230,11 @@ public class GetMessagesMethodStepdefs {
appendMessage(messageName, "eml/windows1252charset.eml");
}
+ @Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with long and complicated HTML content$")
+ public void appendMessageWithSpecialCase(String messageName, String mailbox) throws Throwable {
+ appendMessage(messageName, "eml/htmlWithLongAndComplicatedContent.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,
@@ -421,10 +428,19 @@ public class GetMessagesMethodStepdefs {
@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();
+ String actual = jsonPath.<String>read(FIRST_MESSAGE + ".preview");
assertThat(actual).isNotEmpty();
}
+ @Then("^the preview should not contain consecutive spaces or blank characters$")
+ public void assertPreviewShouldBeNormalized() throws Throwable {
+ String actual = jsonPath.<String>read(FIRST_MESSAGE + ".preview");
+ assertThat(actual).hasSize(MessagePreviewGenerator.MAX_PREVIEW_LENGTH)
+ .doesNotMatch(" ")
+ .doesNotContain(StringUtils.CR)
+ .doesNotContain(StringUtils.LF);
+ }
+
@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/ae36fda5/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 7d35ac4..f1ea2e7 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
@@ -276,7 +276,7 @@ Feature: GetMessages method
And the list should contain 1 message
And the hasAttachment of the message is "false"
And the list of attachments of the message contains only one attachment with cid "1482981567586480bfca67b793175279@linagora.com"
-
+
Scenario: Preview and bodies should respect given charset
Given the user has a message "m1" in "INBOX" mailbox with specific charset
When the user ask for messages "m1"
@@ -285,3 +285,11 @@ Feature: GetMessages method
And the preview of the message is "àààà éééé èèèè"
And the textBody of the message is "àààà\r\n\r\néééé\r\n\r\nèèèè\r\n"
And the htmlBody of the message is "<html>\r\n <p>àààà</p>\r\n <p>éééé</p>\r\n <p>èèèè</p>\r\n</html>\r\n"
+
+ Scenario: Preview should be normalized in case of long and complicated HTML content
+ Given the user has a message "m1" in "INBOX" mailbox with long and complicated HTML content
+ 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
+ And the preview should not contain consecutive spaces or blank characters
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org