james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r831840 - in /james/server/trunk: management-library/src/main/java/org/apache/james/management/ management-library/src/test/java/org/ management-library/src/test/java/org/apache/ management-library/src/test/java/org/apache/james/ management...
Date Mon, 02 Nov 2009 10:08:25 GMT
Author: norman
Date: Mon Nov  2 10:08:24 2009
New Revision: 831840

URL: http://svn.apache.org/viewvc?rev=831840&view=rev
Log:
Add AvalonRemoteManager(JAMES-893)

Added:
    james/server/trunk/management-library/src/test/java/org/
    james/server/trunk/management-library/src/test/java/org/apache/
    james/server/trunk/management-library/src/test/java/org/apache/james/
    james/server/trunk/management-library/src/test/java/org/apache/james/management/
    james/server/trunk/management-library/src/test/java/org/apache/james/management/mock/
    james/server/trunk/management-library/src/test/java/org/apache/james/management/mock/MockVirtualUserTableManagementService.java
    james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/AvalonRemoteManager.java
    james/server/trunk/remotemanager-function/src/main/resources/org/apache/james/remotemanager/AvalonRemoteManager.xinfo
      - copied unchanged from r829709, james/server/trunk/remotemanager-function/src/main/resources/org/apache/james/remotemanager/RemoteManager.xinfo
    james/server/trunk/remotemanager-function/src/test/java/org/apache/james/remotemanager/AvalonRemoteManagerTest.java
Removed:
    james/server/trunk/remotemanager-function/src/main/resources/org/apache/james/remotemanager/RemoteManager.xinfo
Modified:
    james/server/trunk/management-library/src/main/java/org/apache/james/management/SpoolManagementService.java
    james/server/trunk/phoenix-deployment/src/conf/james-assembly.xml
    james/server/trunk/remotemanager-function/src/test/java/org/apache/james/remotemanager/RemoteManagerTest.java

Modified: james/server/trunk/management-library/src/main/java/org/apache/james/management/SpoolManagementService.java
URL: http://svn.apache.org/viewvc/james/server/trunk/management-library/src/main/java/org/apache/james/management/SpoolManagementService.java?rev=831840&r1=831839&r2=831840&view=diff
==============================================================================
--- james/server/trunk/management-library/src/main/java/org/apache/james/management/SpoolManagementService.java
(original)
+++ james/server/trunk/management-library/src/main/java/org/apache/james/management/SpoolManagementService.java
Mon Nov  2 10:08:24 2009
@@ -54,7 +54,7 @@
      * @throws MessagingException 
      * @throws SpoolManagementException
      */
-    public int removeSpoolItems(String spoolRepositoryURL, String key, List lockingFailures,
SpoolFilter filter) 
+    public int removeSpoolItems(String spoolRepositoryURL, String key, List<String>
lockingFailures, SpoolFilter filter) 
             throws MessagingException, SpoolManagementException;
     
     /**
@@ -69,7 +69,7 @@
      * @throws MessagingException
      * @throws SpoolManagementException
      */
-    public int resendSpoolItems(String spoolRepositoryURL, String key, List lockingFailures,
SpoolFilter filter) 
+    public int resendSpoolItems(String spoolRepositoryURL, String key, List<String>
lockingFailures, SpoolFilter filter) 
             throws MessagingException, SpoolManagementException;
 
     /**
@@ -82,6 +82,6 @@
      * @throws MessagingException
      * @throws SpoolManagementException
      */
-    public List getSpoolItems(String spoolRepositoryURL, SpoolFilter filter) 
+    public List<String> getSpoolItems(String spoolRepositoryURL, SpoolFilter filter)

             throws MessagingException, SpoolManagementException;
 }

