01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: /*
18: * Created on Oct 21, 2004
19: *
20: * TODO To change the template for this generated file go to
21: * Window - Preferences - Java - Code Generation - Code and Comments
22: */
23: package org.apache.jetspeed.prefs;
24:
25: import java.util.prefs.Preferences;
26:
27: import org.apache.jetspeed.prefs.util.test.AbstractPrefsSupportedTestCase;
28:
29: /**
30: * <p>
31: * TestPreferencesNoPropManager
32: * </p>
33: *
34: * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
35: * @version $Id: TestPreferencesNoPropManager.java 516881 2007-03-11 10:34:21Z ate $
36: */
37: public class TestPreferencesNoPropManager extends
38: AbstractPrefsSupportedTestCase {
39:
40: /**
41: * @see junit.framework.TestCase#setUp()
42: */
43: public void setUp() throws Exception {
44: super .setUp();
45:
46: // Make sure we are starting with a clean slate
47: clearChildren(Preferences.userRoot());
48: clearChildren(Preferences.systemRoot());
49:
50: }
51:
52: /**
53: * @see junit.framework.TestCase#tearDown()
54: */
55: public void tearDown() throws Exception {
56: super .tearDown();
57: }
58:
59: protected void clearChildren(Preferences node) throws Exception {
60: String[] names = node.childrenNames();
61: for (int i = 0; i < names.length; i++) {
62: node.node(names[i]).removeNode();
63: }
64: }
65:
66: /**
67: * <p>
68: * Legacy test from the times where we add a property manager. The property manager is
69: * since gone, but the test still tests the prefs implementation.
70: * </p>
71: *
72: * @throws Exception
73: */
74: public void testSansPropertyManager() throws Exception {
75:
76: // Make sure we are starting with a clean slate
77: clearChildren(Preferences.userRoot());
78: clearChildren(Preferences.systemRoot());
79:
80: Preferences pref0 = Preferences.userRoot();
81: // Test that the property manager is off
82: Preferences pref1 = pref0.node("testOpenNode");
83: pref1.put("0", "I am 0 key");
84:
85: assertNotNull(pref1.get("0", null));
86:
87: }
88:
89: /**
90: * @see org.apache.jetspeed.components.test.AbstractSpringTestCase#getConfigurations()
91: */
92: protected String[] getConfigurations() {
93: return new String[] { "prefs.xml", "transaction.xml",
94: "cache.xml" };
95: }
96: }
|