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/18 17:23:29 UTC

svn commit: r1232949 - in /james/protocols/trunk: pop3/src/test/java/org/apache/james/protocols/pop3/ pop3/src/test/java/org/apache/james/protocols/pop3/netty/ pop3/src/test/java/org/apache/james/protocols/pop3/utils/ smtp/src/test/java/org/apache/jame...

Author: norman
Date: Wed Jan 18 16:23:28 2012
New Revision: 1232949

URL: http://svn.apache.org/viewvc?rev=1232949&view=rev
Log:
Add tests for POP3 STLS (starttls)

Added:
    james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/AbstractStartTlsPOP3ServerTest.java   (with props)
    james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/netty/NettyStartTlsPOP3ServerTest.java   (with props)
    james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/utils/
    james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/utils/AdvancedPOP3Client.java   (with props)
    james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/utils/AdvancedPOP3SClient.java   (with props)
    james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/utils/MockMailbox.java   (with props)
    james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/utils/TestPassCmdHandler.java   (with props)
Modified:
    james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/AbstractPOP3ServerTest.java
    james/protocols/trunk/smtp/src/test/java/org/apache/james/protocols/smtp/AbstractStartTlsSMTPServerTest.java

Modified: james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/AbstractPOP3ServerTest.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/AbstractPOP3ServerTest.java?rev=1232949&r1=1232948&r2=1232949&view=diff
==============================================================================
--- james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/AbstractPOP3ServerTest.java (original)
+++ james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/AbstractPOP3ServerTest.java Wed Jan 18 16:23:28 2012
@@ -25,17 +25,11 @@ import static org.junit.Assert.assertNul
 import static org.junit.Assert.assertTrue;
 
 import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.Reader;
-import java.io.SequenceInputStream;
 import java.net.InetSocketAddress;
-import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
-import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.commons.net.pop3.POP3Client;
 import org.apache.commons.net.pop3.POP3MessageInfo;
@@ -48,8 +42,9 @@ import org.apache.james.protocols.api.ut
 import org.apache.james.protocols.pop3.core.AbstractApopCmdHandler;
 import org.apache.james.protocols.pop3.core.AbstractPassCmdHandler;
 import org.apache.james.protocols.pop3.mailbox.Mailbox;
-import org.apache.james.protocols.pop3.mailbox.MessageMetaData;
-
+import org.apache.james.protocols.pop3.utils.MockMailbox;
+import org.apache.james.protocols.pop3.utils.MockMailbox.Message;
+import org.apache.james.protocols.pop3.utils.TestPassCmdHandler;
 import org.junit.Test;
 
 public abstract class AbstractPOP3ServerTest {
@@ -533,21 +528,7 @@ public abstract class AbstractPOP3Server
         assertEquals(lines, linesRead);
         
     }
-    
-    private final class TestPassCmdHandler extends AbstractPassCmdHandler {
-        private final Map<String, Mailbox> mailboxes = new HashMap<String, Mailbox>();
-       
-        public void add(String username, Mailbox mailbox) {
-            mailboxes.put(username, mailbox);
-        }
-        
-        protected Mailbox auth(POP3Session session, String username, String password) throws Exception{
-            return mailboxes.get(username);
-        }
 
-        
-    }
-    
     private final class TestApopCmdHandler extends AbstractApopCmdHandler {
         private final Map<String, Mailbox> mailboxes = new HashMap<String, Mailbox>();
        
@@ -563,85 +544,5 @@ public abstract class AbstractPOP3Server
         
     }
     
-    private final class MockMailbox implements Mailbox {
-
-        private final Map<Long, Message> messages = new HashMap<Long, AbstractPOP3ServerTest.Message>();
-        private final String identifier;
-
-        public MockMailbox(String identifier, Message... messages) {
-            this.identifier = identifier;
-            for (Message m: messages) {
-                this.messages.put(m.meta.getUid(), m);
-            }
-        }
-        
-        public MockMailbox(String identifier) {
-            this(identifier, new Message[0]);
-        }
-        public InputStream getMessageBody(long uid) throws IOException {
-            Message m = messages.get(uid);
-            if (m == null) {
-                return null;
-            }
-            return new ByteArrayInputStream(m.body.getBytes("US-ASCII"));
-        }
-
-        public InputStream getMessageHeaders(long uid) throws IOException {
-            Message m = messages.get(uid);
-            if (m == null) {
-                return null;
-            }
-            return new ByteArrayInputStream((m.headers + "\r\n").getBytes("US-ASCII"));
-        }
-
-        public InputStream getMessage(long uid) throws IOException {
-            InputStream body = getMessageBody(uid);
-            InputStream headers = getMessageHeaders(uid);
-            if (body == null || headers == null) {
-                return null;
-            }
-            return new SequenceInputStream(headers, body);
-        }
-
-        public List<MessageMetaData> getMessages() throws IOException {
-            List<MessageMetaData> meta = new ArrayList<MessageMetaData>();
-            for (Message m: messages.values()) {
-                meta.add(m.meta);
-            }
-            return meta;
-        }
-
-        public void remove(long... uids) throws IOException {
-            for (long uid: uids) {
-                messages.remove(uid);
-            }
-        }
-
-        public String getIdentifier() throws IOException {
-            return identifier;
-        }
-
-        public void close() throws IOException {
-            // nothing
-        }
-        
-    }
-    
-    private static final class Message {
-        private static final AtomicLong UIDS = new AtomicLong(0);
-        public final String headers;
-        public final String body;
-        public final MessageMetaData meta;
-
-        public Message(String headers, String body) {
-            this.headers = headers;
-            this.body = body;
-            this.meta = new MessageMetaData(UIDS.incrementAndGet(), headers.length() + body.length() + 2);
-        }
-        
-        public String toString() {
-            return headers + "\r\n" + body;
-        }
-        
-    }
+   
 }