Added: james/server/trunk/management-library/src/test/java/org/apache/james/management/mock/MockVirtualUserTableManagementService.java
URL: http://svn.apache.org/viewvc/james/server/trunk/management-library/src/test/java/org/apache/james/management/mock/MockVirtualUserTableManagementService.java?rev=831840&view=auto
==============================================================================
--- james/server/trunk/management-library/src/test/java/org/apache/james/management/mock/MockVirtualUserTableManagementService.java
(added)
+++ james/server/trunk/management-library/src/test/java/org/apache/james/management/mock/MockVirtualUserTableManagementService.java
Mon Nov  2 10:08:24 2009
@@ -0,0 +1,181 @@
+/****************************************************************
+ * 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.management.mock;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.james.api.vut.management.VirtualUserTableManagementException;
+import org.apache.james.api.vut.management.VirtualUserTableManagementService;
+
+public class MockVirtualUserTableManagementService implements VirtualUserTableManagementService{
+    private Map<String,Collection<String>> mappings = new HashMap<String,
Collection<String>>();
+
+    public boolean addAddressMapping(String virtualUserTable, String user,
+            String domain, String address)
+            throws VirtualUserTableManagementException {
+        Collection<String> map = mappings.get(user + "@" + domain);
+        if (map == null) {
+            map = new ArrayList<String>();
+            mappings.put(user + "@" + domain, map);
+
+        } else {
+            if (map.contains(address)) return false;
+        }
+        return map.add(address);
+    }
+
+    public boolean addAliasDomainMapping(String virtualUserTable,
+            String aliasDomain, String realDomain)
+            throws VirtualUserTableManagementException {
+        Collection<String> map = mappings.get(realDomain);
+        if (map == null) {
+            map = new ArrayList<String>();
+            mappings.put(realDomain, map);
+
+        } else {
+            if (map.contains(aliasDomain)) return false;
+        }
+        return map.add(aliasDomain);
+    }
+
+    public boolean addErrorMapping(String virtualUserTable, String user,
+            String domain, String error)
+            throws VirtualUserTableManagementException {
+        Collection<String> map = mappings.get(user + "@" + domain);
+        if (map == null) {
+            map = new ArrayList<String>();
+            mappings.put(user + "@" + domain, map);
+        } else {
+            if (map.contains(error)) return false;
+        }
+        return map.add(error);
+    }
+
+    public boolean addMapping(String virtualUserTable, String user,
+            String domain, String mapping)
+            throws VirtualUserTableManagementException {
+        Collection<String> map = mappings.get(user + "@" + domain);
+        if (map == null) {
+            map = new ArrayList<String>();           
+            mappings.put(user + "@" + domain, map);
+        } else {
+            if (map.contains(mapping)) return false;
+        }     
+        return map.add(mapping);
+    }
+
+    public boolean addRegexMapping(String virtualUserTable, String user,
+            String domain, String regex)
+            throws VirtualUserTableManagementException {
+        Collection<String> map = mappings.get(user + "@" + domain);
+        if (map == null) {
+            map = new ArrayList<String>();
+            mappings.put(user + "@" + domain, map);
+        } else {
+            if (map.contains(regex)) return false;
+        }     
+        return map.add(regex);
+    }
+
+    public Map<String, Collection<String>> getAllMappings(
+            String virtualUserTable) throws VirtualUserTableManagementException {
+        return mappings;
+    }
+
+    public Collection<String> getUserDomainMappings(String virtualUserTable,
+            String user, String domain)
+            throws VirtualUserTableManagementException {
+        return mappings.get(user + "@" + domain);
+    }
+
+    public boolean removeAddressMapping(String virtualUserTable, String user,
+            String domain, String address)
+            throws VirtualUserTableManagementException {
+        Collection<String> col = mappings.get(user + "@" + domain);
+        Iterator<String> it = col.iterator();
+        while (it.hasNext()) {
+            String mapping = it.next();
+            if (mapping.equalsIgnoreCase(address)) {
+                return col.remove(address);  
+            }
+        }
+        return false;
+    }
+
+    public boolean removeAliasDomainMapping(String virtualUserTable,
+            String aliasDomain, String realDomain)
+            throws VirtualUserTableManagementException {
+        Collection<String> col = mappings.get(realDomain);
+        Iterator<String> it = col.iterator();
+        while (it.hasNext()) {
+            String mapping = it.next();
+            if (mapping.equalsIgnoreCase(aliasDomain)) {
+                return col.remove(aliasDomain);  
+            }
+        }
+        return false;
+    }
+
+    public boolean removeErrorMapping(String virtualUserTable, String user,
+            String domain, String error)
+            throws VirtualUserTableManagementException {
+        Collection<String> col = mappings.get(user + "@" + domain);
+        Iterator<String> it = col.iterator();
+        while (it.hasNext()) {
+            String mapping = it.next();
+            if (mapping.equalsIgnoreCase(error)) {
+                return col.remove(error);  
+            }
+        }
+        return false;
+    }
+
+    public boolean removeMapping(String virtualUserTable, String user,
+            String domain, String rawmapping)
+            throws VirtualUserTableManagementException {
+        Collection<String> col = mappings.get(user + "@" + domain);
+        Iterator<String> it = col.iterator();
+        while (it.hasNext()) {
+            String mapping = it.next();
+            if (mapping.equalsIgnoreCase(rawmapping)) {
+                return col.remove(rawmapping);  
+            }
+        }
+        return false;
+    }
+
+    public boolean removeRegexMapping(String virtualUserTable, String user,
+            String domain, String regex)
+            throws VirtualUserTableManagementException {
+        Collection<String> col = mappings.get(user + "@" + domain);
+        Iterator<String> it = col.iterator();
+        while (it.hasNext()) {
+            String mapping = it.next();
+            if (mapping.equalsIgnoreCase(regex)) {
+                return col.remove(regex);  
+            }
+        }
+        return false;
+    }
+
+}

Modified: james/server/trunk/phoenix-deployment/src/conf/james-assembly.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/phoenix-deployment/src/conf/james-assembly.xml?rev=831840&r1=831839&r2=831840&view=diff
==============================================================================
--- james/server/trunk/phoenix-deployment/src/conf/james-assembly.xml (original)
+++ james/server/trunk/phoenix-deployment/src/conf/james-assembly.xml Mon Nov  2 10:08:24
2009
@@ -95,7 +95,7 @@
     <proxy disable='true'/>
   </block>
 
-  <block name="remotemanager" class="org.apache.james.remotemanager.RemoteManager" >
+  <block name="remotemanager" class="org.apache.james.remotemanager.AvalonRemoteManager"
>
     <provide name="mailstore" role="org.apache.avalon.cornerstone.services.store.Store"/>
     <provide name="users-store" role="org.apache.james.api.user.UsersStore"/>
     <provide name="localusersrepository" role="org.apache.james.api.user.UsersRepository"/>

Added: james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/AvalonRemoteManager.java
URL: http://svn.apache.org/viewvc/james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/AvalonRemoteManager.java?rev=831840&view=auto
==============================================================================
--- james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/AvalonRemoteManager.java
(added)
+++ james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/AvalonRemoteManager.java
Mon Nov  2 10:08:24 2009
@@ -0,0 +1,187 @@
+/****************************************************************
+ * 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.remotemanager;
+
+import org.apache.avalon.cornerstone.services.sockets.SocketManager;
+import org.apache.avalon.cornerstone.services.store.Store;
+import org.apache.avalon.cornerstone.services.threads.ThreadManager;
+import org.apache.avalon.framework.activity.Initializable;
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.impl.AvalonLogger;
+import org.apache.james.api.dnsservice.DNSService;
+import org.apache.james.api.kernel.LoaderService;
+import org.apache.james.api.user.UsersStore;
+import org.apache.james.api.vut.management.VirtualUserTableManagementService;
+import org.apache.james.bridge.GuiceInjected;
+import org.apache.james.management.BayesianAnalyzerManagementService;
+import org.apache.james.management.DomainListManagementService;
+import org.apache.james.management.ProcessorManagementService;
+import org.apache.james.management.SpoolManagementService;
+import org.apache.james.services.FileSystem;
+import org.apache.james.services.MailServer;
+import org.apache.james.socket.JamesConnectionManager;
+import org.apache.james.socket.api.ProtocolHandlerFactory;
+import org.apache.james.util.ConfigurationAdapter;
+import org.guiceyfruit.jsr250.Jsr250Module;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Provider;
+import com.google.inject.name.Names;
+
+public class AvalonRemoteManager implements GuiceInjected, Initializable, Serviceable, Configurable,
LogEnabled, RemoteManagerMBean {
+    
+    private FileSystem filesystem;
+    private MailServer mailserver;
+    private DNSService dns;
+    private Log logger;
+    private org.apache.commons.configuration.HierarchicalConfiguration config;
+    private Injector injector;
+    private JamesConnectionManager connectionManager;
+    private SocketManager socketManager;
+    private RemoteManager server = new RemoteManager();
+    private ThreadManager threadManager;
+    private SpoolManagementService spoolService;
+    private BayesianAnalyzerManagementService bayesianServer;
+    private VirtualUserTableManagementService vutService;
+    private DomainListManagementService domainService;
+    private UsersStore usersStore;
+    private ProcessorManagementService processorService;
+    private Store store;
+    
+    public String getNetworkInterface() {
+        return server.getNetworkInterface();
+    }
+
+    public int getPort() {
+        return server.getPort();
+    }
+
+    public String getSocketType() {
+        return server.getSocketType();
+    }
+
+    public boolean isEnabled() {
+        return server.isEnabled();
+    }
+
+    /**
+     * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
+     */
+    public void configure(Configuration config) throws ConfigurationException {
+        try {
+            this.config = new ConfigurationAdapter(config);
+        } catch (org.apache.commons.configuration.ConfigurationException e) {
+            throw new ConfigurationException("Unable to convert configuration", e);
+        }
+    }
+
+    /**
+     * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
+     */
+    public void service(ServiceManager manager) throws ServiceException {
+        dns = (DNSService) manager.lookup(DNSService.ROLE);
+        mailserver = (MailServer) manager.lookup(MailServer.ROLE);
+        filesystem = (FileSystem) manager.lookup(FileSystem.ROLE);
+        socketManager = (SocketManager) manager.lookup(SocketManager.ROLE);
+        connectionManager = (JamesConnectionManager) manager.lookup(JamesConnectionManager.ROLE);
    
+        threadManager = (ThreadManager) manager.lookup(ThreadManager.ROLE);
+        spoolService = (SpoolManagementService) manager.lookup(SpoolManagementService.ROLE);
+        bayesianServer = (BayesianAnalyzerManagementService) manager.lookup(BayesianAnalyzerManagementService.ROLE);
+        vutService = (VirtualUserTableManagementService) manager.lookup(VirtualUserTableManagementService.ROLE);
+        domainService = (DomainListManagementService) manager.lookup(DomainListManagementService.ROLE);
+        usersStore = (UsersStore) manager.lookup(UsersStore.ROLE);
+        processorService = (ProcessorManagementService) manager.lookup(ProcessorManagementService.ROLE);
+        store = (Store) manager.lookup(Store.ROLE);
+        // thats needed because of used excalibur socket components
+        server.service(manager);
+    }
+
+    /**
+     * @see org.apache.avalon.framework.activity.Initializable#initialize()
+     */
+    public void initialize() throws Exception {
+        injector = Guice.createInjector(new RemoteManagerModule(), new Jsr250Module());
+        injector.injectMembers(server);
+    }
+                 
+    /**
+     * @see org.apache.avalon.framework.logger.LogEnabled#enableLogging(org.apache.avalon.framework.logger.Logger)
+     */
+    public void enableLogging(Logger logger) {
+        this.logger = new AvalonLogger(logger);
+    }
+
+    private final class RemoteManagerModule extends AbstractModule {
+
+        @Override
+        protected void configure() {
+            bind(DNSService.class).annotatedWith(Names.named("org.apache.james.api.dnsservice.DNSService")).toInstance(dns);
+            bind(MailServer.class).annotatedWith(Names.named("org.apache.james.services.MailServer")).toInstance(mailserver);
+            bind(org.apache.commons.configuration.HierarchicalConfiguration.class).annotatedWith(Names.named("org.apache.commons.configuration.Configuration")).toInstance(config);
+            bind(Log.class).annotatedWith(Names.named("org.apache.commons.logging.Log")).toInstance(logger);
+            bind(FileSystem.class).annotatedWith(Names.named("org.apache.james.services.FileSystem")).toInstance(filesystem);
+            bind(ProtocolHandlerFactory.class).annotatedWith(Names.named("org.apache.james.socket.api.ProtocolHandlerFactory")).toProvider(new
Provider<ProtocolHandlerFactory>() {
+
+                public ProtocolHandlerFactory get() {
+                    return server;
+                }
+                
+            });
+            bind(SocketManager.class).annotatedWith(Names.named("org.apache.avalon.cornerstone.services.sockets.SocketManager")).toInstance(socketManager);
+            bind(JamesConnectionManager.class).annotatedWith(Names.named("org.apache.james.socket.JamesConnectionManager")).toInstance(connectionManager);
+            bind(ThreadManager.class).annotatedWith(Names.named("org.apache.avalon.cornerstone.services.threads.ThreadManager")).toInstance(threadManager);
+            bind(SpoolManagementService.class).annotatedWith(Names.named("org.apache.james.management.SpoolManagementService")).toInstance(spoolService);
+            bind(BayesianAnalyzerManagementService.class).annotatedWith(Names.named("org.apache.james.management.BayesianAnalyzerManagementService")).toInstance(bayesianServer);
+            bind(UsersStore.class).annotatedWith(Names.named("org.apache.james.api.user.UsersStore")).toInstance(usersStore);
+            bind(ProcessorManagementService.class).annotatedWith(Names.named("org.apache.james.management.ProcessorManagementService")).toInstance(processorService);
+            bind(VirtualUserTableManagementService.class).annotatedWith(Names.named("org.apache.james.api.vut.management.VirtualUserTableManagementService")).toInstance(vutService);
+            bind(DomainListManagementService.class).annotatedWith(Names.named("org.apache.james.management.DomainListManagementService")).toInstance(domainService);
+            bind(Store.class).annotatedWith(Names.named("org.apache.avalon.cornerstone.services.store.Store")).toInstance(store);
+            // we bind the LoaderService to an Provider to get sure everything is there when
the SMTPLoaderService get created.
+            bind(LoaderService.class).annotatedWith(Names.named("org.apache.james.LoaderService")).toProvider(new
Provider<LoaderService>() {
+
+                public LoaderService get() {
+                    return new RemoteManagerLoaderService();
+                }
+                
+                // Mimic the loaderservice
+                class RemoteManagerLoaderService implements LoaderService {
+                    Injector injector = Guice.createInjector(new RemoteManagerModule(), new
Jsr250Module());
+
+                    public <T> T load(Class<T> type) {
+                        return injector.getInstance(type);
+                    }
+                    
+                }
+                
+            });
+
+        }
+    }
+}
\ No newline at end of file

