KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > servicemix > remoting > RemoteServiceMixClientTest


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.remoting;
18
19 import org.apache.commons.logging.Log;
20 import org.apache.commons.logging.LogFactory;
21 import org.apache.servicemix.client.ServiceMixClient;
22 import org.apache.servicemix.jbi.container.SpringJBIContainer;
23 import org.springframework.context.support.AbstractXmlApplicationContext;
24 import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
25
26 import javax.jbi.messaging.InOut;
27 import javax.jbi.messaging.NormalizedMessage;
28 import javax.xml.transform.stream.StreamSource JavaDoc;
29
30 import java.io.StringReader JavaDoc;
31
32 import junit.framework.TestCase;
33
34 /**
35  * @version $Revision: 426415 $
36  */

37 public class RemoteServiceMixClientTest extends TestCase {
38     private static final transient Log log = LogFactory.getLog(RemoteServiceMixClientTest.class);
39     protected AbstractXmlApplicationContext context;
40     protected ServiceMixClient client;
41
42     // Send methods
43
// -------------------------------------------------------------------------
44
public void testRemoteSend() throws Exception JavaDoc {
45         InOut exchange = client.createInOutExchange();
46         NormalizedMessage message = exchange.getInMessage();
47         message.setProperty("name", "lufc");
48         message.setContent(new StreamSource JavaDoc(new StringReader JavaDoc("<hello>world</hello>")));
49         assertTrue(client.sendSync(exchange));
50         System.out.println("OUT = " + exchange.getOutMessage());
51         //assertEquals(exchange.getInMessage().getContent(),exchange.getOutMessage().getContent());
52
}
53
54     protected void setUp() throws Exception JavaDoc {
55         context = createBeanFactory();
56         client = (ServiceMixClient) getBean("client");
57         SpringJBIContainer jbi = (SpringJBIContainer) getBean("jbi");
58     }
59
60     protected Object JavaDoc getBean(String JavaDoc name) {
61         Object JavaDoc answer = context.getBean(name);
62         assertNotNull("Could not find object in Spring for key: " + name, answer);
63         return answer;
64     }
65
66     protected AbstractXmlApplicationContext createBeanFactory() {
67         return new ClassPathXmlApplicationContext("org/apache/servicemix/remoting/example.xml");
68     }
69 }
70
Popular Tags