Example usage for org.apache.commons.net.smtp SMTPClient sendNoOp

List of usage examples for org.apache.commons.net.smtp SMTPClient sendNoOp

Introduction

In this page you can find the example usage for org.apache.commons.net.smtp SMTPClient sendNoOp.

Prototype

public boolean sendNoOp() throws IOException 

Source Link

Document

Sends a NOOP command to the SMTP server.

Usage

From source file:me.schiz.jmeter.protocol.smtp.sampler.SMTPSampler.java

private SampleResult sampleNoop(SampleResult sr) {
    SocketClient soclient = SessionStorage.getInstance().getClient(getSOClient());
    SMTPClient client = null;
    if (soclient instanceof SMTPClient)
        client = (SMTPClient) soclient;//from   w w  w.j  av  a2  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 {
                sr.setSuccessful(client.sendNoOp());
                sr.setResponseCode(String.valueOf(client.getReplyCode()));
                sr.setResponseData(client.getReplyString().getBytes());
                setSuccessfulByResponseCode(sr, client.getReplyCode());
            } 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;
}