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/29 02:09:16 UTC
[2/2] james-project git commit: JAMES-2077 The RFC 1123 time
formatter doesn't support RFC 5322 year definition
JAMES-2077 The RFC 1123 time formatter doesn't support RFC 5322 year definition
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/5095da26
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/5095da26
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/5095da26
Branch: refs/heads/master
Commit: 5095da26c8f17a17cf74b18b99bde054dd5af6d4
Parents: 869f315
Author: Antoine Duprat <ad...@linagora.com>
Authored: Wed Jun 28 13:39:03 2017 +0200
Committer: benwa <bt...@linagora.com>
Committed: Thu Jun 29 09:05:14 2017 +0700
----------------------------------------------------------------------
.../elasticsearch/json/HeaderCollection.java | 4 +-
.../json/HeaderCollectionTest.java | 10 +
.../james/util/date/ImapDateTimeFormatter.java | 94 +++++++
.../util/date/ImapDateTimeFormatterTest.java | 252 +++++++++++++++++++
.../integration/GetMessageListMethodTest.java | 24 ++
5 files changed, 382 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/5095da26/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/HeaderCollection.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/HeaderCollection.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/HeaderCollection.java
index 3db1c9a..2b26a66 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/HeaderCollection.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/HeaderCollection.java
@@ -20,7 +20,6 @@
package org.apache.james.mailbox.elasticsearch.json;
import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
import java.util.HashSet;
import java.util.Locale;
import java.util.Optional;
@@ -37,6 +36,7 @@ import org.apache.james.mime4j.dom.address.Mailbox;
import org.apache.james.mime4j.field.address.LenientAddressParser;
import org.apache.james.mime4j.stream.Field;
import org.apache.james.mime4j.util.MimeUtil;
+import org.apache.james.util.date.ImapDateTimeFormatter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -157,7 +157,7 @@ public class HeaderCollection {
try {
return Optional.of(ZonedDateTime.parse(
sanitizeDateStringHeaderValue(value),
- DateTimeFormatter.RFC_1123_DATE_TIME));
+ ImapDateTimeFormatter.rfc5322()));
} catch (Exception e) {
LOGGER.info("Can not parse receive date " + value);
return Optional.empty();
http://git-wip-us.apache.org/repos/asf/james-project/blob/5095da26/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/json/HeaderCollectionTest.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/json/HeaderCollectionTest.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/json/HeaderCollectionTest.java
index d12cca8..b1f8fae 100644
--- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/json/HeaderCollectionTest.java
+++ b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/json/HeaderCollectionTest.java
@@ -223,6 +223,16 @@ public class HeaderCollectionTest {
}
@Test
+ public void partialYearShouldBeCompleted() {
+ HeaderCollection headerCollection = HeaderCollection.builder()
+ .add(new FieldImpl("Date", "Thu, 4 Jun 15 06:08:41 +0200"))
+ .build();
+
+ assertThat(DATE_TIME_FORMATTER.format(headerCollection.getSentDate().get()))
+ .isEqualTo("2015/06/04 06:08:41");
+ }
+
+ @Test
public void nonStandardDatesShouldBeRetreived() {
HeaderCollection headerCollection = HeaderCollection.builder()
.add(new FieldImpl("Date", "Thu, 4 Jun 2015 06:08:41 +0200 (UTC)"))
http://git-wip-us.apache.org/repos/asf/james-project/blob/5095da26/server/container/util-java8/src/main/java/org/apache/james/util/date/ImapDateTimeFormatter.java
----------------------------------------------------------------------
diff --git a/server/container/util-java8/src/main/java/org/apache/james/util/date/ImapDateTimeFormatter.java b/server/container/util-java8/src/main/java/org/apache/james/util/date/ImapDateTimeFormatter.java
new file mode 100644
index 0000000..049ad08
--- /dev/null
+++ b/server/container/util-java8/src/main/java/org/apache/james/util/date/ImapDateTimeFormatter.java
@@ -0,0 +1,94 @@
+/****************************************************************
+ * 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.util.date;
+
+import static java.time.temporal.ChronoField.DAY_OF_MONTH;
+import static java.time.temporal.ChronoField.DAY_OF_WEEK;
+import static java.time.temporal.ChronoField.HOUR_OF_DAY;
+import static java.time.temporal.ChronoField.MINUTE_OF_HOUR;
+import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
+import static java.time.temporal.ChronoField.SECOND_OF_MINUTE;
+import static java.time.temporal.ChronoField.YEAR;
+
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeFormatterBuilder;
+import java.time.format.SignStyle;
+
+import com.google.common.collect.ImmutableMap;
+
+public class ImapDateTimeFormatter {
+
+ private static final int INITIAL_YEAR = 1970;
+
+ public static DateTimeFormatter rfc5322() {
+ return new DateTimeFormatterBuilder()
+ .parseCaseInsensitive()
+ .parseLenient()
+ .optionalStart()
+ .appendText(DAY_OF_WEEK, dayOfWeek())
+ .appendLiteral(", ")
+ .optionalEnd()
+ .appendValue(DAY_OF_MONTH, 1, 2, SignStyle.NOT_NEGATIVE)
+ .appendLiteral(' ')
+ .appendText(MONTH_OF_YEAR, monthOfYear())
+ .appendLiteral(' ')
+ .appendValueReduced(YEAR, 2, 4, INITIAL_YEAR)
+ .appendLiteral(' ')
+ .appendValue(HOUR_OF_DAY, 2)
+ .appendLiteral(':')
+ .appendValue(MINUTE_OF_HOUR, 2)
+ .optionalStart()
+ .appendLiteral(':')
+ .appendValue(SECOND_OF_MINUTE, 2)
+ .optionalEnd()
+ .appendLiteral(' ')
+ .appendOffset("+HHMM", "GMT")
+ .toFormatter();
+ }
+
+ private static ImmutableMap<Long, String> monthOfYear() {
+ return ImmutableMap.<Long, String> builder()
+ .put(1L, "Jan")
+ .put(2L, "Feb")
+ .put(3L, "Mar")
+ .put(4L, "Apr")
+ .put(5L, "May")
+ .put(6L, "Jun")
+ .put(7L, "Jul")
+ .put(8L, "Aug")
+ .put(9L, "Sep")
+ .put(10L, "Oct")
+ .put(11L, "Nov")
+ .put(12L, "Dec")
+ .build();
+ }
+
+ private static ImmutableMap<Long, String> dayOfWeek() {
+ return ImmutableMap.<Long, String> builder()
+ .put(1L, "Mon")
+ .put(2L, "Tue")
+ .put(3L, "Wed")
+ .put(4L, "Thu")
+ .put(5L, "Fri")
+ .put(6L, "Sat")
+ .put(7L, "Sun")
+ .build();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/5095da26/server/container/util-java8/src/test/java/org/apache/james/util/date/ImapDateTimeFormatterTest.java
----------------------------------------------------------------------
diff --git a/server/container/util-java8/src/test/java/org/apache/james/util/date/ImapDateTimeFormatterTest.java b/server/container/util-java8/src/test/java/org/apache/james/util/date/ImapDateTimeFormatterTest.java
new file mode 100644
index 0000000..ec970fb
--- /dev/null
+++ b/server/container/util-java8/src/test/java/org/apache/james/util/date/ImapDateTimeFormatterTest.java
@@ -0,0 +1,252 @@
+/****************************************************************
+ * 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.util.date;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.time.DayOfWeek;
+import java.time.Month;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeParseException;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+public class ImapDateTimeFormatterTest {
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Test
+ public void dayOfWeekShouldBeParsed() {
+ ZonedDateTime dateTime = ZonedDateTime.parse("Wed, 28 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ assertThat(dateTime.getDayOfWeek()).isEqualTo(DayOfWeek.WEDNESDAY);
+ }
+
+ @Test
+ public void parseShouldNotThrowWhenDayOfWeekIsAbsent() {
+ ZonedDateTime.parse("28 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ }
+
+ @Test
+ public void parseShouldThrowWhenDayOfWeekIsWrong() {
+ expectedException.expect(DateTimeParseException.class);
+ // must be wednesday
+ ZonedDateTime.parse("Mon, 28 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ }
+
+ @Test
+ public void parseShouldThrowWhenDayOfWeekIsUnknow() {
+ expectedException.expect(DateTimeParseException.class);
+ ZonedDateTime.parse("Abc, 28 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ }
+
+ @Test
+ public void dayOfWeekShouldBeParsedWhenOneDigit() {
+ ZonedDateTime dateTime = ZonedDateTime.parse("3 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ assertThat(dateTime.getDayOfMonth()).isEqualTo(3);
+ }
+
+ @Test
+ public void dayOfWeekShouldBeParsedWhenTwoDigits() {
+ ZonedDateTime dateTime = ZonedDateTime.parse("13 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ assertThat(dateTime.getDayOfMonth()).isEqualTo(13);
+ }
+
+ @Test
+ public void parseShouldThrowWhenDayOfMonthIsAbsent() {
+ expectedException.expect(DateTimeParseException.class);
+ ZonedDateTime.parse("Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ }
+
+ @Test
+ public void parseShouldThrowWhenDayOfMonthIsNegative() {
+ expectedException.expect(DateTimeParseException.class);
+ ZonedDateTime.parse("-2 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ }
+
+ @Test
+ public void parseShouldThrowWhenDayOfMonthIsUnknow() {
+ expectedException.expect(DateTimeParseException.class);
+ ZonedDateTime.parse("64 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ }
+
+ @Test
+ public void monthOfYearShouldBeParsed() {
+ ZonedDateTime dateTime = ZonedDateTime.parse("Wed, 28 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ assertThat(dateTime.getMonth()).isEqualTo(Month.JUNE);
+ }
+
+ @Test
+ public void parseShouldThrowWhenMonthOfYearIsAbsent() {
+ expectedException.expect(DateTimeParseException.class);
+ ZonedDateTime.parse("Wed, 28 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ }
+
+ @Test
+ public void parseShouldThrowWhenMonthOfYearIsUnknow() {
+ expectedException.expect(DateTimeParseException.class);
+ ZonedDateTime.parse("Wed, 28 Abc 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ }
+
+ @Test
+ public void yearShouldBeParsedWhenFourDigits() {
+ ZonedDateTime dateTime = ZonedDateTime.parse("Wed, 28 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ assertThat(dateTime.getYear()).isEqualTo(2017);
+ }
+
+ @Test
+ public void yearShouldBeParsedWhenTwoDigitsGreaterThanInitialYear() {
+ ZonedDateTime dateTime = ZonedDateTime.parse("28 Jun 77 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ assertThat(dateTime.getYear()).isEqualTo(1977);
+ }
+
+ @Test
+ public void yearShouldBeParsedWhenTwoDigitsLesserThanInitialYear() {
+ ZonedDateTime dateTime = ZonedDateTime.parse("28 Jun 64 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ assertThat(dateTime.getYear()).isEqualTo(2064);
+ }
+
+ @Test
+ public void parseShouldThrowWhenYearIsAbsent() {
+ expectedException.expect(DateTimeParseException.class);
+ ZonedDateTime.parse("Wed, 28 Jun 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ }
+
+ @Test
+ public void parseShouldThrowWhenYearIsLesserThanTwoDigits() {
+ expectedException.expect(DateTimeParseException.class);
+ ZonedDateTime.parse("Wed, 28 Jun 1 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ }
+
+ @Test
+ public void parseShouldThrowWhenYearIsGreaterThanFourDigits() {
+ expectedException.expect(DateTimeParseException.class);
+ ZonedDateTime.parse("Wed, 28 Jun 12345 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ }
+
+ @Test
+ public void hourOfDayShouldBeParsed() {
+ ZonedDateTime dateTime = ZonedDateTime.parse("3 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ assertThat(dateTime.getHour()).isEqualTo(4);
+ }
+
+ @Test
+ public void parseShouldNotThrowWhenHourOfDayIsLesserThanTwoDigits() {
+ ZonedDateTime dateTime = ZonedDateTime.parse("3 Jun 2017 4:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ assertThat(dateTime.getHour()).isEqualTo(4);
+ }
+
+ @Test
+ public void parseShouldThrowWhenHourOfDayIsAbsent() {
+ expectedException.expect(DateTimeParseException.class);
+ ZonedDateTime.parse("3 Jun 2017 :35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ }
+
+ @Test
+ public void parseShouldThrowWhenHourOfDayIsGreaterThanTwoDigits() {
+ expectedException.expect(DateTimeParseException.class);
+ ZonedDateTime.parse("3 Jun 2017 123:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ }
+
+ @Test
+ public void parseShouldThrowWhenHourOfDayIsUnknow() {
+ expectedException.expect(DateTimeParseException.class);
+ ZonedDateTime.parse("3 Jun 2017 48:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ }
+
+ @Test
+ public void minuteOfHourShouldBeParsed() {
+ ZonedDateTime dateTime = ZonedDateTime.parse("3 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ assertThat(dateTime.getMinute()).isEqualTo(35);
+ }
+
+ @Test
+ public void parseShouldNotThrowWhenMinuteOfHourIsLesserThanTwoDigits() {
+ ZonedDateTime dateTime = ZonedDateTime.parse("3 Jun 2017 04:5:11 -0700", ImapDateTimeFormatter.rfc5322());
+ assertThat(dateTime.getMinute()).isEqualTo(5);
+ }
+
+ @Test
+ public void parseShouldThrowWhenMinuteOfHourIsAbsent() {
+ expectedException.expect(DateTimeParseException.class);
+ ZonedDateTime.parse("3 Jun 2017 04::11 -0700", ImapDateTimeFormatter.rfc5322());
+ }
+
+ @Test
+ public void parseShouldThrowWhenMinuteOfHourIsGreaterThanTwoDigits() {
+ expectedException.expect(DateTimeParseException.class);
+ ZonedDateTime.parse("3 Jun 2017 04:123:11 -0700", ImapDateTimeFormatter.rfc5322());
+ }
+
+ @Test
+ public void parseShouldThrowWhenMinuteOfHourDayIsUnknow() {
+ expectedException.expect(DateTimeParseException.class);
+ ZonedDateTime.parse("3 Jun 2017 04:72:11 -0700", ImapDateTimeFormatter.rfc5322());
+ }
+
+ @Test
+ public void secondOfMinuteShouldBeParsed() {
+ ZonedDateTime dateTime = ZonedDateTime.parse("3 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322());
+ assertThat(dateTime.getSecond()).isEqualTo(11);
+ }
+
+ @Test
+ public void parseShouldNotThrowWhenSecondOfMinuteIsLesserThanTwoDigits() {
+ ZonedDateTime dateTime = ZonedDateTime.parse("3 Jun 2017 04:35:1 -0700", ImapDateTimeFormatter.rfc5322());
+ assertThat(dateTime.getSecond()).isEqualTo(1);
+ }
+
+ @Test
+ public void parseShouldNotThrowWhenSecondOfMinuteIsAbsent() {
+ ZonedDateTime.parse("28 Jun 2017 04:35 -0700", ImapDateTimeFormatter.rfc5322());
+ }
+
+ @Test
+ public void parseShouldThrowWhenSecondOfMinuteIsGreaterThanTwoDigits() {
+ expectedException.expect(DateTimeParseException.class);
+ ZonedDateTime.parse("3 Jun 2017 04:35:123 -0700", ImapDateTimeFormatter.rfc5322());
+ }
+
+ @Test
+ public void parseShouldThrowWhenSecondOfMinuteDayIsUnknow() {
+ expectedException.expect(DateTimeParseException.class);
+ ZonedDateTime.parse("3 Jun 2017 04:35:78 -0700", ImapDateTimeFormatter.rfc5322());
+ }
+
+ @Test
+ public void offsetShouldBeParsed() {
+ ZonedDateTime dateTime = ZonedDateTime.parse("3 Jun 2017 04:35:11 -0712", ImapDateTimeFormatter.rfc5322());
+ assertThat(dateTime.getOffset()).isEqualTo(ZoneOffset.ofHoursMinutes(-7, -12));
+ }
+
+ @Test
+ public void parseShouldThrowWhenOffsetIsAbsent() {
+ expectedException.expect(DateTimeParseException.class);
+ ZonedDateTime.parse("3 Jun 2017 04:35:11", ImapDateTimeFormatter.rfc5322());
+ }
+
+ @Test
+ public void parseShouldThrowWhenOffsetIsUnknow() {
+ expectedException.expect(DateTimeParseException.class);
+ ZonedDateTime.parse("3 Jun 2017 04:35:11 +7894", ImapDateTimeFormatter.rfc5322());
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/5095da26/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
index b166420..562e1ea 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
@@ -50,6 +50,7 @@ import org.apache.james.mailbox.store.mail.model.Mailbox;
import org.apache.james.mailbox.store.probe.MailboxProbe;
import org.apache.james.modules.MailboxProbeImpl;
import org.apache.james.probe.DataProbe;
+import org.apache.james.util.date.ImapDateTimeFormatter;
import org.apache.james.utils.DataProbeImpl;
import org.apache.james.utils.JmapGuiceProbe;
import org.junit.After;
@@ -802,6 +803,29 @@ public abstract class GetMessageListMethodTest {
}
@Test
+ public void getMessageListShouldSortMessagesWhenDateDoesntHaveCentury() throws Exception {
+ mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
+
+ LocalDate date = LocalDate.parse("Wed, 28 Jun 17 09:23:01 +0200", ImapDateTimeFormatter.rfc5322());
+ ComposedMessageId message1 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), convertToDate(date.plusDays(1)), false, new Flags());
+ LocalDate date2 = LocalDate.parse("Tue, 27 Jun 2017 09:23:01 +0200", ImapDateTimeFormatter.rfc5322());
+ ComposedMessageId message2 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+ new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), convertToDate(date2), false, new Flags());
+ await();
+
+ given()
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessageList\", {\"sort\":[\"date desc\"]}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messageList"))
+ .body(ARGUMENTS + ".messageIds", contains(message1.getMessageId().serialize(), message2.getMessageId().serialize()));
+ }
+
+ @Test
public void getMessageListShouldSortMessagesWhenSortedByDateAsc() throws Exception {
mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org