KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > servicemix > eip > StaticRecipientListTxTest


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.servicemix.eip;
18
19 import javax.jbi.messaging.ExchangeStatus;
20 import javax.jbi.messaging.InOnly;
21 import javax.xml.namespace.QName JavaDoc;
22
23 import org.apache.servicemix.eip.patterns.StaticRecipientList;
24 import org.apache.servicemix.eip.support.ExchangeTarget;
25 import org.apache.servicemix.tck.ReceiverComponent;
26
27 public class StaticRecipientListTxTest extends AbstractEIPTransactionalTest {
28
29     protected StaticRecipientList recipientList;
30     
31     protected void setUp() throws Exception JavaDoc {
32         super.setUp();
33
34         recipientList = new StaticRecipientList();
35         recipientList.setRecipients(
36                 new ExchangeTarget[] {
37                         createServiceExchangeTarget(new QName JavaDoc("recipient1")),
38                         createServiceExchangeTarget(new QName JavaDoc("recipient2")),
39                         createServiceExchangeTarget(new QName JavaDoc("recipient3"))
40                 });
41         configurePattern(recipientList);
42         activateComponent(recipientList, "recipientList");
43     }
44
45     public void testInOnlySync() throws Exception JavaDoc {
46         ReceiverComponent r1 = activateReceiver("recipient1");
47         ReceiverComponent r2 = activateReceiver("recipient2");
48         ReceiverComponent r3 = activateReceiver("recipient3");
49         
50         tm.begin();
51         
52         InOnly me = client.createInOnlyExchange();
53         me.setService(new QName JavaDoc("recipientList"));
54         me.getInMessage().setContent(createSource("<hello/>"));
55         client.sendSync(me);
56         assertEquals(ExchangeStatus.DONE, me.getStatus());
57         
58         tm.commit();
59         
60         r1.getMessageList().assertMessagesReceived(1);
61         r2.getMessageList().assertMessagesReceived(1);
62         r3.getMessageList().assertMessagesReceived(1);
63     }
64     
65     public void testInOnlyAsync() throws Exception JavaDoc {
66         ReceiverComponent r1 = activateReceiver("recipient1");
67         ReceiverComponent r2 = activateReceiver("recipient2");
68         ReceiverComponent r3 = activateReceiver("recipient3");
69         
70         tm.begin();
71         
72         InOnly me = client.createInOnlyExchange();
73         me.setService(new QName JavaDoc("recipientList"));
74         me.getInMessage().setContent(createSource("<hello/>"));
75         client.send(me);
76         
77         tm.commit();
78
79         me = (InOnly) client.receive();
80         assertEquals(ExchangeStatus.DONE, me.getStatus());
81         
82         r1.getMessageList().assertMessagesReceived(1);
83         r2.getMessageList().assertMessagesReceived(1);
84         r3.getMessageList().assertMessagesReceived(1);
85     }
86     
87 }
88
Popular Tags