Examples of NettyServer


Examples of org.apache.james.protocols.netty.NettyServer

   
    @Test
    public void testAPop() throws Exception {
        InetSocketAddress address = new InetSocketAddress("127.0.0.1", TestUtils.getFreePort());
       
        NettyServer server = null;
        try {
            TestApopCmdHandler handler = new TestApopCmdHandler();
            server = new NettyServer(createProtocol(handler));
            server.setListenAddresses(address);
            server.bind();
           
            POP3Client client =  new POP3Client();
            client.connect(address.getAddress().getHostAddress(), address.getPort());
            String welcomeMessage = client.getReplyString();
           
            // check for valid syntax that include all info needed for APOP
            assertTrue(welcomeMessage.trim().matches("\\+OK \\<\\d+\\.\\d+@.+\\> .+"));
           
            int reply = client.sendCommand("APOP invalid invalid");
            assertEquals(POP3Reply.ERROR, reply);
           
            handler.add("valid", new MockMailbox("id"));
            reply = client.sendCommand("APOP valid valid");
            assertEquals(POP3Reply.OK, reply);
           
            assertTrue(client.logout());
          
        } finally {
            if (server != null) {
                server.unbind();
            }
        }
       
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.