james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rouaz...@apache.org
Subject [1/3] james-project git commit: JAMES-2604 Update james-server-mailbox-jmx to JUNIT 5
Date Fri, 23 Nov 2018 09:00:50 GMT
Repository: james-project
Updated Branches:
  refs/heads/master c21204b87 -> 211b3f1cf


JAMES-2604 Update james-server-mailbox-jmx to 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/211b3f1c
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/211b3f1c
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/211b3f1c

Branch: refs/heads/master
Commit: 211b3f1cf0bdf40bbfcc8c342b450cefcb64b2c6
Parents: 2ab8091
Author: Gautier DI FOLCO <gdifolco@linagora.com>
Authored: Tue Nov 20 15:45:01 2018 +0100
Committer: Raphael Ouazana <raphael.ouazana@linagora.com>
Committed: Fri Nov 23 09:59:45 2018 +0100

----------------------------------------------------------------------
 .../adapter/mailbox/MailboxManagementTest.java  | 154 ++++++++++---------
 1 file changed, 85 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/211b3f1c/server/container/mailbox-jmx/src/test/java/org/apache/james/adapter/mailbox/MailboxManagementTest.java
----------------------------------------------------------------------
diff --git a/server/container/mailbox-jmx/src/test/java/org/apache/james/adapter/mailbox/MailboxManagementTest.java
b/server/container/mailbox-jmx/src/test/java/org/apache/james/adapter/mailbox/MailboxManagementTest.java
index 39520e7..2d16cec 100644
--- a/server/container/mailbox-jmx/src/test/java/org/apache/james/adapter/mailbox/MailboxManagementTest.java
+++ b/server/container/mailbox-jmx/src/test/java/org/apache/james/adapter/mailbox/MailboxManagementTest.java
@@ -41,8 +41,8 @@ import org.apache.james.mailbox.store.mail.MessageMapper;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 import org.apache.james.mailbox.store.mail.model.MailboxMessage;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class MailboxManagementTest {
 
@@ -54,8 +54,8 @@ public class MailboxManagementTest {
     private MailboxSessionMapperFactory mapperFactory;
     private MailboxSession session;
 
-    @Before
-    public void setUp() throws Exception {
+    @BeforeEach
+    void setUp() throws Exception {
         StoreMailboxManager mailboxManager = new InMemoryIntegrationResources()
             .createMailboxManager(new SimpleGroupMembershipResolver());
         mapperFactory = mailboxManager.getMapperFactory();
@@ -66,28 +66,28 @@ public class MailboxManagementTest {
     }
 
     @Test
-    public void deleteMailboxesShouldDeleteMailboxes() throws Exception {
+    void deleteMailboxesShouldDeleteMailboxes() throws Exception {
         mapperFactory.createMailboxMapper(session).save(new SimpleMailbox(MailboxPath.forUser(USER,
"name"), UID_VALIDITY));
         mailboxManagerManagement.deleteMailboxes(USER);
         assertThat(mapperFactory.createMailboxMapper(session).list()).isEmpty();
     }
 
     @Test
-    public void deleteMailboxesShouldDeleteInbox() throws Exception {
+    void deleteMailboxesShouldDeleteInbox() throws Exception {
         mapperFactory.createMailboxMapper(session).save(new SimpleMailbox(MailboxPath.forUser(USER,
"INBOX"), UID_VALIDITY));
         mailboxManagerManagement.deleteMailboxes(USER);
         assertThat(mapperFactory.createMailboxMapper(session).list()).isEmpty();
     }
 
     @Test
-    public void deleteMailboxesShouldDeleteMailboxesChildren() throws Exception {
+    void deleteMailboxesShouldDeleteMailboxesChildren() throws Exception {
         mapperFactory.createMailboxMapper(session).save(new SimpleMailbox(MailboxPath.forUser(USER,
"INBOX.test"), UID_VALIDITY));
         mailboxManagerManagement.deleteMailboxes(USER);
         assertThat(mapperFactory.createMailboxMapper(session).list()).isEmpty();
     }
 
     @Test
-    public void deleteMailboxesShouldNotDeleteMailboxesBelongingToNotPrivateNamespace() throws
Exception {
+    void deleteMailboxesShouldNotDeleteMailboxesBelongingToNotPrivateNamespace() throws Exception
{
         Mailbox mailbox = new SimpleMailbox(new MailboxPath("#top", USER, "name"), UID_VALIDITY);
         mapperFactory.createMailboxMapper(session).save(mailbox);
         mailboxManagerManagement.deleteMailboxes(USER);
@@ -95,7 +95,7 @@ public class MailboxManagementTest {
     }
 
     @Test
-    public void deleteMailboxesShouldNotDeleteMailboxesBelongingToOtherUsers() throws Exception
{
+    void deleteMailboxesShouldNotDeleteMailboxesBelongingToOtherUsers() throws Exception
{
         Mailbox mailbox = new SimpleMailbox(MailboxPath.forUser("userbis", "name"), UID_VALIDITY);
         mapperFactory.createMailboxMapper(session).save(mailbox);
         mailboxManagerManagement.deleteMailboxes(USER);
@@ -103,24 +103,26 @@ public class MailboxManagementTest {
     }
 
     @Test
-    public void deleteMailboxesShouldDeleteMailboxesWithEmptyNames() throws Exception {
+    void deleteMailboxesShouldDeleteMailboxesWithEmptyNames() throws Exception {
         mapperFactory.createMailboxMapper(session).save(new SimpleMailbox(MailboxPath.forUser(USER,
""), UID_VALIDITY));
         mailboxManagerManagement.deleteMailboxes(USER);
         assertThat(mapperFactory.createMailboxMapper(session).list()).isEmpty();
     }
 
-    @Test(expected = NullPointerException.class)
-    public void deleteMailboxesShouldThrowOnNullUserName() throws Exception {
-        mailboxManagerManagement.deleteMailboxes(null);
+    @Test
+    void deleteMailboxesShouldThrowOnNullUserName() throws Exception {
+        assertThatThrownBy(() -> mailboxManagerManagement.deleteMailboxes(null))
+            .isInstanceOf(NullPointerException.class);
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void deleteMailboxesShouldThrowOnEmptyUserName() throws Exception {
-        mailboxManagerManagement.deleteMailboxes("");
+    @Test
+    void deleteMailboxesShouldThrowOnEmptyUserName() throws Exception {
+        assertThatThrownBy(() -> mailboxManagerManagement.deleteMailboxes(""))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    public void deleteMailboxesShouldDeleteMultipleMailboxes() throws Exception {
+    void deleteMailboxesShouldDeleteMultipleMailboxes() throws Exception {
         mapperFactory.createMailboxMapper(session).save(new SimpleMailbox(MailboxPath.forUser(USER,
"name"), UID_VALIDITY));
         mapperFactory.createMailboxMapper(session).save(new SimpleMailbox(MailboxPath.forUser(USER,
"INBOX"), UID_VALIDITY));
         mapperFactory.createMailboxMapper(session).save(new SimpleMailbox(MailboxPath.forUser(USER,
"INBOX.test"), UID_VALIDITY));
@@ -129,14 +131,14 @@ public class MailboxManagementTest {
     }
 
     @Test
-    public void createMailboxShouldCreateAMailbox() throws Exception {
+    void createMailboxShouldCreateAMailbox() throws Exception {
         mailboxManagerManagement.createMailbox(MailboxConstants.USER_NAMESPACE, USER, "name");
         assertThat(mapperFactory.createMailboxMapper(session).list()).hasSize(1);
         assertThat(mapperFactory.createMailboxMapper(session).findMailboxByPath(MailboxPath.forUser(USER,
"name"))).isNotNull();
     }
 
     @Test
-    public void createMailboxShouldThrowIfMailboxAlreadyExists() throws Exception {
+    void createMailboxShouldThrowIfMailboxAlreadyExists() throws Exception {
         MailboxPath path = MailboxPath.forUser(USER, "name");
         Mailbox mailbox = new SimpleMailbox(path, UID_VALIDITY);
         mapperFactory.createMailboxMapper(session).save(mailbox);
@@ -147,7 +149,7 @@ public class MailboxManagementTest {
     }
 
     @Test
-    public void createMailboxShouldNotCreateAdditionalMailboxesIfMailboxAlreadyExists() throws
Exception {
+    void createMailboxShouldNotCreateAdditionalMailboxesIfMailboxAlreadyExists() throws Exception
{
         MailboxPath path = MailboxPath.forUser(USER, "name");
         Mailbox mailbox = new SimpleMailbox(path, UID_VALIDITY);
         mapperFactory.createMailboxMapper(session).save(mailbox);
@@ -155,38 +157,44 @@ public class MailboxManagementTest {
         assertThat(mapperFactory.createMailboxMapper(session).list()).containsExactly(mailbox);
     }
 
-    @Test(expected = NullPointerException.class)
-    public void createMailboxShouldThrowOnNullNamespace() {
-        mailboxManagerManagement.createMailbox(null, "a", "a");
+    @Test
+    void createMailboxShouldThrowOnNullNamespace() {
+        assertThatThrownBy(() -> mailboxManagerManagement.createMailbox(null, "a", "a"))
+            .isInstanceOf(NullPointerException.class);
     }
 
-    @Test(expected = NullPointerException.class)
-    public void createMailboxShouldThrowOnNullUser() {
-        mailboxManagerManagement.createMailbox("a", null, "a");
+    @Test
+    void createMailboxShouldThrowOnNullUser() {
+        assertThatThrownBy(() -> mailboxManagerManagement.createMailbox("a", null, "a"))
+            .isInstanceOf(NullPointerException.class);
     }
 
-    @Test(expected = NullPointerException.class)
-    public void createMailboxShouldThrowOnNullName() {
-        mailboxManagerManagement.createMailbox("a", "a", null);
+    @Test
+    void createMailboxShouldThrowOnNullName() {
+        assertThatThrownBy(() -> mailboxManagerManagement.createMailbox("a", "a", null))
+            .isInstanceOf(NullPointerException.class);
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void createMailboxShouldThrowOnEmptyNamespace() {
-        mailboxManagerManagement.createMailbox("", "a", "a");
+    @Test
+    void createMailboxShouldThrowOnEmptyNamespace() {
+        assertThatThrownBy(() -> mailboxManagerManagement.createMailbox("", "a", "a"))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void createMailboxShouldThrowOnEmptyUser() {
-        mailboxManagerManagement.createMailbox("a", "", "a");
+    @Test
+    void createMailboxShouldThrowOnEmptyUser() {
+        assertThatThrownBy(() -> mailboxManagerManagement.createMailbox("a", "", "a"))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void createMailboxShouldThrowOnEmptyName() {
-        mailboxManagerManagement.createMailbox("a", "a", "");
+    @Test
+    void createMailboxShouldThrowOnEmptyName() {
+        assertThatThrownBy(() -> mailboxManagerManagement.createMailbox("a", "a", ""))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    public void listMailboxesShouldReturnUserMailboxes() throws Exception {
+    void listMailboxesShouldReturnUserMailboxes() throws Exception {
         Mailbox mailbox1 = new SimpleMailbox(new MailboxPath("#top", USER, "name1"), UID_VALIDITY);
         Mailbox mailbox2 = new SimpleMailbox(MailboxPath.forUser(USER, "name2"), UID_VALIDITY);
         Mailbox mailbox3 = new SimpleMailbox(MailboxPath.forUser("other_user", "name3"),
UID_VALIDITY);
@@ -202,25 +210,27 @@ public class MailboxManagementTest {
         assertThat(mailboxManagerManagement.listMailboxes(USER)).containsOnly("name2", "name4",
"INBOX", "INBOX.toto");
     }
 
-    @Test(expected = NullPointerException.class)
-    public void listMailboxesShouldThrowOnNullUserName() {
-        mailboxManagerManagement.listMailboxes(null);
+    @Test
+    void listMailboxesShouldThrowOnNullUserName() {
+        assertThatThrownBy(() -> mailboxManagerManagement.listMailboxes(null))
+            .isInstanceOf(NullPointerException.class);
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void listMailboxesShouldThrowOnEmptyUserName() {
-        mailboxManagerManagement.listMailboxes("");
+    @Test
+    void listMailboxesShouldThrowOnEmptyUserName() {
+        assertThatThrownBy(() -> mailboxManagerManagement.listMailboxes(""))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
     @Test
-    public void deleteMailboxShouldDeleteGivenMailbox() throws Exception {
+    void deleteMailboxShouldDeleteGivenMailbox() throws Exception {
         mapperFactory.createMailboxMapper(session).save(new SimpleMailbox(MailboxPath.forUser(USER,
"name"), UID_VALIDITY));
         mailboxManagerManagement.deleteMailbox(MailboxConstants.USER_NAMESPACE, USER, "name");
         assertThat(mapperFactory.createMailboxMapper(session).list()).isEmpty();
     }
 
     @Test
-    public void deleteMailboxShouldNotDeleteGivenMailboxIfWrongNamespace() throws Exception
{
+    void deleteMailboxShouldNotDeleteGivenMailboxIfWrongNamespace() throws Exception {
         Mailbox mailbox = new SimpleMailbox(new MailboxPath("#top", USER, "name"), UID_VALIDITY);
         mapperFactory.createMailboxMapper(session).save(mailbox);
         mailboxManagerManagement.deleteMailbox(MailboxConstants.USER_NAMESPACE, USER, "name");
@@ -228,7 +238,7 @@ public class MailboxManagementTest {
     }
 
     @Test
-    public void deleteMailboxShouldNotDeleteGivenMailboxIfWrongUser() throws Exception {
+    void deleteMailboxShouldNotDeleteGivenMailboxIfWrongUser() throws Exception {
         Mailbox mailbox = new SimpleMailbox(MailboxPath.forUser("userbis", "name"), UID_VALIDITY);
         mapperFactory.createMailboxMapper(session).save(mailbox);
         mailboxManagerManagement.deleteMailbox(MailboxConstants.USER_NAMESPACE, USER, "name");
@@ -236,7 +246,7 @@ public class MailboxManagementTest {
     }
 
     @Test
-    public void deleteMailboxShouldNotDeleteGivenMailboxIfWrongName() throws Exception {
+    void deleteMailboxShouldNotDeleteGivenMailboxIfWrongName() throws Exception {
         Mailbox mailbox = new SimpleMailbox(MailboxPath.forUser(USER, "wrong_name"), UID_VALIDITY);
         mapperFactory.createMailboxMapper(session).save(mailbox);
         mailboxManagerManagement.deleteMailbox(MailboxConstants.USER_NAMESPACE, USER, "name");
@@ -244,7 +254,7 @@ public class MailboxManagementTest {
     }
 
     @Test
-    public void importEmlFileToMailboxShouldImportEmlFileToGivenMailbox() throws Exception
{
+    void importEmlFileToMailboxShouldImportEmlFileToGivenMailbox() throws Exception {
         Mailbox mailbox = new SimpleMailbox(MailboxPath.forUser(USER, "name"),
                 UID_VALIDITY);
         mapperFactory.createMailboxMapper(session).save(mailbox);
@@ -261,7 +271,7 @@ public class MailboxManagementTest {
     }
 
     @Test
-    public void importEmlFileToMailboxShouldNotImportEmlFileWithWrongPathToGivenMailbox()
throws Exception {
+    void importEmlFileToMailboxShouldNotImportEmlFileWithWrongPathToGivenMailbox() throws
Exception {
         Mailbox mailbox = new SimpleMailbox(MailboxPath.forUser(USER, "name"),
                 UID_VALIDITY);
         mapperFactory.createMailboxMapper(session).save(mailbox);
@@ -275,34 +285,40 @@ public class MailboxManagementTest {
     }
 
 
-    @Test(expected = NullPointerException.class)
-    public void deleteMailboxShouldThrowOnNullNamespace() {
-        mailboxManagerManagement.deleteMailbox(null, "a", "a");
+    @Test
+    void deleteMailboxShouldThrowOnNullNamespace() {
+        assertThatThrownBy(() -> mailboxManagerManagement.deleteMailbox(null, "a", "a"))
+            .isInstanceOf(NullPointerException.class);
     }
 
-    @Test(expected = NullPointerException.class)
-    public void deleteMailboxShouldThrowOnNullUser() {
-        mailboxManagerManagement.deleteMailbox("a", null, "a");
+    @Test
+    void deleteMailboxShouldThrowOnNullUser() {
+        assertThatThrownBy(() -> mailboxManagerManagement.deleteMailbox("a", null, "a"))
+            .isInstanceOf(NullPointerException.class);
     }
 
-    @Test(expected = NullPointerException.class)
-    public void deleteMailboxShouldThrowOnNullName() {
-        mailboxManagerManagement.deleteMailbox("a", "a", null);
+    @Test
+    void deleteMailboxShouldThrowOnNullName() {
+        assertThatThrownBy(() -> mailboxManagerManagement.deleteMailbox("a", "a", null))
+            .isInstanceOf(NullPointerException.class);
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void deleteMailboxShouldThrowOnEmptyNamespace() {
-        mailboxManagerManagement.deleteMailbox("", "a", "a");
+    @Test
+    void deleteMailboxShouldThrowOnEmptyNamespace() {
+        assertThatThrownBy(() -> mailboxManagerManagement.deleteMailbox("", "a", "a"))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void deleteMailboxShouldThrowOnEmptyUser() {
-        mailboxManagerManagement.deleteMailbox("a", "", "a");
+    @Test
+    void deleteMailboxShouldThrowOnEmptyUser() {
+        assertThatThrownBy(() -> mailboxManagerManagement.deleteMailbox("a", "", "a"))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void deleteMailboxShouldThrowOnEmptyName() {
-        mailboxManagerManagement.deleteMailbox("a", "a", "");
+    @Test
+    void deleteMailboxShouldThrowOnEmptyName() {
+        assertThatThrownBy(() -> mailboxManagerManagement.deleteMailbox("a", "a", ""))
+            .isInstanceOf(IllegalArgumentException.class);
     }
 
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message