KickJava   Java API By Example, From Geeks To Geeks.

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


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.Pipeline;
24 import org.apache.servicemix.tck.ReceiverComponent;
25
26 public class PipelineTxTest extends AbstractEIPTransactionalTest {
27
28     protected Pipeline pipeline;
29     
30     protected void setUp() throws Exception JavaDoc {
31         super.setUp();
32
33         pipeline = new Pipeline();
34         pipeline.setTransformer(createServiceExchangeTarget(new QName JavaDoc("transformer")));
35         pipeline.setTarget(createServiceExchangeTarget(new QName JavaDoc("target")));
36         configurePattern(pipeline);
37         activateComponent(pipeline, "pipeline");
38     }
39     
40     public void testInOnlySync() throws Exception JavaDoc {
41         activateComponent(new ReturnOutComponent(), "transformer");
42         ReceiverComponent target = activateReceiver("target");
43
44         tm.begin();
45         
46         InOnly me = client.createInOnlyExchange();
47         me.setService(new QName JavaDoc("pipeline"));
48         me.getInMessage().setContent(createSource("<hello/>"));
49         client.sendSync(me);
50         assertEquals(ExchangeStatus.DONE, me.getStatus());
51         
52         tm.commit();
53         
54         target.getMessageList().assertMessagesReceived(1);
55         
56         listener.assertExchangeCompleted();
57     }
58     
59     public void testInOnlyAsync() throws Exception JavaDoc {
60         activateComponent(new ReturnOutComponent(), "transformer");
61         ReceiverComponent target = activateReceiver("target");
62
63         tm.begin();
64         
65         InOnly me = client.createInOnlyExchange();
66         me.setService(new QName JavaDoc("pipeline"));
67         me.getInMessage().setContent(createSource("<hello/>"));
68         client.send(me);
69         
70         tm.commit();
71         
72         me = (InOnly) client.receive();
73         assertEquals(ExchangeStatus.DONE, me.getStatus());
74         
75         target.getMessageList().assertMessagesReceived(1);
76         
77         listener.assertExchangeCompleted();
78     }
79     
80 }
81
Popular Tags