Example usage for org.apache.commons.net.pop3 POP3Reply ERROR

List of usage examples for org.apache.commons.net.pop3 POP3Reply ERROR

Introduction

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

Prototype

int ERROR

To view the source code for org.apache.commons.net.pop3 POP3Reply ERROR.

Click Source Link

Document

The reply code indicating failure of an operation.

Usage

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

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

    ProtocolServer server = null;//from w w  w  .ja  va  2s  .  c om
    try {
        TestApopCmdHandler handler = new TestApopCmdHandler();
        server = createServer(createProtocol(handler), address);
        server.bind();

        POP3Client client = createClient();
        client.connect(address.getAddress().getHostAddress(), address.getPort());
        String welcomeMessage = client.getReplyString();

        // check for valid syntax that include all info needed for APOP
        assertThat(welcomeMessage.trim()).matches(Pattern.compile("\\+OK \\<-?\\d+\\.\\d+@.+\\> .+"));

        assertThat(client.sendCommand("APOP invalid invalid")).isEqualTo(POP3Reply.ERROR);

        handler.add("valid", new MockMailbox("id"));
        assertThat(client.sendCommand("APOP valid valid")).isEqualTo(POP3Reply.OK);

        assertThat(client.logout()).isTrue();

    } finally {
        if (server != null) {
            server.unbind();
        }
    }

}