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 no...@apache.org on 2010/04/16 22:07:24 UTC

svn commit: r935066 - in /james/server/trunk/remotemanager: ./ src/main/java/org/apache/james/remotemanager/netty/ src/test/java/org/apache/james/remotemanager/

Author: norman
Date: Fri Apr 16 20:07:23 2010
New Revision: 935066

URL: http://svn.apache.org/viewvc?rev=935066&view=rev
Log:
Add netty implementation of RemoteManager

Added:
    james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/netty/
    james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/netty/NettyRemoteManagerSession.java
    james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/netty/NioRemoteManager.java
    james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/netty/RemoteManagerChannelUpstreamHandler.java
    james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/netty/RemoteManagerResponseEncoder.java
    james/server/trunk/remotemanager/src/test/java/org/apache/james/remotemanager/AbstractRemoteManagerTest.java
      - copied, changed from r934961, james/server/trunk/remotemanager/src/test/java/org/apache/james/remotemanager/AsyncRemoteManagerTest.java
    james/server/trunk/remotemanager/src/test/java/org/apache/james/remotemanager/NioRemoteManagerTest.java
Modified:
    james/server/trunk/remotemanager/pom.xml
    james/server/trunk/remotemanager/src/test/java/org/apache/james/remotemanager/AsyncRemoteManagerTest.java

Modified: james/server/trunk/remotemanager/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/remotemanager/pom.xml?rev=935066&r1=935065&r2=935066&view=diff
==============================================================================
--- james/server/trunk/remotemanager/pom.xml (original)
+++ james/server/trunk/remotemanager/pom.xml Fri Apr 16 20:07:23 2010
@@ -74,6 +74,10 @@
       <artifactId>james-server-mina-socket</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>james-server-netty-socket</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.james.protocols</groupId>
       <artifactId>protocols-api</artifactId>
     </dependency>

