01: package CustomDNS.Tests;
02:
03: import CustomDNS.Tests.CustomDNSTestCase;
04: import CustomDNS.SimpleConfiguration;
05:
06: public class TestSimpleConfiguration extends CustomDNSTestCase {
07:
08: SimpleConfiguration myConfig;
09:
10: public TestSimpleConfiguration(String name) {
11: super (name);
12: }
13:
14: protected void setUp() throws Exception {
15: myConfig = new SimpleConfiguration(fullPath("customdns.prop"));
16: }
17:
18: public void testGetProperty() {
19: assertEquals(myConfig.getProperty("foo"), "bar");
20: assertEquals(myConfig.getProperty("foo.x.y"), "baz");
21: }
22:
23: public void testGetMissingProperty() {
24: assertEquals(myConfig.getProperty("missing"), null);
25: }
26:
27: public void testGetMissingPropertyDefault() {
28: assertEquals(myConfig.getProperty("missing", "default"),
29: "default");
30: }
31:
32: public void testMissingFile() throws Exception {
33: try {
34: new SimpleConfiguration(fullPath("thisFileShouldNotExist"));
35: fail("Expected FileNotFoundException");
36: } catch (java.io.FileNotFoundException e) {
37: }
38: }
39: }
|