Author: btellier
Date: Tue Sep 22 10:32:47 2015
New Revision: 1704554

URL: http://svn.apache.org/viewvc?rev=1704554&view=rev
Log:
JAMES-511 Add JMX support for quotas

Modified:
    
james/server/trunk/container/cli/src/main/java/org/apache/james/cli/ServerCmd.java
    
james/server/trunk/container/cli/src/main/java/org/apache/james/cli/probe/ServerProbe.java
    
james/server/trunk/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxServerProbe.java
    
james/server/trunk/container/cli/src/main/java/org/apache/james/cli/type/CmdType.java
    
james/server/trunk/container/cli/src/test/java/org/apache/james/cli/ServerCmdTest.java
    
james/server/trunk/container/cli/src/test/java/org/apache/james/cli/type/CmdTypeTest.java
    
james/server/trunk/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml

Modified: 
james/server/trunk/container/cli/src/main/java/org/apache/james/cli/ServerCmd.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/container/cli/src/main/java/org/apache/james/cli/ServerCmd.java?rev=1704554&r1=1704553&r2=1704554&view=diff
==============================================================================
--- 
james/server/trunk/container/cli/src/main/java/org/apache/james/cli/ServerCmd.java
 (original)
+++ 
james/server/trunk/container/cli/src/main/java/org/apache/james/cli/ServerCmd.java
 Tue Sep 22 10:32:47 2015
@@ -27,7 +27,9 @@ import org.apache.commons.cli.Option;
 import org.apache.commons.cli.Options;
 import org.apache.commons.cli.ParseException;
 import org.apache.commons.cli.PosixParser;
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.time.StopWatch;
+import org.apache.james.adapter.mailbox.SerializableQuota;
 import org.apache.james.cli.exceptions.InvalidArgumentNumberException;
 import org.apache.james.cli.exceptions.InvalidPortException;
 import org.apache.james.cli.exceptions.JamesCliException;
@@ -36,6 +38,8 @@ import org.apache.james.cli.exceptions.U
 import org.apache.james.cli.probe.ServerProbe;
 import org.apache.james.cli.probe.impl.JmxServerProbe;
 import org.apache.james.cli.type.CmdType;
+import org.apache.james.cli.utils.ValueWithUnit;
+import org.apache.james.mailbox.model.Quota;
 
 import java.io.IOException;
 import java.io.PrintStream;
@@ -216,6 +220,42 @@ public class ServerCmd {
         case DELETEMAILBOX:
             probe.deleteMailbox(arguments[1], arguments[2], arguments[3]);
             break;
+        case GETSTORAGEQUOTA:
+            printStorageQuota(arguments[1], 
probe.getStorageQuota(arguments[1]));
+            break;
+        case GETMESSAGECOUNTQUOTA:
+            printMessageQuota(arguments[1], 
probe.getMessageCountQuota(arguments[1]));
+            break;
+        case GETQUOTAROOT:
+            System.out.println("Quota Root : " + 
probe.getQuotaRoot(arguments[1], arguments[2], arguments[3]));
+            break;
+        case GETMAXSTORAGEQUOTA:
+            System.out.println("Storage space allowed for Quota Root "
+                + arguments[1]
+                + " : "
+                + 
FileUtils.byteCountToDisplaySize(probe.getMaxStorage(arguments[1])));
+            break;
+        case GETMAXMESSAGECOUNTQUOTA:
+            System.out.println("Message count allowed for Quota Root " + 
arguments[1] + " : " + probe.getMaxMessageCount(arguments[1]));
+            break;
+        case SETMAXSTORAGEQUOTA:
+            probe.setMaxStorage(arguments[1], 
ValueWithUnit.parse(arguments[2]).getConvertedValue());
+            break;
+        case SETMAXMESSAGECOUNTQUOTA:
+            probe.setMaxMessageCount(arguments[1], 
Long.parseLong(arguments[2]));
+            break;
+        case SETDEFAULTMAXSTORAGEQUOTA:
+            
probe.setDefaultMaxStorage(ValueWithUnit.parse(arguments[1]).getConvertedValue());
+            break;
+        case SETDEFAULTMAXMESSAGECOUNTQUOTA:
+            probe.setDefaultMaxMessageCount(Long.parseLong(arguments[1]));
+            break;
+        case GETDEFAULTMAXSTORAGEQUOTA:
+            System.out.println("Default Maximum Storage Quota : " + 
FileUtils.byteCountToDisplaySize(probe.getDefaultMaxStorage()));
+            break;
+        case GETDEFAULTMAXMESSAGECOUNTQUOTA:
+            System.out.println("Default Maximum message count Quota : " + 
probe.getDefaultMaxMessageCount());
+            break;
         default:
             throw new UnrecognizedCommandException(cmdType.getCommand());
         }
