james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r811777 - in /james/server/trunk: phoenix-deployment/src/test/org/apache/james/ phoenix-deployment/src/test/org/apache/james/smtpserver/ smtpserver-function/src/main/java/org/apache/james/smtpserver/ smtpserver-function/src/main/java/org/ap...
Date Sun, 06 Sep 2009 08:36:17 GMT
Author: rdonkin
Date: Sun Sep  6 08:36:16 2009
New Revision: 811777

URL: http://svn.apache.org/viewvc?rev=811777&view=rev
Log:
Inject MailServer to those handlers that require it. Remove getter from session.

Modified:
    james/server/trunk/phoenix-deployment/src/test/org/apache/james/FakeLoader.java
    james/server/trunk/phoenix-deployment/src/test/org/apache/james/smtpserver/SMTPServerRemoteDeliveryIntegrationTest.java
    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPSession.java
    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/AuthRequiredToRelayRcptHook.java
    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataCmdHandler.java
    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataLineMessageHookHandler.java
    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/MailCmdHandler.java
    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/RcptCmdHandler.java
    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/SenderAuthIdentifyVerificationRcptHook.java
    james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/FakeLoader.java
    james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java

Modified: james/server/trunk/phoenix-deployment/src/test/org/apache/james/FakeLoader.java
URL: http://svn.apache.org/viewvc/james/server/trunk/phoenix-deployment/src/test/org/apache/james/FakeLoader.java?rev=811777&r1=811776&r2=811777&view=diff
==============================================================================
--- james/server/trunk/phoenix-deployment/src/test/org/apache/james/FakeLoader.java (original)
+++ james/server/trunk/phoenix-deployment/src/test/org/apache/james/FakeLoader.java Sun Sep
 6 08:36:16 2009
@@ -26,9 +26,11 @@
 
 import javax.annotation.Resource;
 
+import org.apache.avalon.framework.service.ServiceException;
 import org.apache.james.api.kernel.LoaderService;
 
-public class FakeLoader implements LoaderService {
+public class FakeLoader implements LoaderService, org.apache.avalon.framework.service.ServiceManager{
+
     private final Map<String, Object> servicesByName;
     
     public FakeLoader() {
@@ -81,4 +83,19 @@
         }
     }
 
+
+    public boolean hasService(String name) {
+        return servicesByName.containsKey(name);
+    }
+
+    public Object lookup(String name) throws ServiceException {
+        return servicesByName.get(name);
+    }
+
+    public void release(Object service) {
+    }
+
+    public void put(String role, Object service) {
+        servicesByName.put(role, service);
+    }
 }

Modified: james/server/trunk/phoenix-deployment/src/test/org/apache/james/smtpserver/SMTPServerRemoteDeliveryIntegrationTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/phoenix-deployment/src/test/org/apache/james/smtpserver/SMTPServerRemoteDeliveryIntegrationTest.java?rev=811777&r1=811776&r2=811777&view=diff
==============================================================================
--- james/server/trunk/phoenix-deployment/src/test/org/apache/james/smtpserver/SMTPServerRemoteDeliveryIntegrationTest.java
(original)
+++ james/server/trunk/phoenix-deployment/src/test/org/apache/james/smtpserver/SMTPServerRemoteDeliveryIntegrationTest.java
Sun Sep  6 08:36:16 2009
@@ -19,6 +19,24 @@
 
 package org.apache.james.smtpserver;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import javax.mail.MessagingException;
+import javax.mail.Session;
+import javax.mail.internet.MimeMessage;
+
+import junit.framework.TestCase;
+
 import org.apache.avalon.cornerstone.services.sockets.SocketManager;
 import org.apache.avalon.cornerstone.services.store.Store;
 import org.apache.avalon.cornerstone.services.threads.ThreadManager;
@@ -31,38 +49,19 @@
 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.MockServiceManager;
 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.InMemorySpoolRepository;
 import org.apache.james.test.mock.james.MockMailServer;
-import org.apache.mailet.base.test.FakeMailContext;
-import org.apache.mailet.base.test.FakeMailetConfig;
 import org.apache.james.test.util.Util;
 import org.apache.james.transport.mailets.RemoteDelivery;
 import org.apache.james.userrepository.MockUsersRepository;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
 import org.apache.mailet.MailetContext;
