Package br.com.caelum.vraptor.simplemail.testing

Source Code of br.com.caelum.vraptor.simplemail.testing.MockTemplateMail

package br.com.caelum.vraptor.simplemail.testing;

import java.io.File;
import java.net.URL;

import javax.enterprise.inject.Vetoed;

import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;

import br.com.caelum.vraptor.simplemail.template.TemplateMail;

@Vetoed
public class MockTemplateMail implements TemplateMail {

  @Override
  public TemplateMail with(String key, Object value) {
    return this;
  }

  @Override
  public Email to(String name, String toMail) {
    SimpleEmail email = new SimpleEmail();
    try {
      email.addTo(toMail, name);
    } catch (EmailException e) {
      throw new IllegalArgumentException(e);
    }
    return email;
  }

  @Override
  public TemplateMail embed(String name, File file) {
    return this;
  }

  @Override
  public TemplateMail embed(String name, URL url) {
    return this;
  }

  @Override
  public TemplateMail attach(String name, File file) {
    return this;
  }

  @Override
  public TemplateMail attach(String name, URL url) {
    return this;
  }

}
TOP

Related Classes of br.com.caelum.vraptor.simplemail.testing.MockTemplateMail

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.