OrderMailer extends BaseMailer { public AsyncToken sendConfirmOrder(final String username) { final SimpleMailMessage msg = createConfirmOrder(username); AsyncToken token = getAsyncJavaMailSender().send(SimpleMailMessageUtils.toHtmlMsg(msg,"rapid小明")); token.addResponder(new IResponder() { public void onFault(Exception fault) { System.out.println("[ERROR] confirmOrder mail send fail,cause:"+fault); } public void onResult(Object result) { System.out.println("[INFO] confirmOrder mail send success"); } }); return token; }  SimpleMailMessage createConfirmOrder(String username); AsyncToken sendConfirmOrder(final String username);  }
@Test public void testSendFromOrderMailer() throws TemplateException, IOException, Exception { AsyncToken token = orderMailer.sendConfirmOrder("badqiu"); token.waitForResult(); }