Source Code Cross Referenced for TestExchangeFactory.java in  » ESB » open-esb » com » sun » jbi » messaging » 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.messaging 
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:         * @(#)TestExchangeFactory.java
025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026:         *
027:         * END_HEADER - DO NOT EDIT
028:         */
029:        package com.sun.jbi.messaging;
030:
031:        import java.net.URI;
032:
033:        import javax.jbi.component.Component;
034:        import javax.jbi.component.ComponentContext;
035:
036:        import javax.jbi.messaging.MessageExchange;
037:        import javax.jbi.messaging.InOnly;
038:        import javax.jbi.messaging.InOptionalOut;
039:        import javax.jbi.messaging.InOut;
040:        import javax.jbi.messaging.RobustInOnly;
041:
042:        import javax.jbi.servicedesc.ServiceEndpoint;
043:
044:        import javax.xml.namespace.QName;
045:
046:        import org.w3c.dom.Document;
047:
048:        /**
049:         * Tests for the TestExchangeFactory class
050:         *
051:         * @author Sun Microsystems, Inc.
052:         */
053:        public class TestExchangeFactory extends junit.framework.TestCase {
054:            /** NMS impl */
055:            private MessageService mMsgSvc;
056:
057:            /** NMR Environment Context */
058:            private NMRContext mContext;
059:
060:            /** Exchange Factory */
061:            private ExchangeFactory mFactory;
062:
063:            /**
064:             * The constructor for this testcase, forwards the test name to
065:             * the jUnit TestCase base class.
066:             * @param aTestName String with the name of this test.
067:             */
068:            public TestExchangeFactory(String aTestName) {
069:                super (aTestName);
070:
071:                mMsgSvc = new MessageService();
072:                mFactory = new ExchangeFactory(mMsgSvc);
073:                mContext = new NMRContext(mMsgSvc);
074:            }
075:
076:            /**
077:             * Setup for the test. This creates the ComponentRegistry instance
078:             * and other objects needed for the tests.
079:             * @throws Exception when set up fails for any reason.
080:             */
081:            public void setUp() throws Exception {
082:                super .setUp();
083:
084:                mMsgSvc.initService(mContext);
085:                mMsgSvc.startService();
086:            }
087:
088:            /**
089:             * Cleanup for the test.
090:             * @throws Exception when tearDown fails for any reason.
091:             */
092:            public void tearDown() throws Exception {
093:                super .tearDown();
094:
095:                mMsgSvc.stopService();
096:                mContext.reset();
097:
098:            }
099:
100:            // =============================  test methods ================================
101:
102:            /**
103:             *  Test to make sure the 4 standard URIs are good.
104:             */
105:            public void testCreateExchangeUriGood() throws Exception {
106:                assertTrue(mFactory.createExchange(ExchangePattern.IN_ONLY
107:                        .getURI()) instanceof  InOnly);
108:
109:                assertTrue(mFactory.createExchange(ExchangePattern.IN_OUT
110:                        .getURI()) instanceof  InOut);
111:
112:                assertTrue(mFactory
113:                        .createExchange(ExchangePattern.ROBUST_IN_ONLY.getURI()) instanceof  RobustInOnly);
114:
115:                assertTrue(mFactory
116:                        .createExchange(ExchangePattern.IN_OPTIONAL_OUT
117:                                .getURI()) instanceof  InOptionalOut);
118:            }
119:
120:            /** 
121:             *  Factory which has been initialized with an interface should always
122:             *  set that value on created exchanges.
123:             */
124:            public void testCreateExchangeWithInterface() throws Exception {
125:                QName interfaceName = new QName("boo");
126:                ExchangeFactory iFactory;
127:
128:                iFactory = ExchangeFactory.newInterfaceFactory(mMsgSvc,
129:                        interfaceName);
130:
131:                assertEquals(iFactory.createExchange(
132:                        ExchangePattern.IN_ONLY.getURI()).getInterfaceName(),
133:                        interfaceName);
134:            }
135:
136:            /** 
137:             *  Test WSDL 2.0 parsing.
138:             */
139:            public void testCreateExchangeFromWsdl20() throws Exception {
140:                String id = "testcomp";
141:                Component com;
142:                ComponentContext ctx;
143:                MessageExchange me;
144:
145:                // create a component, add it to env, and get it's context object
146:                com = new NMRComponent();
147:                mContext.addComponentInstance(id, com);
148:                ctx = mContext.getComponentContext(id);
149:
150:                // activate an endpoint and create an exchange for one of its operations
151:                ctx.activateEndpoint(WsdlDocument.STOCK_SERVICE_Q,
152:                        WsdlDocument.STOCK_ENDPOINT);
153:                me = mFactory.createExchange(WsdlDocument.STOCK_SERVICE_Q,
154:                        WsdlDocument.STOCK_OPERATION_Q);
155:
156:                assertTrue(me instanceof  InOut);
157:            }
158:
159:            /** 
160:             *  Test WSDL 1.1 parsing.
161:             */
162:            public void testCreateExchangeFromWsdl11() throws Exception {
163:                String id = "testcomp";
164:                Component com;
165:                ComponentContext ctx;
166:                MessageExchange me;
167:
168:                // create a component, add it to env, and get it's context object
169:                com = new NMRComponent(NMRComponent.WSDL_11);
170:                mContext.addComponentInstance(id, com);
171:                ctx = mContext.getComponentContext(id);
172:
173:                // activate an endpoint and create an exchange for one of its operations
174:                ctx.activateEndpoint(WsdlDocument.STOCK_SERVICE_Q,
175:                        WsdlDocument.STOCK_ENDPOINT);
176:                me = mFactory.createExchange(WsdlDocument.STOCK_SERVICE_Q,
177:                        WsdlDocument.STOCK_OPERATION_Q);
178:
179:                assertTrue(me instanceof  InOut);
180:            }
181:
182:            /** 
183:             *  Factory which has been initialized with an endpoint should always
184:             *  set that value on created exchanges.
185:             */
186:            public void testCreateExchangeWithEndpoint() throws Exception {
187:                RegisteredEndpoint endpoint;
188:                ExchangeFactory eFactory;
189:
190:                endpoint = new InternalEndpoint(new QName("foo"), "bar", "la");
191:                eFactory = ExchangeFactory
192:                        .newEndpointFactory(mMsgSvc, endpoint);
193:
194:                assertEquals(eFactory.createExchange(
195:                        ExchangePattern.IN_OUT.getURI()).getEndpoint(),
196:                        endpoint);
197:            }
198:
199:            /**
200:             *  Test to make sure bogus URIs throw an exception
201:             */
202:            public void testCreateExchangeUriBad() throws Exception {
203:                try {
204:                    // this line should throw an exception
205:                    mFactory.createExchange(new URI("inside-out-mep"));
206:                    // shouldn't get here
207:                    fail("able to create exchange with bogus uri");
208:                } catch (Exception ex) {
209:                    // expected
210:                }
211:            }
212:
213:            /**
214:             * Test MEP factory method.
215:             * @throws Exception if an unexpected error occurs
216:             */
217:            public void testCreateInOnlyExchange() throws Exception {
218:                InOnly inOnly = mFactory.createInOnlyExchange();
219:            }
220:
221:            /**
222:             * Test MEP factory method.
223:             * @throws Exception if an unexpected error occurs
224:             */
225:            public void testCreateInOptionalOutExchange() throws Exception {
226:                InOptionalOut inOptionalOut = mFactory
227:                        .createInOptionalOutExchange();
228:            }
229:
230:            /**
231:             * Test MEP factory method.
232:             * @throws Exception if an unexpected error occurs
233:             */
234:            public void testCreateInOutExchange() throws Exception {
235:                InOut inOut = mFactory.createInOutExchange();
236:            }
237:
238:            /**
239:             * Test MEP factory method.
240:             * @throws Exception if an unexpected error occurs
241:             */
242:            public void testCreateRobustInOnlyExchange() throws Exception {
243:                RobustInOnly robInOnly = mFactory.createRobustInOnlyExchange();
244:            }
245:
246:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.