org.exolab.jmscts.core
Class MessagingHelper

java.lang.Object
  |
  +--org.exolab.jmscts.core.MessagingHelper

public final class MessagingHelper
extends java.lang.Object

Helper class for performing messaging operations

Version:
$Revision: 1.4 $ $Date: 2004/01/31 13:44:24 $
Author:
Tim Anderson
See Also:
SessionHelper, TestContext

Method Summary
static java.util.List receive(MessageReceiver receiver, int count, long timeout)
          Helper to receive messages
static java.util.List receive(TestContext context, MessageReceiver receiver, int count)
          Helper to receive messages
static void send(TestContext context, javax.jms.Destination destination, int count)
          Helper to send messages to a destination, using the message supplied by the test context
static void send(TestContext context, javax.jms.Message message, javax.jms.Destination destination, int count)
          Helper to send messages to a destination.
static javax.jms.Message sendReceive(TestContext context, javax.jms.Destination destination)
          Helper to send a message to a destination, and return a message from the same destination.
static javax.jms.Message sendReceive(TestContext context, javax.jms.Message message, javax.jms.Destination destination)
          Helper to send a message to a destination, and return a message from the same destination.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

send

public static void send(TestContext context,
                        javax.jms.Destination destination,
                        int count)
                 throws java.lang.Exception
Helper to send messages to a destination, using the message supplied by the test context

If the session is transactional, it will be committed.

Parameters:
context - the test context
destination - the destination
count - the number of times to send the message
Throws:
java.lang.Exception - for any error

send

public static void send(TestContext context,
                        javax.jms.Message message,
                        javax.jms.Destination destination,
                        int count)
                 throws java.lang.Exception
Helper to send messages to a destination.

If the session is transactional, it will be committed.

Parameters:
context - the test context
message - the message to send
destination - the destination
count - the number of times to send the message
Throws:
java.lang.Exception - for any error

sendReceive

public static javax.jms.Message sendReceive(TestContext context,
                                            javax.jms.Destination destination)
                                     throws java.lang.Exception
Helper to send a message to a destination, and return a message from the same destination. The message is obtained from the test context.

If the session is transactional, it will be committed.
Note: the persistent state of the receiver is removed on completion, so tests for durable topic subcribers should not use this method if more than one message is expected.

Parameters:
context - the test context
destination - the destination
Returns:
the message received from the destination
Throws:
java.lang.Exception - if the message cannot be sent, no message is received, or more than one message is received.

sendReceive

public static javax.jms.Message sendReceive(TestContext context,
                                            javax.jms.Message message,
                                            javax.jms.Destination destination)
                                     throws java.lang.Exception
Helper to send a message to a destination, and return a message from the same destination.

If the session is transactional, it will be committed.
Note: the persistent state of the receiver is removed on completion, so tests for durable topic subcribers should not use this method if more than one message is expected.

Parameters:
context - the test context
message - the message to send
destination - the destination
Returns:
Message the message received from the destination
Throws:
java.lang.Exception - if the message cannot be sent, no message is received, or more than one message is received.

receive

public static java.util.List receive(TestContext context,
                                     MessageReceiver receiver,
                                     int count)
                              throws java.lang.Exception
Helper to receive messages
Parameters:
context - the test context
receiver - the message receiver
count - the expected number of messages
Returns:
the list of messages, or null, if no messages were expected
Throws:
java.lang.Exception - if the receive fails, or the wrong number of messages were returned

receive

public static java.util.List receive(MessageReceiver receiver,
                                     int count,
                                     long timeout)
                              throws java.lang.Exception
Helper to receive messages
Parameters:
receiver - the message receiver
count - the expected number of messages
timeout - the maximum time to wait for each message
Returns:
the list of messages, or null, if no messages were expected
Throws:
java.lang.Exception - if the receive fails, or the wrong number of messages were returned


Copyright © 2001-2004 JMS CTS Team. All Rights Reserved.