01: /*
02: * Copyright 2007 The Kuali Foundation
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: // Created on Aug 29, 2006
17: package org.kuali.rice.config;
18:
19: import java.io.File;
20: import java.io.FileInputStream;
21: import java.io.IOException;
22: import java.util.Properties;
23:
24: import junit.framework.TestCase;
25:
26: import org.junit.Test;
27:
28: public class SimpleNodeSettingStoreTest extends TestCase {
29:
30: @Test
31: public void test() throws Exception {
32: SimpleNodeSettingsStore s = new SimpleNodeSettingsStore();
33: File f = File.createTempFile("simplenodesettingstoretest",
34: "unittest");
35: f.deleteOnExit();
36: s.setPropertiesPath(f.getAbsolutePath());
37: s.afterPropertiesSet();
38: assertEquals(0, s.getSettings().size());
39: s.setSetting("foo", "bar");
40:
41: assertSetting(f.getAbsolutePath(), "foo", "bar");
42:
43: s.removeSetting("foo");
44:
45: assertSetting(f.getAbsolutePath(), "foo", null);
46: }
47:
48: protected void assertSetting(String path, String name, String value)
49: throws IOException {
50: Properties p = new Properties();
51: FileInputStream fis = new FileInputStream(path);
52: try {
53: p.load(fis);
54: } finally {
55: fis.close();
56: }
57: assertEquals(value, p.getProperty(name));
58: }
59: }
|