@@ -230,6 +270,20 @@ public class ServerCmd {
         }
     }
 
+    private void printStorageQuota(String quotaRootString, SerializableQuota 
quota) {
+        System.out.println(String.format("Storage quota for %s is : %s / %s",
+            quotaRootString,
+            FileUtils.byteCountToDisplaySize(quota.getUsed()),
+            FileUtils.byteCountToDisplaySize(quota.getMax())));
+    }
+
+    private void printMessageQuota(String quotaRootString, SerializableQuota 
quota) {
+        System.out.println(String.format("Message count quota for %s is : %d / 
%d",
+            quotaRootString,
+            quota.getUsed(),
+            quota.getMax()));
+    }
+
     private void print(Map<String, Collection<String>> map, PrintStream out) {
         if (map != null) {
             for (Entry<String, Collection<String>> entry : map.entrySet()) {

Modified: 
james/server/trunk/container/cli/src/main/java/org/apache/james/cli/probe/ServerProbe.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/container/cli/src/main/java/org/apache/james/cli/probe/ServerProbe.java?rev=1704554&r1=1704553&r2=1704554&view=diff
==============================================================================
--- 
james/server/trunk/container/cli/src/main/java/org/apache/james/cli/probe/ServerProbe.java
 (original)
+++ 
james/server/trunk/container/cli/src/main/java/org/apache/james/cli/probe/ServerProbe.java
 Tue Sep 22 10:32:47 2015
@@ -18,6 +18,11 @@
  ****************************************************************/
 package org.apache.james.cli.probe;
 
+import org.apache.james.adapter.mailbox.SerializableQuota;
+import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.Quota;
+import org.apache.james.mailbox.model.QuotaRoot;
+
 import java.io.Closeable;
 import java.util.Collection;
 import java.util.Map;
@@ -217,4 +222,26 @@ public interface ServerProbe extends Clo
      * @param name Name of the mailbox to delete
      */
     void deleteMailbox(String namespace, String user, String name);
+
+    String getQuotaRoot(String namespace, String user, String name) throws 
MailboxException;
+
+    SerializableQuota getMessageCountQuota(String quotaRoot) throws 
MailboxException;
+
+    SerializableQuota getStorageQuota(String quotaRoot) throws 
MailboxException;
+
+    long getMaxMessageCount(String quotaRoot) throws MailboxException;
+
+    long getMaxStorage(String quotaRoot) throws MailboxException;
+
+    long getDefaultMaxMessageCount() throws MailboxException;
+
+    long getDefaultMaxStorage() throws MailboxException;
+
+    void setMaxMessageCount(String quotaRoot, long maxMessageCount) throws 
MailboxException;
+
+    void setMaxStorage(String quotaRoot, long maxSize) throws MailboxException;
+
+    void setDefaultMaxMessageCount(long maxDefaultMessageCount) throws 
MailboxException;
+
+    void setDefaultMaxStorage(long maxDefaultSize) throws MailboxException;
 }

Modified: 
james/server/trunk/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxServerProbe.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxServerProbe.java?rev=1704554&r1=1704553&r2=1704554&view=diff
==============================================================================
--- 
james/server/trunk/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxServerProbe.java
 (original)
+++ 
james/server/trunk/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxServerProbe.java
 Tue Sep 22 10:32:47 2015
@@ -32,8 +32,11 @@ import javax.management.remote.JMXServic
 
 import org.apache.james.adapter.mailbox.MailboxCopierManagementMBean;
 import org.apache.james.adapter.mailbox.MailboxManagerManagementMBean;
+import org.apache.james.adapter.mailbox.QuotaManagementMBean;
+import org.apache.james.adapter.mailbox.SerializableQuota;
 import org.apache.james.cli.probe.ServerProbe;
 import org.apache.james.domainlist.api.DomainListManagementMBean;
+import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.rrt.api.RecipientRewriteTableManagementMBean;
 import org.apache.james.user.api.UsersRepositoryManagementMBean;
 
@@ -45,6 +48,7 @@ public class JmxServerProbe implements S
     private final static String USERSREPOSITORY_OBJECT_NAME = 
"org.apache.james:type=component,name=usersrepository";
     private final static String MAILBOXCOPIER_OBJECT_NAME = 
"org.apache.james:type=component,name=mailboxcopier";
     private final static String MAILBOXMANAGER_OBJECT_NAME = 
"org.apache.james:type=component,name=mailboxmanagerbean";
+    private final static String QUOTAMANAGER_OBJECT_NAME = 
"org.apache.james:type=component,name=quotamanagerbean";
 
     private JMXConnector jmxc;
     
@@ -53,6 +57,7 @@ public class JmxServerProbe implements S
     private UsersRepositoryManagementMBean usersRepositoryProxy;
     private MailboxCopierManagementMBean mailboxCopierManagement;
     private MailboxManagerManagementMBean mailboxManagerManagement;
+    private QuotaManagementMBean quotaManagement;
 
     private static final String fmtUrl = 
"service:jmx:rmi:///jndi/rmi://%s:%d/jmxrmi";
     private static final int defaultPort = 9999;
@@ -110,6 +115,9 @@ public class JmxServerProbe implements S
             name = new ObjectName(MAILBOXMANAGER_OBJECT_NAME);
             mailboxManagerManagement = 
MBeanServerInvocationHandler.newProxyInstance(
                     mbeanServerConn, name, 
MailboxManagerManagementMBean.class, true);
+            name = new ObjectName(QUOTAMANAGER_OBJECT_NAME);
+            quotaManagement = MBeanServerInvocationHandler.newProxyInstance(
+                    mbeanServerConn, name, QuotaManagementMBean.class, true);
         } catch (MalformedObjectNameException e) {
             throw new RuntimeException("Invalid ObjectName? Please report this 
as a bug.", e);
         }
@@ -214,4 +222,59 @@ public class JmxServerProbe implements S
     public void deleteMailbox(String namespace, String user, String name) {
         mailboxManagerManagement.deleteMailbox(namespace, user, name);
     }
+
+    @Override
+    public String getQuotaRoot(String namespace, String user, String name) 
throws MailboxException {
+        return quotaManagement.getQuotaRoot(namespace, user, name);
+    }
+
+    @Override
+    public SerializableQuota getMessageCountQuota(String quotaRoot) throws 
MailboxException {
+        return quotaManagement.getMessageCountQuota(quotaRoot);
+    }
+
+    @Override
+    public SerializableQuota getStorageQuota(String quotaRoot) throws 
MailboxException {
+        return quotaManagement.getStorageQuota(quotaRoot);
+    }
+
+    @Override
+    public long getMaxMessageCount(String quotaRoot) throws MailboxException {
+        return quotaManagement.getMaxMessageCount(quotaRoot);
+    }
+
+    @Override
+    public long getMaxStorage(String quotaRoot) throws MailboxException {
+        return quotaManagement.getMaxStorage(quotaRoot);
+    }
+
+    @Override
+    public long getDefaultMaxMessageCount() throws MailboxException {
+        return quotaManagement.getDefaultMaxMessageCount();
+    }
+
+    @Override
+    public long getDefaultMaxStorage() throws MailboxException {
+        return quotaManagement.getDefaultMaxStorage();
+    }
+
+    @Override
+    public void setMaxMessageCount(String quotaRoot, long maxMessageCount) 
throws MailboxException {
+        quotaManagement.setMaxMessageCount(quotaRoot, maxMessageCount);
+    }
+
+    @Override
+    public void setMaxStorage(String quotaRoot, long maxSize) throws 
MailboxException {
+        quotaManagement.setMaxStorage(quotaRoot, maxSize);
+    }
+
+    @Override
+    public void setDefaultMaxMessageCount(long maxDefaultMessageCount) throws 
MailboxException {
+        quotaManagement.setDefaultMaxMessageCount(maxDefaultMessageCount);
+    }
+
+    @Override
+    public void setDefaultMaxStorage(long maxDefaultSize) throws 
MailboxException {
+        quotaManagement.setDefaultMaxStorage(maxDefaultSize);
+    }
 }

Modified: 
james/server/trunk/container/cli/src/main/java/org/apache/james/cli/type/CmdType.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/container/cli/src/main/java/org/apache/james/cli/type/CmdType.java?rev=1704554&r1=1704553&r2=1704554&view=diff
==============================================================================
--- 
james/server/trunk/container/cli/src/main/java/org/apache/james/cli/type/CmdType.java
 (original)
+++ 
james/server/trunk/container/cli/src/main/java/org/apache/james/cli/type/CmdType.java
 Tue Sep 22 10:32:47 2015
@@ -40,7 +40,18 @@ public enum CmdType {
     DELETEUSERMAILBOXES("deleteusermailboxes", "user"),
     CREATEMAILBOX("createmailbox", "namespace", "user", "name"),
     LISTUSERMAILBOXES("listusermailboxes", "user"),
-    DELETEMAILBOX("deletemailbox", "namespace", "user", "name");
+    DELETEMAILBOX("deletemailbox", "namespace", "user", "name"),
+    GETSTORAGEQUOTA("getstoragequota", "quotaroot"),
+    GETMESSAGECOUNTQUOTA("getmessagecountquota", "quotaroot"),
+    GETQUOTAROOT("getquotaroot", "namespace", "user", "name"),
+    GETMAXSTORAGEQUOTA("getmaxstoragequota", "quotaroot"),
+    GETMAXMESSAGECOUNTQUOTA("getmaxmessagecountquota", "quotaroot"),
+    SETMAXSTORAGEQUOTA("setmaxstoragequota", "quotaroot", "max_message_count"),
+    SETMAXMESSAGECOUNTQUOTA("setmaxmessagecountquota", "quotaroot", 
"max_storage"),
+    SETDEFAULTMAXSTORAGEQUOTA("setdefaultmaxstoragequota", "max_storage"),
+    SETDEFAULTMAXMESSAGECOUNTQUOTA("setdefaultmaxmessagecountquota", 
"max_message_count"),
+    GETDEFAULTMAXSTORAGEQUOTA("getdefaultmaxstoragequota"),
+    GETDEFAULTMAXMESSAGECOUNTQUOTA("getdefaultmaxmessagecountquota");
 
     private final String command;
     private final String[] arguments;

Modified: 
james/server/trunk/container/cli/src/test/java/org/apache/james/cli/ServerCmdTest.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/container/cli/src/test/java/org/apache/james/cli/ServerCmdTest.java?rev=1704554&r1=1704553&r2=1704554&view=diff
==============================================================================
--- 
james/server/trunk/container/cli/src/test/java/org/apache/james/cli/ServerCmdTest.java
 (original)
+++ 
james/server/trunk/container/cli/src/test/java/org/apache/james/cli/ServerCmdTest.java
 Tue Sep 22 10:32:47 2015
@@ -26,18 +26,19 @@ import static org.easymock.EasyMock.expe
 import static org.easymock.EasyMock.expectLastCall;
 
 import java.util.ArrayList;
-import java.util.Calendar;
 import java.util.Collection;
 import java.util.HashMap;
 
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.ParseException;
+import org.apache.james.adapter.mailbox.SerializableQuota;
 import org.apache.james.cli.exceptions.InvalidArgumentNumberException;
 import org.apache.james.cli.exceptions.InvalidPortException;
 import org.apache.james.cli.exceptions.MissingCommandException;
 import org.apache.james.cli.exceptions.UnrecognizedCommandException;
 import org.apache.james.cli.probe.ServerProbe;
 import org.apache.james.cli.type.CmdType;
+import org.apache.james.mailbox.model.Quota;
 import org.easymock.IMocksControl;
 import org.junit.Before;
 import org.junit.Test;
@@ -330,6 +331,151 @@ public class ServerCmdTest {
 
         control.replay();
         testee.executeCommandLine(commandLine);
+        control.verify();
+    }
+
+    @Test
+    public void getQuotaRootCommandShouldWork() throws Exception {
+        String namespace = "#private";
+        String user = "user@domain";
+        String name = "INBOX";
+        String[] arguments = { "-h", "127.0.0.1", "-p", "9999", 
CmdType.GETQUOTAROOT.getCommand(), namespace, user, name};
+        CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
+
+        expect(serverProbe.getQuotaRoot(namespace, user, 
name)).andReturn(namespace + "&" + user);
+
+        control.replay();
+        testee.executeCommandLine(commandLine);
+        control.verify();
+    }
+
+    @Test
+    public void getDefaultMaxMessageCountCommandShouldWork() throws Exception {
+        String[] arguments = { "-h", "127.0.0.1", "-p", "9999", 
CmdType.GETDEFAULTMAXMESSAGECOUNTQUOTA.getCommand()};
+        CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
+
+        expect(serverProbe.getDefaultMaxMessageCount()).andReturn(1024L * 
1024L);
+
+        control.replay();
+        testee.executeCommandLine(commandLine);
+        control.verify();
+    }
+
+    @Test
+    public void getDefaultMaxStorageCommandShouldWork() throws Exception {
+        String[] arguments = { "-h", "127.0.0.1", "-p", "9999", 
CmdType.GETDEFAULTMAXSTORAGEQUOTA.getCommand()};
+        CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
+
+        expect(serverProbe.getDefaultMaxStorage()).andReturn(1024L * 1024L * 
1024L);
+
+        control.replay();
+        testee.executeCommandLine(commandLine);
+        control.verify();
+    }
+
+    @Test
+    public void setDefaultMaxMessageCountCommandShouldWork() throws Exception {
+        String[] arguments = { "-h", "127.0.0.1", "-p", "9999", 
CmdType.SETDEFAULTMAXMESSAGECOUNTQUOTA.getCommand(), "1054"};
+        CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
+
+       serverProbe.setDefaultMaxMessageCount(1054);
+        expectLastCall();
+
+        control.replay();
+        testee.executeCommandLine(commandLine);
+        control.verify();
+    }
+
+    @Test
+    public void setDefaultMaxStorageCommandShouldWork() throws Exception {
+        String[] arguments = { "-h", "127.0.0.1", "-p", "9999", 
CmdType.SETDEFAULTMAXSTORAGEQUOTA.getCommand(), "1G"};
+        CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
+
+        serverProbe.setDefaultMaxStorage(1024 * 1024 * 1024);
+        expectLastCall();
+
+        control.replay();
+        testee.executeCommandLine(commandLine);
+        control.verify();
+    }
+
+    @Test
+    public void setMaxMessageCountCommandShouldWork() throws Exception {
+        String quotaroot = "#private&user@domain";
+        String[] arguments = { "-h", "127.0.0.1", "-p", "9999", 
CmdType.SETMAXMESSAGECOUNTQUOTA.getCommand(), quotaroot, "1000"};
+        CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
+
+        serverProbe.setMaxMessageCount(quotaroot, 1000);
+        expectLastCall();
+
+        control.replay();
+        testee.executeCommandLine(commandLine);
+        control.verify();
+    }
+
+    @Test
+    public void setMaxStorageCommandShouldWork() throws Exception {
+        String quotaroot = "#private&user@domain";
+        String[] arguments = { "-h", "127.0.0.1", "-p", "9999", 
CmdType.SETMAXSTORAGEQUOTA.getCommand(), quotaroot, "5M"};
+        CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
+
+        serverProbe.setMaxStorage(quotaroot, 5 * 1024 * 1024);
+        expectLastCall();
+
+        control.replay();
+        testee.executeCommandLine(commandLine);
+        control.verify();
+    }
+
+    @Test
+    public void getMaxMessageCountCommandShouldWork() throws Exception {
+        String quotaroot = "#private&user@domain";
+        String[] arguments = { "-h", "127.0.0.1", "-p", "9999", 
CmdType.GETMAXMESSAGECOUNTQUOTA.getCommand(), quotaroot};
+        CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
+
+        
expect(serverProbe.getMaxMessageCount(quotaroot)).andReturn(Quota.UNLIMITED);
+
+        control.replay();
+        testee.executeCommandLine(commandLine);
+        control.verify();
+    }
+
+    @Test
+    public void getMaxStorageQuotaCommandShouldWork() throws Exception {
+        String quotaroot = "#private&user@domain";
+        String[] arguments = { "-h", "127.0.0.1", "-p", "9999", 
CmdType.GETMAXSTORAGEQUOTA.getCommand(), quotaroot};
+        CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
+
+        
expect(serverProbe.getMaxStorage(quotaroot)).andReturn(Quota.UNLIMITED);
+
+        control.replay();
+        testee.executeCommandLine(commandLine);
+        control.verify();
+    }
+
+    @Test
+    public void getStorageQuotaCommandShouldWork() throws Exception {
+        String quotaroot = "#private&user@domain";
+        String[] arguments = { "-h", "127.0.0.1", "-p", "9999", 
CmdType.GETSTORAGEQUOTA.getCommand(), quotaroot};
+        CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
+
+        expect(serverProbe.getStorageQuota(quotaroot)).andReturn(new 
SerializableQuota(Quota.UNLIMITED, Quota.UNKNOWN));
+
+        control.replay();
+        testee.executeCommandLine(commandLine);
+        control.verify();
+    }
+
+    @Test
+    public void getMessageCountQuotaCommandShouldWork() throws Exception {
+        String quotaroot = "#private&user@domain";
+        String[] arguments = { "-h", "127.0.0.1", "-p", "9999", 
CmdType.GETMESSAGECOUNTQUOTA.getCommand(), quotaroot};
+        CommandLine commandLine = ServerCmd.parseCommandLine(arguments);
+
+        expect(serverProbe.getMessageCountQuota(quotaroot)).andReturn(new 
SerializableQuota(Quota.UNLIMITED, Quota.UNKNOWN));
+
+        control.replay();
+        testee.executeCommandLine(commandLine);
         control.verify();
     }
 

Modified: 
james/server/trunk/container/cli/src/test/java/org/apache/james/cli/type/CmdTypeTest.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/container/cli/src/test/java/org/apache/james/cli/type/CmdTypeTest.java?rev=1704554&r1=1704553&r2=1704554&view=diff
==============================================================================
--- 
james/server/trunk/container/cli/src/test/java/org/apache/james/cli/type/CmdTypeTest.java
 (original)
+++ 
james/server/trunk/container/cli/src/test/java/org/apache/james/cli/type/CmdTypeTest.java
 Tue Sep 22 10:32:47 2015
@@ -138,6 +138,61 @@ public class CmdTypeTest {
         
assertThat(CmdType.lookup("deletemailbox")).isEqualTo(CmdType.DELETEMAILBOX);
     }
 
+    @Test
+    public void lookupSetDefaultMaxStorageQuotaShouldReturnEnumValue() {
+        
assertThat(CmdType.lookup("setdefaultmaxstoragequota")).isEqualTo(CmdType.SETDEFAULTMAXSTORAGEQUOTA);
+    }
+
+    @Test
+    public void lookupSetDefaultMaxMessageCountQuotaShouldReturnEnumValue() {
+        
assertThat(CmdType.lookup("setdefaultmaxmessagecountquota")).isEqualTo(CmdType.SETDEFAULTMAXMESSAGECOUNTQUOTA);
+    }
+
+    @Test
+    public void lookupGetDefaultMaxStorageQuotaShouldReturnEnumValue() {
+        
assertThat(CmdType.lookup("getdefaultmaxstoragequota")).isEqualTo(CmdType.GETDEFAULTMAXSTORAGEQUOTA);
+    }
+
+    @Test
+    public void lookupGetDefaultMaxMessageCountQuotaShouldReturnEnumValue() {
+        
assertThat(CmdType.lookup("getdefaultmaxmessagecountquota")).isEqualTo(CmdType.GETDEFAULTMAXMESSAGECOUNTQUOTA);
+    }
+
+    @Test
+    public void lookupSetMaxStorageQuotaShouldReturnEnumValue() {
+        
assertThat(CmdType.lookup("setmaxstoragequota")).isEqualTo(CmdType.SETMAXSTORAGEQUOTA);
+    }
+
+    @Test
+    public void lookupSetMaxMessageCountQuotaShouldReturnEnumValue() {
+        
assertThat(CmdType.lookup("setmaxmessagecountquota")).isEqualTo(CmdType.SETMAXMESSAGECOUNTQUOTA);
+    }
+
+    @Test
+    public void lookupGetMaxStorageQuotaShouldReturnEnumValue() {
+        
assertThat(CmdType.lookup("getmaxstoragequota")).isEqualTo(CmdType.GETMAXSTORAGEQUOTA);
+    }
+
+    @Test
+    public void lookupGetMaxMessageCountQuotaShouldReturnEnumValue() {
+        
assertThat(CmdType.lookup("getmaxmessagecountquota")).isEqualTo(CmdType.GETMAXMESSAGECOUNTQUOTA);
+    }
+
+    @Test
+    public void lookupGetStorageQuotaShouldReturnEnumValue() {
+        
assertThat(CmdType.lookup("getstoragequota")).isEqualTo(CmdType.GETSTORAGEQUOTA);
+    }
+
+    @Test
+    public void lookupGetMessageCountQuotaShouldReturnEnumValue() {
+        
assertThat(CmdType.lookup("getmessagecountquota")).isEqualTo(CmdType.GETMESSAGECOUNTQUOTA);
+    }
+
+    @Test
+    public void lookupGetQuotaRootShouldReturnEnumValue() {
+        
assertThat(CmdType.lookup("getquotaroot")).isEqualTo(CmdType.GETQUOTAROOT);
+    }
+
     @Test 
     public void lookupEmptyStringShouldReturnNull() {
         assertThat(CmdType.lookup("")).isNull();

Modified: 
james/server/trunk/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
URL: 
http://svn.apache.org/viewvc/james/server/trunk/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml?rev=1704554&r1=1704553&r2=1704554&view=diff
==============================================================================
--- 
james/server/trunk/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
 (original)
+++ 
james/server/trunk/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
 Tue Sep 22 10:32:47 2015
@@ -221,12 +221,13 @@
                           <entry 
key="org.apache.james:type=component,name=james23importer" 
value-ref="james23importermanagement"/>
                 -->
                 <entry key="org.apache.james:type=container,name=logprovider" 
value-ref="logprovider"/>
+                <entry 
key="org.apache.james:type=component,name=quotamanagerbean" 
value-ref="quotamanagermanagement"/>
             </map>
         </property>
         <property name="assembler">
             <bean 
class="org.springframework.jmx.export.assembler.InterfaceBasedMBeanInfoAssembler">
                 <property name="managedInterfaces"
-                          
value="org.apache.james.fetchmail.FetchSchedulerMBean,org.apache.james.domainlist.api.DomainListManagementMBean,org.apache.james.dnsservice.api.DNSServiceMBean,org.apache.james.rrt.api.RecipientRewriteTableManagementMBean,org.apache.james.user.api.UsersRepositoryManagementMBean,org.apache.james.adapter.mailbox.MailboxManagerManagementMBean,org.apache.james.adapter.mailbox.MailboxCopierManagementMBean,org.apache.james.mailetcontainer.api.jmx.MailSpoolerMBean,org.apache.james.container.spring.lifecycle.LogProviderManagementMBean"/>
+                          
value="org.apache.james.fetchmail.FetchSchedulerMBean,org.apache.james.domainlist.api.DomainListManagementMBean,org.apache.james.dnsservice.api.DNSServiceMBean,org.apache.james.rrt.api.RecipientRewriteTableManagementMBean,org.apache.james.user.api.UsersRepositoryManagementMBean,org.apache.james.adapter.mailbox.MailboxManagerManagementMBean,org.apache.james.adapter.mailbox.MailboxCopierManagementMBean,org.apache.james.mailetcontainer.api.jmx.MailSpoolerMBean,org.apache.james.container.spring.lifecycle.LogProviderManagementMBean,org.apache.james.adapter.mailbox.QuotaManagementMBean"/>
             </bean>
         </property>
     </bean>
@@ -236,6 +237,7 @@
     <bean id="domainlistmanagement" 
class="org.apache.james.domainlist.lib.DomainListManagement"/>
     <bean id="mailboxmanagermanagementbean" 
class="org.apache.james.adapter.mailbox.MailboxManagerManagement"/>
     <bean id="mailboxcopiermanagement" 
class="org.apache.james.adapter.mailbox.MailboxCopierManagement"/>
+    <bean id="quotamanagermanagement" 
class="org.apache.james.adapter.mailbox.QuotaManagement"/>
     <!--
         <bean id="james23importermanagement" 
class="org.apache.james.container.spring.tool.James23ImporterManagement" />
     -->



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to