Added: james/server/trunk/remotemanager-function/src/test/java/org/apache/james/remotemanager/AvalonRemoteManagerTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/remotemanager-function/src/test/java/org/apache/james/remotemanager/AvalonRemoteManagerTest.java?rev=831840&view=auto
==============================================================================
--- james/server/trunk/remotemanager-function/src/test/java/org/apache/james/remotemanager/AvalonRemoteManagerTest.java
(added)
+++ james/server/trunk/remotemanager-function/src/test/java/org/apache/james/remotemanager/AvalonRemoteManagerTest.java
Mon Nov  2 10:08:24 2009
@@ -0,0 +1,43 @@
+/****************************************************************
+ * 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.remotemanager;
+
+import org.apache.avalon.framework.container.ContainerUtil;
+import org.apache.james.test.mock.avalon.MockLogger;
+
+public class AvalonRemoteManagerTest extends RemoteManagerTest{
+
+    private AvalonRemoteManager server;
+    @Override
+    protected void setUp() throws Exception {
+        server = new AvalonRemoteManager();
+        setUpServiceManager();
+        ContainerUtil.enableLogging(server, new MockLogger());
+        ContainerUtil.service(server, serviceManager);
+        m_testConfiguration = new RemoteManagerTestConfiguration(m_remoteManagerListenerPort);
+    }
+
+    @Override
+    protected void finishSetUp(RemoteManagerTestConfiguration testConfiguration)
+            throws Exception {
+        testConfiguration.init();
+        ContainerUtil.configure(server, testConfiguration);
+        ContainerUtil.initialize(server);
+    }
+}

Modified: james/server/trunk/remotemanager-function/src/test/java/org/apache/james/remotemanager/RemoteManagerTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/remotemanager-function/src/test/java/org/apache/james/remotemanager/RemoteManagerTest.java?rev=831840&r1=831839&r2=831840&view=diff
==============================================================================
--- james/server/trunk/remotemanager-function/src/test/java/org/apache/james/remotemanager/RemoteManagerTest.java
(original)
+++ james/server/trunk/remotemanager-function/src/test/java/org/apache/james/remotemanager/RemoteManagerTest.java
Mon Nov  2 10:08:24 2009
@@ -35,16 +35,21 @@
 import org.apache.james.api.user.UsersRepository;
 import org.apache.james.api.user.UsersStore;
 import org.apache.james.api.vut.management.VirtualUserTableManagementService;
-import org.apache.james.impl.vut.VirtualUserTableManagement;
 import org.apache.james.management.BayesianAnalyzerManagementException;
 import org.apache.james.management.BayesianAnalyzerManagementService;
 import org.apache.james.management.DomainListManagementException;
 import org.apache.james.management.DomainListManagementService;
+import org.apache.james.management.ProcessorManagementService;
+import org.apache.james.management.SpoolFilter;
+import org.apache.james.management.SpoolManagementException;
+import org.apache.james.management.SpoolManagementService;
+import org.apache.james.management.mock.MockVirtualUserTableManagementService;
 import org.apache.james.services.MailServer;
 import org.apache.james.socket.JamesConnectionManager;
 import org.apache.james.socket.SimpleConnectionManager;
 import org.apache.james.test.mock.avalon.MockLogger;
 import org.apache.james.test.mock.avalon.MockSocketManager;
+import org.apache.james.test.mock.avalon.MockStore;
 import org.apache.james.test.mock.avalon.MockThreadManager;
 import org.apache.james.test.mock.james.MockFileSystem;
 import org.apache.james.test.mock.james.MockMailServer;
@@ -64,8 +69,12 @@
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
+
+import javax.mail.MessagingException;
 
 import junit.framework.TestCase;
 
@@ -87,13 +96,14 @@
     protected TelnetClient m_telnetClient;
     private MockUsersRepository m_mockUsersRepository;
     private MockMailServer mailServer;
-    private FakeLoader serviceManager;
+    protected FakeLoader serviceManager;
     private SimpleConnectionManager connectionManager;
     private MockUsersStore usersStore;
     private MockSocketManager socketManager;
     private MockThreadManager threadManager;
     private DNSService dnsservice;
     private MockFileSystem filesystem;
+    private MockVirtualUserTableManagementService vutManagement;
 
     protected void setUp() throws Exception {
         m_remoteManager = new RemoteManager();
@@ -116,7 +126,7 @@
         super.tearDown();
     }
 
-    protected void finishSetUp(RemoteManagerTestConfiguration testConfiguration) {
+    protected void finishSetUp(RemoteManagerTestConfiguration testConfiguration) throws Exception
{
         testConfiguration.init();
         try {
             m_remoteManager.setConfiguration(new ConfigurationAdapter(testConfiguration));
@@ -186,7 +196,7 @@
         readAnswer(3);
     }
 
-    private void setUpServiceManager() throws ServiceException {
+    protected void setUpServiceManager() throws ServiceException {
         serviceManager = new FakeLoader();
         connectionManager = new SimpleConnectionManager();
         ContainerUtil.enableLogging(connectionManager, new MockLogger());
@@ -211,11 +221,13 @@
         
         dnsservice = setUpDNSServer();
         serviceManager.put(DNSService.ROLE, dnsservice);
-        MockVirtualUserTableStore vutStore = new MockVirtualUserTableStore(); 
-        VirtualUserTableManagement vutManagement = new VirtualUserTableManagement();
-        vutManagement.setVirtualUserTableStore(vutStore);
-        vutManagement.setVirtualUserTableManagement(new MockVirtualUserTableManagementImpl());
-        serviceManager.put(VirtualUserTableManagementService.ROLE, vutManagement);
+        vutManagement = new MockVirtualUserTableManagementService();
+        //VirtualUserTableManagementService vutManagement = new VirtualUserTableManagement();
+        //vutManagement.setVirtualUserTableStore(vutStore);
+        //vutManagement.setVirtualUserTableManagement(new MockVirtualUserTableManagementImpl());
+        serviceManager.put(VirtualUserTableManagementService.ROLE, new MockVirtualUserTableManagementService());
+
+            
        
         ManageableDomainList xml = new SimpleDomainList();
         
@@ -292,6 +304,64 @@
                 return 0;
             }
         });
+        
+        serviceManager.put(SpoolManagementService.ROLE, new SpoolManagementService() {
+            
+            public int resendSpoolItems(String spoolRepositoryURL, String key,
+                    List lockingFailures, SpoolFilter filter)
+                    throws MessagingException, SpoolManagementException {
+                // TODO Auto-generated method stub
+                return 0;
+            }
+            
+            public int removeSpoolItems(String spoolRepositoryURL, String key,
+                    List lockingFailures, SpoolFilter filter)
+                    throws MessagingException, SpoolManagementException {
+                // TODO Auto-generated method stub
+                return 0;
+            }
+            
+            public int moveSpoolItems(String srcSpoolRepositoryURL,
+                    String dstSpoolRepositoryURL, String dstState, SpoolFilter filter)
+                    throws MessagingException, SpoolManagementException {
+                // TODO Auto-generated method stub
+                return 0;
+            }
+            
+            public List getSpoolItems(String spoolRepositoryURL, SpoolFilter filter)
+                    throws MessagingException, SpoolManagementException {
+                // TODO Auto-generated method stub
+                return null;
+            }
+        });
+        serviceManager.put(MockStore.ROLE,new MockStore());
+        serviceManager.put(ProcessorManagementService.ROLE, new ProcessorManagementService()
{
+            
+            public String[] getProcessorNames() {
+                // TODO Auto-generated method stub
+                return null;
+            }
+            
+            public String[] getMatcherParameters(String processorName, int matcherIndex)
{
+                // TODO Auto-generated method stub
+                return null;
+            }
+            
+            public String[] getMatcherNames(String processorName) {
+                // TODO Auto-generated method stub
+                return null;
+            }
+            
+            public String[] getMailetParameters(String processorName, int mailetIndex) {
+                // TODO Auto-generated method stub
+                return null;
+            }
+            
+            public String[] getMailetNames(String processorName) {
+                // TODO Auto-generated method stub
+                return null;
+            }
+        });
     }
     
     private DNSService setUpDNSServer() {
@@ -323,14 +393,14 @@
         assertEquals("Arguments echoed", "hsif eht lla rof sknaht", lastLine);
     }
     */
