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 CallEmailTest extends SpringTestSupport {
34:
35: public CallEmailTest() {
36: Properties properties = new Properties();
37: properties.put("log4j.rootCategory", "DEBUG, 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 testCallSoap() throws Exception {
49: DefaultServiceMixClient client = new DefaultServiceMixClient(
50: jbi);
51: InOut me = client.createInOutExchange();
52: me.setService(new QName("http://bpmscript.org/jbi", "email"));
53: me
54: .getInMessage()
55: .setContent(
56: new StringSource(
57: "<request><symbol>MSFT</symbol><min>30.0</min><max>35.0</max><to>bpmscript@googlemail.com</to></request>"));
58: assertTrue(client.sendSync(me, 1000000));
59: if (me.getStatus() == ExchangeStatus.ERROR) {
60: if (me.getFault() != null) {
61: fail("Received fault: "
62: + new SourceTransformer().toString(me
63: .getFault().getContent()));
64: } else if (me.getError() != null) {
65: throw me.getError();
66: } else {
67: fail("Received ERROR status");
68: }
69: } else {
70: System.out.println(new SourceTransformer().toString(me
71: .getOutMessage().getContent()));
72: }
73: client.done(me);
74: }
75:
76: protected AbstractXmlApplicationContext createBeanFactory() {
77: return new ClassPathXmlApplicationContext("/email/spring.xml");
78: }
79:
80: }
|