git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1367622 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2012-07-31 15:50:36 +00:00
parent 79bce92c33
commit 3eed779378
2 changed files with 16 additions and 7 deletions

View File

@ -59,10 +59,13 @@ public class JMSUsecaseTest extends JmsTestSupport {
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
destination = createDestination(session, destinationType);
sendMessages(session, destination, 5);
MessageProducer producer = session.createProducer(destination);
producer.setDeliveryMode(this.deliveryMode);
sendMessages(session, producer, 5);
producer.close();
QueueBrowser browser = session.createBrowser((Queue)destination);
Enumeration enumeration = browser.getEnumeration();
Enumeration<?> enumeration = browser.getEnumeration();
for (int i = 0; i < 5; i++) {
Thread.sleep(100);
assertTrue(enumeration.hasMoreElements());
@ -85,6 +88,7 @@ public class JMSUsecaseTest extends JmsTestSupport {
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
destination = createDestination(session, destinationType);
MessageProducer producer = session.createProducer(destination);
producer.setDeliveryMode(this.deliveryMode);
MessageConsumer consumer = session.createConsumer(destination);
ActiveMQMessage message = new ActiveMQMessage();
producer.send(message);
@ -106,6 +110,7 @@ public class JMSUsecaseTest extends JmsTestSupport {
Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
destination = createDestination(session, destinationType);
MessageProducer producer = session.createProducer(destination);
producer.setDeliveryMode(this.deliveryMode);
MessageConsumer consumer = session.createConsumer(destination);
producer.send(session.createTextMessage("test"));

View File

@ -39,8 +39,8 @@ import org.apache.activemq.command.ActiveMQDestination;
/**
* Test cases used to test the JMS message consumer.
*
*
*
*
*/
public class JmsTestSupport extends CombinationTestSupport {
@ -96,10 +96,14 @@ public class JmsTestSupport extends CombinationTestSupport {
protected void sendMessages(Session session, Destination destination, int count) throws JMSException {
MessageProducer producer = session.createProducer(destination);
sendMessages(session, producer, count);
producer.close();
}
protected void sendMessages(Session session, MessageProducer producer, int count) throws JMSException {
for (int i = 0; i < count; i++) {
producer.send(session.createTextMessage(messageTextPrefix + i));
}
producer.close();
}
protected ConnectionFactory createConnectionFactory() throws Exception {
@ -126,8 +130,8 @@ public class JmsTestSupport extends CombinationTestSupport {
}
protected void tearDown() throws Exception {
for (Iterator iter = connections.iterator(); iter.hasNext();) {
Connection conn = (Connection)iter.next();
for (Iterator<Connection> iter = connections.iterator(); iter.hasNext();) {
Connection conn = iter.next();
try {
conn.close();
} catch (Throwable e) {