Example usage for org.apache.commons.net.pop3 POP3SClient getAdditionalReply

List of usage examples for org.apache.commons.net.pop3 POP3SClient getAdditionalReply

Introduction

In this page you can find the example usage for org.apache.commons.net.pop3 POP3SClient getAdditionalReply.

Prototype

public void getAdditionalReply() throws IOException 

Source Link

Document

Retrieves the additional lines of a multi-line server reply.

Usage

From source file:org.apache.james.protocols.pop3.AbstractStartTlsPOP3ServerTest.java

@Test
public void testStartTls() throws Exception {
    InetSocketAddress address = new InetSocketAddress("127.0.0.1", TestUtils.getFreePort());

    ProtocolServer server = null;/*  w w w . ja  va 2 s.  c o  m*/
    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();

        POP3SClient client = createClient();
        client.connect(address.getAddress().getHostAddress(), address.getPort());

        // TODO: Make use of client.capa() once possible
        //       See NET-438
        assertEquals(POP3Reply.OK, client.sendCommand("CAPA"));
        client.getAdditionalReply();

        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();
        }
    }

}