List of usage examples for org.apache.commons.net.imap IMAPClient doCommand
public boolean doCommand(IMAPCommand command) throws IOException
From source file:me.schiz.jmeter.protocol.imap.sampler.IMAPSampler.java
private SampleResult sampleCommand(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 o m boolean success = false; String request = "COMMAND\n"; request += "Client : " + getClient() + "\n"; request += "Client Name : " + getClientName() + "\n"; request += "Command : `" + getCommand() + " " + getCommandArgs() + "`\n"; sr.setRequestHeaders(request); if (client == null) { clientNotFound(sr); return sr; } else { synchronized (client) { sr.sampleStart(); try { if (getCommandArgs().isEmpty()) { success = client.doCommand(IMAPCommand.valueOf(getCommand())); } else { success = client.doCommand(IMAPCommand.valueOf(getCommand()), getCommandArgs()); } sr.setSuccessful(success); if (getCheckSuccessful()) { sr.setSuccessful(success); if (success) sr.setResponseCodeOK(); else sr.setResponseCode(RC_ERROR); } else 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() + "` ", e); removeClient(); } sr.sampleEnd(); } } return sr; }