You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2018/08/03 00:58:18 UTC
[3/8] james-project git commit: JAMES-2468 Add tests for quota
updates upon mailbox deletion
JAMES-2468 Add tests for quota updates upon mailbox deletion
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/31662d59
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/31662d59
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/31662d59
Branch: refs/heads/master
Commit: 31662d5969f5758754e4a0bbc846177a95d9c49c
Parents: a4214bd
Author: benwa <bt...@linagora.com>
Authored: Wed Aug 1 15:28:43 2018 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Fri Aug 3 07:56:28 2018 +0700
----------------------------------------------------------------------
.../manager/QuotaMessageManagerTest.java | 41 ++++++++++++++++++++
1 file changed, 41 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/31662d59/mailbox/api/src/test/java/org/apache/james/mailbox/manager/QuotaMessageManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/manager/QuotaMessageManagerTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/manager/QuotaMessageManagerTest.java
index f8e6308..cea2c5d 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/manager/QuotaMessageManagerTest.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/manager/QuotaMessageManagerTest.java
@@ -19,6 +19,8 @@
package org.apache.james.mailbox.manager;
+import java.nio.charset.StandardCharsets;
+
import javax.mail.Flags;
import org.apache.james.core.quota.QuotaCount;
@@ -31,8 +33,12 @@ import org.apache.james.mailbox.exception.OverQuotaException;
import org.apache.james.mailbox.mock.MockMail;
import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.model.MessageRange;
+import org.apache.james.mailbox.model.Quota;
+import org.apache.james.mailbox.model.QuotaRoot;
import org.apache.james.mailbox.quota.MaxQuotaManager;
import org.apache.james.mailbox.quota.QuotaRootResolver;
+import org.apache.james.mime4j.dom.Message;
+import org.assertj.core.api.SoftAssertions;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -142,5 +148,40 @@ public abstract class QuotaMessageManagerTest<T extends MailboxManager> {
resources.appendMessage(messageManager, session, new FlagsBuilder().add(Flags.Flag.SEEN).build());
}
+ @Test
+ public void deletingAMailboxShouldDecreaseCurrentQuota() throws Exception {
+ resources.fillMailbox();
+
+ mailboxManager.deleteMailbox(inbox, session);
+
+ QuotaRoot quotaRoot = quotaRootResolver.getQuotaRoot(inbox);
+ Quota<QuotaCount> messageQuota = resources.getQuotaManager().getMessageQuota(quotaRoot);
+ Quota<QuotaSize> storageQuota = resources.getQuotaManager().getStorageQuota(quotaRoot);
+ SoftAssertions.assertSoftly(softly -> {
+ softly.assertThat(messageQuota.getUsed()).isEqualTo(QuotaCount.count(0));
+ softly.assertThat(storageQuota.getUsed()).isEqualTo(QuotaSize.size(0));
+ });
+ }
+
+ @Test
+ public void deletingAMailboxShouldPreserveQuotaOfOtherMailboxes() throws Exception {
+ resources.fillMailbox();
+ mailboxManager.getMailbox(subFolder, session)
+ .appendMessage(MessageManager.AppendCommand.from(
+ Message.Builder.of()
+ .setSubject("test")
+ .setBody("testmail", StandardCharsets.UTF_8)
+ .build()), session);
+
+ mailboxManager.deleteMailbox(subFolder, session);
+
+ QuotaRoot quotaRoot = quotaRootResolver.getQuotaRoot(inbox);
+ Quota<QuotaCount> messageQuota = resources.getQuotaManager().getMessageQuota(quotaRoot);
+ Quota<QuotaSize> storageQuota = resources.getQuotaManager().getStorageQuota(quotaRoot);
+ SoftAssertions.assertSoftly(softly -> {
+ softly.assertThat(messageQuota.getUsed()).isEqualTo(QuotaCount.count(32));
+ softly.assertThat(storageQuota.getUsed()).isEqualTo(QuotaSize.size(7904));
+ });
+ }
}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org