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: * @(#)TestDeploymentConfigurationFactory.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.config;
030:
031: import com.sun.jbi.management.system.ScaffoldEnvironmentContext;
032: import java.util.Properties;
033:
034: import javax.management.Descriptor;
035: import javax.management.modelmbean.ModelMBeanAttributeInfo;
036:
037: public class TestDeploymentConfigurationFactory extends
038: junit.framework.TestCase {
039:
040: ScaffoldEnvironmentContext mEnvCtx;
041:
042: public TestDeploymentConfigurationFactory(String aTestName)
043: throws Exception {
044: super (aTestName);
045:
046: // The ConfigurationFactory gets the Env. Ctx from Environment Access
047: // Instantiating Env. Ctx here causes the context to be set in EnvironmentAccess
048: mEnvCtx = new ScaffoldEnvironmentContext();
049: mEnvCtx.setJbiInstanceRoot("C:/as8/domains/CAS/jbi");
050: }
051:
052: public void setUp() throws Exception {
053: super .setUp();
054: }
055:
056: public void tearDown() throws Exception {
057: }
058:
059: /**
060: * Test the creation of the MBean Attribute Info
061: */
062: public void testCreateMBeanAttributeInfo() throws Exception {
063: Properties emptyProps = new Properties();
064:
065: DeploymentConfigurationFactory dFactory = new DeploymentConfigurationFactory(
066: emptyProps);
067:
068: ModelMBeanAttributeInfo[] mbeanInfos = dFactory
069: .createMBeanAttributeInfo();
070:
071: for (ModelMBeanAttributeInfo mbeanInfo : mbeanInfos) {
072: // -- test getting the serviceUnitTimeout attribute
073: if (mbeanInfo.getName().equals("serviceUnitTimeout")) {
074: Descriptor descr = mbeanInfo.getDescriptor();
075: assertEquals(new Integer(0), (Integer) descr
076: .getFieldValue("default"));
077: }
078: }
079: }
080:
081: /**
082: * Test the creation of the MBean Attribute Info with defualt overrides
083: */
084: public void testCreateMBeanAttributeInfoWithOverrides()
085: throws Exception {
086: Properties defProps = new Properties();
087: defProps.setProperty("deployment.serviceUnitTimeout", "1000");
088:
089: DeploymentConfigurationFactory dFactory = new DeploymentConfigurationFactory(
090: defProps);
091:
092: ModelMBeanAttributeInfo[] mbeanInfos = dFactory
093: .createMBeanAttributeInfo();
094:
095: for (ModelMBeanAttributeInfo mbeanInfo : mbeanInfos) {
096: // -- test getting the serviceUnitTimeout attribute overriden value
097: if (mbeanInfo.getName().equals("serviceUnitTimeout")) {
098: Descriptor descr = mbeanInfo.getDescriptor();
099: assertEquals(new Integer(1000), (Integer) descr
100: .getFieldValue("default"));
101: }
102: }
103: }
104: }
|