Added: james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/AbstractStartTlsPOP3ServerTest.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/AbstractStartTlsPOP3ServerTest.java?rev=1232949&view=auto
==============================================================================
--- james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/AbstractStartTlsPOP3ServerTest.java (added)
+++ james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/AbstractStartTlsPOP3ServerTest.java Wed Jan 18 16:23:28 2012
@@ -0,0 +1,95 @@
+/****************************************************************
+ * 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 static org.junit.Assert.assertTrue;
+
+import java.net.InetSocketAddress;
+
+import org.apache.james.protocols.api.Encryption;
+import org.apache.james.protocols.api.Protocol;
+import org.apache.james.protocols.api.ProtocolServer;
+import org.apache.james.protocols.api.handler.WiringException;
+import org.apache.james.protocols.api.utils.BogusSslContextFactory;
+import org.apache.james.protocols.api.utils.BogusTrustManagerFactory;
+import org.apache.james.protocols.api.utils.MockLogger;
+import org.apache.james.protocols.api.utils.TestUtils;
+import org.apache.james.protocols.pop3.core.AbstractPassCmdHandler;
+import org.apache.james.protocols.pop3.utils.AdvancedPOP3SClient;
+import org.apache.james.protocols.pop3.utils.MockMailbox;
+import org.apache.james.protocols.pop3.utils.TestPassCmdHandler;
+import org.junit.Test;
+
+public abstract class AbstractStartTlsPOP3ServerTest {
+
+    private POP3Protocol createProtocol(AbstractPassCmdHandler handler) throws WiringException {
+        return new POP3Protocol(new POP3ProtocolHandlerChain(handler), new POP3Configuration(), new MockLogger());
+    }
+    
+    protected AdvancedPOP3SClient createClient() {
+        AdvancedPOP3SClient client = new AdvancedPOP3SClient(false, BogusSslContextFactory.getClientContext());
+        client.setTrustManager(BogusTrustManagerFactory.getTrustManagers()[0]);
+        return client;
+    }
+    
+    protected abstract ProtocolServer createServer(Protocol protocol, InetSocketAddress address, Encryption enc);
+    
+    
+    @Test
+    public void testStartTls() throws Exception {
+        InetSocketAddress address = new InetSocketAddress("127.0.0.1", TestUtils.getFreePort());
+        
+        ProtocolServer server = null;
+        try {
+            String identifier = "id";
+            TestPassCmdHandler handler = new TestPassCmdHandler();
+            
+            handler.add("valid", new MockMailbox(identifier));
+            server = createServer(createProtocol(handler), address, Encryption.createStartTls(BogusSslContextFactory.getServerContext()));
+            server.bind();
+            
+            AdvancedPOP3SClient client =  createClient();
+            client.connect(address.getAddress().getHostAddress(), address.getPort());
+            assertTrue(client.capa());
+            
+            boolean startTlsCapa = false;
+            for (String cap: client.getReplyStrings()) {
+                if (cap.equalsIgnoreCase("STLS")) {
+                    startTlsCapa = true;
+                    break;
+                }
+            }
+            assertTrue(startTlsCapa);
+            
+            assertTrue(client.execTLS());
+            // TODO: Reenable when commons-net 3.1.0 was released
+            //       See NET-430
+            //
+            //assertTrue(client.logout());
+            client.disconnect();
+           
+        } finally {
+            if (server != null) {
+                server.unbind();
+            }
+        }
+        
+    }
+
+}

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

Added: james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/netty/NettyStartTlsPOP3ServerTest.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/netty/NettyStartTlsPOP3ServerTest.java?rev=1232949&view=auto
==============================================================================
--- james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/netty/NettyStartTlsPOP3ServerTest.java (added)
+++ james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/netty/NettyStartTlsPOP3ServerTest.java Wed Jan 18 16:23:28 2012
@@ -0,0 +1,39 @@
+/****************************************************************
+ * 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.netty;
+
+import java.net.InetSocketAddress;
+
+import org.apache.james.protocols.api.Encryption;
+import org.apache.james.protocols.api.Protocol;
+import org.apache.james.protocols.api.ProtocolServer;
+import org.apache.james.protocols.netty.NettyServer;
+import org.apache.james.protocols.pop3.AbstractStartTlsPOP3ServerTest;
+
+public class NettyStartTlsPOP3ServerTest extends AbstractStartTlsPOP3ServerTest{
+
+    @Override
+    protected ProtocolServer createServer(Protocol protocol, InetSocketAddress address, Encryption enc) {
+        NettyServer server = new NettyServer(protocol, enc);
+        server.setListenAddresses(address);
+        
+        return server;
+    }
+
+}

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

Added: james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/utils/AdvancedPOP3Client.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/utils/AdvancedPOP3Client.java?rev=1232949&view=auto
==============================================================================
--- james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/utils/AdvancedPOP3Client.java (added)
+++ james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/utils/AdvancedPOP3Client.java Wed Jan 18 16:23:28 2012
@@ -0,0 +1,38 @@
+/****************************************************************
+ * 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.utils;
+
+import java.io.IOException;
+
+import org.apache.commons.net.pop3.POP3Client;
+import org.apache.commons.net.pop3.POP3Reply;
+
+public class AdvancedPOP3Client extends POP3Client{
+
+    public boolean capa() throws IOException {
+        
+        int code = sendCommand("CAPA");
+        if (code == POP3Reply.OK) {
+            getAdditionalReply();
+            return true;
+        }
+        return false;
+        
+    }
+}

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

Added: james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/utils/AdvancedPOP3SClient.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/utils/AdvancedPOP3SClient.java?rev=1232949&view=auto
==============================================================================
--- james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/utils/AdvancedPOP3SClient.java (added)
+++ james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/utils/AdvancedPOP3SClient.java Wed Jan 18 16:23:28 2012
@@ -0,0 +1,68 @@
+/****************************************************************
+ * 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.utils;
+
+import java.io.IOException;
+
+import javax.net.ssl.SSLContext;
+
+import org.apache.commons.net.pop3.POP3Reply;
+import org.apache.commons.net.pop3.POP3SClient;
+
+public class AdvancedPOP3SClient extends POP3SClient {
+
+    public AdvancedPOP3SClient() {
+        super();
+    }
+
+    public AdvancedPOP3SClient(boolean implicit, SSLContext ctx) {
+        super(implicit, ctx);
+    }
+
+    public AdvancedPOP3SClient(boolean implicit) {
+        super(implicit);
+    }
+
+    public AdvancedPOP3SClient(SSLContext context) {
+        super(context);
+    }
+
+    public AdvancedPOP3SClient(String proto, boolean implicit, SSLContext ctx) {
+        super(proto, implicit, ctx);
+    }
+
+    public AdvancedPOP3SClient(String proto, boolean implicit) {
+        super(proto, implicit);
+    }
+
+    public AdvancedPOP3SClient(String proto) {
+        super(proto);
+    }
+
+    public boolean capa() throws IOException {
+        
+        int code = sendCommand("CAPA");
+        if (code == POP3Reply.OK) {
+            getAdditionalReply();
+            return true;
+        }
+        return false;
+        
+    }
+}

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

Added: james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/utils/MockMailbox.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/utils/MockMailbox.java?rev=1232949&view=auto
==============================================================================
--- james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/utils/MockMailbox.java (added)
+++ james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/utils/MockMailbox.java Wed Jan 18 16:23:28 2012
@@ -0,0 +1,116 @@
+/****************************************************************
+ * 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.utils;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.SequenceInputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.james.protocols.pop3.mailbox.Mailbox;
+import org.apache.james.protocols.pop3.mailbox.MessageMetaData;
+
+public class MockMailbox implements Mailbox {
+
+    private final Map<Long, Message> messages = new HashMap<Long, Message>();
+    private final String identifier;
+
+    public MockMailbox(String identifier, Message... messages) {
+        this.identifier = identifier;
+        for (Message m: messages) {
+            this.messages.put(m.meta.getUid(), m);
+        }
+    }
+    
+    public MockMailbox(String identifier) {
+        this(identifier, new Message[0]);
+    }
+    public InputStream getMessageBody(long uid) throws IOException {
+        Message m = messages.get(uid);
+        if (m == null) {
+            return null;
+        }
+        return new ByteArrayInputStream(m.body.getBytes("US-ASCII"));
+    }
+
+    public InputStream getMessageHeaders(long uid) throws IOException {
+        Message m = messages.get(uid);
+        if (m == null) {
+            return null;
+        }
+        return new ByteArrayInputStream((m.headers + "\r\n").getBytes("US-ASCII"));
+    }
+
+    public InputStream getMessage(long uid) throws IOException {
+        InputStream body = getMessageBody(uid);
+        InputStream headers = getMessageHeaders(uid);
+        if (body == null || headers == null) {
+            return null;
+        }
+        return new SequenceInputStream(headers, body);
+    }
+
+    public List<MessageMetaData> getMessages() throws IOException {
+        List<MessageMetaData> meta = new ArrayList<MessageMetaData>();
+        for (Message m: messages.values()) {
+            meta.add(m.meta);
+        }
+        return meta;
+    }
+
+    public void remove(long... uids) throws IOException {
+        for (long uid: uids) {
+            messages.remove(uid);
+        }
+    }
+
+    public String getIdentifier() throws IOException {
+        return identifier;
+    }
+
+    public void close() throws IOException {
+        // nothing
+    }
+    
+    public static final class Message {
+        private static final AtomicLong UIDS = new AtomicLong(0);
+        public final String headers;
+        public final String body;
+        public final MessageMetaData meta;
+
+        public Message(String headers, String body) {
+            this.headers = headers;
+            this.body = body;
+            this.meta = new MessageMetaData(UIDS.incrementAndGet(), headers.length() + body.length() + 2);
+        }
+        
+        public String toString() {
+            return headers + "\r\n" + body;
+        }
+        
+    }
+    
+}
+
+

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

Added: james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/utils/TestPassCmdHandler.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/utils/TestPassCmdHandler.java?rev=1232949&view=auto
==============================================================================
--- james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/utils/TestPassCmdHandler.java (added)
+++ james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/utils/TestPassCmdHandler.java Wed Jan 18 16:23:28 2012
@@ -0,0 +1,39 @@
+/****************************************************************
+ * 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.utils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.james.protocols.pop3.POP3Session;
+import org.apache.james.protocols.pop3.core.AbstractPassCmdHandler;
+import org.apache.james.protocols.pop3.mailbox.Mailbox;
+
+public class TestPassCmdHandler extends AbstractPassCmdHandler {
+    private final Map<String, Mailbox> mailboxes = new HashMap<String, Mailbox>();
+   
+    public void add(String username, Mailbox mailbox) {
+        mailboxes.put(username, mailbox);
+    }
+    
+    protected Mailbox auth(POP3Session session, String username, String password) throws Exception{
+        return mailboxes.get(username);
+    }
+
+}

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

Modified: james/protocols/trunk/smtp/src/test/java/org/apache/james/protocols/smtp/AbstractStartTlsSMTPServerTest.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/smtp/src/test/java/org/apache/james/protocols/smtp/AbstractStartTlsSMTPServerTest.java?rev=1232949&r1=1232948&r2=1232949&view=diff
==============================================================================
--- james/protocols/trunk/smtp/src/test/java/org/apache/james/protocols/smtp/AbstractStartTlsSMTPServerTest.java (original)
+++ james/protocols/trunk/smtp/src/test/java/org/apache/james/protocols/smtp/AbstractStartTlsSMTPServerTest.java Wed Jan 18 16:23:28 2012
@@ -24,6 +24,7 @@ import java.net.InetSocketAddress;
 import java.util.Arrays;
 import java.util.Locale;
 
+
 import org.apache.commons.net.smtp.SMTPReply;
 import org.apache.commons.net.smtp.SMTPSClient;
 import org.apache.james.protocols.api.Encryption;
@@ -57,7 +58,7 @@ public abstract class AbstractStartTlsSM
 
 
     @Test
-    public void testStartTLSAnnounced() throws Exception {
+    public void testStartTLS() throws Exception {
         InetSocketAddress address = new InetSocketAddress("127.0.0.1", TestUtils.getFreePort());
         
         
@@ -82,10 +83,14 @@ public abstract class AbstractStartTlsSM
             }
             assertTrue(startTLSAnnounced);
             
-           // assertTrue(client.execTLS());
+            assertTrue(client.execTLS());
+            
+            // TODO: Add back once commons-net 3.1.0 was released.
+            // See: NET-421
+            //
+            //client.quit();
+            //assertTrue("Reply="+ client.getReplyString(), SMTPReply.isPositiveCompletion(client.getReplyCode()));
             
-            client.quit();
-            assertTrue("Reply="+ client.getReplyString(), SMTPReply.isPositiveCompletion(client.getReplyCode()));
             client.disconnect();
 
 



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