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

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

Introduction

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

Prototype

public int noop() throws IOException 

Source Link

Document

A convenience method to send the SMTP NOOP command to the server, receive the reply, and return the reply code.

Usage

From source file:org.apache.james.protocols.smtp.AbstractSMTPServerTest.java

@Test
public void testNoop() throws Exception {
    TestMessageHook hook = new TestMessageHook();
    InetSocketAddress address = new InetSocketAddress("127.0.0.1", TestUtils.getFreePort());

    ProtocolServer server = null;//from   ww  w .j  a v a 2 s  . c o  m
    try {
        server = createServer(createProtocol(hook), address);
        server.bind();

        SMTPClient client = createClient();
        client.connect(address.getAddress().getHostAddress(), address.getPort());
        assertTrue(SMTPReply.isPositiveCompletion(client.getReplyCode()));

        client.noop();
        assertTrue(SMTPReply.isPositiveCompletion(client.getReplyCode()));

        client.quit();
        assertTrue("Reply=" + client.getReplyString(), SMTPReply.isPositiveCompletion(client.getReplyCode()));
        client.disconnect();
        Iterator<MailEnvelope> queued = hook.getQueued().iterator();
        assertFalse(queued.hasNext());

    } finally {
        if (server != null) {
            server.unbind();
        }
    }

}