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 2012/01/01 17:16:56 UTC

svn commit: r1226261 - in /james/protocols/trunk/pop3/src: main/java/org/apache/james/protocols/pop3/POP3ProtocolHandlerChain.java test/java/org/apache/james/protocols/pop3/MockLogger.java test/java/org/apache/james/protocols/pop3/POP3ServerTest.java

Author: norman
Date: Sun Jan  1 16:16:56 2012
New Revision: 1226261

URL: http://svn.apache.org/viewvc?rev=1226261&view=rev
Log:
Correctly wire handlers in pop3 and also some minor work on tests.

Added:
    james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/MockLogger.java   (with props)
Modified:
    james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3ProtocolHandlerChain.java
    james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/POP3ServerTest.java

Modified: james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3ProtocolHandlerChain.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3ProtocolHandlerChain.java?rev=1226261&r1=1226260&r2=1226261&view=diff
==============================================================================
--- james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3ProtocolHandlerChain.java (original)
+++ james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3ProtocolHandlerChain.java Sun Jan  1 16:16:56 2012
@@ -25,6 +25,7 @@ import java.util.List;
 import org.apache.james.protocols.api.handler.CommandDispatcher;
 import org.apache.james.protocols.api.handler.ProtocolHandler;
 import org.apache.james.protocols.api.handler.ProtocolHandlerChainImpl;
+import org.apache.james.protocols.api.handler.WiringException;
 import org.apache.james.protocols.pop3.core.CapaCmdHandler;
 import org.apache.james.protocols.pop3.core.DeleCmdHandler;
 import org.apache.james.protocols.pop3.core.ListCmdHandler;
