### Question:
MailTransportMonitor extends AbstractServiceMonitor { @Override public PollStatus poll(MonitoredService svc, Map<String, Object> parameters) { PollStatus status = null; try { final MailTransportParameters mailParms = MailTransportParameters.get(parameters); try { if ("${ipaddr}".equals(mailParms.getReadTestHost())) { mailParms.setReadTestHost(svc.getIpAddr()); } } catch (final IllegalStateException ise) { } try { if ("${ipaddr}".equals(mailParms.getSendTestHost())) { mailParms.setSendTestHost(svc.getIpAddr()); } } catch (final IllegalStateException ise) { } parseJavaMailProperties(mailParms); status = doMailTest(mailParms); } catch (final IllegalStateException ise) { } catch (final Throwable e) { LogUtils.errorf(this, e, "An error occurred while polling."); status = PollStatus.down("Exception from mailer: " + e.getLocalizedMessage()); } return status; }  @Override PollStatus poll(MonitoredService svc, Map<String, Object> parameters);  }### Answer:
@Test @Ignore("requires real mail server") public void testEndToEnd() throws Exception { setupLocalhostSendGoogleRead2(); final PollStatus status = m_monitor.poll(getMailService("127.0.0.1"), m_params); assertEquals(PollStatus.SERVICE_AVAILABLE, status.getStatusCode()); }
@Test @Ignore("requires real mail server") public void readOnlyTest() throws Exception { m_params.put("timeout", "3000"); m_params.put("retry", "1"); m_params.put("strict-timeouts", "true"); m_params.put("mail-transport-test", " <mail-transport-test >\n" + " <mail-test>\n" + " <readmail-test attempt-interval=\"2000\" mail-folder=\"INBOX\" subject-match=\"READTEST\" >\n" + " <readmail-host host=\"imap.gmail.com\" port=\"993\">\n" + " <readmail-protocol ssl-enable=\"true\" transport=\"imaps\" />\n" + " </readmail-host>\n" + " <user-auth user-name=\"username\" password=\"password\"/>\n" + " </readmail-test>\n" + " </mail-test>\n"+ " </mail-transport-test>\n"); PollStatus status = m_monitor.poll(getMailService("127.0.0.1"), m_params); assertEquals(PollStatus.SERVICE_AVAILABLE, status.getStatusCode()); }