This is an automated email from the ASF dual-hosted git repository. rouazana pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
The following commit(s) were added to refs/heads/master by this push: new ec765e8 JAMES-2675 Rewrite flacky Cucumber test (not really retrying) to plain Java new d4edc46 Merge remote-tracking branch 'mine/JAMES-2675-masterfix' ec765e8 is described below commit ec765e8db71395e15189132bd980ebf29a2b5ba1 Author: Raphael Ouazana <raphael.ouaz...@linagora.com> AuthorDate: Fri Mar 8 16:04:38 2019 +0100 JAMES-2675 Rewrite flacky Cucumber test (not really retrying) to plain Java --- .../cucumber/CassandraIMAPInconsistenciesTest.java | 36 --------------- .../integration/GetMessageListMethodTest.java | 54 ++++++++++++++++++++++ .../methods/integration/cucumber/ImapStepdefs.java | 7 --- .../resources/cucumber/ImapConsistency.feature | 36 --------------- .../cucumber/MemoryIMAPInconsistenciesTest.java | 33 ------------- .../cucumber/RabbitMQIMAPInconsistenciesTest.java | 36 --------------- 6 files changed, 54 insertions(+), 148 deletions(-) diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraIMAPInconsistenciesTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraIMAPInconsistenciesTest.java deleted file mode 100644 index 740ab2b..0000000 --- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraIMAPInconsistenciesTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************** - * 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.jmap.cassandra.cucumber; - -import org.apache.james.jmap.categories.EnableCucumber; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; - -import cucumber.api.CucumberOptions; -import cucumber.api.junit.Cucumber; - -@RunWith(Cucumber.class) -@CucumberOptions(features = "classpath:cucumber/ImapConsistency.feature", - glue = {"org.apache.james.jmap.methods.integration", "org.apache.james.jmap.cassandra.cucumber"}, - tags = {"not @Ignore", "@BasicFeature"}, - strict = true) -@Category(EnableCucumber.class) -public class CassandraIMAPInconsistenciesTest { -} 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 869bca0..640d893 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 @@ -20,6 +20,7 @@ package org.apache.james.jmap.methods.integration; import static io.restassured.RestAssured.given; +import static io.restassured.RestAssured.with; import static org.apache.james.jmap.HttpJmapAuthentication.authenticateJamesUser; import static org.apache.james.jmap.JmapURIBuilder.baseUri; import static org.apache.james.jmap.TestingConstants.ALICE; @@ -29,7 +30,9 @@ import static org.apache.james.jmap.TestingConstants.BOB; import static org.apache.james.jmap.TestingConstants.BOB_PASSWORD; import static org.apache.james.jmap.TestingConstants.DOMAIN; import static org.apache.james.jmap.TestingConstants.NAME; +import static org.apache.james.jmap.TestingConstants.calmlyAwait; import static org.apache.james.jmap.TestingConstants.jmapRequestSpecBuilder; +import static org.apache.james.transport.mailets.remote.delivery.HeloNameProvider.LOCALHOST; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.containsInAnyOrder; @@ -45,6 +48,7 @@ import java.nio.charset.StandardCharsets; import java.time.LocalDate; import java.time.ZoneId; import java.util.Date; +import java.util.concurrent.TimeUnit; import javax.mail.Flags; @@ -69,10 +73,12 @@ import org.apache.james.mime4j.message.MultipartBuilder; import org.apache.james.mime4j.message.SingleBodyBuilder; import org.apache.james.modules.ACLProbeImpl; import org.apache.james.modules.MailboxProbeImpl; +import org.apache.james.modules.protocols.ImapGuiceProbe; import org.apache.james.probe.DataProbe; import org.apache.james.util.ClassLoaderUtils; import org.apache.james.util.date.ImapDateTimeFormatter; import org.apache.james.utils.DataProbeImpl; +import org.apache.james.utils.IMAPMessageReader; import org.apache.james.utils.JmapGuiceProbe; import org.junit.After; import org.junit.Before; @@ -2169,4 +2175,52 @@ public abstract class GetMessageListMethodTest { .body(ARGUMENTS + ".type", equalTo("invalidArguments")) .body(ARGUMENTS + ".description", containsString("value should be positive and less than 2^53")); } + + @Test + public void getMessageListShouldReturnTwoMessagesWhenCopiedAtOnceViaIMAP() throws Exception { + mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, ALICE, "mailbox"); + MailboxId otherMailboxId = mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, ALICE, "otherMailbox"); + + mailboxProbe.appendMessage(ALICE, MailboxPath.forUser(ALICE, "mailbox"), + MessageManager.AppendCommand.builder() + .build(Message.Builder.of() + .setSubject("test 1") + .setBody("content 1", StandardCharsets.UTF_8))); + + mailboxProbe.appendMessage(ALICE, MailboxPath.forUser(ALICE, "mailbox"), + MessageManager.AppendCommand.builder() + .build(Message.Builder.of() + .setSubject("test 2") + .setBody("content 2", StandardCharsets.UTF_8))); + + try (IMAPMessageReader imap = new IMAPMessageReader()) { + imap.connect(LOCALHOST, jmapServer.getProbe(ImapGuiceProbe.class).getImapPort()) + .login(ALICE, ALICE_PASSWORD) + .select("mailbox") + .copyAllMessagesInMailboxTo("otherMailbox"); + } + + await(); + + calmlyAwait + .atMost(30, TimeUnit.SECONDS) + .until(() -> twoMessagesFoundInMailbox(otherMailboxId)); + } + + private boolean twoMessagesFoundInMailbox(MailboxId mailboxId) { + try { + with() + .header("Authorization", aliceAccessToken.serialize()) + .body("[[\"getMessageList\", {\"filter\":{\"inMailboxes\":[\"" + mailboxId.serialize() + "\"]}}, \"#0\"]]") + .when() + .post("/jmap") + .then() + .statusCode(200) + .body(NAME, equalTo("messageList")) + .body(ARGUMENTS + ".messageIds", hasSize(2)); + return true; + } catch (AssertionError e) { + return false; + } + } } diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/ImapStepdefs.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/ImapStepdefs.java index 03194d0..b09b4d8 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/ImapStepdefs.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/ImapStepdefs.java @@ -122,13 +122,6 @@ public class ImapStepdefs { mainStepdefs.awaitMethod.run(); } - @Then("^the user copies via IMAP all messages from mailbox \"([^\"]*)\" to mailbox \"([^\"]*)\"$") - public void copyAllMessagesViaIMAPInMailbox(String sourceMailbox, String destinationMailbox) throws Throwable { - IMAPMessageReader imapMessageReader = imapConnections.get(sourceMailbox); - imapMessageReader.copyAllMessagesInMailboxTo(destinationMailbox); - mainStepdefs.awaitMethod.run(); - } - @Then("^the user has a IMAP RECENT and a notification about (\\d+) new messages on connection for mailbox \"([^\"]*)\"$") public void checkNotificationForNewMessageOnActiveConnection(int numberOfMessages, String mailbox) throws Throwable { IMAPMessageReader imapMessageReader = imapConnections.get(mailbox); diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/ImapConsistency.feature b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/ImapConsistency.feature deleted file mode 100644 index 4354208..0000000 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/ImapConsistency.feature +++ /dev/null @@ -1,36 +0,0 @@ -#*************************************************************** -# 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. * -# **************************************************************/ -Feature: Impact of IMAP on JMAP consistency - - Background: - Given a domain named "domain.tld" - And a connected user "usern...@domain.tld" - And "usern...@domain.tld" has a mailbox "source" - And "usern...@domain.tld" has a mailbox "trash" - - @BasicFeature - Scenario: Two messages copied in one step via IMAP should be seen via JMAP - Given the user has a message "m1" in "source" mailbox with subject "My awesome subject 1", content "This is the content 1" - And the user has a message "m2" in "source" mailbox with subject "My awesome subject 2", content "This is the content 2" - And the user has an open IMAP connection with mailbox "source" selected - And the user copies via IMAP all messages from mailbox "source" to mailbox "trash" - When "usern...@domain.tld" asks for message list in mailbox "trash" - Then the message list has size 2 - And the message list contains "m1" - And the message list contains "m2" \ No newline at end of file diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/cucumber/MemoryIMAPInconsistenciesTest.java b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/cucumber/MemoryIMAPInconsistenciesTest.java deleted file mode 100644 index 3ff06e2..0000000 --- a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/cucumber/MemoryIMAPInconsistenciesTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************** - - * 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.jmap.memory.cucumber; - -import org.junit.runner.RunWith; - -import cucumber.api.CucumberOptions; -import cucumber.api.junit.Cucumber; - -@RunWith(Cucumber.class) -@CucumberOptions(features = "classpath:cucumber/ImapConsistency.feature", - glue = {"org.apache.james.jmap.methods.integration", "org.apache.james.jmap.memory.cucumber"}, - strict = true) -public class MemoryIMAPInconsistenciesTest { -} diff --git a/server/protocols/jmap-integration-testing/rabbitmq-jmap-integration-testing/src/test/java/org/apache/james/jmap/rabbitmq/cucumber/RabbitMQIMAPInconsistenciesTest.java b/server/protocols/jmap-integration-testing/rabbitmq-jmap-integration-testing/src/test/java/org/apache/james/jmap/rabbitmq/cucumber/RabbitMQIMAPInconsistenciesTest.java deleted file mode 100644 index 5aec9d3..0000000 --- a/server/protocols/jmap-integration-testing/rabbitmq-jmap-integration-testing/src/test/java/org/apache/james/jmap/rabbitmq/cucumber/RabbitMQIMAPInconsistenciesTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************** - * 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.jmap.rabbitmq.cucumber; - -import org.apache.james.jmap.categories.EnableCucumber; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; - -import cucumber.api.CucumberOptions; -import cucumber.api.junit.Cucumber; - -@RunWith(Cucumber.class) -@CucumberOptions(features = "classpath:cucumber/ImapConsistency.feature", - glue = {"org.apache.james.jmap.methods.integration", "org.apache.james.jmap.rabbitmq.cucumber"}, - tags = {"not @Ignore", "@BasicFeature"}, - strict = true) -@Category(EnableCucumber.class) -public class RabbitMQIMAPInconsistenciesTest { -} --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org