JAMES-1823 Enable quota for testing and test

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

Branch: refs/heads/master
Commit: e2e0f1032a7e140f3a83cdbaacf94d7358dc65e7
Parents: e30634c
Author: quynhn <qngu...@linagora.com>
Authored: Thu Apr 27 17:30:24 2017 +0700
Committer: benwa <btell...@linagora.com>
Committed: Thu May 4 09:25:52 2017 +0700

----------------------------------------------------------------------
 .../resources/META-INF/spring/quota-alias.xml   |  6 +-
 .../event/DefaultDelegatingMailboxListener.java | 10 +--
 .../app/spring/JamesSpringContextTest.java      | 65 ++++++++++++++++++++
 server/app/src/test/resources/mailbox.xml       |  2 +-
 4 files changed, 75 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/e2e0f103/mailbox/spring/src/test/resources/META-INF/spring/quota-alias.xml
----------------------------------------------------------------------
diff --git a/mailbox/spring/src/test/resources/META-INF/spring/quota-alias.xml 
b/mailbox/spring/src/test/resources/META-INF/spring/quota-alias.xml
index 57552c6..c91f1f7 100644
--- a/mailbox/spring/src/test/resources/META-INF/spring/quota-alias.xml
+++ b/mailbox/spring/src/test/resources/META-INF/spring/quota-alias.xml
@@ -22,9 +22,9 @@
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd";>
 
-    <alias name="noMaxQuotaManager" alias="maxQuotaManager"/>
-    <alias name="noQuotaManager" alias="quotaManager"/>
-    <alias name="noQuotaUpdater" alias="quotaUpdater"/>
+    <alias name="fixedMaxQuotaManager" alias="maxQuotaManager"/>
+    <alias name="storeQuotaManager" alias="quotaManager"/>
+    <alias name="eventQuotaUpdater" alias="quotaUpdater"/>
     <alias name="defaultQuotaRootResolver" alias="quotaRootResolver"/>
     <alias name="jpa-sessionMapperFactory" alias="messageMapperFactory"/>
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/e2e0f103/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/DefaultDelegatingMailboxListener.java
----------------------------------------------------------------------
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/DefaultDelegatingMailboxListener.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/DefaultDelegatingMailboxListener.java
index d4c0b04..b4faef1 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/DefaultDelegatingMailboxListener.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/DefaultDelegatingMailboxListener.java
@@ -19,15 +19,14 @@
 
 package org.apache.james.mailbox.store.event;
 
-import java.util.Collection;
-
-import javax.inject.Inject;
-
 import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.MailboxPath;
 
+import javax.inject.Inject;
+import java.util.Collection;
+
 /**
  * Receive a {@link org.apache.james.mailbox.MailboxListener.Event} and 
delegate it to an other
  * {@link MailboxListener} depending on the registered name
@@ -110,4 +109,7 @@ public class DefaultDelegatingMailboxListener implements 
DelegatingMailboxListen
         }
     }
 
+    public MailboxListenerRegistry getRegistry() {
+        return registry;
+    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/e2e0f103/server/app/src/test/java/org/apache/james/app/spring/JamesSpringContextTest.java
----------------------------------------------------------------------
diff --git 
a/server/app/src/test/java/org/apache/james/app/spring/JamesSpringContextTest.java
 
b/server/app/src/test/java/org/apache/james/app/spring/JamesSpringContextTest.java
new file mode 100644
index 0000000..a3743fd
--- /dev/null
+++ 
b/server/app/src/test/java/org/apache/james/app/spring/JamesSpringContextTest.java
@@ -0,0 +1,65 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.app.spring;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import org.apache.james.container.spring.context.JamesServerApplicationContext;
+import org.apache.james.mailbox.MailboxListener;
+import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
+import org.apache.james.mailbox.store.quota.ListeningCurrentQuotaUpdater;
+
+import org.assertj.core.api.Condition;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JamesSpringContextTest {
+    private static final Condition<MailboxListener> QUOTA_UPDATER_LISTENER = 
new Condition<MailboxListener>() {
+        @Override
+        public boolean matches(MailboxListener mailboxListener) {
+            return mailboxListener instanceof ListeningCurrentQuotaUpdater;
+        }
+    };
+    private static final int ONCE = 1;
+    private JamesServerApplicationContext context;
+
+    @Before
+    public void setup() throws Exception {
+        context = new JamesServerApplicationContext(new String[] { 
"META-INF/org/apache/james/spring-server.xml" });
+        context.registerShutdownHook();
+        context.start();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        context.stop();
+        context.destroy();
+    }
+
+    @Test
+    public void springShouldLoadAndAddOnlyOneQuotaUpdaterListener() {
+        DefaultDelegatingMailboxListener mailboxListener = 
context.getBean(DefaultDelegatingMailboxListener.class);
+
+        assertThat(mailboxListener.getRegistry().getGlobalListeners())
+            .hasSize(2)
+            .areExactly(ONCE, QUOTA_UPDATER_LISTENER);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/e2e0f103/server/app/src/test/resources/mailbox.xml
----------------------------------------------------------------------
diff --git a/server/app/src/test/resources/mailbox.xml 
b/server/app/src/test/resources/mailbox.xml
index 22c2e3e..366d377 100644
--- a/server/app/src/test/resources/mailbox.xml
+++ b/server/app/src/test/resources/mailbox.xml
@@ -25,7 +25,7 @@
 
 <mailbox>
     <!-- supported providers are: -->
-    <!-- jpa, jcr, maildir, hbase, memory, maildir, jpa -->
+    <!-- jpa, jcr, maildir, hbase, memory -->
     <!--  -->
     <!-- Be aware that maildir will only work on unix like operation systems! 
-->
     <provider>jpa</provider>


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

Reply via email to