01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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.bpmscript.jbi.component;
18:
19: import javax.jbi.messaging.ExchangeStatus;
20: import javax.jbi.messaging.InOut;
21: import javax.xml.namespace.QName;
22:
23: import org.apache.servicemix.client.DefaultServiceMixClient;
24: import org.apache.servicemix.jbi.jaxp.SourceTransformer;
25: import org.apache.servicemix.jbi.jaxp.StringSource;
26: import org.apache.servicemix.tck.SpringTestSupport;
27: import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
28: import org.springframework.context.support.AbstractXmlApplicationContext;
29:
30: public class BpmScriptSpringComponentSmokeTest extends
31: SpringTestSupport {
32:
33: public void testEcho() throws Exception {
34: DefaultServiceMixClient client = new DefaultServiceMixClient(
35: jbi);
36: InOut me = client.createInOutExchange();
37: me.setService(new QName("http://bpmscript.org/jbi", "echo"));
38: me.getInMessage().setContent(
39: new StringSource("<hello>world</hello>"));
40: assertTrue(client.sendSync(me, 5000));
41: if (me.getStatus() == ExchangeStatus.ERROR) {
42: if (me.getFault() != null) {
43: fail("Received fault: "
44: + new SourceTransformer().toString(me
45: .getFault().getContent()));
46: } else if (me.getError() != null) {
47: throw me.getError();
48: } else {
49: fail("Received ERROR status");
50: }
51: } else {
52: System.out.println(new SourceTransformer().toString(me
53: .getOutMessage().getContent()));
54: }
55: client.done(me);
56: }
57:
58: protected AbstractXmlApplicationContext createBeanFactory() {
59: return new ClassPathXmlApplicationContext(
60: "/org/bpmscript/jbi/component/spring.xml");
61: }
62:
63: }
|