james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [01/22] james-project git commit: MAILBOX-350 Review MailboxManagerTest: Get rid of ExpectedException
Date Wed, 21 Nov 2018 10:07:11 GMT
Repository: james-project
Updated Branches:
  refs/heads/master 466a4f461 -> 3a25b92a8


MAILBOX-350 Review MailboxManagerTest: Get rid of ExpectedException


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/17e5ecad
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/17e5ecad
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/17e5ecad

Branch: refs/heads/master
Commit: 17e5ecad5d45dc00c0d12f017966f3abf72772f5
Parents: 466a4f4
Author: Benoit Tellier <btellier@linagora.com>
Authored: Tue Nov 20 13:13:11 2018 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Wed Nov 21 16:40:17 2018 +0700

----------------------------------------------------------------------
 .../james/mailbox/MailboxManagerTest.java       | 32 +++++++++-----------
 1 file changed, 15 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/17e5ecad/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
index 8ad168e..3d42fec 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
@@ -90,9 +90,6 @@ public abstract class MailboxManagerTest {
     private static final List<MailboxAnnotation> ANNOTATIONS = ImmutableList.of(PRIVATE_ANNOTATION,
SHARED_ANNOTATION);
 
     @Rule
-    public ExpectedException expected = ExpectedException.none();
-
-    @Rule
     public JUnitSoftAssertions softly = new JUnitSoftAssertions();
 
     private MailboxManager mailboxManager;
@@ -156,12 +153,13 @@ public abstract class MailboxManagerTest {
 
     @Test
     public void user1ShouldNotBeAbleToCreateInboxTwice() throws MailboxException, UnsupportedEncodingException
{
-        expected.expect(MailboxException.class);
         session = mailboxManager.createSystemSession(USER_1);
         mailboxManager.startProcessingRequest(session);
         MailboxPath inbox = MailboxPath.inbox(session);
         mailboxManager.createMailbox(inbox, session);
-        mailboxManager.createMailbox(inbox, session);
+
+        assertThatThrownBy(() -> mailboxManager.createMailbox(inbox, session))
+            .isInstanceOf(MailboxException.class);
     }
 
     @Test
@@ -319,11 +317,11 @@ public abstract class MailboxManagerTest {
     @Test
     public void updateAnnotationsShouldThrowExceptionIfMailboxDoesNotExist() throws MailboxException
{
         Assume.assumeTrue(mailboxManager.hasCapability(MailboxCapabilities.Annotation));
-        expected.expect(MailboxException.class);
         session = mailboxManager.createSystemSession(USER_2);
         MailboxPath inbox = MailboxPath.inbox(session);
 
-        mailboxManager.updateAnnotations(inbox, session, ImmutableList.of(PRIVATE_ANNOTATION));
+        assertThatThrownBy(() -> mailboxManager.updateAnnotations(inbox, session, ImmutableList.of(PRIVATE_ANNOTATION)))
+            .isInstanceOf(MailboxException.class);
     }
 
     @Test
@@ -351,11 +349,11 @@ public abstract class MailboxManagerTest {
     @Test
     public void getAllAnnotationsShouldThrowExceptionIfMailboxDoesNotExist() throws MailboxException
{
         Assume.assumeTrue(mailboxManager.hasCapability(MailboxCapabilities.Annotation));
-        expected.expect(MailboxException.class);
         session = mailboxManager.createSystemSession(USER_2);
         MailboxPath inbox = MailboxPath.inbox(session);
 
-        mailboxManager.getAllAnnotations(inbox, session);
+        assertThatThrownBy(() -> mailboxManager.getAllAnnotations(inbox, session))
+            .isInstanceOf(MailboxException.class);
     }
 
     @Test
@@ -374,11 +372,11 @@ public abstract class MailboxManagerTest {
     @Test
     public void getAnnotationsByKeysShouldThrowExceptionIfMailboxDoesNotExist() throws MailboxException
{
         Assume.assumeTrue(mailboxManager.hasCapability(MailboxCapabilities.Annotation));
-        expected.expect(MailboxException.class);
         session = mailboxManager.createSystemSession(USER_2);
         MailboxPath inbox = MailboxPath.inbox(session);
 
-        mailboxManager.getAnnotationsByKeys(inbox, session, ImmutableSet.of(PRIVATE_KEY));
+        assertThatThrownBy(() -> mailboxManager.getAnnotationsByKeys(inbox, session, ImmutableSet.of(PRIVATE_KEY)))
+            .isInstanceOf(MailboxException.class);
     }
 
     @Test
@@ -397,11 +395,11 @@ public abstract class MailboxManagerTest {
     @Test
     public void getAnnotationsByKeysWithAllDepthShouldThrowExceptionWhenMailboxDoesNotExist()
throws MailboxException {
         Assume.assumeTrue(mailboxManager.hasCapability(MailboxCapabilities.Annotation));
-        expected.expect(MailboxException.class);
         session = mailboxManager.createSystemSession(USER_2);
         MailboxPath inbox = MailboxPath.inbox(session);
 
-        mailboxManager.getAnnotationsByKeysWithAllDepth(inbox, session, ImmutableSet.of(PRIVATE_KEY));
+        assertThatThrownBy(() -> mailboxManager.getAnnotationsByKeysWithAllDepth(inbox,
session, ImmutableSet.of(PRIVATE_KEY)))
+            .isInstanceOf(MailboxException.class);
     }
 
     @Test
@@ -420,12 +418,12 @@ public abstract class MailboxManagerTest {
     @Test
     public void updateAnnotationsShouldThrowExceptionIfAnnotationDataIsOverLimitation() throws
MailboxException {
         Assume.assumeTrue(mailboxManager.hasCapability(MailboxCapabilities.Annotation));
-        expected.expect(AnnotationException.class);
         session = mailboxManager.createSystemSession(USER_2);
         MailboxPath inbox = MailboxPath.inbox(session);
         mailboxManager.createMailbox(inbox, session);
 
-        mailboxManager.updateAnnotations(inbox, session, ImmutableList.of(MailboxAnnotation.newInstance(PRIVATE_KEY,
"The limitation of data is less than 30")));
+        assertThatThrownBy(() -> mailboxManager.updateAnnotations(inbox, session, ImmutableList.of(MailboxAnnotation.newInstance(PRIVATE_KEY,
"The limitation of data is less than 30"))))
+            .isInstanceOf(AnnotationException.class);
     }
 
     @Test
@@ -446,7 +444,6 @@ public abstract class MailboxManagerTest {
     @Test
     public void updateAnnotationsShouldThrowExceptionIfRequestCreateNewButMailboxIsOverLimit()
throws MailboxException {
         Assume.assumeTrue(mailboxManager.hasCapability(MailboxCapabilities.Annotation));
-        expected.expect(MailboxException.class);
         session = mailboxManager.createSystemSession(USER_2);
         MailboxPath inbox = MailboxPath.inbox(session);
         mailboxManager.createMailbox(inbox, session);
@@ -457,7 +454,8 @@ public abstract class MailboxManagerTest {
         builder.add(MailboxAnnotation.newInstance(new MailboxAnnotationKey("/private/comment3"),
"AnyValue"));
         builder.add(MailboxAnnotation.newInstance(new MailboxAnnotationKey("/private/comment4"),
"AnyValue"));
 
-        mailboxManager.updateAnnotations(inbox, session, builder.build());
+        assertThatThrownBy(() -> mailboxManager.updateAnnotations(inbox, session, builder.build()))
+            .isInstanceOf(MailboxException.class);
     }
 
     @Test


---------------------------------------------------------------------
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