-    public void testLogin() throws IOException {
+    public void testLogin() throws Exception {
         finishSetUp(m_testConfiguration);
         connect();
 
         login();
     }
 
-    public void testWrongLoginUser() throws IOException {
+    public void testWrongLoginUser() throws Exception {
         finishSetUp(m_testConfiguration);
         connect();
 
@@ -344,7 +414,7 @@
         assertTrue("Last line does not start with 'Login id:' but with '"+last+"'",last.startsWith("Login
id:")); // login failed, getting new login prompt
     }
 
-    public void testWrongLoginPassword() throws IOException {
+    public void testWrongLoginPassword() throws Exception {
         finishSetUp(m_testConfiguration);
         connect();
 
@@ -357,7 +427,7 @@
         assertTrue("Line does not start with 'Login id:' but with '"+last+"'", last.startsWith("Login
id:")); // login failed, getting new login prompt
     }
 
-    public void testUserCount() throws IOException {
+    public void testUserCount() throws Exception {
         finishSetUp(m_testConfiguration);
         connect();
         login();
@@ -383,7 +453,7 @@
         assertTrue(getLastLine(readAnswer()).endsWith(" 1")); // 1 total
     }
 
-    public void testAddUserAndVerify() throws IOException {
+    public void testAddUserAndVerify() throws Exception {
         finishSetUp(m_testConfiguration);
         connect();
         login();
@@ -404,7 +474,7 @@
         assertTrue(getLastLine(readAnswer()).endsWith(" does not exist"));
     }
 
-    public void testDelUser() throws IOException {
+    public void testDelUser() throws Exception {
         finishSetUp(m_testConfiguration);
         connect();
         login();
@@ -425,7 +495,7 @@
         assertTrue(getLastLine(readAnswer()).endsWith(" does not exist"));
     }
 
-    public void testQuit() throws IOException {
+    public void testQuit() throws Exception {
     
         finishSetUp(m_testConfiguration);
         connect();
@@ -445,7 +515,7 @@
     }   
   
 
-    public void testListUsers() throws IOException {
+    public void testListUsers() throws Exception {
         finishSetUp(m_testConfiguration);
         connect();
         login();
@@ -487,7 +557,7 @@
         }
     }
 
-    public void testCommandCaseInsensitive() throws IOException {
+    public void testCommandCaseInsensitive() throws Exception {
         finishSetUp(m_testConfiguration);
         connect();
         login();
@@ -505,7 +575,7 @@
         assertTrue(getLastLine(readAnswer()).endsWith(" exists"));
     }
 
-    public void testParameterCaseSensitive() throws IOException {
+    public void testParameterCaseSensitive() throws Exception {
         finishSetUp(m_testConfiguration);
         connect();
         login();
@@ -523,7 +593,7 @@
         assertTrue(getLastLine(readAnswer()).endsWith(" does not exist"));
     }
 
-    public void testAlias() throws IOException {
+    public void testAlias() throws Exception {
         m_mockUsersRepository.setForceUseJamesUser();
         finishSetUp(m_testConfiguration);
         connect();
@@ -585,7 +655,7 @@
 
     }
 
-    public void testForward() throws IOException {
+    public void testForward() throws Exception {
         m_mockUsersRepository.setForceUseJamesUser();
         finishSetUp(m_testConfiguration);
         connect();
@@ -626,7 +696,7 @@
 
     }
 
-    public void testSetPassword() throws IOException {
+    public void testSetPassword() throws Exception {
         finishSetUp(m_testConfiguration);
         connect();
         login();
@@ -656,7 +726,7 @@
         
     }
     
-    public void testAddMapping() throws IOException {
+    public void testAddMapping() throws Exception {
         String lastLine;
         finishSetUp(m_testConfiguration);
         connect();
@@ -671,7 +741,7 @@
         assertTrue("Not add mapping... allready exists",lastLine.endsWith("false"));
     }
     
-    public void testRemoveMapping() throws IOException {
+    public void testRemoveMapping() throws Exception {
         String lastLine;
         finishSetUp(m_testConfiguration);
         connect();
@@ -690,7 +760,7 @@
         assertTrue("Not remove mapping... mapping not exists",lastLine.endsWith("false"));
     }
     
-    public void testListAllMappings() throws IOException {
+    public void testListAllMappings() throws Exception {
         String lastLine;
         finishSetUp(m_testConfiguration);
         connect();
@@ -706,11 +776,11 @@
        
         sendCommand("listallmappings");
         List answer = readAnswer(3);
-        assertTrue("Read first mapping", answer.get(1).toString().endsWith("junit"));
-        assertTrue("Read second mapping line", answer.get(2).toString().endsWith("junit2"));
+        assertTrue("Read first mapping", answer.get(1).toString().contains("junit"));
+        assertTrue("Read second mapping line", answer.get(2).toString().contains("junit2"));
     }
     
-    public void testListMapping() throws IOException {
+    public void testListMapping() throws Exception {
         String lastLine;
         finishSetUp(m_testConfiguration);
         connect();
@@ -729,7 +799,7 @@
         assertTrue("list mapping", lastLine.endsWith("junit"));
     }
     
-    public void testaddDomain() throws IOException {
+    public void testaddDomain() throws Exception {
         String lastLine;
         finishSetUp(m_testConfiguration);
         connect();
@@ -749,7 +819,7 @@
         assertTrue("list domain", lastLine.endsWith("domain"));       
     }
     
-    public void testremoveDomain() throws IOException {
+    public void testremoveDomain() throws Exception {
         String lastLine;
         finishSetUp(m_testConfiguration);
         connect();
@@ -768,7 +838,7 @@
         assertTrue("Remove domain which not exist", lastLine.endsWith("fail"));    
     }
     
-    public void testListDomains() throws IOException {
+    public void testListDomains() throws Exception {
         String lastLine;
         finishSetUp(m_testConfiguration);
         connect();



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