01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. The ASF licenses this file to You
04: * under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
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. For additional information regarding
15: * copyright in this work, please see the NOTICE file in the top level
16: * directory of this distribution.
17: */
18:
19: package org.apache.roller.util;
20:
21: import java.util.HashMap;
22: import java.util.Map;
23: import junit.framework.TestCase;
24:
25: /**
26: * Unit test for org.apache.roller.util.PropertyExpander.
27: *
28: * @author <a href="mailto:anil@busybuddha.org">Anil Gangolli</a>
29: */
30: public class PropertyExpanderTest extends TestCase {
31:
32: private static final Map props = new HashMap();
33:
34: static {
35: props.put("defined.property.one", "value one");
36: props.put("defined.property.two", "value two");
37: props.put("defined.property.with.dollar.sign.in.value", "$2");
38: }
39:
40: public void testExpansion() throws Exception {
41: String expanded = PropertyExpander
42: .expandProperties(
43: "String with ${defined.property.one} and ${defined.property.two} and ${defined.property.with.dollar.sign.in.value} and ${undefined.property} and some stuff.",
44: props);
45:
46: assertEquals(
47: "Expanded string doesn't match expected",
48: "String with value one and value two and $2 and ${undefined.property} and some stuff.",
49: expanded);
50: }
51:
52: public void testSystemProperty() throws Exception {
53: String expanded = PropertyExpander
54: .expandSystemProperties("${java.home}");
55: assertEquals("Expanded string doesn't match expected", System
56: .getProperty("java.home"), expanded);
57: }
58:
59: }
|