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

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

Introduction

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

Prototype

public void getAdditionalReply() throws IOException 

Source Link

Document

Retrieves the additional lines of a multi-line server reply.

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;//from  w ww  . j  av  a  2  s.c om

    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;
}