1 package org.microemu;
2
3 import java.io.File;
4 import java.io.FileInputStream;
5 import java.io.InputStream;
6 import java.util.Properties;
7
8 import org.microemu.app.Config;
9
10 public class TestEnvPropertiesHelper {
11
12 static final Properties utProperties = loadProperties();
13
14 static final String FILE_NAME = "tests.properties";
15
16
17
18
19
20 public static String getProperty(String key, String defaultValue) {
21 return utProperties.getProperty(key, defaultValue);
22 }
23
24 private static Properties loadProperties() {
25 Properties prop = new Properties();
26
27 File meHomeRoot = Config.getConfigPath();
28 if (meHomeRoot == null) {
29 return prop;
30 }
31
32 File file = new File(meHomeRoot, FILE_NAME);
33 if (!file.exists() || !file.canRead()) {
34 return prop;
35 }
36
37 FileInputStream input;
38 try {
39 input = new FileInputStream(file);
40 prop.load((InputStream) input);
41 } catch (Exception e) {
42 System.err.println("Error reading properties " + e.toString());
43 }
44 return prop;
45 }
46 }