};
InetSocketAddress address = new InetSocketAddress("127.0.0.1", TestUtils.getFreePort());
ProtocolServer server = null;
try {
server = createServer(createProtocol(hook, testHook), address);
server.bind();
SMTPClient client = createClient();
client.connect(address.getAddress().getHostAddress(), address.getPort());
assertTrue("Reply="+ client.getReplyString(), SMTPReply.isPositiveCompletion(client.getReplyCode()));
client.helo("localhost");
assertTrue("Reply="+ client.getReplyString(), SMTPReply.isPositiveCompletion(client.getReplyCode()));
client.setSender(SENDER);
assertTrue("Reply="+ client.getReplyString(), SMTPReply.isPositiveCompletion(client.getReplyCode()));
client.addRecipient(RCPT2);
assertTrue("Reply="+ client.getReplyString(), SMTPReply.isPositiveCompletion(client.getReplyCode()));
assertFalse(client.sendShortMessageData(MSG1));
assertTrue("Reply="+ client.getReplyString(), SMTPReply.isNegativePermanent(client.getReplyCode()));
client.quit();
assertTrue("Reply="+ client.getReplyString(), SMTPReply.isPositiveCompletion(client.getReplyCode()));
client.disconnect();
Iterator<MailEnvelope> queued = testHook.getQueued().iterator();
assertFalse(queued.hasNext());
} finally {
if (server != null) {
server.unbind();
}
}
}