@Override protected void assertMessage(WiserMessage msg) throws MessagingException { super.assertMessage(msg); String data = new String(msg.getData()); String match = "name=image.png"; assertTrue("Was expecting " + data + " to contain <" + match + ">", data.contains(match)); } };
@Override protected void execute(TestPluginLifeCycle lifeCycle, Wiser wiser) throws IOException, MessagingException, ExecutionException, InterruptedException { Shell shell = lifeCycle.createShell(); lifeCycle.bindClass("produce", Commands.ProduceValue.class); lifeCycle.bindClass("consume", Commands.ConsumeObject.class); Commands.list.clear(); BaseProcessContext process = BaseProcessContext.create(shell, "produce | mail send -s the_subject -b admin@gmail.com | consume").execute(); ShellResponse.Ok ok = assertInstance(ShellResponse.Ok.class, process.getResponse()); Assert.assertEquals(1, wiser.getMessages().size()); WiserMessage msg = wiser.getMessages().get(0); Assert.assertEquals("foo@gmail.com", msg.getEnvelopeSender()); Assert.assertEquals("admin@gmail.com", msg.getEnvelopeReceiver()); Assert.assertEquals("the_subject", msg.getMimeMessage().getSubject()); String data = new String(msg.getData()); String content = (String)msg.getMimeMessage().getContent(); assertTrue(content.contains("<value>abc</value>")); assertTrue(data.contains("Content-Type: text/html;charset=UTF-8")); System.out.println("data = " + data); assertEquals(Arrays.<Object>asList(new Value("abc")), Commands.list); } };
/** * Dumps the rough contents of the message for debugging purposes */ public void dumpMessage(PrintStream out) throws MessagingException { out.println("===== Dumping message ====="); out.println("Envelope sender: " + this.getEnvelopeSender()); out.println("Envelope recipient: " + this.getEnvelopeReceiver()); // It should all be convertible with ascii or utf8 String content = new String(this.getData(), Constants.SMTP_CHARSET); out.println(content); out.println("===== End message dump ====="); }
/** * Dumps the rough contents of the message for debugging purposes */ public void dumpMessage(PrintStream out) throws MessagingException { out.println("===== Dumping message ====="); out.println("Envelope sender: " + this.getEnvelopeSender()); out.println("Envelope recipient: " + this.getEnvelopeReceiver()); // It should all be convertible with ascii or utf8 String content = new String(this.getData()); out.println(content); out.println("===== End message dump ====="); }
/** * Dumps the rough contents of the message for debugging purposes */ public void dumpMessage(PrintStream out) throws MessagingException { out.println("===== Dumping message ====="); out.println("Envelope sender: " + this.getEnvelopeSender()); out.println("Envelope recipient: " + this.getEnvelopeReceiver()); // It should all be convertible with ascii or utf8 String content = new String(this.getData()); out.println(content); out.println("===== End message dump ====="); }