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.InOut;
22: import javax.xml.namespace.QName;
23:
24: import org.apache.log4j.PropertyConfigurator;
25: import org.apache.servicemix.client.DefaultServiceMixClient;
26: import org.apache.servicemix.jbi.jaxp.StringSource;
27: import org.apache.servicemix.tck.SpringTestSupport;
28: import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
29: import org.bpmscript.TimeoutException;
30: import org.springframework.context.support.AbstractXmlApplicationContext;
31:
32: public class JmsTimeoutSmokeTest extends SpringTestSupport {
33:
34: public JmsTimeoutSmokeTest() {
35: Properties properties = new Properties();
36: properties.put("log4j.rootCategory", "INFO, stdout");
37: properties.put("log4j.appender.stdout",
38: "org.apache.log4j.ConsoleAppender");
39: properties.put("log4j.appender.stdout.layout",
40: "org.apache.log4j.PatternLayout");
41: properties.put(
42: "log4j.appender.stdout.layout.ConversionPattern",
43: "%p [%t] %c{1}.%M(%L) | %m%n");
44: PropertyConfigurator.configure(properties);
45: }
46:
47: public void testEcho() throws Exception {
48: DefaultServiceMixClient client = new DefaultServiceMixClient(
49: jbi);
50: InOut me = client.createInOutExchange();
51: me.setService(new QName("http://bpmscript.org/jbi", "timeout"));
52: me.getInMessage().setContent(
53: new StringSource("<hello>world</hello>"));
54: assertTrue(client.sendSync(me, 1000000));
55: Exception error = me.getError();
56: assertTrue(error instanceof TimeoutException);
57: }
58:
59: public void testDirect() throws Exception {
60: DefaultServiceMixClient client = new DefaultServiceMixClient(
61: jbi);
62: InOut me = client.createInOutExchange();
63: me.setService(new QName("http://bpmscript.org/jbi", "alarm"));
64: me.getInMessage().setProperty("delay", 2000);
65: long start = System.currentTimeMillis();
66: assertTrue(client.sendSync(me, 1000000));
67: long duration = System.currentTimeMillis() - start;
68: assertTrue(duration > 2000);
69: }
70:
71: protected AbstractXmlApplicationContext createBeanFactory() {
72: return new ClassPathXmlApplicationContext(
73: "/jmsalarm/spring.xml");
74: }
75:
76: }
|