JAMES-2553 Rewrite DefaultCassandraJamesServerTest 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/e6ab27c0 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/e6ab27c0 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/e6ab27c0 Branch: refs/heads/master Commit: e6ab27c01610ab6ac2bc7d07cc539041d25c77a8 Parents: 64c11d0 Author: Benoit Tellier <[email protected]> Authored: Mon Oct 1 11:24:52 2018 +0700 Committer: Benoit Tellier <[email protected]> Committed: Thu Oct 4 17:48:43 2018 +0700 ---------------------------------------------------------------------- .../james/DefaultCassandraJamesServerTest.java | 55 ++++++++------------ 1 file changed, 22 insertions(+), 33 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/e6ab27c0/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DefaultCassandraJamesServerTest.java ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DefaultCassandraJamesServerTest.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DefaultCassandraJamesServerTest.java index d4b2b75..7e6b6a9 100644 --- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DefaultCassandraJamesServerTest.java +++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DefaultCassandraJamesServerTest.java @@ -19,47 +19,36 @@ package org.apache.james; +import static org.apache.james.CassandraJamesServerMain.ALL_BUT_JMX_CASSANDRA_MODULE; import static org.assertj.core.api.Assertions.assertThat; -import java.io.IOException; - import org.apache.commons.configuration.HierarchicalConfiguration; +import org.apache.james.mailbox.extractor.TextExtractor; +import org.apache.james.mailbox.store.search.PDFTextExtractor; +import org.apache.james.modules.TestJMAPServerModule; import org.apache.james.server.core.configuration.ConfigurationProvider; import org.apache.james.utils.FailingPropertiesProvider; import org.apache.james.utils.PropertiesProvider; -import org.junit.After; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.Test; - -public class DefaultCassandraJamesServerTest { - - @ClassRule - public static DockerCassandraRule cassandra = new DockerCassandraRule(); - - @Rule - public CassandraJmapTestRule cassandraJmap = CassandraJmapTestRule.defaultTestRule(); - - private GuiceJamesServer guiceJamesServer; - - @Before - public void setUp() throws IOException { - guiceJamesServer = cassandraJmap.jmapServer(cassandra.getModule()) +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +class DefaultCassandraJamesServerTest { + private static final int LIMIT_TO_10_MESSAGES = 10; + + @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)) .overrideWith(binder -> binder.bind(PropertiesProvider.class).to(FailingPropertiesProvider.class)) - .overrideWith(binder -> binder.bind(ConfigurationProvider.class).toInstance(s -> new HierarchicalConfiguration())); - } - - @After - public void clean() { - guiceJamesServer.stop(); - } + .overrideWith(binder -> binder.bind(ConfigurationProvider.class).toInstance(s -> new HierarchicalConfiguration()))) + .build(); @Test - public void memoryJamesServerShouldStartWithNoConfigurationFile() throws Exception { - guiceJamesServer.start(); - - assertThat(guiceJamesServer.isStarted()).isTrue(); + void cassandraJamesServerShouldStartWithNoConfigurationFile(GuiceJamesServer server) { + assertThat(server.isStarted()).isTrue(); } - } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