-
-import javax.mail.MessagingException;
-import javax.mail.Session;
-import javax.mail.internet.MimeMessage;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-
-import junit.framework.TestCase;
+import org.apache.mailet.base.test.FakeMailContext;
+import org.apache.mailet.base.test.FakeMailetConfig;
 
 /**
  * Tests the org.apache.james.smtpserver.SMTPServer unit 
@@ -179,7 +178,7 @@
         ContainerUtil.enableLogging(m_smtpServer,new MockLogger());
         m_serviceManager = setUpServiceManager();
         ContainerUtil.service(m_smtpServer, m_serviceManager);
-        m_smtpServer.setLoader(new FakeLoader());
+        m_smtpServer.setLoader(m_serviceManager);
         m_testConfiguration = new SMTPTestConfiguration(m_smtpListenerPort);
     }
 
@@ -195,14 +194,16 @@
         m_mailServer.setMaxMessageSizeBytes(m_testConfiguration.getMaxMessageSize()*1024);
     }
 
-    private MockServiceManager setUpServiceManager() throws Exception {
-        m_serviceManager = new MockServiceManager();
+    private FakeLoader setUpServiceManager() throws Exception {
+        m_serviceManager = new FakeLoader();
         SimpleConnectionManager connectionManager = new SimpleConnectionManager();
         ContainerUtil.enableLogging(connectionManager, new MockLogger());
         m_serviceManager.put(JamesConnectionManager.ROLE, connectionManager);
         m_serviceManager.put(MailetContext.class.getName(), new FakeMailContext());
         m_mailServer = new MockMailServer(new MockUsersRepository());
         m_serviceManager.put(MailServer.ROLE, m_mailServer);
+        // Phoenix loader does not understand aliases
+        m_serviceManager.put("James", m_mailServer);
         m_serviceManager.put(UsersRepository.ROLE, m_usersRepository);
         m_serviceManager.put(SocketManager.ROLE, new MockSocketManager(m_smtpListenerPort));
         m_serviceManager.put(ThreadManager.ROLE, new MockThreadManager());
@@ -215,7 +216,7 @@
     // RemoteDelivery tests.
     
     InMemorySpoolRepository outgoingSpool;
-    private MockServiceManager m_serviceManager;
+    private FakeLoader m_serviceManager;
     private AlterableDNSServer m_dnsServer;
     
     private Properties getStandardParameters() {

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPSession.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPSession.java?rev=811777&r1=811776&r2=811777&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPSession.java
(original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPSession.java
Sun Sep  6 08:36:16 2009
@@ -22,7 +22,6 @@
 import java.util.Map;
 
 import org.apache.james.api.user.UsersRepository;
-import org.apache.james.services.MailServer;
 
 /**
  * All the handlers access this interface to communicate with
@@ -64,14 +63,6 @@
      *
      */
     void resetState();
-
-    /**
-     * Returns the MailServer interface for this service.
-     *
-     * @return the MailServer interface for this service
-     * @deprecated this service should be injection
-     */
-    MailServer getMailServer();
     
     /**
      * Returns the UsersRepository for this service.

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/AuthRequiredToRelayRcptHook.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/AuthRequiredToRelayRcptHook.java?rev=811777&r1=811776&r2=811777&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/AuthRequiredToRelayRcptHook.java
(original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/AuthRequiredToRelayRcptHook.java
Sun Sep  6 08:36:16 2009
@@ -18,8 +18,11 @@
  ****************************************************************/
 package org.apache.james.smtpserver.core;
 
+import javax.annotation.Resource;
+
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.james.dsn.DSNStatus;
+import org.apache.james.services.MailServer;
 import org.apache.james.smtpserver.SMTPRetCode;
 import org.apache.james.smtpserver.SMTPSession;
 import org.apache.james.smtpserver.hook.HookResult;
