001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)TestPropertyFilter.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.management.util;
030:
031: /**
032: *
033: * @author Sun Microsystems, Inc.
034: */
035:
036: public class TestPropertyFilter extends junit.framework.TestCase {
037:
038: public TestPropertyFilter(String testName) {
039: super (testName);
040: }
041:
042: public void testFilterProperties() throws Exception {
043: System.setProperty("Company.Name", "SUN MICRO");
044: System.setProperty("Stock.Value", "10.00");
045:
046: String testString = "The stock of ${Company.Name} has reached USD ${Stock.Value}";
047:
048: String result = PropertyFilter.filterProperties(testString);
049:
050: System.out.println(result);
051: String expectedResult = "The stock of SUN MICRO has reached USD 10.00";
052:
053: assertEquals(expectedResult, result);
054: }
055:
056: public void testFilterProperties1() throws Exception {
057:
058: String testString = "It is a bright sunny day.";
059:
060: String result = PropertyFilter.filterProperties(testString);
061:
062: System.out.println(result);
063:
064: assertEquals(testString, result);
065: }
066:
067: public void testFilterProperties2() throws Exception {
068:
069: String testString = "It is a bright sunny ${day.";
070:
071: String result = PropertyFilter.filterProperties(testString);
072:
073: System.out.println(result);
074:
075: assertEquals(testString, result);
076: }
077:
078: public void testFilterProperties3() throws Exception {
079: System.setProperty("com.sun.aas.instanceRoot",
080: "C:\\Sun\\AppServerEE\\domains\\cas");
081:
082: String testString = "${com.sun.aas.instanceRoot}/jbi/components/jmsbinding/install_root";
083:
084: String result = PropertyFilter.filterProperties(testString);
085:
086: System.out.println(result);
087: String expectedResult = "C:\\Sun\\AppServerEE\\domains\\cas/jbi/components/jmsbinding/install_root";
088:
089: assertEquals(expectedResult, result);
090: }
091:
092: public void testReplacePropertyValues() {
093: String testString = "C:\\Sun\\AppServerEE\\domains\\cas/jbi/components\\jmsbinding/install_root";
094: System.setProperty("com.sun.aas.instanceRoot",
095: "C:\\Sun\\AppServerEE\\domains\\cas");
096:
097: String result = PropertyFilter.replacePropertyValues(
098: testString, "com.sun.aas.instanceRoot");
099: System.out.println(result);
100:
101: String expectedResult = "${com.sun.aas.instanceRoot}/jbi/components\\jmsbinding/install_root";
102:
103: assertEquals(expectedResult, result);
104: }
105: }
|