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 java.util.Properties;
20:
21: import javax.jbi.messaging.ExchangeStatus;
22: import javax.jbi.messaging.InOut;
23: import javax.xml.namespace.QName;
24:
25: import org.apache.log4j.PropertyConfigurator;
26: import org.apache.servicemix.client.DefaultServiceMixClient;
27: import org.apache.servicemix.jbi.jaxp.SourceTransformer;
28: import org.apache.servicemix.jbi.jaxp.StringSource;
29: import org.apache.servicemix.tck.SpringTestSupport;
30: import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
31: import org.springframework.context.support.AbstractXmlApplicationContext;
32:
33: public class CallProcessSmokeTest extends SpringTestSupport {
34:
35: public CallProcessSmokeTest() {
36: Properties properties = new Properties();
37: properties.put("log4j.rootCategory", "INFO, stdout");
38: properties.put("log4j.appender.stdout",
39: "org.apache.log4j.ConsoleAppender");
40: properties.put("log4j.appender.stdout.layout",
41: "org.apache.log4j.PatternLayout");
42: properties.put(
43: "log4j.appender.stdout.layout.ConversionPattern",
44: "%p [%t] %c{1}.%M(%L) | %m%n");
45: PropertyConfigurator.configure(properties);
46: }
47:
48: public void testEcho() throws Exception {
49: DefaultServiceMixClient client = new DefaultServiceMixClient(
50: jbi);
51: InOut me = client.createInOutExchange();
52: me.setService(new QName("http://bpmscript.org/jbi",
53: "callprocess"));
54: me.getInMessage().setContent(
55: new StringSource("<hello>world</hello>"));
56: assertTrue(client.sendSync(me, 1000000));
57: if (me.getStatus() == ExchangeStatus.ERROR) {
58: if (me.getFault() != null) {
59: fail("Received fault: "
60: + new SourceTransformer().toString(me
61: .getFault().getContent()));
62: } else if (me.getError() != null) {
63: throw me.getError();
64: } else {
65: fail("Received ERROR status");
66: }
67: } else {
68: System.out.println(new SourceTransformer().toString(me
69: .getOutMessage().getContent()));
70: }
71: client.done(me);
72: }
73:
74: protected AbstractXmlApplicationContext createBeanFactory() {
75: return new ClassPathXmlApplicationContext(
76: "/callprocess/spring.xml");
77: }
78:
79: }
|