1 package se.anatom.ejbca.util; 2 3 import java.util.HashMap ; 4 5 import junit.framework.TestCase; 6 7 import org.ejbca.util.TemplateMimeMessage; 8 9 12 public class TestTemplateMimeMessage extends TestCase { 13 14 private TemplateMimeMessage message; 15 16 protected void setUp() throws Exception { 17 HashMap patterns = new HashMap (); 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 { 24 String input = "Hello ${username}, your password is ${password}"; 25 String expected ="Hello John Doe, your password is secret"; 26 message.setContent(input, "text/plain"); 27 String output = (String )message.getContent(); 28 assertEquals(expected, output); 29 } 30 31 public void testContentPatternCase() throws Exception { 32 String input = "Hello ${uSeRnAmE}, your password is ${pAsSwOrD}"; 33 String expected = input; 34 message.setContent(input, "text/plain"); 35 String output = (String )message.getContent(); 36 assertEquals(expected, output); 37 } 38 39 public void testMixedPatterns() throws Exception { 40 String input = "Hello ${username}, your password is ${pAsSwOrD}"; 41 String expected = "Hello John Doe, your password is ${pAsSwOrD}"; 42 message.setContent(input, "text/plain"); 43 String output = (String )message.getContent(); 44 assertEquals(expected, output); 45 } 46 47 } 48 | Popular Tags |