package jp.agentec.sinaburocast.common.util.velocity;

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

import junit.framework.TestCase;
import junit.framework.TestSuite;

import org.apache.velocity.VelocityContext;
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;

public class TemplateUtilTest extends TestCase {

	public TemplateUtilTest(String string) {
		super(string);
	}

	public static TestSuite suite() {
		TestSuite suite = new TestSuite("TemplateUtilTest");
		suite.addTest(new TemplateUtilTest("testTemplateUtil"));
		return suite;
	}


	/**
	 * @throws java.lang.Exception
	 */
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}

	/**
	 * @throws java.lang.Exception
	 */
	@AfterClass
	public static void tearDownAfterClass() throws Exception {
	}

	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
	}

	/**
	 * @throws java.lang.Exception
	 */
	@After
	public void tearDown() throws Exception {
	}

	public void testTemplateUtil() {
	      try{
	          VelocityContext context = new VelocityContext();
	          Map<String, String> map = new HashMap<String, String>();
	          map.put("message", "nantoka");
	          map.put("company", "hoge");
	          map.put("sender", "boke");
	          context.put("m", map);
	          System.out.println(TemplateUtil.parse("mail/sample.tpl", context));
	      } catch (ResourceNotFoundException e) {
	    	  e.printStackTrace();
	      } catch (ParseErrorException e) {
	    	  e.printStackTrace();
	      } catch (MethodInvocationException e) {
	    	  e.printStackTrace();
	      } catch (Exception e) {
	    	  e.printStackTrace();
	      }
	}

}