@@ -33,6 +36,25 @@
 public class AuthRequiredToRelayRcptHook extends AbstractLogEnabled implements
         RcptHook {
 
+    private MailServer mailServer;
+    
+    /**
+     * Gets the mail server.
+     * @return the mailServer
+     */
+    public final MailServer getMailServer() {
+        return mailServer;
+    }
+
+    /**
+     * Sets the mail server.
+     * @param mailServer the mailServer to set
+     */
+    @Resource(name="James")
+    public final void setMailServer(MailServer mailServer) {
+        this.mailServer = mailServer;
+    }
+    
     /**
      * @see org.apache.james.smtpserver.hook.RcptHook#doRcpt(org.apache.james.smtpserver.SMTPSession,
      *      org.apache.mailet.MailAddress, org.apache.mailet.MailAddress)
@@ -41,7 +63,7 @@
             MailAddress rcpt) {
         if (!session.isRelayingAllowed()) {
             String toDomain = rcpt.getDomain();
-            if (!session.getMailServer().isLocalServer(toDomain)) {
+            if (!mailServer.isLocalServer(toDomain)) {
                 if (session.isAuthSupported()) {
                     return new HookResult(HookReturnCode.DENY,
                             SMTPRetCode.AUTH_REQUIRED, DSNStatus.getStatus(

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataCmdHandler.java?rev=811777&r1=811776&r2=811777&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataCmdHandler.java
(original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataCmdHandler.java
Sun Sep  6 08:36:16 2009
@@ -27,6 +27,7 @@
 import java.util.LinkedList;
 import java.util.List;
 
+import javax.annotation.Resource;
 import javax.mail.MessagingException;
 
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
@@ -34,6 +35,7 @@
 import org.apache.james.core.MailHeaders;
 import org.apache.james.core.MimeMessageInputStreamSource;
 import org.apache.james.dsn.DSNStatus;
+import org.apache.james.services.MailServer;
 import org.apache.james.smtpserver.CommandHandler;
 import org.apache.james.smtpserver.ExtensibleHandler;
 import org.apache.james.smtpserver.LineHandler;
@@ -94,6 +96,25 @@
     // Keys used to store/lookup data in the internal state hash map
 
     private LineHandler lineHandler;
+
+    private MailServer mailServer;
+    
+    /**
+     * Gets the mail server.
+     * @return the mailServer
+     */
+    public final MailServer getMailServer() {
+        return mailServer;
+    }
+
+    /**
+     * Sets the mail server.
+     * @param mailServer the mailServer to set
+     */
+    @Resource(name="James")
+    public final void setMailServer(MailServer mailServer) {
+        this.mailServer = mailServer;
+    }
     
     /**
      * process DATA command
@@ -131,7 +152,7 @@
 //        }
 
         try {
-            MimeMessageInputStreamSource mmiss = new MimeMessageInputStreamSource(session.getMailServer().getId());
+            MimeMessageInputStreamSource mmiss = new MimeMessageInputStreamSource(mailServer.getId());
             OutputStream out = mmiss.getWritableOutputStream();
 
             // Prepend output headers with out Received

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataLineMessageHookHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataLineMessageHookHandler.java?rev=811777&r1=811776&r2=811777&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataLineMessageHookHandler.java
(original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataLineMessageHookHandler.java
Sun Sep  6 08:36:16 2009
@@ -26,6 +26,7 @@
 import java.util.LinkedList;
 import java.util.List;
 
+import javax.annotation.Resource;
 import javax.mail.MessagingException;
 
 import org.apache.avalon.framework.container.ContainerUtil;
@@ -34,6 +35,7 @@
 import org.apache.james.core.MimeMessageCopyOnWriteProxy;
 import org.apache.james.core.MimeMessageInputStreamSource;
 import org.apache.james.dsn.DSNStatus;
+import org.apache.james.services.MailServer;
 import org.apache.james.smtpserver.ExtensibleHandler;
 import org.apache.james.smtpserver.LineHandler;
 import org.apache.james.smtpserver.SMTPResponse;
@@ -52,6 +54,25 @@
     
     private List rHooks;
     
+    private MailServer mailServer;
+    
+    /**
+     * Gets the mail server.
+     * @return the mailServer
+     */
+    public final MailServer getMailServer() {
+        return mailServer;
+    }
+
+    /**
+     * Sets the mail server.
+     * @param mailServer the mailServer to set
+     */
+    @Resource(name="James")
+    public final void setMailServer(MailServer mailServer) {
+        this.mailServer = mailServer;
+    }
+    
     /**
      * @see org.apache.james.smtpserver.core.DataLineFilter#onLine(org.apache.james.smtpserver.SMTPSession,
byte[], org.apache.james.smtpserver.LineHandler)
      */
@@ -67,7 +88,7 @@
                 
                 List recipientCollection = (List) session.getState().get(SMTPSession.RCPT_LIST);
                 MailImpl mail =
-                    new MailImpl(session.getMailServer().getId(),
+                    new MailImpl(mailServer.getId(),
                                  (MailAddress) session.getState().get(SMTPSession.SENDER),
                                  recipientCollection);
                 MimeMessageCopyOnWriteProxy mimeMessageCopyOnWriteProxy = null;

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/MailCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/MailCmdHandler.java?rev=811777&r1=811776&r2=811777&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/MailCmdHandler.java
(original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/MailCmdHandler.java
Sun Sep  6 08:36:16 2009
@@ -28,7 +28,10 @@
 import java.util.Map;
 import java.util.StringTokenizer;
 
+import javax.annotation.Resource;
+
 import org.apache.james.dsn.DSNStatus;
+import org.apache.james.services.MailServer;
 import org.apache.james.smtpserver.CommandHandler;
 import org.apache.james.smtpserver.SMTPResponse;
 import org.apache.james.smtpserver.SMTPRetCode;
@@ -49,8 +52,25 @@
      */
     private Map<String, MailParametersHook> paramHooks;
 
-    
-    
+    private MailServer mailServer;
+        
+    /**
+     * Gets the mail server.
+     * @return the mailServer
+     */
+    public final MailServer getMailServer() {
+        return mailServer;
+    }
+
+    /**
+     * Sets the mail server.
+     * @param mailServer the mailServer to set
+     */
+    @Resource(name="James")
+    public final void setMailServer(MailServer mailServer) {
+        this.mailServer = mailServer;
+    }
+
     @Override
 	public SMTPResponse onCommand(SMTPSession session, String command,
 			String parameters) {
@@ -223,8 +243,7 @@
                 if (sender.indexOf("@") < 0) {
                     sender = sender
                             + "@"
-                            + session.getMailServer()
-                                    .getDefaultDomain();
+                            + mailServer.getDefaultDomain();
                 }
 
                 try {

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/RcptCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/RcptCmdHandler.java?rev=811777&r1=811776&r2=811777&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/RcptCmdHandler.java
(original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/RcptCmdHandler.java
Sun Sep  6 08:36:16 2009
@@ -24,7 +24,10 @@
 import java.util.Locale;
 import java.util.StringTokenizer;
 
+import javax.annotation.Resource;
+
 import org.apache.james.dsn.DSNStatus;
+import org.apache.james.services.MailServer;
 import org.apache.james.smtpserver.CommandHandler;
 import org.apache.james.smtpserver.SMTPResponse;
 import org.apache.james.smtpserver.SMTPRetCode;
@@ -41,6 +44,25 @@
 
     public static final String CURRENT_RECIPIENT = "CURRENT_RECIPIENT"; // Current recipient
 
+    private MailServer mailServer;
+    
+    /**
+     * Gets the mail server.
+     * @return the mailServer
+     */
+    public final MailServer getMailServer() {
+        return mailServer;
+    }
+
+    /**
+     * Sets the mail server.
+     * @param mailServer the mailServer to set
+     */
+    @Resource(name="James")
+    public final void setMailServer(MailServer mailServer) {
+        this.mailServer = mailServer;
+    }
+    
     /**
      * Handler method called upon receipt of a RCPT command. Reads recipient.
      * Does some connection validation.
@@ -142,7 +164,7 @@
             // set the default domain
             recipient = recipient
                     + "@"
-                    + session.getMailServer().getDefaultDomain();
+                    + mailServer.getDefaultDomain();
         }
 
         try {

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/SenderAuthIdentifyVerificationRcptHook.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/SenderAuthIdentifyVerificationRcptHook.java?rev=811777&r1=811776&r2=811777&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/SenderAuthIdentifyVerificationRcptHook.java
(original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/SenderAuthIdentifyVerificationRcptHook.java
Sun Sep  6 08:36:16 2009
@@ -20,8 +20,11 @@
 
 import java.util.Locale;
 
+import javax.annotation.Resource;
+
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.james.dsn.DSNStatus;
+import org.apache.james.services.MailServer;
 import org.apache.james.smtpserver.SMTPRetCode;
 import org.apache.james.smtpserver.SMTPSession;
 import org.apache.james.smtpserver.hook.HookResult;
@@ -35,6 +38,25 @@
 public class SenderAuthIdentifyVerificationRcptHook extends AbstractLogEnabled
         implements RcptHook {
 
+    private MailServer mailServer;
+    
+    /**
+     * Gets the mail server.
+     * @return the mailServer
+     */
+    public final MailServer getMailServer() {
+        return mailServer;
+    }
+
+    /**
+     * Sets the mail server.
+     * @param mailServer the mailServer to set
+     */
+    @Resource(name="James")
+    public final void setMailServer(MailServer mailServer) {
+        this.mailServer = mailServer;
+    }
+    
     /**
      * @see org.apache.james.smtpserver.hook.RcptHook#doRcpt(org.apache.james.smtpserver.SMTPSession,
      *      org.apache.mailet.MailAddress, org.apache.mailet.MailAddress)
@@ -48,7 +70,7 @@
 
             if ((senderAddress == null)
                     || (!authUser.equals(senderAddress.getLocalPart()))
-                    || (!session.getMailServer()
+                    || (!mailServer
                             .isLocalServer(senderAddress.getDomain()))) {
                 return new HookResult(HookReturnCode.DENY, 
                         SMTPRetCode.BAD_SEQUENCE,

Modified: james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/FakeLoader.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/FakeLoader.java?rev=811777&r1=811776&r2=811777&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/FakeLoader.java
(original)
+++ james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/FakeLoader.java
Sun Sep  6 08:36:16 2009
@@ -26,9 +26,10 @@
 
 import javax.annotation.Resource;
 
+import org.apache.avalon.framework.service.ServiceException;
 import org.apache.james.api.kernel.LoaderService;
 
-public class FakeLoader implements LoaderService {
+public class FakeLoader implements LoaderService, org.apache.avalon.framework.service.ServiceManager{
 
     private final Map<String, Object> servicesByName;
     
@@ -82,4 +83,19 @@
         }
     }
 
+
+    public boolean hasService(String name) {
+        return servicesByName.containsKey(name);
+    }
+
+    public Object lookup(String name) throws ServiceException {
+        return servicesByName.get(name);
+    }
+
+    public void release(Object service) {
+    }
+
+    public void put(String role, Object service) {
+        servicesByName.put(role, service);
+    }
 }

Modified: james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java?rev=811777&r1=811776&r2=811777&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
(original)
+++ james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
Sun Sep  6 08:36:16 2009
@@ -19,6 +19,25 @@
 
 package org.apache.james.smtpserver;
 
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.mail.MessagingException;
+import javax.mail.internet.MimeMessage;
+
+import junit.framework.TestCase;
+
 import org.apache.avalon.cornerstone.services.sockets.SocketManager;
 import org.apache.avalon.cornerstone.services.store.Store;
 import org.apache.avalon.cornerstone.services.threads.ThreadManager;
@@ -29,39 +48,19 @@
 import org.apache.james.api.user.UsersRepository;
 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.MockServiceManager;
 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.MockMailServer;
-import org.apache.mailet.base.test.FakeMailContext;
 import org.apache.james.test.util.Util;
 import org.apache.james.userrepository.MockUsersRepository;
 import org.apache.james.util.codec.Base64;
-import org.apache.james.socket.SimpleConnectionManager;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
 import org.apache.mailet.MailetContext;
-
-import javax.mail.MessagingException;
-import javax.mail.internet.MimeMessage;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.Writer;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import junit.framework.TestCase;
+import org.apache.mailet.base.test.FakeMailContext;
 
 /**
  * Tests the org.apache.james.smtpserver.SMTPServer unit 
@@ -150,7 +149,7 @@
     private SMTPTestConfiguration m_testConfiguration;
     private SMTPServer m_smtpServer;
     private MockUsersRepository m_usersRepository = new MockUsersRepository();
-    private MockServiceManager m_serviceManager;
+    private FakeLoader m_serviceManager;
     private AlterableDNSServer m_dnsServer;
 
     public SMTPServerTest() {
@@ -181,7 +180,7 @@
         ContainerUtil.enableLogging(m_smtpServer,new MockLogger());
         m_serviceManager = setUpServiceManager();
         ContainerUtil.service(m_smtpServer, m_serviceManager);
-        m_smtpServer.setLoader(new FakeLoader());
+        m_smtpServer.setLoader(m_serviceManager);
         m_testConfiguration = new SMTPTestConfiguration(m_smtpListenerPort);
     }
 
@@ -197,14 +196,16 @@
         m_mailServer.setMaxMessageSizeBytes(m_testConfiguration.getMaxMessageSize()*1024);
     }
 
-    private MockServiceManager setUpServiceManager() throws Exception {
-        m_serviceManager = new MockServiceManager();
+    private FakeLoader setUpServiceManager() throws Exception {
+        m_serviceManager = new FakeLoader();
         SimpleConnectionManager connectionManager = new SimpleConnectionManager();
         ContainerUtil.enableLogging(connectionManager, new MockLogger());
         m_serviceManager.put(JamesConnectionManager.ROLE, connectionManager);
         m_serviceManager.put(MailetContext.class.getName(), new FakeMailContext());
         m_mailServer = new MockMailServer(new MockUsersRepository());
         m_serviceManager.put(MailServer.ROLE, m_mailServer);
+     // Phoenix loader does not understand aliases
+        m_serviceManager.put("James", m_mailServer);
         m_serviceManager.put(UsersRepository.ROLE, m_usersRepository);
         m_serviceManager.put(SocketManager.ROLE, new MockSocketManager(m_smtpListenerPort));
         m_serviceManager.put(ThreadManager.ROLE, new MockThreadManager());



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