@@ -45,7 +46,7 @@ import org.apache.james.protocols.pop3.m
 public class POP3ProtocolHandlerChain extends ProtocolHandlerChainImpl{
 
     public POP3ProtocolHandlerChain() {
-        this(null);
+        super();
     }
 
         
@@ -54,10 +55,12 @@ public class POP3ProtocolHandlerChain ex
      * will add all default handlers
      * 
      * @param mailboxFactory
+     * @throws WiringException 
      */
-    public POP3ProtocolHandlerChain(MailboxFactory mailboxFactory) {
+    public POP3ProtocolHandlerChain(MailboxFactory mailboxFactory) throws WiringException {
         if (mailboxFactory != null) {
             addAll(initDefaultHandlers(mailboxFactory));      
+            wireExtensibleHandlers();
         }
     }
     

Added: james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/MockLogger.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/MockLogger.java?rev=1226261&view=auto
==============================================================================
--- james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/MockLogger.java (added)
+++ james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/MockLogger.java Sun Jan  1 16:16:56 2012
@@ -0,0 +1,129 @@
+/****************************************************************
+ * 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.protocols.pop3;
+
+import org.apache.james.protocols.api.logger.Logger;
+
+public class MockLogger implements Logger {
+
+    public String getName() {
+        return "MockLogger to System out";
+    }
+
+    public boolean isTraceEnabled() {
+        return true;
+    }
+
+    public void trace(String msg) {
+        SysPrint(msg);
+    }
+
+    public void trace(String msg, Throwable t) {
+        SysPrint(msg, t);
+    }
+
+    public boolean isDebugEnabled() {
+        return true;
+    }
+
+    public void debug(String msg) {
+        SysPrint(msg);
+    }
+
+    public void debug(String msg, Throwable t) {
+        SysPrint(msg, t);
+    }
+
+    public boolean isInfoEnabled() {
+        return true;
+    }
+
+    public void info(String msg) {
+        SysPrint(msg);
+    }
+
+    public void info(String msg, Throwable t) {
+        SysPrint(msg, t);
+    }
+
+    public boolean isWarnEnabled() {
+        return true;
+    }
+
+    public void warn(String msg) {
+        SysPrint(msg);
+    }
+
+    public void warn(String msg, Throwable t) {
+        SysPrint(msg, t);
+    }
+
+    public boolean isErrorEnabled() {
+        return true;
+    }
+
+    public void error(String msg) {
+        SysPrint(msg);
+    }
+
+    public void error(String msg, Throwable t) {
+        SysPrint(msg, t);
+    }
+
+    private void SysPrint(String msg, Object... obj) {
+        if (obj != null) {
+            Throwable t = null;
+            StringBuffer s = new StringBuffer(msg);
+            s.append(" args=[");
+            boolean first = true;
+            for (Object o : obj) {
+                if (o instanceof Throwable) {
+                    t = (Throwable) o;
+                } else {
+                    if (first) {
+                        s.append(o.toString());
+                        first = false;
+                    } else {
+                        s.append(", ").append(o.toString());
+                    }
+                }
+            }
+            s.append("]");
+            System.out.println(s.toString());
+            if (t != null) {
+                t.printStackTrace();
+            }
+        } else {
+            System.out.println(msg);
+        }
+    }
+
+    public boolean isFatalEnabled() {
+        return true;
+    }
+
+    public void fatal(String message) {
+        SysPrint(message);
+    }
+
+    public void fatal(String message, Throwable t) {
+        SysPrint(message, t);
+    }
+}

Propchange: james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/MockLogger.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/POP3ServerTest.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/POP3ServerTest.java?rev=1226261&r1=1226260&r2=1226261&view=diff
==============================================================================
--- james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/POP3ServerTest.java (original)
+++ james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/POP3ServerTest.java Sun Jan  1 16:16:56 2012
@@ -25,7 +25,7 @@ import java.io.IOException;
 import java.net.InetSocketAddress;
 
 import org.apache.commons.net.pop3.POP3Client;
-import org.apache.james.protocols.api.logger.Logger;
+import org.apache.james.protocols.api.handler.WiringException;
 import org.apache.james.protocols.netty.NettyServer;
 import org.apache.james.protocols.pop3.mailbox.Mailbox;
 import org.apache.james.protocols.pop3.mailbox.MailboxFactory;
@@ -34,68 +34,8 @@ import org.junit.Test;
 
 public class POP3ServerTest {
 
-    private POP3Protocol createProtocol(MailboxFactory factory) {
-        return new POP3Protocol(new POP3ProtocolHandlerChain(factory), new POP3Configuration(), new Logger() {
-            
-            public void warn(String message, Throwable t) {
-                
-            }
-            
-            public void warn(String message) {
-                
-            }
-            
-            public void trace(String message, Throwable t) {
-                
-            }
-            
-            public void trace(String message) {
-                
-            }
-            
-            public boolean isWarnEnabled() {
-                return false;
-            }
-            
-            public boolean isTraceEnabled() {
-                return false;
-            }
-            
-            public boolean isInfoEnabled() {
-                return false;
-            }
-            
-            public boolean isErrorEnabled() {
-                return false;
-            }
-            
-            public boolean isDebugEnabled() {
-                return false;
-            }
-            
-            public void info(String message, Throwable t) {
-                
-            }
-            
-            public void info(String message) {                
-            }
-            
-            public void error(String message, Throwable t) {
-                
-            }
-            
-            public void error(String message) {
-                
-            }
-            
-            public void debug(String message, Throwable t) {
-                
-            }
-            
-            public void debug(String message) {
-                
-            }
-        });
+    private POP3Protocol createProtocol(MailboxFactory factory) throws WiringException {
+        return new POP3Protocol(new POP3ProtocolHandlerChain(factory), new POP3Configuration(), new MockLogger());
     }
     @Test
     public void testInvalidAuth() throws Exception {
@@ -112,7 +52,7 @@ public class POP3ServerTest {
             
             assertFalse(client.login("invalid", "invalid"));
            
-            //assertTrue(client.logout());
+            assertTrue(client.logout());
            
         } finally {
             if (server != null) {



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