1 /**
2 * Copyright 2005-2013 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
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 package org.kuali.rice.krad.uif.util;
17
18 import java.util.Collections;
19 import java.util.Map;
20 import java.util.Properties;
21
22 import org.kuali.rice.core.api.config.property.ConfigurationService;
23
24 /**
25 * Properties-based configuration service for supporting simple unit testing scenarios.
26 *
27 * @author Kuali Rice Team (rice.collab@kuali.org)
28 */
29 public class SimpleConfigurationService implements ConfigurationService {
30
31 private Properties properties;
32
33 /**
34 * Get the configuration properties.
35 *
36 * @return The properties.
37 */
38 public Properties getProperties() {
39 return this.properties;
40 }
41
42 /**
43 * Set the configuration properties.
44 *
45 * @param properties The properties to set
46 */
47 public void setProperties(Properties properties) {
48 this.properties = properties;
49 }
50
51 /**
52 * @see org.kuali.rice.core.api.config.property.ConfigurationService#getPropertyValueAsString(java.lang.String)
53 */
54 @Override
55 public String getPropertyValueAsString(String key) {
56 return properties.getProperty(key);
57 }
58
59 /**
60 * @see org.kuali.rice.core.api.config.property.ConfigurationService#getPropertyValueAsBoolean(java.lang.String)
61 */
62 @Override
63 public boolean getPropertyValueAsBoolean(String key) {
64 return "true".equals(properties.getProperty(key));
65 }
66
67 /**
68 * @see org.kuali.rice.core.api.config.property.ConfigurationService#getAllProperties()
69 */
70 @SuppressWarnings("unchecked")
71 @Override
72 public Map<String, String> getAllProperties() {
73 return Collections.<String, String> unmodifiableMap((Map<String, String>) ((Map<?, ?>) properties));
74 }
75
76 }