1 37 package net.sourceforge.cruisecontrol; 38 39 import java.util.Properties ; 40 41 import junit.framework.TestCase; 42 43 public class ProjectXMLHelperTest extends TestCase { 44 45 public void testParsePropertiesInString1() throws CruiseControlException { 46 Properties properties = new Properties (); 47 properties.put("property", "value"); 48 String s = ProjectXMLHelper.parsePropertiesInString(properties, "${property}", false); 49 assertEquals("value", s); 50 51 properties.put("one", "1"); 52 properties.put("two", "2"); 53 String s2 = ProjectXMLHelper.parsePropertiesInString(properties, "a${one}b${two}c", false); 54 assertEquals("a1b2c", s2); 55 56 properties.put("one", "1"); 57 properties.put("two", "2"); 58 59 String s3 = ProjectXMLHelper.parsePropertiesInString(properties, "a${oneb${two}}c", false); 60 assertEquals("a${oneb2}c", s3); 61 62 properties.put("foo-bar", "b"); 63 properties.put("two", "bar"); 64 String s4 = ProjectXMLHelper.parsePropertiesInString(properties, "a${foo-${two}}c", false); 65 assertEquals("abc", s4); 66 67 try { 68 ProjectXMLHelper.parsePropertiesInString(properties, "${foo", false); 69 fail("badly formatted properties. Should have failed"); 70 } catch (CruiseControlException e) { 71 } 73 74 String s5 = ProjectXMLHelper.parsePropertiesInString(properties, "${}", false); 75 assertEquals("", s5); 76 } 77 78 public void testParsePropertiesInString2() throws CruiseControlException { 79 Properties properties = new Properties (); 80 String s = ProjectXMLHelper.parsePropertiesInString(properties, "${missing}", false); 81 assertEquals("${missing}", s); 82 } 83 } 84 | Popular Tags |