Source Code Cross Referenced for TestJBIResultXmlBuilder.java in  » ESB » open-esb » com » sun » jbi » ui » common » 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.ui.common 
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:         * @(#)TestJBIResultXmlBuilder.java
025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026:         *
027:         * END_HEADER - DO NOT EDIT
028:         */
029:        package com.sun.jbi.ui.common;
030:
031:        import java.io.IOException;
032:        import junit.framework.TestCase;
033:
034:        /**
035:         * Tests the temporary ui class.
036:         *
037:         * @author Sun Microsystems, Inc.
038:         */
039:        public class TestJBIResultXmlBuilder extends TestCase {
040:
041:            /**
042:             * test case constructor
043:             * @param aTestName name of the text
044:             */
045:            public TestJBIResultXmlBuilder(String aTestName) {
046:                super (aTestName);
047:            }
048:
049:            // =============================  test methods ================================
050:
051:            /**
052:             * returns test data dir
053:             * @return test data dir
054:             */
055:            private String getTestDataDir() {
056:                String srcroot = System.getProperty("junit.srcroot");
057:                String testDataDir = srcroot
058:                        + "/shasta/ui/admin-client/regress/testdata/result/";
059:                return testDataDir;
060:            }
061:
062:            /**
063:             * prints the formatted jbi results
064:             * @param resultFor main message
065:             * @param jbiResultXml xml text
066:             * @throws java.lang.Exception on error
067:             */
068:            private void printFormattedJbiResultXml(String resultFor,
069:                    String jbiResultXml) throws Exception {
070:
071:                //        System.out.println();
072:                //        System.out.println(jbiResultXml);
073:                //        System.out.println();
074:
075:                JBIManagementMessage mgmtMsg = JBIManagementMessage
076:                        .createJBIManagementMessage(jbiResultXml);
077:
078:                String result = mgmtMsg.getMessage();
079:
080:                System.out.println();
081:                System.out.println(resultFor + " [");
082:                System.out.println(result);
083:                System.out.println("]");
084:                System.out.println();
085:                System.out
086:                        .println("----------------------------------------------------");
087:
088:            }
089:
090:            /**
091:             * testTest
092:             * @throws Exception if an unexpected error occurs
093:             */
094:            public void testCreateMessageOnlyJbiResultXml() throws Exception {
095:                String jbiResultXml = JBIResultXmlBuilder.getInstance()
096:                        .createJbiResultXml("UIANT_TASK",
097:                                JBIResultXmlBuilder.SUCCESS_RESULT,
098:                                JBIResultXmlBuilder.INFO_MSG_TYPE, "UIANT000",
099:                                "This is a message for ant task1", null);
100:
101:                printFormattedJbiResultXml(
102:                        "Esb Result from builder - esb message only",
103:                        jbiResultXml);
104:            }
105:
106:            /**
107:             * testTest
108:             * @throws Exception if an unexpected error occurs
109:             */
110:            public void testCreateExceptionOnlyJbiResultXml() throws Exception {
111:
112:                Exception ex1 = new Exception("First Exception");
113:                Exception ex2 = new Exception("Second Exception", ex1);
114:                Exception ex = new Exception("Final Exception", ex2);
115:
116:                String jbiResultXml = JBIResultXmlBuilder.getInstance()
117:                        .createJbiResultXml("UIANT_TASK", "UIANT002", ex);
118:
119:                printFormattedJbiResultXml(
120:                        "Esb Result from builder - esb exception only message",
121:                        jbiResultXml);
122:            }
123:
124:            /**
125:             * testTest
126:             * @throws Exception if an unexpected error occurs
127:             */
128:            public void testCreateMessageAndExceptionJbiResultXml()
129:                    throws Exception {
130:                Exception ex1 = new Exception("First Exception");
131:                Exception ex2 = new Exception("Second Exception", ex1);
132:                Exception ex = new Exception("Final Exception", ex2);
133:
134:                String jbiResultXml = JBIResultXmlBuilder.getInstance()
135:                        .createJbiResultXml("UIANT_TASK",
136:                                JBIResultXmlBuilder.FAILED_RESULT,
137:                                JBIResultXmlBuilder.ERROR_MSG_TYPE, "UIANT002",
138:                                "This is a task level message", null, ex);
139:
140:                printFormattedJbiResultXml(
141:                        "Esb Result from builder - esb message and exception only message",
142:                        jbiResultXml);
143:            }
144:
145:            /**
146:             * testTest
147:             * @throws Exception if an unexpected error occurs
148:             */
149:            public void testCreateJbiResultXmlFromI18NBundle() throws Exception {
150:                Exception ex1 = new Exception("First Connection Exception");
151:                Exception ex2 = new Exception("Second Connection Exception",
152:                        ex1);
153:                Exception ex = new Exception("Final Connection Exception", ex2);
154:
155:                String url = "http://host:8989/xjy";
156:                //        IOException ioEx = new IOException("This is Connection IO Exception");
157:
158:                IOException ioEx = new IOException(
159:                        "IO Error occurred connecting to jmx server");
160:                I18NBundle i18nBundle = new I18NBundle("com.sun.jbi.ui.client");
161:
162:                JMXConnectionException jmxEx = new JMXConnectionException(
163:                        JBIResultXmlBuilder.createJbiResultXml(i18nBundle,
164:                                "jbi.ui.jmx.open.io.error",
165:                                new Object[] { url }, ioEx), null);
166:
167:                //        String result = JBIResultXmlBuilder.createFormattedJbiResult(
168:                //            i18nBundle,"jbi.ui.jmx.open.io.error", new Object[] {url}, ex);
169:
170:                //            JMXConnectionException jmxEx = new JMXConnectionException(result, ex);
171:                // JBIRemoteException rEx = new JBIRemoteException(connEx);
172:
173:                //            JBIRemoteException rEx = new JBIRemoteException(jmxEx.getMessage(), jmxEx.getCause());
174:                JBIRemoteException rEx = new JBIRemoteException(jmxEx);
175:                System.out.println("JMX COnnection Exception Message : "
176:                        + jmxEx.getMessage());
177:
178:                System.out
179:                        .println("JMX Connection results In JBIRemoteException [ ");
180:                String result = null;
181:                JBIManagementMessage mgmtMsg = rEx
182:                        .extractJBIManagementMessage();
183:                if (mgmtMsg != null) {
184:                    result = mgmtMsg.getMessage();
185:                } else {
186:                    result = rEx.getMessage();
187:                }
188:                System.out.println(result);
189:
190:                System.out.println("]");
191:
192:                System.out
193:                        .println("JMX Connection results In JBIRemoteException.toString() [ ");
194:                System.out.println(rEx.toString());
195:                System.out.println("]");
196:            }
197:
198:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.