Example usage for org.apache.commons.net.imap IMAPClient noop

List of usage examples for org.apache.commons.net.imap IMAPClient noop

Introduction

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

Prototype

public boolean noop() throws IOException 

Source Link

Document

Send a NOOP command to the server.

Usage

From source file:me.schiz.jmeter.protocol.imap.sampler.IMAPSampler.java

private SampleResult sampleNoop(SampleResult sr) {
    SocketClient soclient = SessionStorage.getInstance().getClient(getSOClient());
    IMAPClient client = null;
    if (soclient instanceof IMAPClient)
        client = (IMAPClient) soclient;//from   w  ww .  j ava 2 s .c  om

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