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

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

Introduction

In this page you can find the example usage for org.apache.commons.net.pop3 POP3Client 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:me.schiz.jmeter.protocol.pop3.sampler.POP3Sampler.java

private SampleResult sampleCommand(SampleResult sr) {
    SocketClient soclient = SessionStorage.getInstance().getClient(getSOClient());
    POP3Client client = null;
    int responseCode;
    if (soclient instanceof POP3Client)
        client = (POP3Client) soclient;//  w w  w.  j a  va 2 s  .c o m

    String request = "COMMAND\n";
    request += "Client : " + getClient() + "\n";
    request += "Command : " + getCommand() + "\n";
    sr.setRequestHeaders(request);
    if (client == null) {
        clientNotFound(sr);
    } else {
        synchronized (client) {
            sr.sampleStart();
            try {
                String command, args = null;
                int index = getCommand().indexOf(' ');
                if (index != -1) {
                    command = getCommand().substring(0, index);
                    if (index + 1 < getCommand().length())
                        args = getCommand().substring(index + 1, getCommand().length() - 1);
                } else
                    command = getCommand();

                responseCode = (args != null ? client.sendCommand(command, args) : client.sendCommand(command));
                if (getAdditionalReply())
                    client.getAdditionalReply();
                setSuccessfulByResponseCode(sr, responseCode);
                setResponse(sr, client.getReplyStrings());
            } catch (IOException e) {
                sr.setSuccessful(false);
                sr.setResponseData(e.toString().getBytes());
                sr.setResponseCode(e.getClass().getName());
                log.error("client `" + client + "` ", e);
                removeClient();
            }
            sr.sampleEnd();
        }
    }
    return sr;
}