1   /*
2   * Licensed to the Apache Software Foundation (ASF) under one or more
3   * contributor license agreements.  See the NOTICE file distributed with
4   * this work for additional information regarding copyright ownership.
5   * The ASF licenses this file to You under the Apache License, Version 2.0
6   * (the "License"); you may not use this file except in compliance with
7   * the License.  You may obtain a copy of the License at
8   *
9   *     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 AbstractPrefsSupportedTestCase
38  {
39  
40      /***
41       * @see junit.framework.TestCase#setUp()
42       */
43      public void setUp() throws Exception
44      {
45          super.setUp();
46  
47          // Make sure we are starting with a clean slate
48          clearChildren(Preferences.userRoot());
49          clearChildren(Preferences.systemRoot());
50  
51      }
52  
53      /***
54       * @see junit.framework.TestCase#tearDown()
55       */
56      public void tearDown() throws Exception
57      {
58          super.tearDown();
59      }
60  
61      protected void clearChildren(Preferences node) throws Exception
62      {
63          String[] names = node.childrenNames();
64          for (int i = 0; i < names.length; i++)
65          {
66              node.node(names[i]).removeNode();
67          }
68      }
69  
70      /***
71       * <p>
72       * Legacy test from the times where we add a property manager. The property manager is
73       * since gone, but the test still tests the prefs implementation.
74       * </p>
75       * 
76       * @throws Exception
77       */
78      public void testSansPropertyManager() throws Exception
79      {
80  
81          // Make sure we are starting with a clean slate
82          clearChildren(Preferences.userRoot());
83          clearChildren(Preferences.systemRoot());
84  
85          Preferences pref0 = Preferences.userRoot();
86          // Test that the property manager is off
87          Preferences pref1 = pref0.node("testOpenNode");
88          pref1.put("0", "I am 0 key");
89  
90          assertNotNull(pref1.get("0", null));
91  
92      }
93  
94      /***
95       * @see org.apache.jetspeed.components.test.AbstractSpringTestCase#getConfigurations()
96       */
97      protected String[] getConfigurations()
98      {
99          return new String[]
100         { "prefs.xml", "transaction.xml", "cache.xml" };
101     }
102 }