1 37 38 package net.sourceforge.cruisecontrol.distributed.util; 39 40 import java.util.Map ; 41 42 import junit.framework.TestCase; 43 44 public class PropertiesHelperTest extends TestCase { 45 private static final String TEST_PROPERTIES_FILENAME = "testdist.properties"; 46 private static final String TEST_PROP_NAME = "testProperty"; 47 48 public void testLoadOptionalProperties() { 49 Map propertiesMap = PropertiesHelper.loadOptionalProperties(TEST_PROPERTIES_FILENAME); 50 assertNotNull(propertiesMap); 51 String value = (String ) propertiesMap.get(TEST_PROP_NAME); 52 assertEquals("true", value); 53 54 propertiesMap = PropertiesHelper.loadOptionalProperties("bogus.properties"); 55 assertNotNull(propertiesMap); 56 value = (String ) propertiesMap.get(TEST_PROP_NAME); 57 assertNull(value); 58 } 59 60 public void testLoadRequiredProperties() { 61 Map propertiesMap = PropertiesHelper.loadRequiredProperties(TEST_PROPERTIES_FILENAME); 62 assertNotNull(propertiesMap); 63 String value = (String ) propertiesMap.get(TEST_PROP_NAME); 64 assertEquals("true", value); 65 66 try { 67 propertiesMap = PropertiesHelper.loadRequiredProperties("bogus.properties"); 68 fail("Should throw RuntimeException when a required properties file is not found"); 69 } catch (RuntimeException e) { 70 assertEquals("Failed to load required properties file 'bogus.properties'", 72 e.getMessage()); 73 } 74 } 75 76 } 77 | Popular Tags |