Example usage for org.apache.commons.net.pop3 POP3Client noop

List of usage examples for org.apache.commons.net.pop3 POP3Client noop

Introduction

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

Prototype

public boolean noop() throws IOException 

Source Link

Document

Send a NOOP command to the POP3 server.

Usage

From source file:me.schiz.jmeter.protocol.pop3.sampler.POP3Sampler.java

private SampleResult sampleNoop(SampleResult sr) {
    SocketClient soclient = SessionStorage.getInstance().getClient(getSOClient());
    POP3Client client = null;
    if (soclient instanceof POP3Client)
        client = (POP3Client) soclient;/*  ww w .  ja  v  a 2 s .c  o m*/

    String request = "NOOP\n";
    request += "Client : " + getClient() + "\n";
    sr.setRequestHeaders(request);
    if (client == null) {
        clientNotFound(sr);
    } else {
        synchronized (client) {
            sr.sampleStart();
            try {
                boolean noop = client.noop();
                sr.setSuccessful(noop);
                sr.setResponseCode(noop ? RC_200 : RC_500);
            } catch (IOException e) {
                sr.setSuccessful(false);
                sr.setResponseData(e.toString().getBytes());
                sr.setResponseCode(e.getClass().getName());
                log.error("client `" + client + "` io exception", e);
                removeClient();
            }
            sr.sampleEnd();
        }
    }
    return sr;
}

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

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

    ProtocolServer server = null;//  w w  w.  j  a  v a  2  s . c om
    try {
        String identifier = "id";
        TestPassCmdHandler factory = new TestPassCmdHandler();

        factory.add("valid", new MockMailbox(identifier));
        server = createServer(createProtocol(factory), address);
        server.bind();

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

        assertThat(client.login("valid", "valid")).isTrue();
        assertThat(client.noop()).isTrue();
        assertThat(client.logout()).isTrue();

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

}