Source Code Cross Referenced for TestMessageHelper.java in  » ESB » open-esb » com » sun » jbi » management » message » 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.jbi.management.message 
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:         * @(#)TestMessageHelper.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.message;
030:
031:        import com.sun.jbi.management.system.Util;
032:        import com.sun.jbi.management.ComponentMessageHolder;
033:        import com.sun.jbi.management.system.ScaffoldEnvironmentContext;
034:        import java.util.logging.Level;
035:
036:        public class TestMessageHelper extends junit.framework.TestCase {
037:
038:            private static String TAB = "\t";
039:            private static String NEWLINE = System
040:                    .getProperty("line.separator");
041:
042:            public TestMessageHelper(String aTestName) {
043:                super (aTestName);
044:                try {
045:                    Util.createManagementContext();
046:                } catch (Exception ex) {
047:                    ex.printStackTrace();
048:                }
049:            }
050:
051:            public void setUp() throws Exception {
052:                super .setUp();
053:            }
054:
055:            public void tearDown() throws Exception {
056:            }
057:
058:            /**
059:             * @throws Exception if an unexpected error occurs
060:             */
061:            public void testFrameworkMessageExtraction() throws Exception {
062:
063:                String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><jbi-task version=\"1.0\" xmlns=\"http://java.sun.com/xml/ns/jbi/management-message\">"
064:                        + "<jbi-task-result><frmwk-task-result><frmwk-task-result-details><task-result-details><task-id>archiveEqualityCheck</task-id><task-result>FAILED</task-result>"
065:                        + "<message-type>ERROR</message-type><task-status-msg><msg-loc-info><loc-token>JBIMA1327</loc-token>"
066:                        + "<loc-message>Installation archive for component manage-binding-1 is not identical to the archive"
067:                        + " which already exists in the domain. </loc-message><loc-param>manage-binding-1</loc-param></msg-loc-info>"
068:                        + "</task-status-msg></task-result-details><locale>en</locale></frmwk-task-result-details></frmwk-task-result></jbi-task-result></jbi-task>";
069:
070:                try {
071:                    String message = MessageHelper.getMsgString(new Exception(
072:                            xml));
073:                    System.out.println(message);
074:                    assertEquals(
075:                            "The strings are not equal",
076:                            NEWLINE
077:                                    + "Scaffolded String isTASK_ID archiveEqualityCheck failed"
078:                                    + NEWLINE
079:                                    + TAB
080:                                    + "ERROR: "
081:                                    + NEWLINE
082:                                    + TAB
083:                                    + "Installation archive for component manage-binding-1 is not identical to the archive which already exists in the domain. "
084:                                    + NEWLINE, message);
085:                } catch (Exception ex) {
086:                    ex.printStackTrace();
087:                }
088:            }
089:
090:            String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><jbi-task xmlns=\"http://java.sun.com/xml/ns/jbi/management-message\" "
091:                    + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" version=\"1.0\" xsi:schemaLocation=\"http://java.sun.com/xml/ns/jbi/management-message "
092:                    + "./managementMessage.xsd\"><jbi-task-result><frmwk-task-result><frmwk-task-result-details><task-result-details><task-id>rollbackSUInits</task-id>"
093:                    + "<task-result>FAILED</task-result><message-type>ERROR</message-type><task-status-msg><msg-loc-info><loc-token>TEST_TOKEN</loc-token>"
094:                    + "<loc-message>This is a test message"
095:                    + " used for testing. </loc-message><loc-param>manage-binding-1</loc-param></msg-loc-info>"
096:                    + "</task-status-msg><task-status-msg><msg-loc-info><loc-token>TEST_TOKEN</loc-token>"
097:                    + "<loc-message>This is one more test message"
098:                    + " used for testing. </loc-message><loc-param>manage-binding-1</loc-param></msg-loc-info>"
099:                    + "</task-status-msg><exception-info><nesting-level>1</nesting-level><msg-loc-info><loc-token>WRONG_DOC</loc-token><loc-message>"
100:                    + "ENT_ERR: A node is used in a different document than the one that created it.</loc-message></msg-loc-info><stack-trace>com.sun.org.apache.xerces."
101:                    + "internal.dom.ParentNode.internalInsertBefore(ParentNode.java:389) "
102:                    + "com.sun.org.apache.xerces.internal.dom.ParentNode.insertBefore(ParentNode.java:321)"
103:                    + "sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)"
104:                    + "..."
105:                    + "com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:93)"
106:                    + "</stack-trace></exception-info></task-result-details><locale>en_US</locale></frmwk-task-result-details><is-cause-framework>YES</is-cause-framework></frmwk-task-result></jbi-task-result></jbi-task>";
107:
108:            /**
109:             * @throws Exception if an unexpected error occurs
110:             */
111:            public void testFrameworkExceptionExtraction() throws Exception {
112:
113:                try {
114:                    String message = MessageHelper.getMsgString(new Exception(
115:                            xml));
116:                    System.out.println(message);
117:                    assertEquals(
118:                            "The strings are not equal",
119:                            NEWLINE
120:                                    + "Scaffolded String isTASK_ID rollbackSUInits failed"
121:                                    + NEWLINE
122:                                    + TAB
123:                                    + "ERROR: "
124:                                    + NEWLINE
125:                                    + TAB
126:                                    + "This is a test message used for testing. "
127:                                    + NEWLINE
128:                                    + TAB
129:                                    + "This is one more test message used for testing. "
130:                                    + NEWLINE
131:                                    + TAB
132:                                    + TAB
133:                                    + "Scaffolded String isEXCEPTION_INFO:"
134:                                    + NEWLINE
135:                                    + TAB
136:                                    + TAB
137:                                    + TAB
138:                                    + "ENT_ERR: A node is used in a different document than the one that created it."
139:                                    + NEWLINE, message);
140:                } catch (Exception ex) {
141:                    ex.printStackTrace();
142:                }
143:            }
144:
145:            /**
146:             * @throws Exception if an unexpected error occurs
147:             */
148:            public void testFrameworkExceptionExtractionAtInfo()
149:                    throws Exception {
150:                try {
151:                    String messageWithTrace = MessageHelper.getMsgString(
152:                            new Exception(xml), Level.INFO);
153:                    System.out.println(messageWithTrace);
154:                    assertEquals(
155:                            "The strings are not equal",
156:                            NEWLINE
157:                                    + "Scaffolded String isTASK_ID rollbackSUInits failed"
158:                                    + NEWLINE
159:                                    + TAB
160:                                    + "ERROR: "
161:                                    + NEWLINE
162:                                    + TAB
163:                                    + "This is a test message used for testing. "
164:                                    + NEWLINE
165:                                    + TAB
166:                                    + "This is one more test message used for testing. "
167:                                    + NEWLINE
168:                                    + TAB
169:                                    + TAB
170:                                    + "Scaffolded String isEXCEPTION_INFO:"
171:                                    + NEWLINE
172:                                    + TAB
173:                                    + TAB
174:                                    + TAB
175:                                    + "ENT_ERR: A node is used in a different document than the one that created it."
176:                                    + NEWLINE, messageWithTrace);
177:                } catch (Exception ex) {
178:                    ex.printStackTrace();
179:                }
180:            }
181:
182:            /**
183:             * @throws Exception if an unexpected error occurs
184:             */
185:            public void testFrameworkExceptionExtractionAtFiner()
186:                    throws Exception {
187:                try {
188:                    String messageWithTrace = MessageHelper.getMsgString(
189:                            new Exception(xml), Level.FINER);
190:                    System.out.println(messageWithTrace);
191:                    assertEquals(
192:                            "The strings are not equal",
193:                            NEWLINE
194:                                    + "Scaffolded String isTASK_ID rollbackSUInits failed"
195:                                    + NEWLINE
196:                                    + TAB
197:                                    + "ERROR: "
198:                                    + NEWLINE
199:                                    + TAB
200:                                    + "This is a test message used for testing. "
201:                                    + NEWLINE
202:                                    + TAB
203:                                    + "This is one more test message used for testing. "
204:                                    + NEWLINE
205:                                    + TAB
206:                                    + TAB
207:                                    + "Scaffolded String isEXCEPTION_INFO:"
208:                                    + NEWLINE
209:                                    + TAB
210:                                    + TAB
211:                                    + TAB
212:                                    + "ENT_ERR: A node is used in a different document than the one that created it."
213:                                    + NEWLINE
214:                                    + TAB
215:                                    + TAB
216:                                    + TAB
217:                                    + "com.sun.org.apache.xerces.internal.dom.ParentNode.internalInsertBefore(ParentNode.java:389) com.sun.org.apache.xerces.internal.dom.ParentNode.insertBefore(ParentNode.java:321)sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)...com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:93)"
218:                                    + NEWLINE, messageWithTrace);
219:                } catch (Exception ex) {
220:                    ex.printStackTrace();
221:                }
222:            }
223:
224:            public void testComponentMessageExtraction() throws Exception {
225:
226:                String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><jbi-task xmlns=\"http://java.sun.com/xml/ns/"
227:                        + "jbi/management-message\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" version=\"1.0\" xsi:schemaLocation=\"http://"
228:                        + "java.sun.com/xml/ns/jbi/management-message ./managementMessage.xsd\"><jbi-task-result><frmwk-task-result>"
229:                        + "<frmwk-task-result-details><task-result-details><task-id>start</task-id><task-result>SUCCESS</task-result><message-type>WARNING</message-type>"
230:                        + "<task-status-msg><msg-loc-info><loc-token>TEST_TOKEN</loc-token>"
231:                        + "<loc-message>This is a test message"
232:                        + " used for testing. </loc-message><loc-param>manage-binding-1</loc-param></msg-loc-info>"
233:                        + "</task-status-msg> "
234:                        + "</task-result-details><locale>en_US</locale></frmwk-task-result-details></frmwk-task-result><component-task-result>"
235:                        + "<component-name>manage-binding-1</component-name><component-task-result-details><task-result-details><task-id>start</task-id>"
236:                        + "<task-result>FAILED</task-result><message-type>ERROR</message-type><task-status-msg><msg-loc-info><loc-token>JBIWHOOPS</loc-token>"
237:                        + "<loc-message>Service unit esbadmin00089-su-1 start failed</loc-message></msg-loc-info></task-status-msg></task-result-details>"
238:                        + "</component-task-result-details></component-task-result><component-task-result><component-name>manage-binding-2</component-name>"
239:                        + "<component-task-result-details><task-result-details><task-id>start</task-id><task-result>SUCCESS</task-result><message-type>"
240:                        + "INFO</message-type><task-status-msg><msg-loc-info><loc-token>JBIMA0500</loc-token><loc-message>"
241:                        + "Lifecycle operation start succeeded for Service Unit esbadmin00089-su-2.</loc-message><loc-param>start</loc-param>"
242:                        + "<loc-param>esbadmin00089-su-2</loc-param></msg-loc-info></task-status-msg></task-result-details>"
243:                        + "</component-task-result-details></component-task-result></jbi-task-result></jbi-task>";
244:                try {
245:                    String message = MessageHelper.getMsgString(new Exception(
246:                            xml));
247:                    System.out.println(message);
248:                    assertEquals(
249:                            "The strings are not equal",
250:                            NEWLINE
251:                                    + "Scaffolded String isTASK_ID start success"
252:                                    + NEWLINE
253:                                    + TAB
254:                                    + "WARNING: "
255:                                    + NEWLINE
256:                                    + TAB
257:                                    + "This is a test message used for testing. "
258:                                    + NEWLINE
259:                                    + TAB
260:                                    + TAB
261:                                    + TAB
262:                                    + "Scaffolded String isCOMPONENT_NAME: manage-binding-1"
263:                                    + NEWLINE
264:                                    + TAB
265:                                    + TAB
266:                                    + TAB
267:                                    + TAB
268:                                    + "Scaffolded String isTASK_ID start failed"
269:                                    + NEWLINE
270:                                    + TAB
271:                                    + TAB
272:                                    + TAB
273:                                    + TAB
274:                                    + TAB
275:                                    + "ERROR: "
276:                                    + NEWLINE
277:                                    + TAB
278:                                    + TAB
279:                                    + TAB
280:                                    + TAB
281:                                    + TAB
282:                                    + "Service unit esbadmin00089-su-1 start failed"
283:                                    + NEWLINE
284:                                    + TAB
285:                                    + TAB
286:                                    + TAB
287:                                    + "Scaffolded String isCOMPONENT_NAME: manage-binding-2"
288:                                    + NEWLINE
289:                                    + TAB
290:                                    + TAB
291:                                    + TAB
292:                                    + TAB
293:                                    + "Scaffolded String isTASK_ID start success"
294:                                    + NEWLINE
295:                                    + TAB
296:                                    + TAB
297:                                    + TAB
298:                                    + TAB
299:                                    + TAB
300:                                    + "INFO: "
301:                                    + NEWLINE
302:                                    + TAB
303:                                    + TAB
304:                                    + TAB
305:                                    + TAB
306:                                    + TAB
307:                                    + "Lifecycle operation start succeeded for Service Unit esbadmin00089-su-2."
308:                                    + NEWLINE, message);
309:
310:                } catch (Exception ex) {
311:                    ex.printStackTrace();
312:                }
313:            }
314:
315:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.