Added: james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/netty/NettyRemoteManagerSession.java
URL: http://svn.apache.org/viewvc/james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/netty/NettyRemoteManagerSession.java?rev=935066&view=auto
==============================================================================
--- james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/netty/NettyRemoteManagerSession.java (added)
+++ james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/netty/NettyRemoteManagerSession.java Fri Apr 16 20:07:23 2010
@@ -0,0 +1,145 @@
+/****************************************************************
+ * 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.netty;
+
+import java.io.InputStream;
+import java.net.InetSocketAddress;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.james.protocols.api.LineHandler;
+import org.apache.james.protocols.api.Response;
+import org.apache.james.remotemanager.RemoteManagerHandlerConfigurationData;
+import org.apache.james.remotemanager.RemoteManagerSession;
+import org.apache.james.socket.netty.LineHandlerUpstreamHandler;
+import org.jboss.netty.channel.Channel;
+import org.jboss.netty.handler.stream.ChunkedStream;
+
+public class NettyRemoteManagerSession implements RemoteManagerSession {
+    private Log logger;
+    private Channel channel;
+    private Map<String, Object> state = new HashMap<String, Object>();
+    private RemoteManagerHandlerConfigurationData config;
+    private int lineHandlerCount = 0;
+    private InetSocketAddress socketAddress;
+
+    
+    public NettyRemoteManagerSession(RemoteManagerHandlerConfigurationData config, Log logger, Channel channel) {
+        this.logger = logger;
+        this.channel = channel;
+        this.config = config;
+        this.socketAddress = (InetSocketAddress) channel.getRemoteAddress();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.james.remotemanager.RemoteManagerSession#getState()
+     */
+    public Map<String, Object> getState() {
+        return state;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.james.api.protocol.LogEnabledSession#getLogger()
+     */
+    public Log getLogger() {
+        return logger;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.james.api.protocol.LogEnabledSession#resetState()
+     */
+    public void resetState() {
+        state.clear();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @seeorg.apache.james.remotemanager.RemoteManagerSession#
+     * getAdministrativeAccountData()
+     */
+    public Map<String, String> getAdministrativeAccountData() {
+        return config.getAdministrativeAccountData();
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.remotemanager.RemoteManagerSession#popLineHandler()
+     */
+    public void popLineHandler() {
+        channel.getPipeline().remove("lineHandler" + lineHandlerCount);
+        lineHandlerCount--;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.remotemanager.RemoteManagerSession#pushLineHandler(org.apache.james.remotemanager.LineHandler)
+     */
+    public void pushLineHandler(LineHandler<RemoteManagerSession> overrideCommandHandler) {
+        lineHandlerCount++;
+        channel.getPipeline().addBefore("coreHandler", "lineHandler" + lineHandlerCount, new LineHandlerUpstreamHandler<RemoteManagerSession>(overrideCommandHandler));
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.api.protocol.LogEnabledSession#getRemoteHost()
+     */
+    public String getRemoteHost() {
+        return socketAddress.getHostName();
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.api.protocol.LogEnabledSession#getRemoteIPAddress()
+     */
+    public String getRemoteIPAddress() {
+        return socketAddress.getAddress().getHostAddress();
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.api.protocol.LogEnabledSession#writeResponse(org.apache.james.api.protocol.Response)
+     */
+    public void writeResponse(Response response) {
+        if (channel.isConnected()) {
+            channel.write(response); 
+            if (response.isEndSession()) {
+                channel.close();
+            }
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.protocols.api.ProtocolSession#writeStream(java.io.InputStream)
+     */
+    public void writeStream(InputStream stream) {
+        if (channel.isConnected()) {
+            channel.write(new ChunkedStream(stream));    
+        }
+    }
+}

Added: james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/netty/NioRemoteManager.java
URL: http://svn.apache.org/viewvc/james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/netty/NioRemoteManager.java?rev=935066&view=auto
==============================================================================
--- james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/netty/NioRemoteManager.java (added)
+++ james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/netty/NioRemoteManager.java Fri Apr 16 20:07:23 2010
@@ -0,0 +1,145 @@
+/****************************************************************
+ * 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.netty;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.james.protocols.api.ProtocolHandlerChain;
+import org.apache.james.remotemanager.RemoteManagerHandlerConfigurationData;
+import org.apache.james.remotemanager.RemoteManagerMBean;
+import org.apache.james.socket.netty.AbstractAsyncServer;
+import org.apache.james.socket.netty.AbstractChannelPipelineFactory;
+import org.jboss.netty.channel.ChannelPipelineFactory;
+import org.jboss.netty.channel.ChannelUpstreamHandler;
+import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
+
+
+public class NioRemoteManager extends AbstractAsyncServer implements RemoteManagerMBean{
+
+
+    private Map<String,String> adminAccounts = new HashMap<String, String>();
+    private RemoteManagerHandlerConfigurationData configData = new RemoteManagerHandlerConfigurationDataImpl();
+   
+    private ProtocolHandlerChain handlerChain;
+
+    public void setProtocolHandlerChain(ProtocolHandlerChain handlerChain) {
+        this.handlerChain = handlerChain;
+    }
+
+    
+    @Override
+    protected int getDefaultPort() {
+        return 4555;
+    }
+
+    @Override
+    protected String getServiceType() {
+        return "RemoteManager Service";
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    protected void doConfigure(HierarchicalConfiguration config) throws ConfigurationException {
+        super.doConfigure(config);
+        HierarchicalConfiguration handlerConfiguration = config.configurationAt("handler");
+        List<HierarchicalConfiguration> accounts = handlerConfiguration.configurationsAt("administrator_accounts.account");
+        for (int i = 0; i < accounts.size(); i++) {
+            adminAccounts.put(accounts.get(i).getString("[@login]"), accounts.get(i).getString("[@password]"));
+        }
+    }
+
+  
+    
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.remotemanager.RemoteManagerMBean#getNetworkInterface()
+     */
+    public String getNetworkInterface() {
+        return "unknown";
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.remotemanager.RemoteManagerMBean#getSocketType()
+     */
+    public String getSocketType() {
+        return "plain";
+    }
+    
+    /**
+     * A class to provide RemoteManager handler configuration to the handlers
+     */
+    private class RemoteManagerHandlerConfigurationDataImpl
+        implements RemoteManagerHandlerConfigurationData {
+
+        /**
+         * @see org.apache.james.remotemanager.RemoteManagerHandlerConfigurationData#getHelloName()
+         */
+        public String getHelloName() {
+            if (getHelloName() == null) {
+                return NioRemoteManager.this.getMailServer().getHelloName();
+            } else {
+                return NioRemoteManager.this.getHelloName();
+            }
+        }
+        
+        /**
+         * @see org.apache.james.remotemanager.RemoteManagerHandlerConfigurationData#getAdministrativeAccountData()
+         */
+        public Map<String,String> getAdministrativeAccountData() {
+            return NioRemoteManager.this.adminAccounts;
+        }
+
+        /**
+         * @see org.apache.james.remotemanager.RemoteManagerHandlerConfigurationData#getPrompt()
+         */
+        public String getPrompt() {
+            return "";
+        }
+        
+    }
+    
+    @Override
+    protected ChannelPipelineFactory createPipelineFactory() {
+        return new AbstractChannelPipelineFactory() {
+
+            @Override
+            protected OneToOneEncoder createEncoder() {
+                return new RemoteManagerResponseEncoder();
+            }
+
+            @Override
+            protected ChannelUpstreamHandler createHandler() {
+                return new RemoteManagerChannelUpstreamHandler(configData, handlerChain, getLogger());
+            }
+
+            @Override
+            protected int getTimeout() {
+                return NioRemoteManager.this.getTimeout();
+            }
+            
+        };
+    }
+
+}

Added: james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/netty/RemoteManagerChannelUpstreamHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/netty/RemoteManagerChannelUpstreamHandler.java?rev=935066&view=auto
==============================================================================
--- james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/netty/RemoteManagerChannelUpstreamHandler.java (added)
+++ james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/netty/RemoteManagerChannelUpstreamHandler.java Fri Apr 16 20:07:23 2010
@@ -0,0 +1,47 @@
+/****************************************************************
+ * 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.netty;
+
+import org.apache.commons.logging.Log;
+import org.apache.james.protocols.api.ProtocolHandlerChain;
+import org.apache.james.protocols.api.ProtocolSession;
+import org.apache.james.remotemanager.RemoteManagerHandlerConfigurationData;
+import org.apache.james.remotemanager.RemoteManagerSession;
+import org.apache.james.socket.netty.AbstractChannelUpstreamHandler;
+import org.jboss.netty.channel.ChannelHandlerContext;
+
+public class RemoteManagerChannelUpstreamHandler extends AbstractChannelUpstreamHandler{
+
+    private Log logger;
+    private RemoteManagerHandlerConfigurationData config;
+    public RemoteManagerChannelUpstreamHandler(RemoteManagerHandlerConfigurationData config, ProtocolHandlerChain chain, Log logger) {
+        super(chain);
+        this.logger = logger;
+        this.config = config;
+    }
+
+    @Override
+    protected ProtocolSession createSession(ChannelHandlerContext ctx) throws Exception {
+        RemoteManagerSession rSession  = new NettyRemoteManagerSession(config, logger, ctx.getChannel());
+        rSession.getState().put(RemoteManagerSession.CURRENT_USERREPOSITORY, "LocalUsers");
+        return rSession;
+    }
+
+}

Added: james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/netty/RemoteManagerResponseEncoder.java
URL: http://svn.apache.org/viewvc/james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/netty/RemoteManagerResponseEncoder.java?rev=935066&view=auto
==============================================================================
--- james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/netty/RemoteManagerResponseEncoder.java (added)
+++ james/server/trunk/remotemanager/src/main/java/org/apache/james/remotemanager/netty/RemoteManagerResponseEncoder.java Fri Apr 16 20:07:23 2010
@@ -0,0 +1,44 @@
+/****************************************************************
+ * 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.netty;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.james.remotemanager.RemoteManagerResponse;
+import org.apache.james.socket.netty.AbstractResponseEncoder;
+
+public class RemoteManagerResponseEncoder extends AbstractResponseEncoder<RemoteManagerResponse>{
+
+    public RemoteManagerResponseEncoder() {
+        super(RemoteManagerResponse.class, "UTF-8");
+    }
+
+    @Override
+    protected List<String> getResponse(RemoteManagerResponse response) {
+        List<String> responseList = new ArrayList<String>();
+        for (int k = 0; k < response.getLines().size(); k++) {
+            responseList.add(response.getLines().get(k).toString());
+        }
+        return responseList;
+        
+    }
+
+}

Copied: james/server/trunk/remotemanager/src/test/java/org/apache/james/remotemanager/AbstractRemoteManagerTest.java (from r934961, james/server/trunk/remotemanager/src/test/java/org/apache/james/remotemanager/AsyncRemoteManagerTest.java)
URL: http://svn.apache.org/viewvc/james/server/trunk/remotemanager/src/test/java/org/apache/james/remotemanager/AbstractRemoteManagerTest.java?p2=james/server/trunk/remotemanager/src/test/java/org/apache/james/remotemanager/AbstractRemoteManagerTest.java&p1=james/server/trunk/remotemanager/src/test/java/org/apache/james/remotemanager/AsyncRemoteManagerTest.java&r1=934961&r2=935066&rev=935066&view=diff
==============================================================================
--- james/server/trunk/remotemanager/src/test/java/org/apache/james/remotemanager/AsyncRemoteManagerTest.java (original)
+++ james/server/trunk/remotemanager/src/test/java/org/apache/james/remotemanager/AbstractRemoteManagerTest.java Fri Apr 16 20:07:23 2010
@@ -65,7 +65,7 @@ import org.apache.james.test.util.Util;
 import org.apache.james.userrepository.MockUsersRepository;
 import org.apache.james.util.InternetPrintWriter;
 
-public class AsyncRemoteManagerTest extends TestCase {
+public abstract class AbstractRemoteManagerTest extends TestCase {
     private int m_remoteManagerListenerPort = Util.getNonPrivilegedPort();
 	private RemoteManagerTestConfiguration m_testConfiguration;
 	private String m_host = "127.0.0.1";
@@ -73,14 +73,13 @@ public class AsyncRemoteManagerTest exte
 	private InternetPrintWriter m_writer;
 	private TelnetClient m_telnetClient;
 	private MockUsersRepository m_mockUsersRepository;
-	private MockMailServer mailServer;
+	protected MockMailServer mailServer;
 	private FakeLoader serviceManager;
 	private MockUsersStore usersStore;
-	private DNSService dnsservice;
-	private MockFileSystem filesystem;
+	protected DNSService dnsservice;
+	protected MockFileSystem filesystem;
 	private MockVirtualUserTableManagementService vutManagement;
-	private AsyncRemoteManager remotemanager;
-	private ProtocolHandlerChainImpl chain;
+	protected ProtocolHandlerChainImpl chain;
 	
 	protected void setUp() throws Exception {
 		setUpFakeLoader();
@@ -89,16 +88,7 @@ public class AsyncRemoteManagerTest exte
 	    chain.setInstanceFactory(serviceManager);
 	    chain.setLog(new SimpleLog("ChainLog"));
 	        
-	        
-		remotemanager = new AsyncRemoteManager();
-		remotemanager.setDNSService(dnsservice);
-		remotemanager.setFileSystem(filesystem);
-		remotemanager.setProtocolHandlerChain(chain);
-       
-		SimpleLog log = new SimpleLog("Mock");
-		log.setLevel(SimpleLog.LOG_LEVEL_DEBUG);
-		remotemanager.setLog(log);
-		remotemanager.setMailServer(mailServer);
+	    setUpRemoteManager();
 		m_testConfiguration = new RemoteManagerTestConfiguration(
 				m_remoteManagerListenerPort);
 	}
@@ -112,11 +102,15 @@ public class AsyncRemoteManagerTest exte
 			throws Exception {
 		testConfiguration.init();
         chain.configure(testConfiguration.configurationAt("handler.handlerchain"));        
-		remotemanager.configure(testConfiguration);
 		chain.init();
-		remotemanager.init();
+		initRemoteManager(testConfiguration);
 	}
 
+
+    protected abstract void setUpRemoteManager() throws Exception;
+    protected abstract void initRemoteManager(RemoteManagerTestConfiguration testConfiguration) throws Exception;
+    
+    
 	protected void login() throws IOException {
 		login(m_testConfiguration.getLoginName(), m_testConfiguration
 				.getLoginPassword());

Modified: james/server/trunk/remotemanager/src/test/java/org/apache/james/remotemanager/AsyncRemoteManagerTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/remotemanager/src/test/java/org/apache/james/remotemanager/AsyncRemoteManagerTest.java?rev=935066&r1=935065&r2=935066&view=diff
==============================================================================
--- james/server/trunk/remotemanager/src/test/java/org/apache/james/remotemanager/AsyncRemoteManagerTest.java (original)
+++ james/server/trunk/remotemanager/src/test/java/org/apache/james/remotemanager/AsyncRemoteManagerTest.java Fri Apr 16 20:07:23 2010
@@ -16,749 +16,33 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-
 package org.apache.james.remotemanager;
 
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.mail.MessagingException;
-
-import junit.framework.TestCase;
-
 import org.apache.commons.logging.impl.SimpleLog;
-import org.apache.commons.net.telnet.TelnetClient;
-import org.apache.james.api.dnsservice.AbstractDNSServer;
-import org.apache.james.api.dnsservice.DNSService;
-import org.apache.james.api.domainlist.ManageableDomainList;
-import org.apache.james.api.domainlist.SimpleDomainList;
-import org.apache.james.api.kernel.mock.FakeLoader;
-import org.apache.james.api.user.UsersRepository;
-import org.apache.james.api.user.UsersStore;
-import org.apache.james.api.vut.management.MockVirtualUserTableManagementService;
-import org.apache.james.api.vut.management.VirtualUserTableManagementService;
-import org.apache.james.lifecycle.LifecycleUtil;
-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.remotemanager.mina.AsyncRemoteManager;
-import org.apache.james.services.MailServer;
-import org.apache.james.socket.ProtocolHandlerChainImpl;
-import org.apache.james.test.mock.avalon.MockStore;
-import org.apache.james.test.mock.james.MockFileSystem;
-import org.apache.james.test.mock.james.MockMailServer;
-import org.apache.james.test.mock.james.MockUsersStore;
-import org.apache.james.test.util.Util;
-import org.apache.james.userrepository.MockUsersRepository;
-import org.apache.james.util.InternetPrintWriter;
-
-public class AsyncRemoteManagerTest extends TestCase {
-    private int m_remoteManagerListenerPort = Util.getNonPrivilegedPort();
-	private RemoteManagerTestConfiguration m_testConfiguration;
-	private String m_host = "127.0.0.1";
-	private BufferedReader m_reader;
-	private InternetPrintWriter m_writer;
-	private TelnetClient m_telnetClient;
-	private MockUsersRepository m_mockUsersRepository;
-	private MockMailServer mailServer;
-	private FakeLoader serviceManager;
-	private MockUsersStore usersStore;
-	private DNSService dnsservice;
-	private MockFileSystem filesystem;
-	private MockVirtualUserTableManagementService vutManagement;
-	private AsyncRemoteManager remotemanager;
-	private ProtocolHandlerChainImpl chain;
-	
-	protected void setUp() throws Exception {
-		setUpFakeLoader();
-
-		chain = new ProtocolHandlerChainImpl();
-	    chain.setInstanceFactory(serviceManager);
-	    chain.setLog(new SimpleLog("ChainLog"));
-	        
-	        
-		remotemanager = new AsyncRemoteManager();
-		remotemanager.setDNSService(dnsservice);
-		remotemanager.setFileSystem(filesystem);
-		remotemanager.setProtocolHandlerChain(chain);
-       
-		SimpleLog log = new SimpleLog("Mock");
-		log.setLevel(SimpleLog.LOG_LEVEL_DEBUG);
-		remotemanager.setLog(log);
-		remotemanager.setMailServer(mailServer);
-		m_testConfiguration = new RemoteManagerTestConfiguration(
-				m_remoteManagerListenerPort);
-	}
-
-	protected void tearDown() throws Exception {
-	    LifecycleUtil.dispose(mailServer);
-		super.tearDown();
-	}
-
-	protected void finishSetUp(RemoteManagerTestConfiguration testConfiguration)
-			throws Exception {
-		testConfiguration.init();
-        chain.configure(testConfiguration.configurationAt("handler.handlerchain"));        
-		remotemanager.configure(testConfiguration);
-		chain.init();
-		remotemanager.init();
-	}
-
-	protected void login() throws IOException {
-		login(m_testConfiguration.getLoginName(), m_testConfiguration
-				.getLoginPassword());
-	}
-
-	protected void login(String name, String password) throws IOException {
-		sendCommand(name);
-		List answers = readAnswer();
-		String last = getLastLine(answers);
-		assertTrue("Last line does not start with Password: " + last, last
-				.startsWith("Password:"));
-		sendCommand(password);
-		answers = readAnswer();
-		last = getLastLine(answers);
-		assertTrue("Last line does not start with Welcome: " + last, last
-				.startsWith("Welcome"));
-	}
-
-	protected String getLastLine(List list) {
-		if (list == null || list.isEmpty())
-			return null;
-		return (String) list.get(list.size() - 1);
-	}
-
-	protected List readAnswer() {
-		return readAnswer(1);
-	}
-
-	protected List readAnswer(int numLines) {
-		List allAnswerLines = new ArrayList();
-		try {
-			if (numLines > 0) {
-				for (int i = 0; i < numLines; i++) {
-					allAnswerLines.add(m_reader.readLine());
-				}
-			} else {
-				String line = m_reader.readLine();
-				allAnswerLines.add(line);
-
-				while (m_reader.ready()) {
-					allAnswerLines.add(m_reader.readLine());
-				}
-			}
-			return allAnswerLines;
-		} catch (IOException e) {
-			return null;
-		}
-	}
-
-	protected void sendCommand(String command) throws IOException {
-		m_writer.println(command);
-		m_writer.flush();
-	}
-
-	protected void connect() throws IOException {
-		m_telnetClient = new TelnetClient();
-		m_telnetClient.connect(m_host, m_remoteManagerListenerPort);
-
-		m_reader = new BufferedReader(new InputStreamReader(
-				new BufferedInputStream(m_telnetClient.getInputStream(), 1024),
-				"ASCII"));
-		m_writer = new InternetPrintWriter(new BufferedOutputStream(
-				m_telnetClient.getOutputStream(), 1024), true);
-
-		readAnswer(3);
-	}
-
-	protected void setUpFakeLoader() throws Exception {
-		serviceManager = new FakeLoader();
-
-		m_mockUsersRepository = new MockUsersRepository();
-
-		mailServer = new MockMailServer(m_mockUsersRepository);
-		usersStore = new MockUsersStore(m_mockUsersRepository);
-
-		serviceManager.put(MailServer.ROLE, mailServer);
-		serviceManager.put(UsersRepository.ROLE, m_mockUsersRepository);
-
-		filesystem = new MockFileSystem();
-		serviceManager.put(MockFileSystem.ROLE, filesystem);
-
-		serviceManager.put(UsersStore.ROLE, usersStore);
-
-		dnsservice = setUpDNSServer();
-		serviceManager.put(DNSService.ROLE, dnsservice);
-		vutManagement = new MockVirtualUserTableManagementService();
-		// VirtualUserTableManagementService vutManagement = new
-		// VirtualUserTableManagement();
-		// vutManagement.setVirtualUserTableStore(vutStore);
-		// vutManagement.setVirtualUserTableManagement(new
-		// MockVirtualUserTableManagementImpl());
-		serviceManager.put(VirtualUserTableManagementService.ROLE,
-				new MockVirtualUserTableManagementService());
-
-		ManageableDomainList xml = new SimpleDomainList();
-
-		DomainListManagementService domManagement = new DomainListManagementService() {
-
-			private ManageableDomainList domainList;
-
-			public boolean addDomain(String domain)
-					throws DomainListManagementException {
-				return domainList.addDomain(domain);
-			}
-
-			public DomainListManagementService setDomainList(
-					ManageableDomainList xml) {
-				this.domainList = xml;
-				return this;
-			}
-
-			public boolean containsDomain(String domain) {
-				return domainList.containsDomain(domain);
-			}
-
-			public List getDomains() {
-				return domainList.getDomains();
-			}
-
-			public boolean removeDomain(String domain)
-					throws DomainListManagementException {
-				return domainList.removeDomain(domain);
-			}
-
-		}.setDomainList(xml);
-
-		serviceManager.put(DomainListManagementService.ROLE, domManagement);
-		serviceManager.put(BayesianAnalyzerManagementService.ROLE,
-				new BayesianAnalyzerManagementService() {
-
-					public void resetData()
-							throws BayesianAnalyzerManagementException {
-						// TODO Auto-generated method stub
-
-					}
-
-					public void importData(String file)
-							throws BayesianAnalyzerManagementException {
-						// TODO Auto-generated method stub
-
-					}
-
-					public void exportData(String file)
-							throws BayesianAnalyzerManagementException {
-						// TODO Auto-generated method stub
-
-					}
-
-					public int addSpamFromMbox(String file)
-							throws BayesianAnalyzerManagementException {
-						// TODO Auto-generated method stub
-						return 0;
-					}
-
-					public int addSpamFromDir(String dir)
-							throws BayesianAnalyzerManagementException {
-						// TODO Auto-generated method stub
-						return 0;
-					}
-
-					public int addHamFromMbox(String file)
-							throws BayesianAnalyzerManagementException {
-						// TODO Auto-generated method stub
-						return 0;
-					}
-
-					public int addHamFromDir(String dir)
-							throws BayesianAnalyzerManagementException {
-						// TODO Auto-generated method stub
-						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("mailStore", 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() {
-		DNSService dns = new AbstractDNSServer() {
-			public String getHostName(InetAddress addr) {
-				return "localhost";
-			}
-
-			public InetAddress getLocalHost() throws UnknownHostException {
-				return InetAddress.getLocalHost();
-			}
-
-			public InetAddress[] getAllByName(String name)
-					throws UnknownHostException {
-				return new InetAddress[] { InetAddress.getLocalHost() };
-			}
-		};
-
-		return dns;
-	}
-
-	/*
-	 * public void testCustomCommand() throws Exception {
-	 * finishSetUp(m_testConfiguration); connect(); login();
-	 * 
-	 * sendCommand("echo hsif eht lla rof sknaht"); String lastLine =
-	 * getLastLine(readAnswer()); assertEquals("Arguments echoed",
-	 * "hsif eht lla rof sknaht", lastLine); }
-	 */
-	public void testLogin() throws Exception {
-		finishSetUp(m_testConfiguration);
-		connect();
-
-		login();
-	}
-
-	public void testWrongLoginUser() throws Exception {
-		finishSetUp(m_testConfiguration);
-		connect();
-
-		sendCommand("sindbad");
-		List answers = readAnswer();
-		sendCommand(m_testConfiguration.getLoginPassword());
-
-		// we should receive the fail message and a new Login id.
-		answers = readAnswer(2);
-		String last = getLastLine(answers);
-		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 Exception {
-		finishSetUp(m_testConfiguration);
-		connect();
-
-		sendCommand(m_testConfiguration.getLoginName());
-		List answers = readAnswer();
-		sendCommand("getmethru");
-
-		answers = readAnswer(2);
-		String last = getLastLine(answers);
-		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 Exception {
-		finishSetUp(m_testConfiguration);
-		connect();
-		login();
-
-		sendCommand("countusers");
-		assertTrue(getLastLine(readAnswer()).endsWith(" 0")); // no user yet
-
-		sendCommand("adduser testCount1 testCount");
-		assertTrue(getLastLine(readAnswer()).endsWith(" added")); // success
-
-		sendCommand("countusers");
-		assertTrue(getLastLine(readAnswer()).endsWith(" 1")); // 1 total
-
-		sendCommand("adduser testCount2 testCount");
-		assertTrue(getLastLine(readAnswer()).endsWith(" added")); // success
-
-		sendCommand("countusers");
-		assertTrue(getLastLine(readAnswer()).endsWith(" 2")); // 2 total
-
-		m_mockUsersRepository.removeUser("testCount1");
-
-		sendCommand("countusers");
-		assertTrue(getLastLine(readAnswer()).endsWith(" 1")); // 1 total
-	}
-
-	public void testAddUserAndVerify() throws Exception {
-		finishSetUp(m_testConfiguration);
-		connect();
-		login();
-
-		sendCommand("adduser testAdd test");
-		assertTrue(getLastLine(readAnswer()).endsWith(" added")); // success
-
-		sendCommand("verify testNotAdded");
-		assertTrue(getLastLine(readAnswer()).endsWith(" does not exist"));
-
-		sendCommand("verify testAdd");
-		assertTrue(getLastLine(readAnswer()).endsWith(" exists"));
-
-		sendCommand("deluser testAdd");
-		readAnswer();
-
-		sendCommand("verify testAdd");
-		assertTrue(getLastLine(readAnswer()).endsWith(" does not exist"));
-	}
-
-	public void testDelUser() throws Exception {
-		finishSetUp(m_testConfiguration);
-		connect();
-		login();
-
-		sendCommand("adduser testDel test");
-		assertTrue(getLastLine(readAnswer()).endsWith(" added")); // success
-
-		sendCommand("deluser testNotDeletable");
-		assertTrue(getLastLine(readAnswer()).endsWith(" doesn't exist"));
-
-		sendCommand("verify testDel");
-		assertTrue(getLastLine(readAnswer()).endsWith(" exists"));
-
-		sendCommand("deluser testDel");
-		assertTrue(getLastLine(readAnswer()).endsWith(" deleted"));
-
-		sendCommand("verify testDel");
-		assertTrue(getLastLine(readAnswer()).endsWith(" does not exist"));
-	}
-
-	public void testQuit() throws Exception {
-
-		finishSetUp(m_testConfiguration);
-		connect();
-		login();
-
-		sendCommand("help");
-		delay();
-		assertTrue("command line is effective", readAnswer().size() > 0);
-
-		sendCommand("quit");
-		delay();
-		assertTrue("", readAnswer(39).contains("Bye"));
-
-		sendCommand("help");
-		delay();
-		assertNull("connection is closed", m_reader.readLine());
-	}
-
-	public void testListUsers() throws Exception {
-		finishSetUp(m_testConfiguration);
-		connect();
-		login();
-
-		String[] users = new String[] { "ccc", "aaa", "dddd", "bbbbb" };
-
-		for (int i = 0; i < users.length; i++) {
-			String user = users[i];
-			sendCommand("adduser " + user + " test");
-			readAnswer(1);
-		}
-
-		delay();
-
-		sendCommand("listusers");
-		List list = readAnswer(5);
-
-		assertEquals("user count line", "Existing accounts " + users.length,
-				list.get(0));
-
-		List readUserNames = new ArrayList();
-		for (Iterator iterator = list.iterator(); iterator.hasNext();) {
-			String answerLine = (String) iterator.next();
-			if (!answerLine.startsWith("user: "))
-				continue;
-			readUserNames.add(answerLine.substring(6));
-		}
-		assertEquals("user count", users.length, readUserNames.size());
-
-		for (int i = 0; i < users.length; i++) {
-			String user = users[i];
-			assertTrue("name found", readUserNames.contains(user));
-		}
-	}
-
-	private void delay() {
-		try {
-			Thread.sleep(100);
-		} catch (InterruptedException e) {
-			; // ignore
-		}
-	}
-
-	public void testCommandCaseInsensitive() throws Exception {
-		finishSetUp(m_testConfiguration);
-		connect();
-		login();
-
-		sendCommand("adduser testDel test");
-		assertTrue(getLastLine(readAnswer()).endsWith(" added")); // success
-
-		sendCommand("verify testDel");
-		assertTrue(getLastLine(readAnswer()).endsWith(" exists"));
-
-		sendCommand("VERIFY testDel");
-		assertTrue(getLastLine(readAnswer()).endsWith(" exists"));
-
-		sendCommand("vErIfY testDel");
-		assertTrue(getLastLine(readAnswer()).endsWith(" exists"));
-	}
-
-	public void testParameterCaseSensitive() throws Exception {
-		finishSetUp(m_testConfiguration);
-		connect();
-		login();
-
-		sendCommand("adduser testDel test");
-		assertTrue(getLastLine(readAnswer()).endsWith(" added")); // success
-
-		sendCommand("verify testDel");
-		assertTrue(getLastLine(readAnswer()).endsWith(" exists"));
-
-		sendCommand("verify TESTDEL");
-		assertTrue(getLastLine(readAnswer()).endsWith(" does not exist"));
-
-		sendCommand("verify testdel");
-		assertTrue(getLastLine(readAnswer()).endsWith(" does not exist"));
-	}
-
-	
-
-	public void testSetPassword() throws Exception {
-		finishSetUp(m_testConfiguration);
-		connect();
-		login();
-
-		String lastLine;
-
-		sendCommand("adduser testPwdUser pwd1");
-		lastLine = getLastLine(readAnswer());
-		assertTrue(lastLine.endsWith(" added"));
-
-		assertTrue("initial password", m_mockUsersRepository.test(
-				"testPwdUser", "pwd1"));
-
-		sendCommand("setpassword testPwdUser     ");
-		lastLine = getLastLine(readAnswer());
-		assertTrue("password changed to empty: " + lastLine,
-				m_mockUsersRepository.test("testPwdUser", "pwd1"));
-
-		// change pwd
-		sendCommand("setpassword testPwdUser pwd2");
-		lastLine = getLastLine(readAnswer());
-		assertTrue("password not changed to pwd2: " + lastLine,
-				m_mockUsersRepository.test("testPwdUser", "pwd2"));
-
-		// assure case sensitivity
-		sendCommand("setpassword testPwdUser pWD2");
-		lastLine = getLastLine(readAnswer());
-		assertFalse("password not changed to pWD2: " + lastLine,
-				m_mockUsersRepository.test("testPwdUser", "pwd2"));
-		assertTrue("password not changed to pWD2: " + lastLine,
-				m_mockUsersRepository.test("testPwdUser", "pWD2"));
-
-	}
-
-	public void testAddMapping() throws Exception {
-		String lastLine;
-		finishSetUp(m_testConfiguration);
-		connect();
-		login();
-
-		sendCommand("addmapping test@test junit");
-		lastLine = getLastLine(readAnswer());
-		assertTrue("Add mapping", lastLine.endsWith("true"));
-
-		sendCommand("addmapping test@test junit");
-		lastLine = getLastLine(readAnswer());
-		assertTrue("Not add mapping... allready exists", lastLine
-				.endsWith("false"));
-	}
-
-	public void testRemoveMapping() throws Exception {
-		String lastLine;
-		finishSetUp(m_testConfiguration);
-		connect();
-		login();
-
-		sendCommand("addmapping test@test junit");
-		lastLine = getLastLine(readAnswer());
-		assertTrue("Add mapping", lastLine.endsWith("true"));
-
-		sendCommand("removemapping test@test junit");
-		lastLine = getLastLine(readAnswer());
-		assertTrue("remove mapping", lastLine.endsWith("true"));
-
-		sendCommand("removemapping test@test junit");
-		lastLine = getLastLine(readAnswer());
-		assertTrue("Not remove mapping... mapping not exists", lastLine
-				.endsWith("false"));
-	}
-
-	public void testListAllMappings() throws Exception {
-		String lastLine;
-		finishSetUp(m_testConfiguration);
-		connect();
-		login();
-
-		sendCommand("addmapping test@test junit");
-		lastLine = getLastLine(readAnswer());
-		assertTrue("Add mapping", lastLine.endsWith("true"));
-
-		sendCommand("addmapping test2@test junit2");
-		lastLine = getLastLine(readAnswer());
-		assertTrue("Add mapping", lastLine.endsWith("true"));
-
-		sendCommand("listallmappings");
-		List answer = readAnswer(3);
-		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 Exception {
-		String lastLine;
-		finishSetUp(m_testConfiguration);
-		connect();
-		login();
-
-		sendCommand("addmapping test@test junit");
-		lastLine = getLastLine(readAnswer());
-		assertTrue("Add mapping", lastLine.endsWith("true"));
-
-		sendCommand("addmapping test2@test junit2");
-		lastLine = getLastLine(readAnswer());
-		assertTrue("Add mapping", lastLine.endsWith("true"));
-
-		sendCommand("listmapping test@test");
-		lastLine = readAnswer(2).get(1).toString();
-		assertTrue("list mapping", lastLine.endsWith("junit"));
-	}
-
-	public void testaddDomain() throws Exception {
-		String lastLine;
-		finishSetUp(m_testConfiguration);
-		connect();
-		login();
-
-		sendCommand("adddomain domain");
-		lastLine = getLastLine(readAnswer());
-		assertTrue("Add domain", lastLine.endsWith("successful"));
-
-		sendCommand("adddomain domain");
-		lastLine = getLastLine(readAnswer());
-		assertTrue("Add domain which exists", lastLine.endsWith("fail"));
-
-		sendCommand("listdomains");
-
-		lastLine = readAnswer(2).get(1).toString();
-		assertTrue("list domain", lastLine.endsWith("domain"));
-	}
-
-	public void testremoveDomain() throws Exception {
-		String lastLine;
-		finishSetUp(m_testConfiguration);
-		connect();
-		login();
-
-		sendCommand("adddomain domain");
-		lastLine = getLastLine(readAnswer());
-		assertTrue("Add domain", lastLine.endsWith("successful"));
-
-		sendCommand("removedomain domain");
-		lastLine = getLastLine(readAnswer());
-		assertTrue("Remove domain", lastLine.endsWith("successful"));
-
-		sendCommand("removedomain domain");
-		lastLine = getLastLine(readAnswer());
-		assertTrue("Remove domain which not exist", lastLine.endsWith("fail"));
-	}
 
-	public void testListDomains() throws Exception {
-		String lastLine;
-		finishSetUp(m_testConfiguration);
-		connect();
-		login();
+public class AsyncRemoteManagerTest extends AbstractRemoteManagerTest{
 
-		sendCommand("adddomain domain");
-		lastLine = getLastLine(readAnswer());
-		assertTrue("Add domain", lastLine.endsWith("successful"));
+    private AsyncRemoteManager remotemanager;
 
-		sendCommand("adddomain domain2");
-		lastLine = getLastLine(readAnswer());
-		assertTrue("Add domain", lastLine.endsWith("successful"));
+    @Override
+    protected void initRemoteManager(RemoteManagerTestConfiguration testConfiguration) throws Exception {
+        remotemanager.configure(testConfiguration);
+        remotemanager.init();
+    }
+
+    @Override
+    protected void setUpRemoteManager() throws Exception {
+        
+        remotemanager = new AsyncRemoteManager();
+        remotemanager.setDNSService(dnsservice);
+        remotemanager.setFileSystem(filesystem);
+        remotemanager.setProtocolHandlerChain(chain);
+        SimpleLog log = new SimpleLog("Mock");
+        log.setLevel(SimpleLog.LOG_LEVEL_DEBUG);
+        remotemanager.setLog(log);
+        remotemanager.setMailServer(mailServer);
+               
+    }
 
-		sendCommand("listdomains");
-		List answer = readAnswer(3);
-		assertTrue("list domain 1", answer.get(1).toString().endsWith("domain"));
-		assertTrue("list domain 2", answer.get(2).toString()
-				.endsWith("domain2"));
-	}
 }

Added: james/server/trunk/remotemanager/src/test/java/org/apache/james/remotemanager/NioRemoteManagerTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/remotemanager/src/test/java/org/apache/james/remotemanager/NioRemoteManagerTest.java?rev=935066&view=auto
==============================================================================
--- james/server/trunk/remotemanager/src/test/java/org/apache/james/remotemanager/NioRemoteManagerTest.java (added)
+++ james/server/trunk/remotemanager/src/test/java/org/apache/james/remotemanager/NioRemoteManagerTest.java Fri Apr 16 20:07:23 2010
@@ -0,0 +1,47 @@
+/****************************************************************
+ * 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.commons.logging.impl.SimpleLog;
+import org.apache.james.remotemanager.netty.NioRemoteManager;
+
+public class NioRemoteManagerTest extends AbstractRemoteManagerTest{
+    private NioRemoteManager remotemanager;
+
+    @Override
+    protected void initRemoteManager(RemoteManagerTestConfiguration testConfiguration) throws Exception {
+        remotemanager.configure(testConfiguration);
+        remotemanager.init();
+    }
+
+    @Override
+    protected void setUpRemoteManager() throws Exception {
+        
+        remotemanager = new NioRemoteManager();
+        remotemanager.setDNSService(dnsservice);
+        remotemanager.setFileSystem(filesystem);
+        remotemanager.setProtocolHandlerChain(chain);
+        SimpleLog log = new SimpleLog("Mock");
+        log.setLevel(SimpleLog.LOG_LEVEL_DEBUG);
+        remotemanager.setLog(log);
+        remotemanager.setMailServer(mailServer);
+               
+    }
+
+}



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