1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.pluto.testsuite;
19
20 import java.io.IOException;
21 import java.io.InputStream;
22 import java.util.Properties;
23
24 /***
25 * A Singleton which loads a properties file containing data expected
26 * by the tests in the testsuite.
27 *
28 */
29 public class ExpectedResults {
30 public static final String PROPERTY_FILENAME = "expectedResults.properties";
31
32 public static final String EXPECTED_PORTAL_INFO_KEY = "expected.portalInfo";
33
34 private static ExpectedResults expectedResults;
35 private Properties properties;
36
37 private ExpectedResults() throws IOException {
38 this.properties = new Properties();
39
40 InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(PROPERTY_FILENAME);
41 if (in == null) {
42 throw new IOException("Could not find " + PROPERTY_FILENAME);
43 }
44 this.properties.load(in);
45 }
46
47 public Properties getProperties() {
48 return this.properties;
49 }
50
51 /***
52 * Retrieves properties expected by the test suite.
53 *
54 * @return the Properties found in the properties file.
55 * @throws InvalidConfigurationException if an error occured reading the properties file.
56 */
57 public static Properties getExpectedProperties() throws InvalidConfigurationException {
58 try {
59 if (expectedResults == null) {
60 expectedResults = new ExpectedResults();
61 }
62
63 return expectedResults.getProperties();
64 } catch (IOException e) {
65 throw new InvalidConfigurationException("An error occured reading the resource " + PROPERTY_FILENAME + ". Error was " + e.getMessage());
66 }
67 }
68
69 }