Source Code Cross Referenced for TestRobustInOnly.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:         * @(#)TestRobustInOnly.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 javax.jbi.messaging.ExchangeStatus;
032:        import javax.jbi.messaging.Fault;
033:        import javax.jbi.messaging.RobustInOnly;
034:        import javax.jbi.messaging.MessageExchange;
035:        import javax.jbi.messaging.MessageExchangeFactory;
036:        import javax.jbi.messaging.NormalizedMessage;
037:
038:        import javax.jbi.servicedesc.ServiceEndpoint;
039:
040:        import javax.xml.namespace.QName;
041:
042:        /**
043:         * Test RobustInOnly Message Exchange.
044:         * @author Sun Microsystems, Inc.
045:         */
046:        public class TestRobustInOnly extends junit.framework.TestCase {
047:            private static final QName SERVICE = new QName(
048:                    "RobustInOnlyService");
049:            private static final String ENDPOINT = "RobustInOnlyEndpoint";
050:            private static final QName OPERATION = new QName("foobar");
051:
052:            private MessageService mMsgSvc;
053:            private MessageExchangeFactory mFactory;
054:            /** NMR Environment Context */
055:            private NMRContext mContext;
056:
057:            /**
058:             * The constructor for this testcase, forwards the test name to
059:             * the jUnit TestCase base class.
060:             * @param aTestName String with the name of this test.
061:             */
062:            public TestRobustInOnly(String aTestName) throws Exception {
063:                super (aTestName);
064:                mMsgSvc = new MessageService();
065:                mFactory = new ExchangeFactory(mMsgSvc);
066:                mContext = new NMRContext(mMsgSvc);
067:            }
068:
069:            /**
070:             * Setup for the test. 
071:             * @throws Exception when set up fails for any reason.
072:             */
073:            public void setUp() throws Exception {
074:                super .setUp();
075:
076:                mMsgSvc.initService(mContext);
077:                mMsgSvc.startService();
078:            }
079:
080:            /**
081:             * Cleanup for the test.
082:             * @throws Exception when tearDown fails for any reason.
083:             */
084:            public void tearDown() throws Exception {
085:                super .tearDown();
086:
087:                mMsgSvc.stopService();
088:                mContext.reset();
089:            }
090:
091:            // =============================  test methods ================================
092:
093:            /**
094:             * Happy path test for an RobustInOnly exchange with fault.
095:             * @throws Exception test failed
096:             */
097:            public void testExchangeGood() throws Exception {
098:                Binding binding;
099:                Engine engine;
100:
101:                binding = new HappyBinding(mMsgSvc.activateChannel("binding",
102:                        null));
103:                engine = new HappyEngine(mMsgSvc
104:                        .activateChannel("engine", null));
105:
106:                engine.init(SERVICE, ENDPOINT, ExchangePattern.ROBUST_IN_ONLY
107:                        .toString());
108:                binding.init(SERVICE);
109:
110:                Framework.runTest(binding, engine);
111:
112:                // check for errors
113:                binding.checkError();
114:                engine.checkError();
115:
116:                binding.stop();
117:                engine.stop();
118:            }
119:
120:            /**
121:             * Happy path test for an RobustInOnly exchange with status.
122:             * @throws Exception test failed
123:             */
124:            public void testExchangeGood2() throws Exception {
125:                Binding binding;
126:                Engine engine;
127:
128:                binding = new HappyBinding2(mMsgSvc.activateChannel("binding",
129:                        null));
130:                engine = new HappyEngine2(mMsgSvc.activateChannel("engine",
131:                        null));
132:
133:                engine.init(SERVICE, ENDPOINT, ExchangePattern.ROBUST_IN_ONLY
134:                        .toString());
135:                binding.init(SERVICE);
136:
137:                Framework.runTest(binding, engine);
138:
139:                // check for errors
140:                binding.checkError();
141:                engine.checkError();
142:
143:                binding.stop();
144:                engine.stop();
145:            }
146:
147:            /**
148:             * Happy path test for an RobustInOnly exchange with fault.
149:             * @throws Exception test failed
150:             */
151:            public void testExchangeBindingSynch() throws Exception {
152:                Binding binding;
153:                Engine engine;
154:
155:                binding = new HappySynchBinding(mMsgSvc.activateChannel(
156:                        "binding", null));
157:                engine = new HappyEngine(mMsgSvc
158:                        .activateChannel("engine", null));
159:
160:                engine.init(SERVICE, ENDPOINT, ExchangePattern.ROBUST_IN_ONLY
161:                        .toString());
162:                binding.init(SERVICE);
163:
164:                Framework.runTest(binding, engine);
165:
166:                // check for errors
167:                binding.checkError();
168:                engine.checkError();
169:
170:                binding.stop();
171:                engine.stop();
172:            }
173:
174:            /**
175:             * Happy path test for an RobustInOnly exchange with fault.
176:             * @throws Exception test failed
177:             */
178:            public void testExchangeEngineSynch() throws Exception {
179:                Binding binding;
180:                Engine engine;
181:
182:                binding = new HappyBinding(mMsgSvc.activateChannel("binding",
183:                        null));
184:                engine = new HappySynchEngine(mMsgSvc.activateChannel("engine",
185:                        null));
186:
187:                engine.init(SERVICE, ENDPOINT, ExchangePattern.ROBUST_IN_ONLY
188:                        .toString());
189:                binding.init(SERVICE);
190:
191:                Framework.runTest(binding, engine);
192:
193:                // check for errors
194:                binding.checkError();
195:                engine.checkError();
196:
197:                binding.stop();
198:                engine.stop();
199:            }
200:
201:            /**
202:             * Happy path test for an RobustInOnly exchange with fault.
203:             * @throws Exception test failed
204:             */
205:            public void testExchangeBothSynch() throws Exception {
206:                Binding binding;
207:                Engine engine;
208:
209:                binding = new HappySynchBinding(mMsgSvc.activateChannel(
210:                        "binding", null));
211:                engine = new HappySynchEngine(mMsgSvc.activateChannel("engine",
212:                        null));
213:
214:                engine.init(SERVICE, ENDPOINT, ExchangePattern.ROBUST_IN_ONLY
215:                        .toString());
216:                binding.init(SERVICE);
217:
218:                Framework.runTest(binding, engine);
219:
220:                // check for errors
221:                binding.checkError();
222:                engine.checkError();
223:
224:                binding.stop();
225:                engine.stop();
226:            }
227:
228:            /**
229:             * Attempt to do bad things with an OutOnly exchange.
230:             * @throws Exception test failed
231:             */
232:            public void testExchangeFailure() throws Exception {
233:                Binding binding;
234:                Engine engine;
235:
236:                binding = new BadBinding(mMsgSvc.activateChannel("binding",
237:                        null));
238:                engine = new BadEngine(mMsgSvc.activateChannel("engine", null));
239:
240:                engine.init(SERVICE, ENDPOINT, ExchangePattern.ROBUST_IN_ONLY
241:                        .toString());
242:                binding.init(SERVICE);
243:
244:                Framework.runTest(binding, engine);
245:
246:                // check for binding or engine failure
247:                binding.checkError();
248:                engine.checkError();
249:
250:                binding.stop();
251:                engine.stop();
252:            }
253:
254:            // ============================ internal stuff ================================
255:
256:            class HappyBinding extends Binding {
257:                HappyBinding(DeliveryChannelImpl channel) {
258:                    super (channel);
259:                }
260:
261:                public void start() throws Exception {
262:                    NormalizedMessage outMsg;
263:                    Fault fault;
264:                    RobustInOnly robInOnly;
265:
266:                    // create the exchange
267:                    robInOnly = mFactory.createRobustInOnlyExchange();
268:                    outMsg = robInOnly.createMessage();
269:                    assertEquals(robInOnly.getPattern().toString(),
270:                            ExchangePattern.ROBUST_IN_ONLY.toString());
271:                    assertEquals(ExchangeStatus.ACTIVE, robInOnly.getStatus());
272:                    assertEquals(MessageExchange.Role.CONSUMER, robInOnly
273:                            .getRole());
274:
275:                    // lookup the endpoint reference and set on exchange
276:                    robInOnly.setEndpoint(mEndpoint);
277:                    robInOnly.setOperation(OPERATION);
278:
279:                    // set the payload
280:                    Payload.setPayload(outMsg);
281:
282:                    // set the out message
283:                    robInOnly.setInMessage(outMsg);
284:
285:                    // send the exchange
286:                    mChannel.send(robInOnly);
287:                    assertEquals(MessageExchange.Role.CONSUMER, robInOnly
288:                            .getRole());
289:
290:                    // Check that settings are ignored while ownership is elsewhere.
291:
292:                    robInOnly.setEndpoint(null);
293:                    assertEquals(mEndpoint, robInOnly.getEndpoint());
294:
295:                    robInOnly.setOperation(null);
296:                    assertEquals(OPERATION, robInOnly.getOperation());
297:
298:                    // receive the response
299:                    robInOnly = (RobustInOnly) mChannel.accept();
300:                    assertEquals(MessageExchange.Role.CONSUMER, robInOnly
301:                            .getRole());
302:
303:                    // check for a fault
304:                    fault = robInOnly.getFault();
305:                    assertTrue(fault != null);
306:
307:                    robInOnly.setStatus(ExchangeStatus.DONE);
308:                    mChannel.send(robInOnly);
309:                    assertEquals(MessageExchange.Role.CONSUMER, robInOnly
310:                            .getRole());
311:
312:                    // Check that settings are ignored when DONE.
313:
314:                    robInOnly.setEndpoint(null);
315:                    assertEquals(mEndpoint, robInOnly.getEndpoint());
316:
317:                    robInOnly.setOperation(null);
318:                    assertEquals(OPERATION, robInOnly.getOperation());
319:                }
320:            }
321:
322:            class HappyBinding2 extends Binding {
323:                HappyBinding2(DeliveryChannelImpl channel) {
324:                    super (channel);
325:                }
326:
327:                public void start() throws Exception {
328:                    NormalizedMessage outMsg;
329:                    Fault fault;
330:                    RobustInOnly robInOnly;
331:
332:                    // create the exchange
333:                    robInOnly = mFactory.createRobustInOnlyExchange();
334:                    outMsg = robInOnly.createMessage();
335:                    assertEquals(MessageExchange.Role.CONSUMER, robInOnly
336:                            .getRole());
337:
338:                    // lookup the endpoint reference and set on exchange
339:                    robInOnly.setEndpoint(mEndpoint);
340:                    robInOnly.setOperation(OPERATION);
341:
342:                    // set the payload
343:                    Payload.setPayload(outMsg);
344:
345:                    // set the out message
346:                    robInOnly.setInMessage(outMsg);
347:
348:                    // send the exchange
349:                    mChannel.send(robInOnly);
350:                    assertEquals(MessageExchange.Role.CONSUMER, robInOnly
351:                            .getRole());
352:
353:                    // receive the response
354:                    robInOnly = (RobustInOnly) mChannel.accept();
355:
356:                    // check for a fault
357:                    fault = robInOnly.getFault();
358:                    assertTrue(fault == null);
359:
360:                    // Check that a Status was returned.
361:                    assertTrue(robInOnly.getStatus() != ExchangeStatus.ACTIVE);
362:
363:                    // Check that we can't set the status.
364:                    try {
365:                        robInOnly.setStatus(ExchangeStatus.DONE);
366:                        setFailure("Able to set Status after DONE.");
367:                    } catch (Exception ex) {
368:                    }
369:                    ;
370:
371:                    // Check that we can't send the status.
372:                    try {
373:                        mChannel.send(robInOnly);
374:                        setFailure("Able to send Status after DONE.");
375:                    } catch (Exception ex) {
376:                    }
377:                    ;
378:
379:                }
380:            }
381:
382:            class HappySynchBinding extends Binding {
383:                HappySynchBinding(DeliveryChannelImpl channel) {
384:                    super (channel);
385:                }
386:
387:                public void start() throws Exception {
388:                    NormalizedMessage outMsg;
389:                    Fault fault;
390:                    RobustInOnly robInOnly;
391:
392:                    // create the exchange
393:                    robInOnly = mFactory.createRobustInOnlyExchange();
394:                    outMsg = robInOnly.createMessage();
395:                    assertEquals(robInOnly.getPattern().toString(),
396:                            ExchangePattern.ROBUST_IN_ONLY.toString());
397:                    assertEquals(ExchangeStatus.ACTIVE, robInOnly.getStatus());
398:                    assertEquals(MessageExchange.Role.CONSUMER, robInOnly
399:                            .getRole());
400:
401:                    // lookup the endpoint reference and set on exchange
402:                    robInOnly.setEndpoint(mEndpoint);
403:                    robInOnly.setOperation(OPERATION);
404:
405:                    // set the payload
406:                    Payload.setPayload(outMsg);
407:
408:                    // set the out message
409:                    robInOnly.setInMessage(outMsg);
410:
411:                    // send the exchange
412:                    assertTrue(mChannel.sendSync(robInOnly));
413:                    assertEquals(MessageExchange.Role.CONSUMER, robInOnly
414:                            .getRole());
415:
416:                    // check for a fault
417:                    fault = robInOnly.getFault();
418:                    assertTrue(fault != null);
419:
420:                    robInOnly.setStatus(ExchangeStatus.DONE);
421:                    // Try sendSync
422:                    try {
423:                        mChannel.sendSync(robInOnly);
424:                        setFailure("Able to sendSync when not legal");
425:                    } catch (Exception ex) {
426:                    }
427:                    ;
428:                    mChannel.send(robInOnly);
429:                    assertEquals(MessageExchange.Role.CONSUMER, robInOnly
430:                            .getRole());
431:
432:                    // Check that settings are ignored when DONE.
433:
434:                    robInOnly.setEndpoint(null);
435:                    assertEquals(mEndpoint, robInOnly.getEndpoint());
436:
437:                    robInOnly.setOperation(null);
438:                    assertEquals(OPERATION, robInOnly.getOperation());
439:                }
440:            }
441:
442:            class BadBinding extends Binding {
443:                BadBinding(DeliveryChannelImpl channel) {
444:                    super (channel);
445:                }
446:
447:                public void start() throws Exception {
448:                    NormalizedMessage outMsg;
449:                    Fault fault;
450:                    RobustInOnly robInOnly;
451:
452:                    // create the exchange
453:                    robInOnly = mFactory.createRobustInOnlyExchange();
454:                    outMsg = robInOnly.createMessage();
455:                    assertEquals(MessageExchange.Role.CONSUMER, robInOnly
456:                            .getRole());
457:
458:                    // lookup the endpoint reference and set on exchange
459:                    robInOnly.setEndpoint(mEndpoint);
460:                    robInOnly.setOperation(OPERATION);
461:
462:                    // set the payload
463:                    Payload.setPayload(outMsg);
464:
465:                    // FAILURE CASE 1 := set fault as the first step
466:                    fault = robInOnly.createFault();
467:                    try {
468:                        robInOnly.setFault(fault);
469:                        setFailure("Able to set fault as first message in exchange");
470:                    } catch (Exception ex) {
471:                    }
472:
473:                    // FAILURE CASE 2 := set status as first step
474:                    try {
475:                        robInOnly.setStatus(ExchangeStatus.DONE);
476:                        setFailure("Able to set status to done as first step in exchange");
477:                    } catch (Exception ex) {
478:                    }
479:
480:                    // Now we can proceed normally            
481:                    mChannel.send(robInOnly);
482:
483:                    // receive the response
484:                    robInOnly = (RobustInOnly) mChannel.accept();
485:                    assertEquals(MessageExchange.Role.CONSUMER, robInOnly
486:                            .getRole());
487:
488:                    // check for a fault
489:                    fault = robInOnly.getFault();
490:                    assertTrue(fault == null);
491:
492:                    // FAILURE CASE 3 := set status after DONE
493:                    try {
494:                        robInOnly.setStatus(ExchangeStatus.DONE);
495:                        setFailure("Able to set status to done after DONE.");
496:                    } catch (Exception ex) {
497:                    }
498:
499:                    // FAILURE CASE 4 := send after DONE.
500:                    try {
501:                        mChannel.send(robInOnly);
502:                        setFailure("Able to send after DONE.");
503:                    } catch (Exception ex) {
504:                    }
505:
506:                }
507:            }
508:
509:            class HappyEngine extends Engine {
510:                HappyEngine(DeliveryChannelImpl channel) {
511:                    super (channel);
512:                }
513:
514:                public void start() throws Exception {
515:                    Fault fault;
516:                    RobustInOnly robInOnly;
517:
518:                    // accept the message exchange
519:                    robInOnly = (RobustInOnly) mChannel.accept();
520:                    assertEquals(robInOnly.getPattern().toString(),
521:                            ExchangePattern.ROBUST_IN_ONLY.toString());
522:                    assertEquals(MessageExchange.Role.PROVIDER, robInOnly
523:                            .getRole());
524:
525:                    // Check that settings are ignored after message is ACTIVE.
526:
527:                    robInOnly.setEndpoint(null);
528:                    assertNotSame("Allowed to set endpoint after ACTIVE", null,
529:                            robInOnly.getEndpoint());
530:
531:                    robInOnly.setOperation(null);
532:                    assertNotSame("Allowed to set operation after ACTIVE",
533:                            null, robInOnly.getOperation());
534:
535:                    // check the out message
536:                    if (robInOnly.getInMessage() == null) {
537:                        setFailure("In message is null!");
538:                        return;
539:                    }
540:
541:                    // generate a fault
542:                    fault = robInOnly.createFault();
543:                    robInOnly.setFault(fault);
544:
545:                    // send the exchange with fault
546:                    mChannel.send(robInOnly);
547:                    assertEquals(MessageExchange.Role.PROVIDER, robInOnly
548:                            .getRole());
549:
550:                    // wait for status from engine
551:                    robInOnly = (RobustInOnly) mChannel.accept();
552:                    assertEquals(ExchangeStatus.DONE, robInOnly.getStatus());
553:                    assertEquals(MessageExchange.Role.PROVIDER, robInOnly
554:                            .getRole());
555:
556:                    // Check that settings are ignored after message is DONE.
557:
558:                    robInOnly.setEndpoint(null);
559:                    assertNotSame("Allowed to set endpoint after done", null,
560:                            robInOnly.getEndpoint());
561:
562:                    robInOnly.setOperation(null);
563:                    assertNotSame("Allowed to set operation after done", null,
564:                            robInOnly.getOperation());
565:                }
566:            }
567:
568:            class HappySynchEngine extends Engine {
569:                HappySynchEngine(DeliveryChannelImpl channel) {
570:                    super (channel);
571:                }
572:
573:                public void start() throws Exception {
574:                    Fault fault;
575:                    RobustInOnly robInOnly;
576:
577:                    // accept the message exchange
578:                    robInOnly = (RobustInOnly) mChannel.accept();
579:                    assertEquals(robInOnly.getPattern().toString(),
580:                            ExchangePattern.ROBUST_IN_ONLY.toString());
581:                    assertEquals(MessageExchange.Role.PROVIDER, robInOnly
582:                            .getRole());
583:
584:                    // Check that settings are ignored after message is ACTIVE.
585:
586:                    robInOnly.setEndpoint(null);
587:                    assertNotSame("Allowed to set endpoint after ACTIVE", null,
588:                            robInOnly.getEndpoint());
589:
590:                    robInOnly.setOperation(null);
591:                    assertNotSame("Allowed to set operation after ACTIVE",
592:                            null, robInOnly.getOperation());
593:
594:                    // check the out message
595:                    if (robInOnly.getInMessage() == null) {
596:                        setFailure("In message is null!");
597:                        return;
598:                    }
599:
600:                    // generate a fault
601:                    fault = robInOnly.createFault();
602:                    robInOnly.setFault(fault);
603:
604:                    // send the exchange with fault
605:                    assertTrue(mChannel.sendSync(robInOnly));
606:                    assertEquals(MessageExchange.Role.PROVIDER, robInOnly
607:                            .getRole());
608:
609:                    assertEquals(ExchangeStatus.DONE, robInOnly.getStatus());
610:
611:                    // Check that settings are ignored after message is DONE.
612:
613:                    robInOnly.setEndpoint(null);
614:                    assertNotSame("Allowed to set endpoint after done", null,
615:                            robInOnly.getEndpoint());
616:
617:                    robInOnly.setOperation(null);
618:                    assertNotSame("Allowed to set operation after done", null,
619:                            robInOnly.getOperation());
620:                }
621:            }
622:
623:            class HappyEngine2 extends Engine {
624:                HappyEngine2(DeliveryChannelImpl channel) {
625:                    super (channel);
626:                }
627:
628:                public void start() throws Exception {
629:                    Fault fault;
630:                    RobustInOnly robInOnly;
631:
632:                    // accept the message exchange
633:                    robInOnly = (RobustInOnly) mChannel.accept();
634:                    assertEquals(MessageExchange.Role.PROVIDER, robInOnly
635:                            .getRole());
636:
637:                    // check the out message
638:                    if (robInOnly.getInMessage() == null) {
639:                        setFailure("In message is null!");
640:                        return;
641:                    }
642:
643:                    // generate a fault
644:                    robInOnly.setStatus(ExchangeStatus.DONE);
645:
646:                    // Try and create a fault after decided to set Status.
647:                    try {
648:                        fault = robInOnly.createFault();
649:                        setFailure("Able to create a fault after setting status.");
650:                    } catch (Exception ex) {
651:                    }
652:
653:                    // Try and set a fault after decided to set Status.
654:                    try {
655:                        robInOnly.setFault(null);
656:                        setFailure("Able to set a fault after setting status.");
657:                    } catch (Exception ex) {
658:                    }
659:
660:                    // Send status to Enging.
661:                    mChannel.send(robInOnly);
662:                    assertEquals(MessageExchange.Role.PROVIDER, robInOnly
663:                            .getRole());
664:
665:                    // wait for status from engine
666:                    assertEquals(ExchangeStatus.DONE, robInOnly.getStatus());
667:                }
668:            }
669:
670:            class BadEngine extends Engine {
671:                BadEngine(DeliveryChannelImpl channel) {
672:                    super (channel);
673:                }
674:
675:                public void start() throws Exception {
676:                    RobustInOnly robInOnly;
677:                    NormalizedMessage msg;
678:
679:                    robInOnly = (RobustInOnly) mChannel.accept();
680:                    assertEquals(MessageExchange.Role.PROVIDER, robInOnly
681:                            .getRole());
682:
683:                    // Try and set out message again
684:                    try {
685:                        msg = robInOnly.createMessage();
686:                        robInOnly.setInMessage(msg);
687:                        setFailure("Able to set in message from binding");
688:                        return;
689:                    } catch (Exception ex1) {
690:                    }
691:                    ;
692:
693:                    // complete the exchange normally
694:                    robInOnly.setStatus(ExchangeStatus.DONE);
695:                    mChannel.send(robInOnly);
696:                    assertEquals(MessageExchange.Role.PROVIDER, robInOnly
697:                            .getRole());
698:                }
699:            }
700:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.