1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.configuration;
19
20 import static org.junit.Assert.assertFalse;
21 import static org.junit.Assert.assertNotNull;
22 import static org.junit.Assert.assertTrue;
23
24 import java.util.Iterator;
25
26 import org.junit.Before;
27 import org.junit.Test;
28
29
30
31
32
33
34
35
36
37 public class TestEnvironmentConfiguration
38 {
39
40 private EnvironmentConfiguration config;
41
42 @Before
43 public void setUp() throws Exception
44 {
45 config = new EnvironmentConfiguration();
46 }
47
48
49
50
51
52 @Test
53 public void testInit()
54 {
55 boolean found = false;
56 assertFalse("No properties found", config.isEmpty());
57 for (Iterator<String> it = config.getKeys(); it.hasNext();)
58 {
59 String key = it.next();
60 assertTrue("Key not found: " + key, config.containsKey(key));
61 assertNotNull("No value for property " + key, config.getString(key));
62 found = true;
63 }
64 assertTrue("No property keys returned", found);
65 }
66
67
68
69
70 @Test(expected = UnsupportedOperationException.class)
71 public void testClearProperty()
72 {
73 String key = config.getKeys().next();
74 config.clearProperty(key);
75 }
76
77
78
79
80 @Test(expected = UnsupportedOperationException.class)
81 public void testClear()
82 {
83 config.clear();
84 }
85
86
87
88
89 @Test(expected = UnsupportedOperationException.class)
90 public void testAddProperty()
91 {
92 config.addProperty("JAVA_HOME", "C:\\java");
93 }
94
95
96
97
98 @Test(expected = UnsupportedOperationException.class)
99 public void testSetProperty()
100 {
101 config.setProperty("JAVA_HOME", "C:\\java");
102 }
103 }