/*
 * Copyright (C) 2008 feilong
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.feilong.spring.mail;

import java.util.HashMap;
import java.util.Map;

import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * The Class MailUtilTest.
 * 
 * @author <a href="http://feitianbenyue.iteye.com/">feilong</a>
 */
public class JavaMailSenderUtilTest{

    /** The context. */
    private ApplicationContext context;

    /** The mail util. */
    private JavaMailSenderUtil mailUtil;

    /**
     * Inits the.
     */
    @Before
    public void init(){
        context = new ClassPathXmlApplicationContext("classpath*:spring-mail.xml");
        mailUtil = context.getBean(JavaMailSenderUtil.class);
    }

    /**
     * Send email.
     */
    @Test
    public void sendEmail(){
        Map<String, Object> model = new HashMap<>();
        model.put("userName", "大关");
        model.put("email" + "Address", "woshidaguan@126.com");
        String[] mailTo = new String[] { "venusdrogon@163.com" };
        // String[] files = new String[] { "F:/Photo 照片/2012/else/120120A011.jpg", "F:/Photo 照片/2012/else/120127A001.jpg" };
        String vmfile = "com/guan/chapter19/email/welcome.vm";
        String subject = "欢迎您的加入";
        mailUtil.sendEmail(null, subject, vmfile, mailTo, null);
    }

    /**
     * Send.
     */
    @Test
    public void send(){
        String[] to = new String[] { "venusdrogon@163.com" };
        String subject = "欢迎您的加入暗示的发射点法";
        String text = "<span style='color:red'><br>鑫哥艾莉梅阿斯达萨</br></span>";
        mailUtil.send(to, subject, text, null);
    }

    /**
     * Send mail native.
     */
    @Test
    public void sendMailNative(){
        String[] to = new String[] { "venusdrogon@163.com" };
        String subject = "你好";
        String text = "<span style='color:red'><br>鑫哥 </br></span>";
        mailUtil.sendMailNative(to, subject, text, null);
    }
}

@@ -1051,16 +1051,19 @@
 Context 
+   
 context;
@@ -1063,16 +1063,16 @@
 ontext;%0A
-
 %0A    /**
@@ -1121,16 +1121,19 @@
 derUtil 
+   
 mailUtil
@@ -1135,16 +1135,96 @@
 lUtil;%0A%0A
+    private final static String%5B%5D to = new String%5B%5D %7B %22venusdrogon@163.com%22 %7D;%0A%0A
     /**%0A
@@ -1669,74 +1669,8 @@
 %22);%0A
-        String%5B%5D mailTo = new String%5B%5D %7B %22venusdrogon@163.com%22 %7D;%0A
     
@@ -1942,13 +1942,9 @@
 le, 
-mailT
+t
 o, n
@@ -2023,70 +2023,8 @@
 ()%7B%0A
-        String%5B%5D to = new String%5B%5D %7B %22venusdrogon@163.com%22 %7D;%0A
     
@@ -2280,69 +2280,8 @@
 ()%7B%0A
-        String%5B%5D to = new String%5B%5D %7B %22venusdrogon@163.com%22 %7D;
 %0A   

update email