package edu.duke.cabig.c3pr.utils;

import java.util.Date;
import java.util.Properties;
import javax.mail.Message.RecipientType;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import junit.framework.TestCase;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import edu.duke.cabig.c3pr.infrastructure.C3PRMailSenderImpl;

public class C3PRMailSenderTest extends TestCase {
	public void testJavaMaiSenderImpl() throws Exception {
		JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
		mailSender.setHost("smtp.gmail.com");
		mailSender.setPassword("semanticbits");
		mailSender.setPort(465);
		mailSender.setProtocol("smtps");
		mailSender
				.setUsername("c3prproject@gmail.com");
		Properties properties = new Properties();
		properties.put("mail.smtps.auth", "true");
		properties.put("mail.smtps.starttls.enable", "true");
		properties.put("mail.smtps.debug", "true");
		mailSender.setJavaMailProperties(properties);
		MimeMessage message = mailSender.createMimeMessage();
		message
				.setFrom(new InternetAddress(
						"biju.joseph.padupurackal@gmail.com"));
		message.setText("Welcome biju");
		message.setReplyTo(new InternetAddress[] { new InternetAddress(
				"c3prproject@gmail.com") });
		message.setRecipient(RecipientType.TO, new InternetAddress(
				"c3prproject@gmail.com"));
		message.setSubject("My mail via javamailsender");
		message.setDescription("Message description");
		message.setSentDate(new Date());
		mailSender.send(message);
	}

	public void testC3PRMaiSenderImpl() throws Exception {
		JavaMailSenderImpl mailSender = new C3PRMailSenderImpl();
		mailSender.setHost("smtp.gmail.com");
		mailSender.setPassword("semanticbits");
		mailSender.setPort(465);
		mailSender.setProtocol("smtps");
		mailSender
				.setUsername("c3prproject@gmail.com");
		Properties properties = new Properties();
		mailSender.setJavaMailProperties(properties);
		MimeMessage message = mailSender.createMimeMessage();
		message
				.setFrom(new InternetAddress(
						"biju.joseph.padupurackal@gmail.com"));
		message.setText("Welcome biju");
		message.setReplyTo(new InternetAddress[] { new InternetAddress(
				"c3prproject@gmail.com") });
		message.setRecipient(RecipientType.TO, new InternetAddress(
				"c3prproject@gmail.com"));
		message.setSubject("My mail via c3prmailsender");
		message.setDescription("Message description");
		message.setSentDate(new Date());
		mailSender.send(message);
	}
}
@@ -81,24 +81,26 @@
 roperties;%0D%0A
+%0D%0A
 import javax
@@ -211,24 +211,26 @@
 meMessage;%0D%0A
+%0D%0A
 import junit
@@ -250,16 +250,64 @@
 stCase;%0D
+%0A%0D%0Aimport org.easymock.classextension.EasyMock;%0D
 %0Aimport 
@@ -361,16 +361,18 @@
 rImpl;%0D%0A
+%0D%0A
 import e
@@ -425,16 +425,65 @@
 erImpl;%0D
+%0Aimport edu.duke.cabig.c3pr.tools.Configuration;%0D
 %0A%0D%0Apubli
@@ -529,16 +529,19 @@
 Case %7B%0D%0A
+%09%0D%0A
 %09public 
@@ -802,38 +802,32 @@
 );%0D%0A%09%09mailSender
-%0D%0A%09%09%09%09
 .setUsername(%22c3
@@ -1701,36 +1701,216 @@
  Exception %7B%0D%0A%09%09
-Java
+%0D%0A%09%09Configuration conf = EasyMock.createMock(Configuration.class);%0D%0A%09%09EasyMock.expect(conf.get(Configuration.OUTGOING_MAIL_AUTH)).andReturn(%22true%22);%0D%0A%09%09EasyMock.replay(conf);%0D%0A%0D%0A%09%09C3PR
 MailSenderImpl m
@@ -1940,32 +1940,70 @@
 lSenderImpl();%0D%0A
+%09%09mailSender.setConfiguration(conf);%0D%0A
 %09%09mailSender.set
@@ -2344,38 +2344,32 @@
 ge();%0D%0A%09%09message
-%0D%0A%09%09%09%09
 .setFrom(new Int
@@ -2757,32 +2757,32 @@
 description%22);%0D%0A
-
 %09%09message.setSen
@@ -2793,32 +2793,36 @@
 e(new Date());%0D%0A
+%09%09%0D%0A
 %09%09mailSender.sen

test case fix