KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > se > anatom > ejbca > util > TestTemplateMimeMessage


1 package se.anatom.ejbca.util;
2
3 import java.util.HashMap JavaDoc;
4
5 import junit.framework.TestCase;
6
7 import org.ejbca.util.TemplateMimeMessage;
8
9 /**
10  * TestCase for TemplateMimeMessage
11  */

12 public class TestTemplateMimeMessage extends TestCase {
13
14     private TemplateMimeMessage message;
15
16     protected void setUp() throws Exception JavaDoc {
17         HashMap JavaDoc patterns = new HashMap JavaDoc();
18         patterns.put("username", "John Doe");
19         patterns.put("password", "secret");
20         message = new TemplateMimeMessage(patterns, null);
21     }
22
23     public void testContent() throws Exception JavaDoc {
24         String JavaDoc input = "Hello ${username}, your password is ${password}";
25         String JavaDoc expected ="Hello John Doe, your password is secret";
26         message.setContent(input, "text/plain");
27         String JavaDoc output = (String JavaDoc)message.getContent();
28         assertEquals(expected, output);
29     }
30
31     public void testContentPatternCase() throws Exception JavaDoc {
32         String JavaDoc input = "Hello ${uSeRnAmE}, your password is ${pAsSwOrD}";
33         String JavaDoc expected = input;
34         message.setContent(input, "text/plain");
35         String JavaDoc output = (String JavaDoc)message.getContent();
36         assertEquals(expected, output);
37     }
38
39     public void testMixedPatterns() throws Exception JavaDoc {
40         String JavaDoc input = "Hello ${username}, your password is ${pAsSwOrD}";
41         String JavaDoc expected = "Hello John Doe, your password is ${pAsSwOrD}";
42         message.setContent(input, "text/plain");
43         String JavaDoc output = (String JavaDoc)message.getContent();
44         assertEquals(expected, output);
45     }
46     
47 }
48
Popular Tags