1 /*** 2 * 3 * Copyright 2005 LogicBlaze, Inc. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * 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 **/ 18 package org.jencks; 19 20 import java.util.Date; 21 import java.util.List; 22 23 import javax.jms.Destination; 24 import javax.jms.TextMessage; 25 26 import org.activemq.spring.TestingConsumer; 27 import org.springframework.context.ConfigurableApplicationContext; 28 import org.springframework.context.support.ClassPathXmlApplicationContext; 29 30 /*** 31 * @version $Revision: 1.1 $ 32 */ 33 public class JCAContainerUsingSpringJtaBatchTest extends JCAContainerTest { 34 protected ConfigurableApplicationContext createApplicationContext() { 35 return new ClassPathXmlApplicationContext("org/jencks/spring-with-jta-batch.xml"); 36 } 37 38 public void testMessageDeliveryUsingSharedMesssageListener() throws Exception { 39 int number = 100; 40 long start = System.currentTimeMillis(); 41 Destination destination = session.createTopic("test.spring.inboundConnectorA"); 42 for (int i = 0; i < number; i++) { 43 TextMessage message = session.createTextMessage("Hello! " + new Date()); 44 producer.send(destination, message); 45 } 46 47 System.out.println("message sent on: " + destination + " of type: " + destination.getClass()); 48 49 50 TestingConsumer consumer = (TestingConsumer) applicationContext.getBean("echoBean"); 51 consumer.waitForMessagesToArrive(number); 52 long stop = System.currentTimeMillis(); 53 System.err.println("Time to send/receive " + number + " messages: " + (stop - start) + " ms"); 54 List list = consumer.flushMessages(); 55 assertEquals("Message count: " + list, number, list.size()); 56 57 } 58 }