You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2021/02/09 04:29:29 UTC
[james-project] 01/33: [REFACTORING] Get rid of JUNIT 4 usages in
CLI integration tests
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 16a26eabb9192513a5b1341d820e2119e7b40070
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Sat Feb 6 09:48:28 2021 +0700
[REFACTORING] Get rid of JUNIT 4 usages in CLI integration tests
---
.../james/cli/DataCommandsIntegrationTest.java | 65 ++++++++++------------
.../james/cli/MailboxCommandsIntegrationTest.java | 42 +++++++-------
.../james/cli/QuotaCommandsIntegrationTest.java | 54 +++++++++---------
.../james/cli/ReindexCommandIntegrationTest.java | 45 +++++++--------
.../cli/SieveQuotaCommandsIntegrationTest.java | 64 +++++++++------------
.../apache/james/cli/util/OutputCaptureTest.java | 11 ++--
.../src/test/resources/jmap.properties | 11 ----
7 files changed, 125 insertions(+), 167 deletions(-)
diff --git a/server/container/cli-integration/src/test/java/org/apache/james/cli/DataCommandsIntegrationTest.java b/server/container/cli-integration/src/test/java/org/apache/james/cli/DataCommandsIntegrationTest.java
index bdd9e80..09de657 100644
--- a/server/container/cli-integration/src/test/java/org/apache/james/cli/DataCommandsIntegrationTest.java
+++ b/server/container/cli-integration/src/test/java/org/apache/james/cli/DataCommandsIntegrationTest.java
@@ -24,7 +24,9 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.Mockito.mock;
import org.apache.james.GuiceJamesServer;
-import org.apache.james.MemoryJmapTestRule;
+import org.apache.james.JamesServerBuilder;
+import org.apache.james.JamesServerExtension;
+import org.apache.james.MemoryJamesServerMain;
import org.apache.james.cli.util.OutputCapture;
import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex;
import org.apache.james.modules.server.JMXServerModule;
@@ -32,47 +34,40 @@ import org.apache.james.rrt.api.SourceDomainIsNotInDomainListException;
import org.apache.james.rrt.lib.Mapping;
import org.apache.james.rrt.lib.MappingsImpl;
import org.apache.james.utils.DataProbeImpl;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-public class DataCommandsIntegrationTest {
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+class DataCommandsIntegrationTest {
public static final String DOMAIN = "domain.com";
public static final String USER = "chibenwa";
public static final String MAIL_ADDRESS = USER + "@" + DOMAIN;
public static final String PASSWORD = "12345";
private OutputCapture outputCapture;
- @Rule
- public MemoryJmapTestRule memoryJmap = new MemoryJmapTestRule();
- private GuiceJamesServer guiceJamesServer;
+ @RegisterExtension
+ JamesServerExtension memoryJmap = new JamesServerBuilder<>(JamesServerBuilder.defaultConfigurationProvider())
+ .server(conf -> MemoryJamesServerMain.createServer(conf)
+ .overrideWith(new JMXServerModule(),
+ binder -> binder.bind(ListeningMessageSearchIndex.class).toInstance(mock(ListeningMessageSearchIndex.class))))
+ .build();
private DataProbeImpl dataProbe;
- @Before
- public void setUp() throws Exception {
- guiceJamesServer = memoryJmap.jmapServer(new JMXServerModule(),
- binder -> binder.bind(ListeningMessageSearchIndex.class).toInstance(mock(ListeningMessageSearchIndex.class)));
- guiceJamesServer.start();
+ @BeforeEach
+ public void setUp(GuiceJamesServer guiceJamesServer) {
dataProbe = guiceJamesServer.getProbe(DataProbeImpl.class);
outputCapture = new OutputCapture();
}
- @After
- public void tearDown() {
- guiceJamesServer.stop();
- }
-
@Test
- public void addDomainShouldWork() throws Exception {
+ void addDomainShouldWork() throws Exception {
ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "ADDDOMAIN", DOMAIN});
assertThat(dataProbe.containsDomain(DOMAIN)).isTrue();
}
@Test
- public void removeDomainShouldWork() throws Exception {
+ void removeDomainShouldWork() throws Exception {
dataProbe.addDomain(DOMAIN);
ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "REMOVEDOMAIN", DOMAIN});
@@ -81,7 +76,7 @@ public class DataCommandsIntegrationTest {
}
@Test
- public void listDomainsShouldWork() throws Exception {
+ void listDomainsShouldWork() throws Exception {
dataProbe.addDomain(DOMAIN);
ServerCmd.executeAndOutputToStream(new String[] {"-h", "127.0.0.1", "-p", "9999", "listdomains"}, outputCapture.getPrintStream());
@@ -90,7 +85,7 @@ public class DataCommandsIntegrationTest {
}
@Test
- public void containsDomainShouldWork() throws Exception {
+ void containsDomainShouldWork() throws Exception {
dataProbe.addDomain(DOMAIN);
ServerCmd.executeAndOutputToStream(new String[] {"-h", "127.0.0.1", "-p", "9999", "containsdomain", DOMAIN},
@@ -101,7 +96,7 @@ public class DataCommandsIntegrationTest {
}
@Test
- public void addUserShouldWork() throws Exception {
+ void addUserShouldWork() throws Exception {
dataProbe.addDomain(DOMAIN);
ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "ADDUSER", MAIL_ADDRESS, PASSWORD});
@@ -110,7 +105,7 @@ public class DataCommandsIntegrationTest {
}
@Test
- public void removeUserShouldWork() throws Exception {
+ void removeUserShouldWork() throws Exception {
dataProbe.fluent()
.addDomain(DOMAIN)
.addUser(MAIL_ADDRESS, PASSWORD);
@@ -121,7 +116,7 @@ public class DataCommandsIntegrationTest {
}
@Test
- public void listUsersShouldWork() throws Exception {
+ void listUsersShouldWork() throws Exception {
dataProbe.fluent()
.addDomain(DOMAIN)
.addUser(MAIL_ADDRESS, PASSWORD);
@@ -133,7 +128,7 @@ public class DataCommandsIntegrationTest {
}
@Test
- public void addAddressMappingShouldWork() throws Exception {
+ void addAddressMappingShouldWork() throws Exception {
dataProbe.addDomain(DOMAIN);
String redirectionAddress = "redirect@apache.org";
@@ -149,7 +144,7 @@ public class DataCommandsIntegrationTest {
}
@Test
- public void addAddressMappingsShouldThrowWhenDomainIsNotInDomainList() throws Exception {
+ void addAddressMappingsShouldThrowWhenDomainIsNotInDomainList() throws Exception {
String redirectionAddress = "redirect@apache.org";
assertThatThrownBy(() -> ServerCmd.executeAndOutputToStream(
@@ -160,7 +155,7 @@ public class DataCommandsIntegrationTest {
}
@Test
- public void listMappingsShouldWork() throws Exception {
+ void listMappingsShouldWork() throws Exception {
dataProbe.addDomain(DOMAIN);
String redirectionAddress = "redirect@apache.org";
@@ -174,7 +169,7 @@ public class DataCommandsIntegrationTest {
}
@Test
- public void listUsersDomainMappingShouldWork() throws Exception {
+ void listUsersDomainMappingShouldWork() throws Exception {
dataProbe.addDomain(DOMAIN);
String redirectionAddress = "redirect@apache.org";
@@ -188,7 +183,7 @@ public class DataCommandsIntegrationTest {
}
@Test
- public void removeAddressMappingShouldWork() throws Exception {
+ void removeAddressMappingShouldWork() throws Exception {
dataProbe.addDomain(DOMAIN);
String redirectionAddress = "redirect@apache.org";
@@ -202,7 +197,7 @@ public class DataCommandsIntegrationTest {
@Test
- public void addRegexMappingsShouldThrowWhenDomainIsNotInDomainList() throws Exception {
+ void addRegexMappingsShouldThrowWhenDomainIsNotInDomainList() throws Exception {
String regexMapping = ".*@apache.org";
assertThatThrownBy(() -> ServerCmd.executeAndOutputToStream(
@@ -213,7 +208,7 @@ public class DataCommandsIntegrationTest {
}
@Test
- public void addRegexMappingShouldWork() throws Exception {
+ void addRegexMappingShouldWork() throws Exception {
dataProbe.addDomain(DOMAIN);
String regex = "regex";
@@ -229,7 +224,7 @@ public class DataCommandsIntegrationTest {
}
@Test
- public void removeRegexMappingShouldWork() throws Exception {
+ void removeRegexMappingShouldWork() throws Exception {
dataProbe.addDomain(DOMAIN);
String regex = "regex";
diff --git a/server/container/cli-integration/src/test/java/org/apache/james/cli/MailboxCommandsIntegrationTest.java b/server/container/cli-integration/src/test/java/org/apache/james/cli/MailboxCommandsIntegrationTest.java
index 9e131bb..88d2c63 100644
--- a/server/container/cli-integration/src/test/java/org/apache/james/cli/MailboxCommandsIntegrationTest.java
+++ b/server/container/cli-integration/src/test/java/org/apache/james/cli/MailboxCommandsIntegrationTest.java
@@ -23,50 +23,46 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import org.apache.james.GuiceJamesServer;
-import org.apache.james.MemoryJmapTestRule;
+import org.apache.james.JamesServerBuilder;
+import org.apache.james.JamesServerExtension;
+import org.apache.james.MemoryJamesServerMain;
import org.apache.james.cli.util.OutputCapture;
import org.apache.james.mailbox.model.MailboxConstants;
import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex;
import org.apache.james.modules.MailboxProbeImpl;
import org.apache.james.modules.server.JMXServerModule;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
-public class MailboxCommandsIntegrationTest {
+class MailboxCommandsIntegrationTest {
public static final String USER = "user";
public static final String MAILBOX = "mailboxExampleName";
- @Rule
- public MemoryJmapTestRule memoryJmap = new MemoryJmapTestRule();
- private GuiceJamesServer guiceJamesServer;
+ @RegisterExtension
+ JamesServerExtension memoryJmap = new JamesServerBuilder<>(JamesServerBuilder.defaultConfigurationProvider())
+ .server(conf -> MemoryJamesServerMain.createServer(conf)
+ .overrideWith(new JMXServerModule(),
+ binder -> binder.bind(ListeningMessageSearchIndex.class).toInstance(mock(ListeningMessageSearchIndex.class))))
+ .build();
private MailboxProbeImpl mailboxProbe;
private OutputCapture outputCapture;
- @Before
- public void setUp() throws Exception {
- guiceJamesServer = memoryJmap.jmapServer(new JMXServerModule(),
- binder -> binder.bind(ListeningMessageSearchIndex.class).toInstance(mock(ListeningMessageSearchIndex.class)));
- guiceJamesServer.start();
+ @BeforeEach
+ void setUp(GuiceJamesServer guiceJamesServer) {
outputCapture = new OutputCapture();
mailboxProbe = guiceJamesServer.getProbe(MailboxProbeImpl.class);
}
- @After
- public void tearDown() {
- guiceJamesServer.stop();
- }
-
@Test
- public void createMailboxShouldWork() throws Exception {
+ void createMailboxShouldWork() throws Exception {
ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "createmailbox", MailboxConstants.USER_NAMESPACE, USER, MAILBOX});
assertThat(mailboxProbe.listUserMailboxes(USER)).containsOnly(MAILBOX);
}
@Test
- public void deleteUserMailboxesShouldWork() throws Exception {
+ void deleteUserMailboxesShouldWork() throws Exception {
ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "createmailbox", MailboxConstants.USER_NAMESPACE, USER, MAILBOX});
ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "deleteusermailboxes", USER});
@@ -75,7 +71,7 @@ public class MailboxCommandsIntegrationTest {
}
@Test
- public void listUserMailboxesShouldWork() throws Exception {
+ void listUserMailboxesShouldWork() throws Exception {
ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "createmailbox", MailboxConstants.USER_NAMESPACE, USER, MAILBOX});
ServerCmd.executeAndOutputToStream(new String[] {"-h", "127.0.0.1", "-p", "9999", "listusermailboxes", USER},
@@ -86,7 +82,7 @@ public class MailboxCommandsIntegrationTest {
}
@Test
- public void deleteMailboxeShouldWork() throws Exception {
+ void deleteMailboxeShouldWork() throws Exception {
ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "createmailbox", MailboxConstants.USER_NAMESPACE, USER, MAILBOX});
ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "deletemailbox", MailboxConstants.USER_NAMESPACE, USER, MAILBOX});
diff --git a/server/container/cli-integration/src/test/java/org/apache/james/cli/QuotaCommandsIntegrationTest.java b/server/container/cli-integration/src/test/java/org/apache/james/cli/QuotaCommandsIntegrationTest.java
index 50d61ff..01d7cf5 100644
--- a/server/container/cli-integration/src/test/java/org/apache/james/cli/QuotaCommandsIntegrationTest.java
+++ b/server/container/cli-integration/src/test/java/org/apache/james/cli/QuotaCommandsIntegrationTest.java
@@ -25,7 +25,9 @@ import static org.mockito.Mockito.mock;
import java.util.Optional;
import org.apache.james.GuiceJamesServer;
-import org.apache.james.MemoryJmapTestRule;
+import org.apache.james.JamesServerBuilder;
+import org.apache.james.JamesServerExtension;
+import org.apache.james.MemoryJamesServerMain;
import org.apache.james.cli.util.OutputCapture;
import org.apache.james.core.quota.QuotaCountLimit;
import org.apache.james.core.quota.QuotaSizeLimit;
@@ -33,44 +35,38 @@ import org.apache.james.mailbox.model.QuotaRoot;
import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex;
import org.apache.james.modules.QuotaProbesImpl;
import org.apache.james.modules.server.JMXServerModule;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
-public class QuotaCommandsIntegrationTest {
+class QuotaCommandsIntegrationTest {
public static final String USER = "user";
public static final QuotaRoot QUOTA_ROOT = QuotaRoot.quotaRoot("#private&" + USER, Optional.empty());
private OutputCapture outputCapture;
- @Rule
- public MemoryJmapTestRule memoryJmap = new MemoryJmapTestRule();
- private GuiceJamesServer guiceJamesServer;
+ @RegisterExtension
+ JamesServerExtension memoryJmap = new JamesServerBuilder<>(JamesServerBuilder.defaultConfigurationProvider())
+ .server(conf -> MemoryJamesServerMain.createServer(conf)
+ .overrideWith(new JMXServerModule(),
+ binder -> binder.bind(ListeningMessageSearchIndex.class).toInstance(mock(ListeningMessageSearchIndex.class))))
+ .build();
private QuotaProbesImpl quotaProbe;
- @Before
- public void setUp() throws Exception {
- guiceJamesServer = memoryJmap.jmapServer(new JMXServerModule(),
- binder -> binder.bind(ListeningMessageSearchIndex.class).toInstance(mock(ListeningMessageSearchIndex.class)));
- guiceJamesServer.start();
+ @BeforeEach
+ void setUp(GuiceJamesServer guiceJamesServer) {
quotaProbe = guiceJamesServer.getProbe(QuotaProbesImpl.class);
outputCapture = new OutputCapture();
}
- @After
- public void tearDown() {
- guiceJamesServer.stop();
- }
-
@Test
- public void setGlobalMaxStorageShouldWork() throws Exception {
+ void setGlobalMaxStorageShouldWork() throws Exception {
ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setglobalmaxstoragequota", "36"});
assertThat(quotaProbe.getGlobalMaxStorage().map(QuotaSizeLimit::asLong)).contains(36L);
}
@Test
- public void getGlobalMaxStorageShouldWork() throws Exception {
+ void getGlobalMaxStorageShouldWork() throws Exception {
ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setglobalmaxstoragequota", "36M"});
ServerCmd.executeAndOutputToStream(new String[] {"-h", "127.0.0.1", "-p", "9999", "getglobalmaxstoragequota"},
@@ -81,14 +77,14 @@ public class QuotaCommandsIntegrationTest {
}
@Test
- public void setGlobalMaxMessageCountShouldWork() throws Exception {
+ void setGlobalMaxMessageCountShouldWork() throws Exception {
ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setglobalmaxmessagecountquota", "36"});
assertThat(quotaProbe.getGlobalMaxMessageCount().map(QuotaCountLimit::asLong)).contains(36L);
}
@Test
- public void getGlobalMaxMessageCountShouldWork() throws Exception {
+ void getGlobalMaxMessageCountShouldWork() throws Exception {
ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setglobalmaxmessagecountquota", "36"});
ServerCmd.executeAndOutputToStream(new String[] {"-h", "127.0.0.1", "-p", "9999", "getglobalmaxmessagecountquota"},
@@ -99,14 +95,14 @@ public class QuotaCommandsIntegrationTest {
}
@Test
- public void setMaxStorageShouldWork() throws Exception {
+ void setMaxStorageShouldWork() throws Exception {
ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setmaxstoragequota", QUOTA_ROOT.getValue(), "36"});
assertThat(quotaProbe.getMaxStorage(QUOTA_ROOT).map(QuotaSizeLimit::asLong)).contains(36L);
}
@Test
- public void getMaxStorageShouldWork() throws Exception {
+ void getMaxStorageShouldWork() throws Exception {
ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setmaxstoragequota", QUOTA_ROOT.getValue(), "1g"});
ServerCmd.executeAndOutputToStream(new String[] {"-h", "127.0.0.1", "-p", "9999", "getmaxstoragequota", QUOTA_ROOT.getValue()},
@@ -117,14 +113,14 @@ public class QuotaCommandsIntegrationTest {
}
@Test
- public void setMaxMessageCountShouldWork() throws Exception {
+ void setMaxMessageCountShouldWork() throws Exception {
ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setmaxmessagecountquota", QUOTA_ROOT.getValue(), "36"});
assertThat(quotaProbe.getMaxMessageCount(QUOTA_ROOT).map(QuotaCountLimit::asLong)).contains(36L);
}
@Test
- public void getMaxMessageCountShouldWork() throws Exception {
+ void getMaxMessageCountShouldWork() throws Exception {
ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setmaxmessagecountquota", QUOTA_ROOT.getValue(), "36"});
ServerCmd.executeAndOutputToStream(new String[] {"-h", "127.0.0.1", "-p", "9999", "getmaxmessagecountquota", QUOTA_ROOT.getValue()},
@@ -135,7 +131,7 @@ public class QuotaCommandsIntegrationTest {
}
@Test
- public void getStorageQuotaShouldWork() throws Exception {
+ void getStorageQuotaShouldWork() throws Exception {
ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setmaxstoragequota", QUOTA_ROOT.getValue(), "36"});
ServerCmd.executeAndOutputToStream(new String[] {"-h", "127.0.0.1", "-p", "9999", "getstoragequota", QUOTA_ROOT.getValue()},
@@ -146,7 +142,7 @@ public class QuotaCommandsIntegrationTest {
}
@Test
- public void getMessageCountQuotaShouldWork() throws Exception {
+ void getMessageCountQuotaShouldWork() throws Exception {
ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setmaxmessagecountquota", QUOTA_ROOT.getValue(), "36"});
ServerCmd.executeAndOutputToStream(new String[] {"-h", "127.0.0.1", "-p", "9999", "getmessagecountquota", QUOTA_ROOT.getValue()},
diff --git a/server/container/cli-integration/src/test/java/org/apache/james/cli/ReindexCommandIntegrationTest.java b/server/container/cli-integration/src/test/java/org/apache/james/cli/ReindexCommandIntegrationTest.java
index cdc2ca3..0b976ec 100644
--- a/server/container/cli-integration/src/test/java/org/apache/james/cli/ReindexCommandIntegrationTest.java
+++ b/server/container/cli-integration/src/test/java/org/apache/james/cli/ReindexCommandIntegrationTest.java
@@ -24,8 +24,9 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import org.apache.james.GuiceJamesServer;
-import org.apache.james.MemoryJmapTestRule;
+import org.apache.james.JamesServerBuilder;
+import org.apache.james.JamesServerExtension;
+import org.apache.james.MemoryJamesServerMain;
import org.apache.james.core.Username;
import org.apache.james.mailbox.indexer.ReIndexer;
import org.apache.james.mailbox.indexer.ReIndexer.RunningOptions;
@@ -35,47 +36,39 @@ import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex;
import org.apache.james.modules.server.JMXServerModule;
import org.apache.james.task.MemoryReferenceTask;
import org.apache.james.task.Task;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
import com.google.inject.name.Names;
-public class ReindexCommandIntegrationTest {
+class ReindexCommandIntegrationTest {
private static final String USER = "user";
- private ReIndexer reIndexer;
+ private ReIndexer reIndexer = mock(ReIndexer.class);
- @Rule
- public MemoryJmapTestRule memoryJmap = new MemoryJmapTestRule();
- private GuiceJamesServer guiceJamesServer;
+ @RegisterExtension
+ JamesServerExtension memoryJmap = new JamesServerBuilder<>(JamesServerBuilder.defaultConfigurationProvider())
+ .server(conf -> MemoryJamesServerMain.createServer(conf)
+ .overrideWith(new JMXServerModule()).overrideWith(
+ binder -> binder.bind(ReIndexer.class).annotatedWith(Names.named("reindexer")).toInstance(reIndexer),
+ binder -> binder.bind(ListeningMessageSearchIndex.class).toInstance(mock(ListeningMessageSearchIndex.class))))
+ .build();
- @Before
- public void setUp() throws Exception {
- reIndexer = mock(ReIndexer.class);
+ @BeforeEach
+ void setUp() throws Exception {
when(reIndexer.reIndex(any(RunningOptions.class))).thenReturn(new MemoryReferenceTask(() -> Task.Result.COMPLETED));
when(reIndexer.reIndex(any(MailboxPath.class), any(RunningOptions.class))).thenReturn(new MemoryReferenceTask(() -> Task.Result.COMPLETED));
- guiceJamesServer = memoryJmap.jmapServer(new JMXServerModule(),
- binder -> binder.bind(ListeningMessageSearchIndex.class).toInstance(mock(ListeningMessageSearchIndex.class)))
- .overrideWith(binder -> binder.bind(ReIndexer.class)
- .annotatedWith(Names.named("reindexer")).toInstance(reIndexer));
- guiceJamesServer.start();
- }
-
- @After
- public void tearDown() {
- guiceJamesServer.stop();
}
@Test
- public void reindexAllShouldWork() throws Exception {
+ void reindexAllShouldWork() throws Exception {
ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "reindexall"});
verify(reIndexer).reIndex(ReIndexer.RunningOptions.DEFAULT);
}
@Test
- public void reindexMailboxShouldWork() throws Exception {
+ void reindexMailboxShouldWork() throws Exception {
String mailbox = "mailbox";
ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "reindexmailbox", MailboxConstants.USER_NAMESPACE, USER, mailbox});
diff --git a/server/container/cli-integration/src/test/java/org/apache/james/cli/SieveQuotaCommandsIntegrationTest.java b/server/container/cli-integration/src/test/java/org/apache/james/cli/SieveQuotaCommandsIntegrationTest.java
index ac7d5b4..0bf0a10 100644
--- a/server/container/cli-integration/src/test/java/org/apache/james/cli/SieveQuotaCommandsIntegrationTest.java
+++ b/server/container/cli-integration/src/test/java/org/apache/james/cli/SieveQuotaCommandsIntegrationTest.java
@@ -20,58 +20,49 @@
package org.apache.james.cli;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.Mockito.mock;
import org.apache.james.GuiceJamesServer;
-import org.apache.james.MemoryJmapTestRule;
+import org.apache.james.JamesServerBuilder;
+import org.apache.james.JamesServerExtension;
+import org.apache.james.MemoryJamesServerMain;
import org.apache.james.cli.util.OutputCapture;
import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex;
import org.apache.james.modules.protocols.SieveProbeImpl;
import org.apache.james.modules.server.JMXServerModule;
import org.apache.james.sieverepository.api.exception.QuotaNotFoundException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.rules.TemporaryFolder;
-
-public class SieveQuotaCommandsIntegrationTest {
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+class SieveQuotaCommandsIntegrationTest {
public static final String USER = "user";
- @Rule
- public MemoryJmapTestRule memoryJmap = new MemoryJmapTestRule();
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
- @Rule
- public TemporaryFolder temporaryFolder = new TemporaryFolder();
- private GuiceJamesServer guiceJamesServer;
+ @RegisterExtension
+ JamesServerExtension memoryJmap = new JamesServerBuilder<>(JamesServerBuilder.defaultConfigurationProvider())
+ .server(conf -> MemoryJamesServerMain.createServer(conf)
+ .overrideWith(new JMXServerModule(),
+ binder -> binder.bind(ListeningMessageSearchIndex.class).toInstance(mock(ListeningMessageSearchIndex.class))))
+ .build();
private SieveProbeImpl sieveProbe;
private OutputCapture outputCapture;
- @Before
- public void setUp() throws Exception {
- guiceJamesServer = memoryJmap.jmapServer(new JMXServerModule(),
- binder -> binder.bind(ListeningMessageSearchIndex.class).toInstance(mock(ListeningMessageSearchIndex.class)));
- guiceJamesServer.start();
+ @BeforeEach
+ void setUp(GuiceJamesServer guiceJamesServer) {
outputCapture = new OutputCapture();
sieveProbe = guiceJamesServer.getProbe(SieveProbeImpl.class);
}
- @After
- public void tearDown() {
- guiceJamesServer.stop();
- }
-
@Test
- public void setSieveUserQuotaShouldWork() throws Exception {
+ void setSieveUserQuotaShouldWork() throws Exception {
ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setsieveuserquota", USER, "36"});
assertThat(sieveProbe.getSieveQuota(USER)).isEqualTo(36);
}
@Test
- public void getSieveUserQuotaShouldWork() throws Exception {
+ void getSieveUserQuotaShouldWork() throws Exception {
ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setsieveuserquota", USER, "36"});
ServerCmd.executeAndOutputToStream(new String[] {"-h", "127.0.0.1", "-p", "9999", "getsieveuserquota", USER},
@@ -82,14 +73,14 @@ public class SieveQuotaCommandsIntegrationTest {
}
@Test
- public void setSieveQuotaShouldWork() throws Exception {
+ void setSieveQuotaShouldWork() throws Exception {
ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setsievequota", "36"});
assertThat(sieveProbe.getSieveQuota()).isEqualTo(36);
}
@Test
- public void getSieveQuotaShouldWork() throws Exception {
+ void getSieveQuotaShouldWork() throws Exception {
ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "setsievequota", "36"});
ServerCmd.executeAndOutputToStream(new String[] {"-h", "127.0.0.1", "-p", "9999", "getsievequota"},
@@ -100,23 +91,22 @@ public class SieveQuotaCommandsIntegrationTest {
}
@Test
- public void removeSieveUserQuotaShouldWork() throws Exception {
+ void removeSieveUserQuotaShouldWork() throws Exception {
sieveProbe.setSieveQuota(USER, 36);
ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "removesieveuserquota", USER});
- expectedException.expect(QuotaNotFoundException.class);
- sieveProbe.getSieveQuota(USER);
+ assertThatThrownBy(() -> sieveProbe.getSieveQuota(USER))
+ .isInstanceOf(QuotaNotFoundException.class);
}
@Test
- public void removeSieveQuotaShouldWork() throws Exception {
+ void removeSieveQuotaShouldWork() throws Exception {
sieveProbe.setSieveQuota(36);
ServerCmd.doMain(new String[] {"-h", "127.0.0.1", "-p", "9999", "removesievequota"});
- expectedException.expect(QuotaNotFoundException.class);
- sieveProbe.getSieveQuota();
+ assertThatThrownBy(() -> sieveProbe.getSieveQuota())
+ .isInstanceOf(QuotaNotFoundException.class);
}
-
}
diff --git a/server/container/cli-integration/src/test/java/org/apache/james/cli/util/OutputCaptureTest.java b/server/container/cli-integration/src/test/java/org/apache/james/cli/util/OutputCaptureTest.java
index 24ca692..4e7232d 100644
--- a/server/container/cli-integration/src/test/java/org/apache/james/cli/util/OutputCaptureTest.java
+++ b/server/container/cli-integration/src/test/java/org/apache/james/cli/util/OutputCaptureTest.java
@@ -23,17 +23,17 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.nio.charset.StandardCharsets;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class OutputCaptureTest {
+class OutputCaptureTest {
@Test
- public void contentShouldBeEmptyByDefault() {
+ void contentShouldBeEmptyByDefault() {
assertThat(new OutputCapture().getContent()).isEmpty();
}
@Test
- public void contentShouldReturnOutputStreamInput() throws Exception {
+ void contentShouldReturnOutputStreamInput() throws Exception {
OutputCapture outputCapture = new OutputCapture();
String message = "Hello world!\n";
@@ -42,9 +42,8 @@ public class OutputCaptureTest {
assertThat(outputCapture.getContent()).isEqualTo(message);
}
-
@Test
- public void mixingReadsAndWritesShouldWork() throws Exception {
+ void mixingReadsAndWritesShouldWork() throws Exception {
OutputCapture outputCapture = new OutputCapture();
String message = "Hello world!\n";
outputCapture.getPrintStream().write(message.getBytes(StandardCharsets.UTF_8));
diff --git a/server/container/cli-integration/src/test/resources/jmap.properties b/server/container/cli-integration/src/test/resources/jmap.properties
deleted file mode 100644
index 34ab451..0000000
--- a/server/container/cli-integration/src/test/resources/jmap.properties
+++ /dev/null
@@ -1,11 +0,0 @@
-# Configuration file for JMAP
-
-tls.keystoreURL=file://conf/keystore
-tls.secret=james72laBalle
-
-#
-# If you wish to use OAuth authentication, you should provide a valid JWT public key.
-# The following entry specify the link to the URL of the public key file,
-# which should be a PEM format file.
-#
-jwt.publickeypem.url=file://conf/jwt_publickey
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org