Source Code Cross Referenced for TestEventManagementControllerMBean.java in  » ESB » open-esb » com » sun » esb » eventmanagement » impl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ESB » open esb » com.sun.esb.eventmanagement.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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:         * @(#)TestAdminService.java
025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026:         *
027:         * END_HEADER - DO NOT EDIT
028:         */
029:        package com.sun.esb.eventmanagement.impl;
030:
031:        import java.io.File;
032:        import java.io.FileInputStream;
033:        import java.net.InetAddress;
034:        import java.net.UnknownHostException;
035:        import java.util.ArrayList;
036:        import java.util.List;
037:        import java.util.Properties;
038:
039:        import javax.management.remote.*;
040:        import javax.management.*;
041:
042:        import com.sun.esb.eventmanagement.api.AlertPersistenceDBType;
043:        import com.sun.esb.eventmanagement.impl.AlertLevelType;
044:        import com.sun.esb.eventmanagement.impl.AlertRemovalPolicyType;
045:        import com.sun.esb.eventmanagement.impl.EventManagementConstants;
046:        import com.sun.jbi.EnvironmentContext;
047:        import com.sun.jbi.management.ee.JavaEEApplicationInterceptor;
048:        import com.sun.jbi.management.system.ScaffoldedEnvironmentContext;
049:
050:        /**
051:         */
052:        public class TestEventManagementControllerMBean extends
053:                junit.framework.TestCase implements  EventManagementConstants {
054:
055:            private static final Boolean ENABLE_PERSISTENCE_TEST_VALUE = true;
056:            private static final Boolean ENABLE_POLICY_EXECUTION_TEST_VALUE = true;
057:            private static final Long PERSISTED_ALERT_MAX_AGE_TEST_VALUE = 12345L;
058:            private static final Long PERSISTED_ALERT_MAX_COUNT_TEST_VALUE = 54321L;
059:            private static final String PERSISTED_ALERT_LEVEL_TEST_VALUE = AlertLevelType.CRITICAL
060:                    .getAlertLevel();
061:            private static final Long PERSISTED_ALERT_REMOVAL_PROLICY_EXEC_INTERVAL_TEST_VALUE = 567890L;
062:            private static final String DATABASE_JNDI_NAME__TEST_VALUE = "testJNDI";
063:            private static final String DATABASE_TYPE_TEST_VALUE = AlertPersistenceDBType.ORACLE
064:                    .getDatabasetype();
065:            private static final String DATABASE_TABLE_TEST_VALUE = "TestTable";
066:
067:            private EventManagementControllerMBean mEventManagementControllerMBean;
068:            private EnvironmentContext mEnvCtx;
069:            private MBeanServer mMBeanServer;
070:
071:            public TestEventManagementControllerMBean() throws Exception {
072:
073:                mEnvCtx = new ScaffoldedEnvironmentContext();
074:                mMBeanServer = mEnvCtx.getMBeanServer();
075:            }
076:
077:            public void setUp() throws Exception {
078:                super .setUp();
079:                mEventManagementControllerMBean = new EventManagementControllerMBean(
080:                        mEnvCtx);
081:
082:                mMBeanServer.registerMBean(mEventManagementControllerMBean,
083:                        this .getControllerName());
084:            }
085:
086:            public void tearDown() throws Exception {
087:                mEnvCtx.getMBeanServer().unregisterMBean(getControllerName());
088:            }
089:
090:            public ObjectName getControllerName() throws Exception {
091:                // this name is subject to change if it need to conform to the JBI runtime MBean convention.
092:                String controller = "EventManagement:name=EventManagementControllerMBean";
093:                return new ObjectName(controller);
094:            }
095:
096:            public void testEnablePolicyExecution() throws Exception {
097:                Attribute attib = new Attribute(
098:                        ENABLE_POLICY_EXECUTION_ATTRIBUTE_NAME,
099:                        ENABLE_POLICY_EXECUTION_TEST_VALUE);
100:                mMBeanServer.setAttribute(getControllerName(), attib);
101:                Boolean enabled = (Boolean) mMBeanServer.getAttribute(
102:                        getControllerName(),
103:                        ENABLE_POLICY_EXECUTION_ATTRIBUTE_NAME);
104:                assertTrue(enabled.equals(true));
105:            }
106:
107:            public void testPersistedEventMaxAge() throws Exception {
108:                Long testAge = this .PERSISTED_ALERT_MAX_AGE_TEST_VALUE;
109:                Attribute attib = new Attribute(
110:                        PERSISTED_ALERT_MAX_AGE_ATTRIBUTE_NAME, testAge);
111:                mMBeanServer.setAttribute(getControllerName(), attib);
112:                Long returnAge = (Long) mMBeanServer.getAttribute(
113:                        getControllerName(),
114:                        PERSISTED_ALERT_MAX_AGE_ATTRIBUTE_NAME);
115:                assertTrue(returnAge.equals(PERSISTED_ALERT_MAX_AGE_TEST_VALUE));
116:            }
117:
118:            public void testPersistedEventMaxCount() throws Exception {
119:                Long testCount = this .PERSISTED_ALERT_MAX_COUNT_TEST_VALUE;
120:                Attribute attib = new Attribute(
121:                        PERSISTED_ALERT_MAX_COUNT_ATTRIBUTE_NAME, testCount);
122:                mMBeanServer.setAttribute(getControllerName(), attib);
123:                Long returnCount = (Long) mMBeanServer.getAttribute(
124:                        getControllerName(),
125:                        PERSISTED_ALERT_MAX_COUNT_ATTRIBUTE_NAME);
126:                assertTrue(returnCount
127:                        .equals(PERSISTED_ALERT_MAX_COUNT_TEST_VALUE));
128:            }
129:
130:            public void testPersistedEventAlertLevel() throws Exception {
131:                String testLevel = this .PERSISTED_ALERT_LEVEL_TEST_VALUE;
132:                Attribute attib = new Attribute(
133:                        PERSISTED_ALERT_LEVEL_ATTRIBUTE_NAME, testLevel);
134:                mMBeanServer.setAttribute(getControllerName(), attib);
135:                String returnlevel = (String) mMBeanServer.getAttribute(
136:                        getControllerName(),
137:                        PERSISTED_ALERT_LEVEL_ATTRIBUTE_NAME);
138:                assertTrue(returnlevel.equals(AlertLevelType.CRITICAL
139:                        .getAlertLevel()));
140:            }
141:
142:            public void testPolicyExecutionInterval() throws Exception {
143:                Long testinterval = this .PERSISTED_ALERT_REMOVAL_PROLICY_EXEC_INTERVAL_TEST_VALUE;
144:                Attribute attib = new Attribute(
145:                        PERSISTED_ALERT_REMOVAL_PROLICY_EXEC_INTERVAL_ATTRIBUTE_NAME,
146:                        testinterval);
147:                mMBeanServer.setAttribute(getControllerName(), attib);
148:                Long returninterval = (Long) mMBeanServer
149:                        .getAttribute(getControllerName(),
150:                                PERSISTED_ALERT_REMOVAL_PROLICY_EXEC_INTERVAL_ATTRIBUTE_NAME);
151:                assertTrue(returninterval
152:                        .equals(PERSISTED_ALERT_REMOVAL_PROLICY_EXEC_INTERVAL_TEST_VALUE));
153:            }
154:
155:            public void testJNDIName() throws Exception {
156:                String testjndi = this .DATABASE_JNDI_NAME__TEST_VALUE;
157:                Attribute attib = new Attribute(
158:                        DATABASE_JNDI_NAME__ATTRIBUTE_NAME, testjndi);
159:                mMBeanServer.setAttribute(getControllerName(), attib);
160:                String returnjndi = (String) mMBeanServer
161:                        .getAttribute(getControllerName(),
162:                                DATABASE_JNDI_NAME__ATTRIBUTE_NAME);
163:                assertTrue(returnjndi.equals(DATABASE_JNDI_NAME__TEST_VALUE));
164:            }
165:
166:            public void testDatabaseType() throws Exception {
167:                String testDBType = this .DATABASE_TYPE_TEST_VALUE;
168:                Attribute attib = new Attribute(DATABASE_TYPE_ATTRIBUTE_NAME,
169:                        testDBType);
170:                mMBeanServer.setAttribute(getControllerName(), attib);
171:                String returnDBType = (String) mMBeanServer.getAttribute(
172:                        getControllerName(), DATABASE_TYPE_ATTRIBUTE_NAME);
173:                assertTrue(returnDBType.equals(AlertPersistenceDBType.ORACLE
174:                        .getDatabasetype()));
175:            }
176:
177:            public void testDatabaseTableName() throws Exception {
178:
179:                String testTableName = DATABASE_TABLE_TEST_VALUE;
180:                Attribute attib = new Attribute(
181:                        DATABASE_ALERT_TABLE_NAME__ATTRIBUTE_NAME,
182:                        testTableName);
183:                mMBeanServer.setAttribute(getControllerName(), attib);
184:                String returnTableName = (String) mMBeanServer.getAttribute(
185:                        getControllerName(),
186:                        DATABASE_ALERT_TABLE_NAME__ATTRIBUTE_NAME);
187:                assertTrue(returnTableName.equals(DATABASE_TABLE_TEST_VALUE));
188:            }
189:
190:            public void testAlertRemovalPolicy() throws Exception {
191:
192:                ArrayList policySettingList = new ArrayList<String>();
193:                policySettingList.add(AlertRemovalPolicyType.ALERTS_LEVEL
194:                        .getPolicyType());
195:                policySettingList.add(AlertRemovalPolicyType.ALERTS_AGE
196:                        .getPolicyType());
197:                policySettingList.add(AlertRemovalPolicyType.ALERTS_COUNT
198:                        .getPolicyType());
199:
200:                Object[] params = { policySettingList };
201:                String[] signature = { "java.util.List" };
202:                mMBeanServer.invoke(getControllerName(),
203:                        UPDATE_PERSISTED_ALERT_REMOVAL_PROLICY_OPERATION_NAME,
204:                        params, signature);
205:                String[] returnpolicy = (String[]) mMBeanServer
206:                        .invoke(
207:                                getControllerName(),
208:                                GET_LAST_PERSISTED_ALERT_REMOVAL_PROLICY_OPERATION_NAME,
209:                                null, null);
210:                assertTrue(parsePolicy(policySettingList).equals(
211:                        parsePolicy(returnpolicy)));
212:            }
213:
214:            private String parsePolicy(List<String> policyItems) {
215:                StringBuffer policyString = new StringBuffer();
216:                for (String item : policyItems) {
217:                    policyString.append(item + " ");
218:                }
219:                return policyString.toString();
220:            }
221:
222:            private String parsePolicy(String[] policyItems) {
223:                StringBuffer policyString = new StringBuffer();
224:                for (String item : policyItems) {
225:                    policyString.append(item + " ");
226:                }
227:                return policyString.toString();
228:            }
229:
230:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.