@Override protected boolean isConditionMet() { TextMessageNotify text = null; for (MTAMessage m : mta.getSentTextToAllMsgs()) { if (m.getContent() instanceof TextMessageNotify) { text = (TextMessageNotify) m.getContent(); } } return (text != null) && (expectedContent.equals(text.getContent())); }
@Override protected boolean isConditionMet() { boolean contains = false; List<MTAMessage> recd = mta.getMessagesForwarded(); for (MTAMessage recMsg : recd) { if (recMsg != null) { boolean contOk = recMsg.getContent().equals(message.getContent()); if (contOk) { contains = true; break; } } } return !contains; }
/** Tests if an MOTD is sent if one is defined. */ @Test public void testWithMOTDSet() { Properties p = new Properties(); p.put(TextMessageManager.FILE_NAME_KEY, "foo"); setup(p); ((MockTextMessageManager) mta.getTextManager()).setMotd("MOTD"); Assert.assertTrue("mta online", mta.isOnline()); Socket socket = null; try { socket = new Socket(MTA_HOST, mtaPort); socket.setSoTimeout(500); write(socket, "GET blabla\r\nHost: blabla\r\n\r\n"); getLogger().info("read from socket after GET chunk: " + read(socket)); // This time we authenticate first writeln(socket, getLoginMessageString()); waitForLoginTell(); // Now we can be sure we're logged in. TextMessageNotify text = null; for (MTAMessage m : mta.getSentToHttpMsgs()) { if (m.getContent() instanceof TextMessageNotify) { text = (TextMessageNotify) m.getContent(); } } Assert.assertNotNull("motd sent", text); Assert.assertEquals("correct motd string sent", "MOTD", text.getContent()); } catch (UnknownHostException e) { getLogger().error("Unknown host: " + MTA_HOST, e); Assert.fail("mta http server not at host localhost"); } catch (IOException e) { getLogger().error("IOException", e); Assert.fail("mta http server not at port " + mtaPort); } finally { ClosingUtils.close(socket); } }
@Override protected boolean isConditionMet() { boolean contains = false; List<MTAMessage> messages = null; if (forwarded) { messages = mta.getMessagesForwarded(); } else { messages = mta.getUnderstoodMessages(); } for (MTAMessage recMsg : messages) { if (recMsg != null) { // boolean contOk = // recMsg.getContent().equals(message.getContent()); boolean contOk = recMsg.equals(message); if (contOk) { contains = true; } } } return contains; }