1 16 package org.outerj.daisy.repository.testsupport; 17 18 import java.util.Properties ; 19 import java.io.File ; 20 import java.io.FileInputStream ; 21 22 public class TestSupportConfig extends Properties { 23 private static final String DEFAULTPROPS = "testsupport.properties"; 24 private static final String USERPROPS = "local.testsupport.properties"; 25 26 public TestSupportConfig() throws Exception { 27 File defaultProps = new File (DEFAULTPROPS); 28 if (defaultProps.exists()) { 29 load(new FileInputStream (defaultProps)); 30 System.out.println("Finished reading properties from " + DEFAULTPROPS); 31 } else { 32 System.out.println("Did not find properties file " + DEFAULTPROPS); 33 } 34 35 File userProps = new File (USERPROPS); 36 if (userProps.exists()) { 37 load(new FileInputStream (userProps)); 38 System.out.println("Finished reading properties from " + USERPROPS); 39 } else { 40 System.out.println("Did not find optional properties file " + USERPROPS); 41 } 42 } 43 44 public String getRequiredProperty(String key) throws Exception { 45 String value = getProperty(key); 46 if (value == null) 47 throw new Exception ("Missing property " + key + "."); 48 return value; 49 } 50 51 } 52 | Popular Tags |