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

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

Introduction

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

Prototype

public String[] getReplyStrings() 

Source Link

Document

Returns an array of lines received as a reply to the last command sent to the server.

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;//from w  w  w.  j  ava  2 s . co 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();
        }
    }

}