Source Code Cross Referenced for TestInOptionalOut.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) 


0001:        /*
0002:         * BEGIN_HEADER - DO NOT EDIT
0003:         *
0004:         * The contents of this file are subject to the terms
0005:         * of the Common Development and Distribution License
0006:         * (the "License").  You may not use this file except
0007:         * in compliance with the License.
0008:         *
0009:         * You can obtain a copy of the license at
0010:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
0011:         * See the License for the specific language governing
0012:         * permissions and limitations under the License.
0013:         *
0014:         * When distributing Covered Code, include this CDDL
0015:         * HEADER in each file and include the License file at
0016:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
0017:         * If applicable add the following below this CDDL HEADER,
0018:         * with the fields enclosed by brackets "[]" replaced with
0019:         * your own identifying information: Portions Copyright
0020:         * [year] [name of copyright owner]
0021:         */
0022:
0023:        /*
0024:         * @(#)TestInOptionalOut.java
0025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
0026:         *
0027:         * END_HEADER - DO NOT EDIT
0028:         */
0029:        package com.sun.jbi.messaging;
0030:
0031:        import javax.jbi.messaging.ExchangeStatus;
0032:        import javax.jbi.messaging.Fault;
0033:        import javax.jbi.messaging.InOptionalOut;
0034:        import javax.jbi.messaging.MessageExchange;
0035:        import javax.jbi.messaging.MessageExchangeFactory;
0036:        import javax.jbi.messaging.NormalizedMessage;
0037:
0038:        import javax.jbi.servicedesc.ServiceEndpoint;
0039:
0040:        import javax.xml.namespace.QName;
0041:
0042:        /**
0043:         * Test InOptionalOut Message Exchange.
0044:         * @author Sun Microsystems, Inc.
0045:         */
0046:        public class TestInOptionalOut extends junit.framework.TestCase {
0047:            private static final QName SERVICE = new QName(
0048:                    "InOptionalOutService");
0049:            private static final String ENDPOINT = "InOptionalOutEndpoint";
0050:            private static final QName OPERATION = new QName("foobar");
0051:
0052:            private MessageService mMsgSvc;
0053:            private MessageExchangeFactory mFactory;
0054:            /** NMR Environment Context */
0055:            private NMRContext mContext;
0056:
0057:            /**
0058:             * The constructor for this testcase, forwards the test name to
0059:             * the jUnit TestCase base class.
0060:             * @param aTestName String with the name of this test.
0061:             */
0062:            public TestInOptionalOut(String aTestName) throws Exception {
0063:                super (aTestName);
0064:                mMsgSvc = new MessageService();
0065:                mContext = new NMRContext(mMsgSvc);
0066:            }
0067:
0068:            /**
0069:             * Setup for the test. 
0070:             * @throws Exception when set up fails for any reason.
0071:             */
0072:            public void setUp() throws Exception {
0073:                super .setUp();
0074:
0075:                mMsgSvc.initService(mContext);
0076:                mMsgSvc.startService();
0077:
0078:                mFactory = new ExchangeFactory(mMsgSvc);
0079:            }
0080:
0081:            /**
0082:             * Cleanup for the test.
0083:             * @throws Exception when tearDown fails for any reason.
0084:             */
0085:            public void tearDown() throws Exception {
0086:                super .tearDown();
0087:
0088:                mMsgSvc.stopService();
0089:                mContext.reset();
0090:            }
0091:
0092:            // =============================  test methods ================================
0093:
0094:            /**
0095:             * Happy path test for an InOptionalOut exchange with status
0096:             * @throws Exception test failed
0097:             */
0098:            public void testExchangeGood() throws Exception {
0099:                Binding binding;
0100:                Engine engine;
0101:
0102:                binding = new HappyBinding(mMsgSvc.activateChannel("binding",
0103:                        null));
0104:                engine = new HappyEngine(mMsgSvc
0105:                        .activateChannel("engine", null));
0106:
0107:                engine.init(SERVICE, ENDPOINT, ExchangePattern.IN_OPTIONAL_OUT
0108:                        .toString());
0109:                binding.init(SERVICE);
0110:
0111:                Framework.runTest(binding, engine);
0112:
0113:                // check for binding or engine failure
0114:                binding.checkError();
0115:                engine.checkError();
0116:
0117:                binding.stop();
0118:                engine.stop();
0119:            }
0120:
0121:            /**
0122:             * Happy path test for an InOptionalOut exchange with fault
0123:             * @throws Exception test failed
0124:             */
0125:            public void testExchangeGood2() throws Exception {
0126:                Binding binding;
0127:                Engine engine;
0128:
0129:                binding = new HappyBinding2(mMsgSvc.activateChannel("binding",
0130:                        null));
0131:                engine = new HappyEngine2(mMsgSvc.activateChannel("engine",
0132:                        null));
0133:
0134:                engine.init(SERVICE, ENDPOINT, ExchangePattern.IN_OPTIONAL_OUT
0135:                        .toString());
0136:                binding.init(SERVICE);
0137:
0138:                Framework.runTest(binding, engine);
0139:
0140:                // check for binding or engine failure
0141:                binding.checkError();
0142:                engine.checkError();
0143:
0144:                binding.stop();
0145:                engine.stop();
0146:            }
0147:
0148:            /**
0149:             * Happy path test for an InOptionalOut exchange with out and status
0150:             * @throws Exception test failed
0151:             */
0152:            public void testExchangeGood3() throws Exception {
0153:                Binding binding;
0154:                Engine engine;
0155:
0156:                binding = new HappyBinding3(mMsgSvc.activateChannel("binding",
0157:                        null));
0158:                engine = new HappyEngine3(mMsgSvc.activateChannel("engine",
0159:                        null));
0160:
0161:                engine.init(SERVICE, ENDPOINT, ExchangePattern.IN_OPTIONAL_OUT
0162:                        .toString());
0163:                binding.init(SERVICE);
0164:
0165:                Framework.runTest(binding, engine);
0166:
0167:                // check for binding or engine failure
0168:                binding.checkError();
0169:                engine.checkError();
0170:
0171:                binding.stop();
0172:                engine.stop();
0173:            }
0174:
0175:            /**
0176:             * Happy path test for an InOptionalOut exchange with out and fault
0177:             * @throws Exception test failed
0178:             */
0179:            public void testExchangeGood4() throws Exception {
0180:                Binding binding;
0181:                Engine engine;
0182:
0183:                binding = new HappyBinding4(mMsgSvc.activateChannel("binding",
0184:                        null));
0185:                engine = new HappyEngine4(mMsgSvc.activateChannel("engine",
0186:                        null));
0187:
0188:                engine.init(SERVICE, ENDPOINT, ExchangePattern.IN_OPTIONAL_OUT
0189:                        .toString());
0190:                binding.init(SERVICE);
0191:
0192:                Framework.runTest(binding, engine);
0193:
0194:                // check for binding or engine failure
0195:                binding.checkError();
0196:                engine.checkError();
0197:
0198:                binding.stop();
0199:                engine.stop();
0200:            }
0201:
0202:            /**
0203:             * Happy path test for an InOptionalOut exchange with status
0204:             * @throws Exception test failed
0205:             */
0206:            public void testExchangeBindingSynch() throws Exception {
0207:                Binding binding;
0208:                Engine engine;
0209:
0210:                binding = new HappySynchBinding(mMsgSvc.activateChannel(
0211:                        "binding", null));
0212:                engine = new HappyEngine(mMsgSvc
0213:                        .activateChannel("engine", null));
0214:
0215:                engine.init(SERVICE, ENDPOINT, ExchangePattern.IN_OPTIONAL_OUT
0216:                        .toString());
0217:                binding.init(SERVICE);
0218:
0219:                Framework.runTest(binding, engine);
0220:
0221:                // check for binding or engine failure
0222:                binding.checkError();
0223:                engine.checkError();
0224:
0225:                binding.stop();
0226:                engine.stop();
0227:            }
0228:
0229:            /**
0230:             * Happy path test for an InOptionalOut exchange with status
0231:             * @throws Exception test failed
0232:             */
0233:            public void testExchangeEngineSynch() throws Exception {
0234:                Binding binding;
0235:                Engine engine;
0236:
0237:                binding = new HappyBinding(mMsgSvc.activateChannel("binding",
0238:                        null));
0239:                engine = new HappySynchEngine(mMsgSvc.activateChannel("engine",
0240:                        null));
0241:
0242:                engine.init(SERVICE, ENDPOINT, ExchangePattern.IN_OPTIONAL_OUT
0243:                        .toString());
0244:                binding.init(SERVICE);
0245:
0246:                Framework.runTest(binding, engine);
0247:
0248:                // check for binding or engine failure
0249:                binding.checkError();
0250:                engine.checkError();
0251:
0252:                binding.stop();
0253:                engine.stop();
0254:            }
0255:
0256:            /**
0257:             * Happy path test for an InOptionalOut exchange with status
0258:             * @throws Exception test failed
0259:             */
0260:            public void testExchangeBothSynch() throws Exception {
0261:                Binding binding;
0262:                Engine engine;
0263:
0264:                binding = new HappySynchBinding(mMsgSvc.activateChannel(
0265:                        "binding", null));
0266:                engine = new HappySynchEngine(mMsgSvc.activateChannel("engine",
0267:                        null));
0268:
0269:                engine.init(SERVICE, ENDPOINT, ExchangePattern.IN_OPTIONAL_OUT
0270:                        .toString());
0271:                binding.init(SERVICE);
0272:
0273:                Framework.runTest(binding, engine);
0274:
0275:                // check for binding or engine failure
0276:                binding.checkError();
0277:                engine.checkError();
0278:
0279:                binding.stop();
0280:                engine.stop();
0281:            }
0282:
0283:            /**
0284:             * Happy path test for an InOptionalOut exchange with status
0285:             * @throws Exception test failed
0286:             */
0287:            public void testExchangeBindingSynch4() throws Exception {
0288:                Binding binding;
0289:                Engine engine;
0290:
0291:                binding = new HappySynchBinding4(mMsgSvc.activateChannel(
0292:                        "binding", null));
0293:                engine = new HappyEngine4(mMsgSvc.activateChannel("engine",
0294:                        null));
0295:
0296:                engine.init(SERVICE, ENDPOINT, ExchangePattern.IN_OPTIONAL_OUT
0297:                        .toString());
0298:                binding.init(SERVICE);
0299:
0300:                Framework.runTest(binding, engine);
0301:
0302:                // check for binding or engine failure
0303:                binding.checkError();
0304:                engine.checkError();
0305:
0306:                binding.stop();
0307:                engine.stop();
0308:            }
0309:
0310:            /**
0311:             * Happy path test for an InOptionalOut exchange with status
0312:             * @throws Exception test failed
0313:             */
0314:            public void testExchangeEngineSynch4() throws Exception {
0315:                Binding binding;
0316:                Engine engine;
0317:
0318:                binding = new HappyBinding4(mMsgSvc.activateChannel("binding",
0319:                        null));
0320:                engine = new HappySynchEngine4(mMsgSvc.activateChannel(
0321:                        "engine", null));
0322:
0323:                engine.init(SERVICE, ENDPOINT, ExchangePattern.IN_OPTIONAL_OUT
0324:                        .toString());
0325:                binding.init(SERVICE);
0326:
0327:                Framework.runTest(binding, engine);
0328:
0329:                // check for binding or engine failure
0330:                binding.checkError();
0331:                engine.checkError();
0332:
0333:                binding.stop();
0334:                engine.stop();
0335:            }
0336:
0337:            /**
0338:             * Happy path test for an InOptionalOut exchange with status
0339:             * @throws Exception test failed
0340:             */
0341:            public void testExchangeBothSynch4() throws Exception {
0342:                Binding binding;
0343:                Engine engine;
0344:
0345:                binding = new HappySynchBinding4(mMsgSvc.activateChannel(
0346:                        "binding", null));
0347:                engine = new HappySynchEngine4(mMsgSvc.activateChannel(
0348:                        "engine", null));
0349:
0350:                engine.init(SERVICE, ENDPOINT, ExchangePattern.IN_OPTIONAL_OUT
0351:                        .toString());
0352:                binding.init(SERVICE);
0353:
0354:                Framework.runTest(binding, engine);
0355:
0356:                // check for binding or engine failure
0357:                binding.checkError();
0358:                engine.checkError();
0359:
0360:                binding.stop();
0361:                engine.stop();
0362:            }
0363:
0364:            /**
0365:             * Attempt to do bad things with an InOptionalOut exchange.
0366:             * @throws Exception test failed
0367:             */
0368:            public void testExchangeFailure() throws Exception {
0369:                Binding binding;
0370:                Engine engine;
0371:
0372:                binding = new HappyBinding3(mMsgSvc.activateChannel("binding",
0373:                        null));
0374:                engine = new BadEngine(mMsgSvc.activateChannel("engine", null));
0375:
0376:                engine.init(SERVICE, ENDPOINT, ExchangePattern.IN_OPTIONAL_OUT
0377:                        .toString());
0378:                binding.init(SERVICE);
0379:
0380:                Framework.runTest(binding, engine);
0381:
0382:                // check for binding or engine failure
0383:                binding.checkError();
0384:                engine.checkError();
0385:
0386:                binding.stop();
0387:                engine.stop();
0388:            }
0389:
0390:            // ============================ internal stuff ================================
0391:
0392:            class HappyBinding extends Binding {
0393:                HappyBinding(DeliveryChannelImpl channel) {
0394:                    super (channel);
0395:                }
0396:
0397:                public void start() throws Exception {
0398:                    NormalizedMessage inMsg;
0399:                    InOptionalOut inOptOut;
0400:
0401:                    // create the exchange
0402:                    inOptOut = mFactory.createInOptionalOutExchange();
0403:                    inMsg = inOptOut.createMessage();
0404:                    assertEquals(inOptOut.getPattern().toString(),
0405:                            ExchangePattern.IN_OPTIONAL_OUT.toString());
0406:                    assertEquals(ExchangeStatus.ACTIVE, inOptOut.getStatus());
0407:                    assertEquals(MessageExchange.Role.CONSUMER, inOptOut
0408:                            .getRole());
0409:
0410:                    // set the stuff we know & check that they are set.
0411:                    inOptOut.setEndpoint(mEndpoint);
0412:                    assertEquals(mEndpoint, inOptOut.getEndpoint());
0413:
0414:                    inOptOut.setOperation(OPERATION);
0415:                    assertEquals(OPERATION, inOptOut.getOperation());
0416:
0417:                    // set the payload
0418:                    Payload.setPayload(inMsg);
0419:
0420:                    // set message on exchange
0421:                    inOptOut.setInMessage(inMsg);
0422:                    assertEquals(inMsg, inOptOut.getInMessage());
0423:
0424:                    // send the exchange
0425:                    mChannel.send(inOptOut);
0426:                    assertEquals(MessageExchange.Role.CONSUMER, inOptOut
0427:                            .getRole());
0428:
0429:                    // Check that settings are ignored while ownership is elsewhere.
0430:
0431:                    inOptOut.setEndpoint(null);
0432:                    assertEquals(mEndpoint, inOptOut.getEndpoint());
0433:
0434:                    inOptOut.setOperation(null);
0435:                    assertEquals(OPERATION, inOptOut.getOperation());
0436:
0437:                    // receive the response            
0438:                    inOptOut = (InOptionalOut) mChannel.accept();
0439:
0440:                    assertEquals(ExchangeStatus.DONE, inOptOut.getStatus());
0441:                    assertTrue(inOptOut.getFault() == null);
0442:                    assertTrue(inOptOut.getOutMessage() == null);
0443:                    assertEquals(MessageExchange.Role.CONSUMER, inOptOut
0444:                            .getRole());
0445:
0446:                    // Check that settings are ignored while DONE.
0447:
0448:                    inOptOut.setEndpoint(null);
0449:                    assertEquals(mEndpoint, inOptOut.getEndpoint());
0450:
0451:                    inOptOut.setOperation(null);
0452:                    assertEquals(OPERATION, inOptOut.getOperation());
0453:                }
0454:            }
0455:
0456:            class HappyBinding2 extends Binding {
0457:                HappyBinding2(DeliveryChannelImpl channel) {
0458:                    super (channel);
0459:                }
0460:
0461:                public void start() throws Exception {
0462:                    NormalizedMessage inMsg;
0463:                    InOptionalOut inOptOut;
0464:
0465:                    // create the exchange
0466:                    inOptOut = mFactory.createInOptionalOutExchange();
0467:                    inMsg = inOptOut.createMessage();
0468:
0469:                    // set the stuff we know & check that they are set.
0470:                    inOptOut.setEndpoint(mEndpoint);
0471:                    assertEquals(mEndpoint, inOptOut.getEndpoint());
0472:
0473:                    inOptOut.setOperation(OPERATION);
0474:                    assertEquals(OPERATION, inOptOut.getOperation());
0475:
0476:                    // set the payload
0477:                    Payload.setPayload(inMsg);
0478:
0479:                    // set message on exchange
0480:                    inOptOut.setInMessage(inMsg);
0481:                    assertEquals(inMsg, inOptOut.getInMessage());
0482:
0483:                    // send the exchange
0484:                    mChannel.send(inOptOut);
0485:                    assertEquals(MessageExchange.Role.CONSUMER, inOptOut
0486:                            .getRole());
0487:
0488:                    // Check that settings are ignored while ownership is elsewhere.
0489:
0490:                    inOptOut.setEndpoint(null);
0491:                    assertEquals(mEndpoint, inOptOut.getEndpoint());
0492:
0493:                    inOptOut.setOperation(null);
0494:                    assertEquals(OPERATION, inOptOut.getOperation());
0495:
0496:                    // receive the response            
0497:                    inOptOut = (InOptionalOut) mChannel.accept();
0498:
0499:                    assertEquals(ExchangeStatus.ACTIVE, inOptOut.getStatus());
0500:                    assertTrue(inOptOut.getFault() != null);
0501:
0502:                    // Check that settings are ignored when DONE.
0503:
0504:                    inOptOut.setEndpoint(null);
0505:                    assertEquals(mEndpoint, inOptOut.getEndpoint());
0506:
0507:                    inOptOut.setOperation(null);
0508:                    assertEquals(OPERATION, inOptOut.getOperation());
0509:
0510:                    // Try and set a fault.
0511:                    try {
0512:                        inOptOut.setFault(inOptOut.createFault());
0513:                        setFailure("Able to create/set fault after fault.");
0514:                    } catch (Exception ex1) {
0515:                    }
0516:                    ;
0517:
0518:                    inOptOut.setStatus(ExchangeStatus.DONE);
0519:                    mChannel.send(inOptOut);
0520:                    assertEquals(MessageExchange.Role.CONSUMER, inOptOut
0521:                            .getRole());
0522:
0523:                    // Check that settings are ignored while still ACTIVE.
0524:
0525:                    inOptOut.setEndpoint(null);
0526:                    assertEquals(mEndpoint, inOptOut.getEndpoint());
0527:
0528:                    inOptOut.setOperation(null);
0529:                    assertEquals(OPERATION, inOptOut.getOperation());
0530:                }
0531:            }
0532:
0533:            class HappyBinding3 extends Binding {
0534:                HappyBinding3(DeliveryChannelImpl channel) {
0535:                    super (channel);
0536:                }
0537:
0538:                public void start() throws Exception {
0539:                    NormalizedMessage inMsg;
0540:                    InOptionalOut inOptOut;
0541:
0542:                    // create the exchange
0543:                    inOptOut = mFactory.createInOptionalOutExchange();
0544:                    inMsg = inOptOut.createMessage();
0545:                    assertEquals(MessageExchange.Role.CONSUMER, inOptOut
0546:                            .getRole());
0547:
0548:                    // set the stuff we know & check that they are set.
0549:                    inOptOut.setEndpoint(mEndpoint);
0550:                    assertEquals(mEndpoint, inOptOut.getEndpoint());
0551:
0552:                    inOptOut.setOperation(OPERATION);
0553:                    assertEquals(OPERATION, inOptOut.getOperation());
0554:
0555:                    // set the payload
0556:                    Payload.setPayload(inMsg);
0557:
0558:                    // set message on exchange
0559:                    inOptOut.setInMessage(inMsg);
0560:                    assertEquals(inMsg, inOptOut.getInMessage());
0561:
0562:                    // send the exchange
0563:                    mChannel.send(inOptOut);
0564:
0565:                    // Check that settings are ignored while ownership is elsewhere.
0566:
0567:                    inOptOut.setEndpoint(null);
0568:                    assertEquals(mEndpoint, inOptOut.getEndpoint());
0569:
0570:                    inOptOut.setOperation(null);
0571:                    assertEquals(OPERATION, inOptOut.getOperation());
0572:
0573:                    // receive the response            
0574:                    inOptOut = (InOptionalOut) mChannel.accept();
0575:
0576:                    assertEquals(ExchangeStatus.ACTIVE, inOptOut.getStatus());
0577:                    assertTrue(inOptOut.getFault() == null);
0578:                    assertTrue(inOptOut.getInMessage() != null);
0579:                    assertEquals(MessageExchange.Role.CONSUMER, inOptOut
0580:                            .getRole());
0581:
0582:                    // Check that settings are ignored when DONE.
0583:
0584:                    inOptOut.setEndpoint(null);
0585:                    assertEquals(mEndpoint, inOptOut.getEndpoint());
0586:
0587:                    inOptOut.setOperation(null);
0588:                    assertEquals(OPERATION, inOptOut.getOperation());
0589:
0590:                    inOptOut.setStatus(ExchangeStatus.DONE);
0591:
0592:                    // Try and set a fault
0593:                    try {
0594:                        inOptOut.setFault(inOptOut.createFault());
0595:                        setFailure("Able to create/set fault after setting status.");
0596:                    } catch (Exception ex1) {
0597:                    }
0598:                    ;
0599:
0600:                    mChannel.send(inOptOut);
0601:                    assertEquals(MessageExchange.Role.CONSUMER, inOptOut
0602:                            .getRole());
0603:
0604:                    // Check that settings are ignored while still ACTIVE.
0605:
0606:                    inOptOut.setEndpoint(null);
0607:                    assertEquals(mEndpoint, inOptOut.getEndpoint());
0608:
0609:                    inOptOut.setOperation(null);
0610:                    assertEquals(OPERATION, inOptOut.getOperation());
0611:                }
0612:            }
0613:
0614:            class HappyBinding4 extends Binding {
0615:                HappyBinding4(DeliveryChannelImpl channel) {
0616:                    super (channel);
0617:                }
0618:
0619:                public void start() throws Exception {
0620:                    NormalizedMessage inMsg;
0621:                    InOptionalOut inOptOut;
0622:
0623:                    // create the exchange
0624:                    inOptOut = mFactory.createInOptionalOutExchange();
0625:                    inMsg = inOptOut.createMessage();
0626:                    assertEquals(MessageExchange.Role.CONSUMER, inOptOut
0627:                            .getRole());
0628:
0629:                    // set the stuff we know & check that they are set.
0630:                    inOptOut.setEndpoint(mEndpoint);
0631:                    assertEquals(mEndpoint, inOptOut.getEndpoint());
0632:
0633:                    inOptOut.setOperation(OPERATION);
0634:                    assertEquals(OPERATION, inOptOut.getOperation());
0635:
0636:                    // set the payload
0637:                    Payload.setPayload(inMsg);
0638:
0639:                    // set message on exchange
0640:                    inOptOut.setInMessage(inMsg);
0641:                    assertEquals(inMsg, inOptOut.getInMessage());
0642:
0643:                    // send the exchange
0644:                    mChannel.send(inOptOut);
0645:
0646:                    // Check that settings are ignored while ownership is elsewhere.
0647:
0648:                    inOptOut.setEndpoint(null);
0649:                    assertEquals(mEndpoint, inOptOut.getEndpoint());
0650:
0651:                    inOptOut.setOperation(null);
0652:                    assertEquals(OPERATION, inOptOut.getOperation());
0653:
0654:                    // receive the response            
0655:                    inOptOut = (InOptionalOut) mChannel.accept();
0656:
0657:                    assertEquals(ExchangeStatus.ACTIVE, inOptOut.getStatus());
0658:                    assertTrue(inOptOut.getFault() == null);
0659:                    assertTrue(inOptOut.getOutMessage() != null);
0660:
0661:                    // Check that settings are ignored when DONE.
0662:
0663:                    inOptOut.setEndpoint(null);
0664:                    assertEquals(mEndpoint, inOptOut.getEndpoint());
0665:
0666:                    inOptOut.setOperation(null);
0667:                    assertEquals(OPERATION, inOptOut.getOperation());
0668:
0669:                    inOptOut.setFault(inOptOut.createFault());
0670:
0671:                    // Try and set Status 
0672:                    try {
0673:                        inOptOut.setStatus(ExchangeStatus.DONE);
0674:                        setFailure("Able to set status after setting fault.");
0675:                    } catch (Exception ex1) {
0676:                    }
0677:                    ;
0678:
0679:                    mChannel.send(inOptOut);
0680:                    assertEquals(MessageExchange.Role.CONSUMER, inOptOut
0681:                            .getRole());
0682:
0683:                    // Check that settings are ignored while still ACTIVE.
0684:
0685:                    inOptOut.setEndpoint(null);
0686:                    assertEquals(mEndpoint, inOptOut.getEndpoint());
0687:
0688:                    inOptOut.setOperation(null);
0689:                    assertEquals(OPERATION, inOptOut.getOperation());
0690:
0691:                    // receive the response            
0692:                    inOptOut = (InOptionalOut) mChannel.accept();
0693:                    assertEquals(MessageExchange.Role.CONSUMER, inOptOut
0694:                            .getRole());
0695:                    assertEquals(ExchangeStatus.DONE, inOptOut.getStatus());
0696:                    assertTrue(inOptOut.getFault() != null);
0697:                    assertTrue(inOptOut.getOutMessage() != null);
0698:                }
0699:            }
0700:
0701:            class HappySynchBinding extends Binding {
0702:                HappySynchBinding(DeliveryChannelImpl channel) {
0703:                    super (channel);
0704:                }
0705:
0706:                public void start() throws Exception {
0707:                    NormalizedMessage inMsg;
0708:                    InOptionalOut inOptOut;
0709:
0710:                    // create the exchange
0711:                    inOptOut = mFactory.createInOptionalOutExchange();
0712:                    inMsg = inOptOut.createMessage();
0713:                    assertEquals(inOptOut.getPattern().toString(),
0714:                            ExchangePattern.IN_OPTIONAL_OUT.toString());
0715:                    assertEquals(ExchangeStatus.ACTIVE, inOptOut.getStatus());
0716:                    assertEquals(MessageExchange.Role.CONSUMER, inOptOut
0717:                            .getRole());
0718:
0719:                    // set the stuff we know & check that they are set.
0720:                    inOptOut.setEndpoint(mEndpoint);
0721:                    assertEquals(mEndpoint, inOptOut.getEndpoint());
0722:
0723:                    inOptOut.setOperation(OPERATION);
0724:                    assertEquals(OPERATION, inOptOut.getOperation());
0725:
0726:                    // set the payload
0727:                    Payload.setPayload(inMsg);
0728:
0729:                    // set message on exchange
0730:                    inOptOut.setInMessage(inMsg);
0731:                    assertEquals(inMsg, inOptOut.getInMessage());
0732:
0733:                    // send the exchange
0734:                    assertTrue(mChannel.sendSync(inOptOut));
0735:                    assertEquals(ExchangeStatus.DONE, inOptOut.getStatus());
0736:                    assertTrue(inOptOut.getFault() == null);
0737:                    assertTrue(inOptOut.getOutMessage() == null);
0738:                    assertEquals(MessageExchange.Role.CONSUMER, inOptOut
0739:                            .getRole());
0740:
0741:                    // Check that settings are ignored while DONE.
0742:
0743:                    inOptOut.setEndpoint(null);
0744:                    assertEquals(mEndpoint, inOptOut.getEndpoint());
0745:
0746:                    inOptOut.setOperation(null);
0747:                    assertEquals(OPERATION, inOptOut.getOperation());
0748:                }
0749:            }
0750:
0751:            class HappySynchBinding4 extends Binding {
0752:                HappySynchBinding4(DeliveryChannelImpl channel) {
0753:                    super (channel);
0754:                }
0755:
0756:                public void start() throws Exception {
0757:                    NormalizedMessage inMsg;
0758:                    InOptionalOut inOptOut;
0759:
0760:                    // create the exchange
0761:                    inOptOut = mFactory.createInOptionalOutExchange();
0762:                    inMsg = inOptOut.createMessage();
0763:                    assertEquals(MessageExchange.Role.CONSUMER, inOptOut
0764:                            .getRole());
0765:
0766:                    // set the stuff we know & check that they are set.
0767:                    inOptOut.setEndpoint(mEndpoint);
0768:                    assertEquals(mEndpoint, inOptOut.getEndpoint());
0769:
0770:                    inOptOut.setOperation(OPERATION);
0771:                    assertEquals(OPERATION, inOptOut.getOperation());
0772:
0773:                    // set the payload
0774:                    Payload.setPayload(inMsg);
0775:
0776:                    // set message on exchange
0777:                    inOptOut.setInMessage(inMsg);
0778:                    assertEquals(inMsg, inOptOut.getInMessage());
0779:
0780:                    // send the exchange
0781:                    assertTrue(mChannel.sendSync(inOptOut));
0782:                    assertEquals(ExchangeStatus.ACTIVE, inOptOut.getStatus());
0783:                    assertTrue(inOptOut.getFault() == null);
0784:                    assertTrue(inOptOut.getOutMessage() != null);
0785:                    assertEquals(MessageExchange.Role.CONSUMER, inOptOut
0786:                            .getRole());
0787:
0788:                    // Check that settings are ignored when DONE.
0789:
0790:                    inOptOut.setEndpoint(null);
0791:                    assertEquals(mEndpoint, inOptOut.getEndpoint());
0792:
0793:                    inOptOut.setOperation(null);
0794:                    assertEquals(OPERATION, inOptOut.getOperation());
0795:
0796:                    inOptOut.setFault(inOptOut.createFault());
0797:
0798:                    // Try and set Status 
0799:                    try {
0800:                        inOptOut.setStatus(ExchangeStatus.DONE);
0801:                        setFailure("Able to set status after setting fault.");
0802:                    } catch (Exception ex1) {
0803:                    }
0804:                    ;
0805:
0806:                    assertTrue(mChannel.sendSync(inOptOut));
0807:                    assertEquals(ExchangeStatus.DONE, inOptOut.getStatus());
0808:                    assertTrue(inOptOut.getFault() != null);
0809:                    assertTrue(inOptOut.getOutMessage() != null);
0810:                    assertEquals(MessageExchange.Role.CONSUMER, inOptOut
0811:                            .getRole());
0812:                }
0813:            }
0814:
0815:            class HappyEngine extends Engine {
0816:                HappyEngine(DeliveryChannelImpl channel) {
0817:                    super (channel);
0818:                }
0819:
0820:                public void start() throws Exception {
0821:                    InOptionalOut inOptOut;
0822:
0823:                    inOptOut = (InOptionalOut) mChannel.accept();
0824:                    assertEquals(ExchangeStatus.ACTIVE, inOptOut.getStatus());
0825:                    assertTrue(inOptOut.getInMessage() != null);
0826:                    assertEquals(inOptOut.getPattern().toString(),
0827:                            ExchangePattern.IN_OPTIONAL_OUT.toString());
0828:                    assertEquals(MessageExchange.Role.PROVIDER, inOptOut
0829:                            .getRole());
0830:
0831:                    // Check that settings are ignored after message is ACTIVE.
0832:
0833:                    inOptOut.setEndpoint(null);
0834:                    assertNotSame("Allowed to set endpoint after ACTIVE", null,
0835:                            inOptOut.getEndpoint());
0836:
0837:                    inOptOut.setOperation(null);
0838:                    assertNotSame("Allowed to set operation after ACTIVE",
0839:                            null, inOptOut.getOperation());
0840:
0841:                    inOptOut.setStatus(ExchangeStatus.DONE);
0842:
0843:                    // Try and set out message after status set.
0844:                    try {
0845:                        inOptOut.setOutMessage(inOptOut.createMessage());
0846:                        setFailure("Able to set out message after status");
0847:                    } catch (Exception ex) {
0848:                    }
0849:                    ;
0850:
0851:                    // Try and create/set fault after status is set.
0852:                    try {
0853:                        inOptOut.setFault(inOptOut.createFault());
0854:                        setFailure("Able to set/create fault after status");
0855:                    } catch (Exception ex) {
0856:                    }
0857:                    ;
0858:
0859:                    mChannel.send(inOptOut);
0860:                    assertEquals(MessageExchange.Role.PROVIDER, inOptOut
0861:                            .getRole());
0862:
0863:                    // Check that settings are ignored after message is DONE.
0864:
0865:                    inOptOut.setEndpoint(null);
0866:                    assertNotSame("Allowed to set endpoint after done", null,
0867:                            inOptOut.getEndpoint());
0868:
0869:                    inOptOut.setOperation(null);
0870:                    assertNotSame("Allowed to set operation after done", null,
0871:                            inOptOut.getOperation());
0872:                }
0873:            }
0874:
0875:            class HappyEngine2 extends Engine {
0876:                HappyEngine2(DeliveryChannelImpl channel) {
0877:                    super (channel);
0878:                }
0879:
0880:                public void start() throws Exception {
0881:                    InOptionalOut inOptOut;
0882:
0883:                    inOptOut = (InOptionalOut) mChannel.accept();
0884:                    assertEquals(ExchangeStatus.ACTIVE, inOptOut.getStatus());
0885:                    assertTrue(inOptOut.getInMessage() != null);
0886:                    assertEquals(MessageExchange.Role.PROVIDER, inOptOut
0887:                            .getRole());
0888:
0889:                    // Check that settings are ignored after message is ACTIVE.
0890:
0891:                    inOptOut.setEndpoint(null);
0892:                    assertNotSame("Allowed to set endpoint after ACTIVE", null,
0893:                            inOptOut.getEndpoint());
0894:
0895:                    inOptOut.setOperation(null);
0896:                    assertNotSame("Allowed to set operation after ACTIVE",
0897:                            null, inOptOut.getOperation());
0898:
0899:                    inOptOut.setFault(inOptOut.createFault());
0900:
0901:                    // Try and set out message after fault
0902:                    try {
0903:                        inOptOut.setOutMessage(inOptOut.createMessage());
0904:                        setFailure("Able to set out message after fault");
0905:                    } catch (Exception ex) {
0906:                    }
0907:                    ;
0908:
0909:                    // Try and set out status after fault
0910:                    try {
0911:                        inOptOut.setStatus(ExchangeStatus.DONE);
0912:                        setFailure("Able to set status after fault");
0913:                    } catch (Exception ex) {
0914:                    }
0915:                    ;
0916:
0917:                    mChannel.send(inOptOut);
0918:                    assertEquals(MessageExchange.Role.PROVIDER, inOptOut
0919:                            .getRole());
0920:
0921:                    // Check that settings are ignored after message is DONE.
0922:
0923:                    inOptOut.setEndpoint(null);
0924:                    assertNotSame("Allowed to set endpoint after done", null,
0925:                            inOptOut.getEndpoint());
0926:
0927:                    inOptOut.setOperation(null);
0928:                    assertNotSame("Allowed to set operation after done", null,
0929:                            inOptOut.getOperation());
0930:
0931:                    inOptOut = (InOptionalOut) mChannel.accept();
0932:                    assertEquals(ExchangeStatus.DONE, inOptOut.getStatus());
0933:                    assertTrue(inOptOut.getInMessage() != null);
0934:
0935:                    // Try and set out status after fault has been sent.
0936:                    try {
0937:                        inOptOut.setStatus(ExchangeStatus.DONE);
0938:                        setFailure("Able to set status after fault is sent");
0939:                    } catch (Exception ex) {
0940:                    }
0941:                    ;
0942:                }
0943:            }
0944:
0945:            class HappyEngine3 extends Engine {
0946:                HappyEngine3(DeliveryChannelImpl channel) {
0947:                    super (channel);
0948:                }
0949:
0950:                public void start() throws Exception {
0951:                    InOptionalOut inOptOut;
0952:
0953:                    inOptOut = (InOptionalOut) mChannel.accept();
0954:                    assertEquals(ExchangeStatus.ACTIVE, inOptOut.getStatus());
0955:                    assertTrue(inOptOut.getInMessage() != null);
0956:                    assertEquals(MessageExchange.Role.PROVIDER, inOptOut
0957:                            .getRole());
0958:
0959:                    // Check that settings are ignored after message is ACTIVE.
0960:
0961:                    inOptOut.setEndpoint(null);
0962:                    assertNotSame("Allowed to set endpoint after ACTIVE", null,
0963:                            inOptOut.getEndpoint());
0964:
0965:                    inOptOut.setOperation(null);
0966:                    assertNotSame("Allowed to set operation after ACTIVE",
0967:                            null, inOptOut.getOperation());
0968:
0969:                    inOptOut.setOutMessage(inOptOut.createMessage());
0970:
0971:                    // Try and set fault after out message
0972:                    try {
0973:                        inOptOut.setFault(inOptOut.createFault());
0974:                        setFailure("Able to set fault after out message");
0975:                    } catch (Exception ex) {
0976:                    }
0977:                    ;
0978:
0979:                    // Try and set out status after out message
0980:                    try {
0981:                        inOptOut.setStatus(ExchangeStatus.DONE);
0982:                        setFailure("Able to set status after out message");
0983:                    } catch (Exception ex) {
0984:                    }
0985:                    ;
0986:
0987:                    mChannel.send(inOptOut);
0988:                    assertEquals(MessageExchange.Role.PROVIDER, inOptOut
0989:                            .getRole());
0990:
0991:                    // Check that settings are ignored after message is DONE.
0992:
0993:                    inOptOut.setEndpoint(null);
0994:                    assertNotSame("Allowed to set endpoint after done", null,
0995:                            inOptOut.getEndpoint());
0996:
0997:                    inOptOut.setOperation(null);
0998:                    assertNotSame("Allowed to set operation after done", null,
0999:                            inOptOut.getOperation());
1000:
1001:                    inOptOut = (InOptionalOut) mChannel.accept();
1002:                    assertEquals(ExchangeStatus.DONE, inOptOut.getStatus());
1003:                    assertTrue(inOptOut.getFault() == null);
1004:                    assertEquals(MessageExchange.Role.PROVIDER, inOptOut
1005:                            .getRole());
1006:                }
1007:            }
1008:
1009:            class HappyEngine4 extends Engine {
1010:                HappyEngine4(DeliveryChannelImpl channel) {
1011:                    super (channel);
1012:                }
1013:
1014:                public void start() throws Exception {
1015:                    InOptionalOut inOptOut;
1016:
1017:                    inOptOut = (InOptionalOut) mChannel.accept();
1018:                    assertEquals(ExchangeStatus.ACTIVE, inOptOut.getStatus());
1019:                    assertTrue(inOptOut.getInMessage() != null);
1020:                    assertEquals(MessageExchange.Role.PROVIDER, inOptOut
1021:                            .getRole());
1022:
1023:                    // Check that settings are ignored after message is ACTIVE.
1024:
1025:                    inOptOut.setEndpoint(null);
1026:                    assertNotSame("Allowed to set endpoint after ACTIVE", null,
1027:                            inOptOut.getEndpoint());
1028:
1029:                    inOptOut.setOperation(null);
1030:                    assertNotSame("Allowed to set operation after ACTIVE",
1031:                            null, inOptOut.getOperation());
1032:
1033:                    inOptOut.setOutMessage(inOptOut.createMessage());
1034:
1035:                    // Try and set fault after out message
1036:                    try {
1037:                        inOptOut.setFault(inOptOut.createFault());
1038:                        setFailure("Able to set fault after out message");
1039:                    } catch (Exception ex) {
1040:                    }
1041:                    ;
1042:
1043:                    // Try and set out status after out message
1044:                    try {
1045:                        inOptOut.setStatus(ExchangeStatus.DONE);
1046:                        setFailure("Able to set status after out message");
1047:                    } catch (Exception ex) {
1048:                    }
1049:                    ;
1050:
1051:                    mChannel.send(inOptOut);
1052:                    assertEquals(MessageExchange.Role.PROVIDER, inOptOut
1053:                            .getRole());
1054:
1055:                    // Check that settings are ignored after message is DONE.
1056:
1057:                    inOptOut.setEndpoint(null);
1058:                    assertNotSame("Allowed to set endpoint after done", null,
1059:                            inOptOut.getEndpoint());
1060:
1061:                    inOptOut.setOperation(null);
1062:                    assertNotSame("Allowed to set operation after done", null,
1063:                            inOptOut.getOperation());
1064:
1065:                    inOptOut = (InOptionalOut) mChannel.accept();
1066:                    assertEquals(ExchangeStatus.ACTIVE, inOptOut.getStatus());
1067:                    assertTrue(inOptOut.getFault() != null);
1068:                    assertEquals(MessageExchange.Role.PROVIDER, inOptOut
1069:                            .getRole());
1070:
1071:                    // Try and set out message after fault
1072:                    try {
1073:                        inOptOut.setOutMessage(inOptOut.createMessage());
1074:                        setFailure("Able to set out message after fault");
1075:                    } catch (Exception ex) {
1076:                    }
1077:                    ;
1078:
1079:                    inOptOut.setStatus(ExchangeStatus.DONE);
1080:                    mChannel.send(inOptOut);
1081:                    assertEquals(MessageExchange.Role.PROVIDER, inOptOut
1082:                            .getRole());
1083:                }
1084:            }
1085:
1086:            class HappySynchEngine extends Engine {
1087:                HappySynchEngine(DeliveryChannelImpl channel) {
1088:                    super (channel);
1089:                }
1090:
1091:                public void start() throws Exception {
1092:                    InOptionalOut inOptOut;
1093:
1094:                    inOptOut = (InOptionalOut) mChannel.accept();
1095:                    assertEquals(ExchangeStatus.ACTIVE, inOptOut.getStatus());
1096:                    assertTrue(inOptOut.getInMessage() != null);
1097:                    assertEquals(inOptOut.getPattern().toString(),
1098:                            ExchangePattern.IN_OPTIONAL_OUT.toString());
1099:                    assertEquals(MessageExchange.Role.PROVIDER, inOptOut
1100:                            .getRole());
1101:
1102:                    // Check that settings are ignored after message is ACTIVE.
1103:
1104:                    inOptOut.setEndpoint(null);
1105:                    assertNotSame("Allowed to set endpoint after ACTIVE", null,
1106:                            inOptOut.getEndpoint());
1107:
1108:                    inOptOut.setOperation(null);
1109:                    assertNotSame("Allowed to set operation after ACTIVE",
1110:                            null, inOptOut.getOperation());
1111:
1112:                    inOptOut.setStatus(ExchangeStatus.DONE);
1113:
1114:                    // Try and set out message after status set.
1115:                    try {
1116:                        inOptOut.setOutMessage(inOptOut.createMessage());
1117:                        setFailure("Able to set out message after status");
1118:                    } catch (Exception ex) {
1119:                    }
1120:                    ;
1121:
1122:                    // Try and create/set fault after status is set.
1123:                    try {
1124:                        inOptOut.setFault(inOptOut.createFault());
1125:                        setFailure("Able to set/create fault after status");
1126:                    } catch (Exception ex) {
1127:                    }
1128:                    ;
1129:
1130:                    // Try sendSync
1131:                    try {
1132:                        mChannel.sendSync(inOptOut);
1133:                        setFailure("Able to sendSync when not legal");
1134:                    } catch (Exception ex) {
1135:                    }
1136:                    ;
1137:
1138:                    mChannel.send(inOptOut);
1139:                    assertEquals(MessageExchange.Role.PROVIDER, inOptOut
1140:                            .getRole());
1141:
1142:                    // Check that settings are ignored after message is DONE.
1143:
1144:                    inOptOut.setEndpoint(null);
1145:                    assertNotSame("Allowed to set endpoint after done", null,
1146:                            inOptOut.getEndpoint());
1147:
1148:                    inOptOut.setOperation(null);
1149:                    assertNotSame("Allowed to set operation after done", null,
1150:                            inOptOut.getOperation());
1151:                }
1152:            }
1153:
1154:            class HappySynchEngine4 extends Engine {
1155:                HappySynchEngine4(DeliveryChannelImpl channel) {
1156:                    super (channel);
1157:                }
1158:
1159:                public void start() throws Exception {
1160:                    InOptionalOut inOptOut;
1161:
1162:                    inOptOut = (InOptionalOut) mChannel.accept();
1163:                    assertEquals(ExchangeStatus.ACTIVE, inOptOut.getStatus());
1164:                    assertTrue(inOptOut.getInMessage() != null);
1165:                    assertEquals(MessageExchange.Role.PROVIDER, inOptOut
1166:                            .getRole());
1167:
1168:                    // Check that settings are ignored after message is ACTIVE.
1169:
1170:                    inOptOut.setEndpoint(null);
1171:                    assertNotSame("Allowed to set endpoint after ACTIVE", null,
1172:                            inOptOut.getEndpoint());
1173:
1174:                    inOptOut.setOperation(null);
1175:                    assertNotSame("Allowed to set operation after ACTIVE",
1176:                            null, inOptOut.getOperation());
1177:
1178:                    inOptOut.setOutMessage(inOptOut.createMessage());
1179:
1180:                    // Try and set fault after out message
1181:                    try {
1182:                        inOptOut.setFault(inOptOut.createFault());
1183:                        setFailure("Able to set fault after out message");
1184:                    } catch (Exception ex) {
1185:                    }
1186:                    ;
1187:
1188:                    // Try and set out status after out message
1189:                    try {
1190:                        inOptOut.setStatus(ExchangeStatus.DONE);
1191:                        setFailure("Able to set status after out message");
1192:                    } catch (Exception ex) {
1193:                    }
1194:                    ;
1195:
1196:                    assertTrue(mChannel.sendSync(inOptOut));
1197:                    assertEquals(MessageExchange.Role.PROVIDER, inOptOut
1198:                            .getRole());
1199:                    assertEquals(ExchangeStatus.ACTIVE, inOptOut.getStatus());
1200:                    assertTrue(inOptOut.getFault() != null);
1201:
1202:                    // Try and set out message after fault
1203:                    try {
1204:                        inOptOut.setOutMessage(inOptOut.createMessage());
1205:                        setFailure("Able to set out message after fault");
1206:                    } catch (Exception ex) {
1207:                    }
1208:                    ;
1209:
1210:                    inOptOut.setStatus(ExchangeStatus.DONE);
1211:                    // Try sendSync
1212:                    try {
1213:                        mChannel.sendSync(inOptOut);
1214:                        setFailure("Able to sendSync when not legal");
1215:                    } catch (Exception ex) {
1216:                    }
1217:                    ;
1218:                    mChannel.send(inOptOut);
1219:                    assertEquals(MessageExchange.Role.PROVIDER, inOptOut
1220:                            .getRole());
1221:                }
1222:            }
1223:
1224:            class BadEngine extends Engine {
1225:                BadEngine(DeliveryChannelImpl channel) {
1226:                    super (channel);
1227:                }
1228:
1229:                public void start() throws Exception {
1230:                    InOptionalOut inOptOut;
1231:                    Fault fault;
1232:                    NormalizedMessage msg;
1233:
1234:                    inOptOut = (InOptionalOut) mChannel.accept();
1235:                    assertEquals(MessageExchange.Role.PROVIDER, inOptOut
1236:                            .getRole());
1237:
1238:                    // Try and set in message from engine
1239:                    try {
1240:                        msg = inOptOut.createMessage();
1241:                        inOptOut.setInMessage(msg);
1242:                        setFailure("Able to set in message from engine");
1243:                    } catch (Exception ex1) {
1244:                    }
1245:                    ;
1246:
1247:                    // complete the exchange normally
1248:                    msg = inOptOut.createMessage();
1249:                    inOptOut.setOutMessage(msg);
1250:                    mChannel.send(inOptOut);
1251:                    assertEquals(MessageExchange.Role.PROVIDER, inOptOut
1252:                            .getRole());
1253:
1254:                    // Try and send after DONE.
1255:                    try {
1256:                        msg = inOptOut.createMessage();
1257:                        inOptOut.setInMessage(msg);
1258:                        setFailure("Able to set status.");
1259:                    } catch (Exception ex1) {
1260:                    }
1261:                    ;
1262:
1263:                    // Try and set a status.
1264:                    try {
1265:                        inOptOut.setStatus(ExchangeStatus.DONE);
1266:                        setFailure("Able to set status.");
1267:                    } catch (Exception ex1) {
1268:                    }
1269:                    ;
1270:
1271:                    inOptOut = (InOptionalOut) mChannel.accept();
1272:                    assertEquals(MessageExchange.Role.PROVIDER, inOptOut
1273:                            .getRole());
1274:                }
1275:            }
1276:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.