Package org.apache.commons.net.pop3

Examples of org.apache.commons.net.pop3.POP3MessageInfo


        try {
            server = new NettyServer(createProtocol(new TestPassCmdHandler()));
            server.setListenAddresses(address);
            server.bind();
           
            POP3Client client =  new POP3Client();
            client.connect(address.getAddress().getHostAddress(), address.getPort());
           
            assertFalse(client.login("invalid", "invalid"));
          
            assertTrue(client.logout());
          
        } finally {
            if (server != null) {
                server.unbind();
            }
View Full Code Here


            handler.add("valid", new MockMailbox(identifier));
            server = new NettyServer(createProtocol(handler));
            server.setListenAddresses(address);
            server.bind();
           
            POP3Client client =  new POP3Client();
            client.connect(address.getAddress().getHostAddress(), address.getPort());
           
            assertTrue(client.login("valid", "valid"));
            POP3MessageInfo[] info = client.listMessages();
            assertEquals(0, info.length);
           
            info = client.listUniqueIdentifiers();
            assertEquals(0, info.length);
            assertTrue(client.logout());
          
        } finally {
            if (server != null) {
                server.unbind();
            }
View Full Code Here

            handler.add("valid", new MockMailbox(identifier, MESSAGE1, MESSAGE2));
            server = new NettyServer(createProtocol(handler));
            server.setListenAddresses(address);
            server.bind();
           
            POP3Client client =  new POP3Client();
            client.connect(address.getAddress().getHostAddress(), address.getPort());
           
            assertTrue(client.login("valid", "valid"));
            POP3MessageInfo[] info = client.listMessages();
            assertEquals(2, info.length);
            assertEquals((int) MESSAGE1.meta.getSize(), info[0].size);
            assertEquals((int) MESSAGE2.meta.getSize(), info[1].size);
            assertEquals(1, info[0].number);
            assertEquals(2, info[1].number);

            POP3MessageInfo mInfo = client.listMessage(1);
            assertEquals((int) MESSAGE1.meta.getSize(), mInfo.size);
            assertEquals(1, mInfo.number);

            // try to retrieve message that not exist
            mInfo = client.listMessage(10);
            assertNull(mInfo);

            info = client.listUniqueIdentifiers();
            assertEquals(2, info.length);
            assertEquals(identifier + "-" + MESSAGE1.meta.getUid(), info[0].identifier);
            assertEquals(identifier + "-" + MESSAGE2.meta.getUid(), info[1].identifier);
            assertEquals(1, info[0].number);
            assertEquals(2, info[1].number);

            mInfo = client.listUniqueIdentifier(1);
            assertEquals(identifier + "-" + MESSAGE1.meta.getUid(), mInfo.identifier);
            assertEquals(1, mInfo.number);

            // try to retrieve message that not exist
            mInfo = client.listUniqueIdentifier(10);
            assertNull(mInfo);
           
            assertTrue(client.logout());
          
        } finally {
            if (server != null) {
                server.unbind();
            }
View Full Code Here

            factory.add("valid", new MockMailbox(identifier, MESSAGE1, MESSAGE2));
            server = new NettyServer(createProtocol(factory));
            server.setListenAddresses(address);
            server.bind();
           
            POP3Client client =  new POP3Client();
            client.connect(address.getAddress().getHostAddress(), address.getPort());
           
            assertTrue(client.login("valid", "valid"));
            Reader reader = client.retrieveMessage(1);
            assertNotNull(reader);
            checkMessage(MESSAGE1, reader);
            reader.close();
           
            // does not exist
            reader = client.retrieveMessage(10);
            assertNull(reader);
           
           
            // delete and check for the message again, should now be deleted
            assertTrue(client.deleteMessage(1));
            reader = client.retrieveMessage(1);
            assertNull(reader);

           
            assertTrue(client.logout());
          
        } finally {
            if (server != null) {
                server.unbind();
            }
View Full Code Here

            factory.add("valid", new MockMailbox(identifier, MESSAGE1, MESSAGE2));
            server = new NettyServer(createProtocol(factory));
            server.setListenAddresses(address);
            server.bind();
           
            POP3Client client =  new POP3Client();
            client.connect(address.getAddress().getHostAddress(), address.getPort());
           
            assertTrue(client.login("valid", "valid"));
            Reader reader = client.retrieveMessageTop(1, 1000);
            assertNotNull(reader);
            checkMessage(MESSAGE1, reader);
            reader.close();
           
            reader = client.retrieveMessageTop(2, 1);
            assertNotNull(reader);
            checkMessage(MESSAGE2, reader,1);
            reader.close();
           
            // does not exist
            reader = client.retrieveMessageTop(10,100);
            assertNull(reader);
           
            // delete and check for the message again, should now be deleted
            assertTrue(client.deleteMessage(1));
            reader = client.retrieveMessageTop(1, 1000);
            assertNull(reader);

            assertTrue(client.logout());
          
        } finally {
            if (server != null) {
                server.unbind();
            }
View Full Code Here

            factory.add("valid", new MockMailbox(identifier, MESSAGE1, MESSAGE2));
            server = new NettyServer(createProtocol(factory));
            server.setListenAddresses(address);
            server.bind();
           
            POP3Client client =  new POP3Client();
            client.connect(address.getAddress().getHostAddress(), address.getPort());
           
            assertTrue(client.login("valid", "valid"));
            POP3MessageInfo[] info = client.listMessages();
            assertEquals(2, info.length);
           
            assertTrue(client.deleteMessage(1));
            info = client.listMessages();
            assertEquals(1, info.length);

           
            assertFalse(client.deleteMessage(1));
            info = client.listMessages();
            assertEquals(1, info.length);
           
           
            assertTrue(client.deleteMessage(2));
            info = client.listMessages();
            assertEquals(0, info.length);
           
            // logout so the messages get expunged
            assertTrue(client.logout());

            client.connect(address.getAddress().getHostAddress(), address.getPort());
 
            assertTrue(client.login("valid", "valid"));
            info = client.listMessages();
            assertEquals(0, info.length);

            assertTrue(client.logout());
          
        } finally {
            if (server != null) {
                server.unbind();
            }
View Full Code Here

            factory.add("valid", new MockMailbox(identifier));
            server = new NettyServer(createProtocol(factory));
            server.setListenAddresses(address);
            server.bind();
           
            POP3Client client =  new POP3Client();
            client.connect(address.getAddress().getHostAddress(), address.getPort());
           
            assertTrue(client.login("valid", "valid"));
            assertTrue(client.noop());
            assertTrue(client.logout());
          
        } finally {
            if (server != null) {
                server.unbind();
            }
View Full Code Here

            factory.add("valid", new MockMailbox(identifier, MESSAGE1));
            server = new NettyServer(createProtocol(factory));
            server.setListenAddresses(address);
            server.bind();
           
            POP3Client client =  new POP3Client();
            client.connect(address.getAddress().getHostAddress(), address.getPort());
           
            assertTrue(client.login("valid", "valid"));
            assertEquals(1, client.listMessages().length);
            assertTrue(client.deleteMessage(1));
            assertEquals(0, client.listMessages().length);
           
            // call RSET. After this the deleted mark should be removed again
            assertTrue(client.reset());
            assertEquals(1, client.listMessages().length);

            assertTrue(client.logout());
          
        } finally {
            if (server != null) {
                server.unbind();
            }
View Full Code Here

            factory.add("valid", new MockMailbox(identifier, MESSAGE1, MESSAGE2));
            server = new NettyServer(createProtocol(factory));
            server.setListenAddresses(address);
            server.bind();
           
            POP3Client client =  new POP3Client();
            client.connect(address.getAddress().getHostAddress(), address.getPort());
           
            assertTrue(client.login("valid", "valid"));
            POP3MessageInfo info = client.status();
            assertEquals((int)(MESSAGE1.meta.getSize() + MESSAGE2.meta.getSize()), info.size);
            assertEquals(2, info.number);
           
            assertTrue(client.logout());
          
        } finally {
            if (server != null) {
                server.unbind();
            }
View Full Code Here

            factory.add("valid", new MockMailbox(identifier, MESSAGE1, MESSAGE2));
            server = new NettyServer(createProtocol(factory));
            server.setListenAddresses(address);
            server.bind();
           
            POP3Client client =  new POP3Client();
           
            client.connect(address.getAddress().getHostAddress(), address.getPort());
            assertNull(client.listMessages());
            assertNull(client.listUniqueIdentifiers());
            assertFalse(client.deleteMessage(1));
            assertNull(client.retrieveMessage(1));
            assertNull(client.retrieveMessageTop(1, 10));
            assertNull(client.status());
            assertFalse(client.reset());
            client.logout();
           
            client.connect(address.getAddress().getHostAddress(), address.getPort());

            assertTrue(client.login("valid", "valid"));
            assertNotNull(client.listMessages());
            assertNotNull(client.listUniqueIdentifiers());
            Reader reader = client.retrieveMessage(1);
            assertNotNull(reader);
            reader.close();
            assertNotNull(client.status());
            reader = client.retrieveMessageTop(1, 1);
            assertNotNull(reader);
            reader.close();
            assertTrue(client.deleteMessage(1));
            assertTrue(client.reset());

            assertTrue(client.logout());

        } finally {
            if (server != null) {
                server.unbind();
            }
View Full Code Here

TOP

Related Classes of org.apache.commons.net.pop3.POP3MessageInfo

Copyright © 2018 www.massapicom. 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.