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/06/06 08:28:52 UTC
[3/6] james-project git commit: JAMES-2039 The IT testing methods
should throws Exception instead of Throwable
JAMES-2039 The IT testing methods should throws Exception instead of Throwable
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/dbf21a1e
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/dbf21a1e
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/dbf21a1e
Branch: refs/heads/master
Commit: dbf21a1e9971ad41b820caf66c23022b20b1b1bd
Parents: 2c85e94
Author: quynhn <qn...@linagora.com>
Authored: Mon Jun 5 10:48:45 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Tue Jun 6 15:27:26 2017 +0700
----------------------------------------------------------------------
.../cucumber/GetMessagesMethodStepdefs.java | 100 +++++++++----------
1 file changed, 50 insertions(+), 50 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/dbf21a1e/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 29af204..357e8ae 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
@@ -101,7 +101,7 @@ public class GetMessagesMethodStepdefs {
}
@Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" and \"([^\"]*)\" mailboxes with subject \"([^\"]*)\", content \"([^\"]*)\"$")
- public void appendMessageInTwoMailboxes(String messageName, String mailbox1, String mailbox2, String subject, String content) throws Throwable {
+ public void appendMessageInTwoMailboxes(String messageName, String mailbox1, String mailbox2, String subject, String content) throws Exception {
MessageId id = appendMessage(mailbox1, ContentType.noContentType(), subject, content, NO_HEADERS);
MailboxId mailboxId1 = mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser, mailbox1).getMailboxId();
MailboxId mailboxId2 = mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser, mailbox2).getMailboxId();
@@ -111,25 +111,25 @@ public class GetMessagesMethodStepdefs {
}
@Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with subject \"([^\"]*)\", content \"([^\"]*)\"$")
- public void appendMessage(String messageName, String mailbox, String subject, String content) throws Throwable {
+ public void appendMessage(String messageName, String mailbox, String subject, String content) throws Exception {
MessageId id = appendMessage(mailbox, ContentType.noContentType(), subject, content, NO_HEADERS);
messageIdsByName.put(messageName, id);
}
@Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with content-type \"([^\"]*)\" subject \"([^\"]*)\", content \"([^\"]*)\"$")
- public void appendMessage(String messageName, String mailbox, String contentType, String subject, String content) throws Throwable {
+ public void appendMessage(String messageName, String mailbox, String contentType, String subject, String content) throws Exception {
MessageId id = appendMessage(mailbox, ContentType.from(contentType), subject, content, NO_HEADERS);
messageIdsByName.put(messageName, id);
}
@Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with subject \"([^\"]*)\", content \"([^\"]*)\", headers$")
- public void appendMessage(String messageName, String mailbox, String subject, String content, DataTable headers) throws Throwable {
+ public void appendMessage(String messageName, String mailbox, String subject, String content, DataTable headers) throws Exception {
MessageId id = appendMessage(mailbox, ContentType.noContentType(), subject, content, Optional.of(headers.asMap(String.class, String.class)));
messageIdsByName.put(messageName, id);
}
@Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox, composed of a multipart with inlined text part and inlined html part$")
- public void appendMessageFromFileInlinedMultipart(String messageName, String mailbox) throws Throwable {
+ public void appendMessageFromFileInlinedMultipart(String messageName, String mailbox) throws Exception {
ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
MessageId id = mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).appendMessage(userStepdefs.lastConnectedUser,
new MailboxPath(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser, mailbox),
@@ -166,77 +166,77 @@ public class GetMessagesMethodStepdefs {
}
@Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with two attachments$")
- public void appendHtmlMessageWithTwoAttachments(String messageName, String mailbox) throws Throwable {
+ public void appendHtmlMessageWithTwoAttachments(String messageName, String mailbox) throws Exception {
appendMessage(messageName, "eml/twoAttachments.eml");
}
@Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with two attachments in text$")
- public void appendTextMessageWithTwoAttachments(String messageName, String mailbox) throws Throwable {
+ public void appendTextMessageWithTwoAttachments(String messageName, String mailbox) throws Exception {
appendMessage(messageName, "eml/twoAttachmentsTextPlain.eml");
}
@Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with two same attachments in text$")
- public void appendTextMessageWithTwoSameAttachments(String messageName, String mailbox) throws Throwable {
+ public void appendTextMessageWithTwoSameAttachments(String messageName, String mailbox) throws Exception {
appendMessage(messageName, "eml/twoSameAttachments.eml");
}
@Given("^the user has a multipart message \"([^\"]*)\" in \"([^\"]*)\" mailbox$")
- public void appendMultipartMessageWithOneAttachments(String messageName, String arg1) throws Throwable {
+ public void appendMultipartMessageWithOneAttachments(String messageName, String arg1) throws Exception {
appendMessage(messageName, "eml/htmlAndTextMultipartWithOneAttachment.eml");
}
@Given("^the user has a multipart/related message \"([^\"]*)\" in \"([^\"]*)\" mailbox$")
- public void appendMultipartRelated(String messageName, String mailbox) throws Throwable {
+ public void appendMultipartRelated(String messageName, String mailbox) throws Exception {
appendMessage(messageName, "eml/multipartRelated.eml");
}
@Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox beginning by a long line$")
- public void appendMessageBeginningByALongLine(String messageName, String mailbox) throws Throwable {
+ public void appendMessageBeginningByALongLine(String messageName, String mailbox) throws Exception {
appendMessage(messageName, "eml/longLine.eml");
}
@Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with plain/text inline attachment$")
- public void appendMessageWithPlainTextInlineAttachment(String messageName, String mailbox) throws Throwable {
+ public void appendMessageWithPlainTextInlineAttachment(String messageName, String mailbox) throws Exception {
appendMessage(messageName, "eml/embeddedMultipartWithInlineTextAttachment.eml");
}
@Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with text in main multipart and html in inner multipart$")
- public void appendMessageWithTextInMainMultipartAndHtmlInInnerMultipart(String messageName, String mailbox) throws Throwable {
+ public void appendMessageWithTextInMainMultipartAndHtmlInInnerMultipart(String messageName, String mailbox) throws Exception {
appendMessage(messageName, "eml/textInMainMultipartHtmlInInnerMultipart.eml");
}
@Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with html body and no text body$")
- public void appendMessageWithNoTextButHtml(String messageName, String mailbox) throws Throwable {
+ public void appendMessageWithNoTextButHtml(String messageName, String mailbox) throws Exception {
appendMessage(messageName, "eml/noTextBodyButHtmlBody.eml");
}
@Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with inline attachment but no CID$")
- public void appendMessageWithInlineAttachmentButNoCid(String messageName, String mailbox) throws Throwable {
+ public void appendMessageWithInlineAttachmentButNoCid(String messageName, String mailbox) throws Exception {
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 {
+ public void appendMessageWithNoPreview(String messageName, String mailbox) throws Exception {
appendMessage(messageName, "eml/htmlBodyWithManyEmptyTags.eml");
}
@Given("^the user has a message \"([^\"]*)\" in the \"([^\"]*)\" mailbox with multiple same inlined attachments \"([^\"]*)\"$")
- public void appendMessageWithSameInlinedAttachmentsToMailbox(String messageName, String mailbox, String attachmentId) throws Throwable {
+ public void appendMessageWithSameInlinedAttachmentsToMailbox(String messageName, String mailbox, String attachmentId) throws Exception {
appendMessage(messageName, "eml/sameInlinedImages.eml");
}
@Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with specific charset$")
- public void appendMessageWithSpecificCharset(String messageName, String mailbox) throws Throwable {
+ public void appendMessageWithSpecificCharset(String messageName, String mailbox) throws Exception {
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 {
+ public void appendMessageWithSpecialCase(String messageName, String mailbox) throws Exception {
appendMessage(messageName, "eml/htmlWithLongAndComplicatedContent.eml");
}
@Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with iso charset")
- public void appendMessageWithEncoding(String messageName, String mailbox) throws Throwable {
+ public void appendMessageWithEncoding(String messageName, String mailbox) throws Exception {
appendMessage(messageName, "eml/iso8859_1charset.eml");
}
@@ -266,12 +266,12 @@ public class GetMessagesMethodStepdefs {
}
@When("^the user ask for messages$")
- public void post() throws Throwable {
+ public void post() throws Exception {
post("[[\"getMessages\", {\"ids\": []}, \"#0\"]]");
}
@When("^the user ask for messages \"(.*?)\"$")
- public void postWithAListOfIds(List<String> ids) throws Throwable {
+ public void postWithAListOfIds(List<String> ids) throws Exception {
requestedMessageIds = ids.stream()
.map(messageIdsByName::get)
.collect(Guavate.toImmutableList());
@@ -279,7 +279,7 @@ public class GetMessagesMethodStepdefs {
}
@When("^the user ask for an unknown message$")
- public void requestUnknownMessage() throws Throwable {
+ public void requestUnknownMessage() throws Exception {
askMessages(ImmutableList.of(mainStepdefs.messageIdFactory.generate()));
}
@@ -297,7 +297,7 @@ public class GetMessagesMethodStepdefs {
}
@When("^the user is getting messages \"(.*?)\" with properties \"(.*?)\"$")
- public void postWithParameters(List<String> ids, List<String> properties) throws Throwable {
+ public void postWithParameters(List<String> ids, List<String> properties) throws Exception {
requestedMessageIds = ids.stream()
.map(messageIdsByName::get)
.collect(Guavate.toImmutableList());
@@ -333,14 +333,14 @@ public class GetMessagesMethodStepdefs {
}
@Then("^an error \"([^\"]*)\" is returned$")
- public void error(String type) throws Throwable {
+ public void error(String type) throws Exception {
assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200);
assertThat(jsonPath.<String>read(NAME)).isEqualTo("error");
assertThat(jsonPath.<String>read(ARGUMENTS + ".type")).isEqualTo(type);
}
@Then("^no error is returned$")
- public void noError() throws Throwable {
+ public void noError() throws Exception {
assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200);
assertThat(jsonPath.<String>read(NAME)).isEqualTo("messages");
}
@@ -356,35 +356,35 @@ public class GetMessagesMethodStepdefs {
}
@Then("^the description is \"(.*?)\"$")
- public void assertDescription(String description) throws Throwable {
+ public void assertDescription(String description) throws Exception {
assertThat(jsonPath.<String>read(ARGUMENTS + ".description")).isEqualTo(description);
}
@Then("^the notFound list should contain \"([^\"]*)\"$")
- public void assertNotFoundListContains(String ids) throws Throwable {
+ public void assertNotFoundListContains(String ids) throws Exception {
assertThat(jsonPath.<List<String>>read(ARGUMENTS + ".notFound")).contains(ids);
}
@Then("^the notFound list should contain the requested message id$")
- public void assertNotFoundListContainsRequestedMessages() throws Throwable {
+ public void assertNotFoundListContainsRequestedMessages() throws Exception {
ImmutableList<String> elements = requestedMessageIds.stream().map(MessageId::serialize).collect(Guavate.toImmutableList());
assertThat(jsonPath.<List<String>>read(ARGUMENTS + ".notFound")).containsExactlyElementsOf(elements);
}
@Then("^the list should contain (\\d+) message$")
- public void assertListContains(int numberOfMessages) throws Throwable {
+ public void assertListContains(int numberOfMessages) throws Exception {
assertThat(jsonPath.<List<String>>read(ARGUMENTS + ".list")).hasSize(numberOfMessages);
}
@Then("^the id of the message is \"([^\"]*)\"$")
- public void assertIdOfTheFirstMessage(String messageName) throws Throwable {
+ public void assertIdOfTheFirstMessage(String messageName) throws Exception {
MessageId id = messageIdsByName.get(messageName);
assertThat(jsonPath.<String>read(FIRST_MESSAGE + ".id")).isEqualTo(id.serialize());
}
@Then("^the message is in \"([^\"]*)\" mailboxes")
- public void assertMailboxIdsOfTheFirstMessage(String mailboxIds) throws Throwable {
+ public void assertMailboxIdsOfTheFirstMessage(String mailboxIds) throws Exception {
List<String> values = Splitter.on(",")
.splitToList(mailboxIds).stream()
.map(Throwing.function(name -> mainStepdefs.jmapServer
@@ -400,45 +400,45 @@ public class GetMessagesMethodStepdefs {
}
@Then("^the threadId of the message is \"([^\"]*)\"$")
- public void assertThreadIdOfTheFirstMessage(String threadId) throws Throwable {
+ public void assertThreadIdOfTheFirstMessage(String threadId) throws Exception {
MessageId id = messageIdsByName.get(threadId);
assertThat(jsonPath.<String>read(FIRST_MESSAGE + ".threadId")).isEqualTo(id.serialize());
}
@Then("^the subject of the message is \"([^\"]*)\"$")
- public void assertSubjectOfTheFirstMessage(String subject) throws Throwable {
+ public void assertSubjectOfTheFirstMessage(String subject) throws Exception {
assertThat(jsonPath.<String>read(FIRST_MESSAGE + ".subject")).isEqualTo(subject);
}
@Then("^the textBody of the message is \"([^\"]*)\"$")
- public void assertTextBodyOfTheFirstMessage(String textBody) throws Throwable {
+ public void assertTextBodyOfTheFirstMessage(String textBody) throws Exception {
assertThat(jsonPath.<String>read(FIRST_MESSAGE + ".textBody")).isEqualTo(StringEscapeUtils.unescapeJava(textBody));
}
@Then("^the htmlBody of the message is \"([^\"]*)\"$")
- public void assertHtmlBodyOfTheFirstMessage(String htmlBody) throws Throwable {
+ public void assertHtmlBodyOfTheFirstMessage(String htmlBody) throws Exception {
assertThat(jsonPath.<String>read(FIRST_MESSAGE + ".htmlBody")).isEqualTo(StringEscapeUtils.unescapeJava(htmlBody));
}
@Then("^the isUnread of the message is \"([^\"]*)\"$")
- public void assertIsUnreadOfTheFirstMessage(String isUnread) throws Throwable {
+ public void assertIsUnreadOfTheFirstMessage(String isUnread) throws Exception {
assertThat(jsonPath.<Boolean>read(FIRST_MESSAGE + ".isUnread")).isEqualTo(Boolean.valueOf(isUnread));
}
@Then("^the preview of the message is \"([^\"]*)\"$")
- public void assertPreviewOfTheFirstMessage(String preview) throws Throwable {
+ public void assertPreviewOfTheFirstMessage(String preview) throws Exception {
String actual = jsonPath.<String>read(FIRST_MESSAGE + ".preview").replace("\n", " ");
assertThat(actual).isEqualToIgnoringWhitespace(StringEscapeUtils.unescapeJava(preview));
}
@Then("^the preview of the message is not empty$")
- public void assertPreviewOfTheFirstMessageIsNotEmpty() throws Throwable {
+ public void assertPreviewOfTheFirstMessageIsNotEmpty() throws Exception {
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 {
+ public void assertPreviewShouldBeNormalized() throws Exception {
String actual = jsonPath.<String>read(FIRST_MESSAGE + ".preview");
assertThat(actual).hasSize(MessagePreviewGenerator.MAX_PREVIEW_LENGTH)
.doesNotMatch(" ")
@@ -447,52 +447,52 @@ public class GetMessagesMethodStepdefs {
}
@Then("^the headers of the message contains:$")
- public void assertHeadersOfTheFirstMessage(DataTable headers) throws Throwable {
+ public void assertHeadersOfTheFirstMessage(DataTable headers) throws Exception {
assertThat(jsonPath.<Map<String, String>>read(FIRST_MESSAGE + ".headers")).containsAllEntriesOf(headers.asMap(String.class, String.class));
}
@Then("^the date of the message is \"([^\"]*)\"$")
- public void assertDateOfTheFirstMessage(String date) throws Throwable {
+ public void assertDateOfTheFirstMessage(String date) throws Exception {
assertThat(jsonPath.<String>read(FIRST_MESSAGE + ".date")).isEqualTo(date);
}
@Then("^the hasAttachment of the message is \"([^\"]*)\"$")
- public void assertHasAttachmentOfTheFirstMessage(String hasAttachment) throws Throwable {
+ public void assertHasAttachmentOfTheFirstMessage(String hasAttachment) throws Exception {
assertThat(jsonPath.<Boolean>read(FIRST_MESSAGE + ".hasAttachment")).isEqualTo(Boolean.valueOf(hasAttachment));
}
@Then("^the list of attachments of the message is empty$")
- public void assertAttachmentsOfTheFirstMessageIsEmpty() throws Throwable {
+ public void assertAttachmentsOfTheFirstMessageIsEmpty() throws Exception {
assertThat(jsonPath.<List<Object>>read(ATTACHMENTS)).isEmpty();
}
@Then("^the property \"([^\"]*)\" of the message is null$")
- public void assertPropertyIsNull(String property) throws Throwable {
+ public void assertPropertyIsNull(String property) throws Exception {
assertThat(jsonPath.<String>read(FIRST_MESSAGE + "." + property + ".date")).isNull();
}
@Then("^the list of attachments of the message contains (\\d+) attachments?$")
- public void assertAttachmentsHasSize(int numberOfAttachments) throws Throwable {
+ public void assertAttachmentsHasSize(int numberOfAttachments) throws Exception {
assertThat(jsonPath.<List<Object>>read(ATTACHMENTS)).hasSize(numberOfAttachments);
}
@Then("^the list of attachments of the message contains only one attachment with cid \"([^\"]*)\"?$")
- public void assertAttachmentsAndItsCid(String cid) throws Throwable {
+ public void assertAttachmentsAndItsCid(String cid) throws Exception {
assertThat(jsonPath.<String>read(FIRST_ATTACHMENT + ".cid")).isEqualTo(cid);
}
@Then("^the first attachment is:$")
- public void assertFirstAttachment(DataTable attachmentProperties) throws Throwable {
+ public void assertFirstAttachment(DataTable attachmentProperties) throws Exception {
assertAttachment(FIRST_ATTACHMENT, attachmentProperties);
}
@Then("^the second attachment is:$")
- public void assertSecondAttachment(DataTable attachmentProperties) throws Throwable {
+ public void assertSecondAttachment(DataTable attachmentProperties) throws Exception {
assertAttachment(SECOND_ATTACHMENT, attachmentProperties);
}
@Then("^the preview of the message contains:$")
- public void assertPreviewOfMessageShouldBePrintedWithEncoding(DataTable preview) throws Throwable {
+ public void assertPreviewOfMessageShouldBePrintedWithEncoding(DataTable preview) throws Exception {
String actual = jsonPath.<String>read(FIRST_MESSAGE + ".preview");
assertThat(actual).contains(preview.asList(String.class));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org