Repository: james-project Updated Branches: refs/heads/master 76900c276 -> 6bfbc8ed4
JAMES-2553 Rewrite CassandraMailRepositoryIntegrationTest test in JUNIT 5 Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/dbb4833c Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/dbb4833c Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/dbb4833c Branch: refs/heads/master Commit: dbb4833c8ec15a26b079d747a053d515b84b6d7a Parents: 8a678c3 Author: Benoit Tellier <[email protected]> Authored: Mon Oct 1 09:47:50 2018 +0700 Committer: Benoit Tellier <[email protected]> Committed: Thu Oct 4 17:48:42 2018 +0700 ---------------------------------------------------------------------- .../CassandraMailRepositoryIntegrationTest.java | 61 ++++++++------------ 1 file changed, 25 insertions(+), 36 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/dbb4833c/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraMailRepositoryIntegrationTest.java ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraMailRepositoryIntegrationTest.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraMailRepositoryIntegrationTest.java index 97c021a..0c3797a 100644 --- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraMailRepositoryIntegrationTest.java +++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraMailRepositoryIntegrationTest.java @@ -19,11 +19,15 @@ package org.apache.james; +import static org.apache.james.CassandraJamesServerMain.ALL_BUT_JMX_CASSANDRA_MODULE; import static org.awaitility.Duration.FIVE_HUNDRED_MILLISECONDS; import java.util.concurrent.TimeUnit; +import org.apache.james.mailbox.extractor.TextExtractor; +import org.apache.james.mailbox.store.search.PDFTextExtractor; import org.apache.james.mailrepository.api.MailRepositoryUrl; +import org.apache.james.modules.TestJMAPServerModule; import org.apache.james.modules.protocols.SmtpGuiceProbe; import org.apache.james.utils.DataProbeImpl; import org.apache.james.utils.MailRepositoryProbeImpl; @@ -31,47 +35,34 @@ import org.apache.james.utils.SMTPMessageSender; import org.awaitility.Awaitility; import org.awaitility.Duration; import org.awaitility.core.ConditionFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.Test; - -public class CassandraMailRepositoryIntegrationTest { +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; +class CassandraMailRepositoryIntegrationTest { private static final MailRepositoryUrl SENDER_DENIED_URL = MailRepositoryUrl.from("cassandra://var/mail/sender-denied/"); private static final Duration ONE_MILLISECOND = new Duration(1, TimeUnit.MILLISECONDS); + private static ConditionFactory await = Awaitility.with() + .pollInterval(FIVE_HUNDRED_MILLISECONDS) + .and() + .with() + .pollDelay(ONE_MILLISECOND) + .await(); + private static final int LIMIT_TO_10_MESSAGES = 10; - @ClassRule - public static DockerCassandraRule cassandra = new DockerCassandraRule(); - - @Rule - public CassandraJmapTestRule cassandraJmap = CassandraJmapTestRule.defaultTestRule(); - @Rule - public SMTPMessageSender smtpMessageSender = new SMTPMessageSender("other.com"); - - private GuiceJamesServer server; - private ConditionFactory await; + private SMTPMessageSender smtpMessageSender = new SMTPMessageSender("other.com"); - @Before - public void setup() throws Exception { - server = cassandraJmap.jmapServer(cassandra.getModule()); - server.start(); - await = Awaitility.with() - .pollInterval(FIVE_HUNDRED_MILLISECONDS) - .and() - .with() - .pollDelay(ONE_MILLISECOND) - .await(); - } - - @After - public void tearDown() { - server.stop(); - } + @RegisterExtension + static JamesServerExtension testExtension = new JamesServerExtensionBuilder() + .extension(new EmbeddedElasticSearchExtension()) + .extension(new CassandraExtension()) + .server(configuration -> GuiceJamesServer.forConfiguration(configuration) + .combineWith(ALL_BUT_JMX_CASSANDRA_MODULE) + .overrideWith(binder -> binder.bind(TextExtractor.class).to(PDFTextExtractor.class)) + .overrideWith(new TestJMAPServerModule(LIMIT_TO_10_MESSAGES))) + .build(); @Test - public void deniedSenderMailShouldBeStoredInCassandraMailRepositoryWhenConfigured() throws Exception { + void deniedSenderMailShouldBeStoredInCassandraMailRepositoryWhenConfigured(GuiceJamesServer server) throws Exception { server.getProbe(DataProbeImpl.class) .fluent() .addDomain("domain.com") @@ -83,6 +74,4 @@ public class CassandraMailRepositoryIntegrationTest { MailRepositoryProbeImpl repositoryProbe = server.getProbe(MailRepositoryProbeImpl.class); await.until(() -> repositoryProbe.getRepositoryMailCount(SENDER_DENIED_URL) == 1); } - - } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
