org.exolab.jmscts.core
Class AbstractSendReceiveTestCase

java.lang.Object
  |
  +--junit.framework.Assert
        |
        +--junit.framework.TestCase
              |
              +--org.exolab.jmscts.core.JMSTestCase
                    |
                    +--org.exolab.jmscts.core.AbstractConnectionFactoryTestCase
                          |
                          +--org.exolab.jmscts.core.AbstractConnectionTestCase
                                |
                                +--org.exolab.jmscts.core.AbstractSessionTestCase
                                      |
                                      +--org.exolab.jmscts.core.AbstractMessageTestCase
                                            |
                                            +--org.exolab.jmscts.core.AbstractSendReceiveTestCase
All Implemented Interfaces:
ConnectionFactoryTestCase, ConnectionTestCase, JMSTest, MessageTestCase, SendReceiveTestCase, SessionTestCase, junit.framework.Test
Direct Known Subclasses:
AbstractSelectorTestCase, AutoAckTest, org.exolab.jmscts.test.session.clientack.ClientAcknowledgeTestCase, CloseTest, CloseTest, CommitTest, ConnectionConsumerTest, DupsAckTest, DurableSubscriberTest, EmptySelectorTest, ExpirationTest, ForeignMessageTest, JMSCorrelationIDTest, JMSDestinationTest, JMSMessageIDTest, JMSReplyToTest, ListenerCloseTest, ListenerTest, MessageCopyTest, MessageListenerTest, NoLocalTest, PropertyTest, ReceiverCloseTest, ReceiverTest, ReceiveSize0KTest, RecoverClearTest, RepublishTest, RollbackClearTest, RollbackTest, Send0KTest, SendReceiveClearTest, SendReceiveReadWriteTest, SendReceiveStopTest, SendReceiveStressTestCase, SubscriberRedeliveredTest, org.exolab.jmscts.test.producer.ttl.TimeToLiveTestCase

public abstract class AbstractSendReceiveTestCase
extends AbstractMessageTestCase
implements SendReceiveTestCase

This class provides a default implementation of the SendReceiveTestCase interface.

Version:
$Revision: 1.9 $ $Date: 2004/02/03 01:00:33 $
Author:
Tim Anderson
See Also:
SendReceiveTestCase, SendReceiveTestRunner

Constructor Summary
AbstractSendReceiveTestCase(java.lang.String name)
          Construct an instance of this class for a specific test case
 
Method Summary
protected  void close(MessageReceiver receiver)
          Helper to close a MessageReceiver
protected  void close(MessageReceiver[] receivers)
          Helper to close a list of MessageReceivers The references are removed from the list.
protected  void close(MessageSender sender)
          Helper to close a MessageSender
protected  void close(MessageSender[] senders)
          Helper to close a list of MessageSenders.
protected  MessageReceiver createReceiver(java.lang.String name)
          Helper to create a MessageReceiver for a single destination returned by getDestination(java.lang.String), using the default test context
protected  MessageReceiver createReceiver(TestContext context, java.lang.String name)
          Helper to create a MessageReceiver for a single destination returned by getDestination(java.lang.String), using the specified test context
protected  MessageReceiver[] createReceivers()
          Helper to create MessageReceiver instances for each destination returned by getDestinations()
protected  MessageReceiver[] createReceivers(TestContext context)
          Helper to create MessageReceiver instances for each destination returned by getDestinations()
protected  MessageSender createSender(java.lang.String name)
          Helper to create a MessageSender for a single destination returned by getDestination(java.lang.String), using the default test context
protected  MessageSender createSender(TestContext context, java.lang.String name)
          Helper to create a MessageSender for a single destination returned by getDestination(java.lang.String), using the specified test context
protected  MessageSender[] createSenders()
          Helper to create MessageSender instances for each destination returned by getDestinations()
protected  MessageSender[] createSenders(TestContext context)
          Helper to create MessageSender instances for each destination returned by getDestinations()
 DeliveryTypes getDeliveryTypes()
          Return the delivery types to run this test case against This implementation returns the values of any jmscts.delivery javadoc tags associated with the test case.
 javax.jms.Destination getDestination(java.lang.String name)
          Returns the named destination
 java.lang.String[] getDestinations()
          Returns the list of destination names used by this test case.
 boolean getDurableOnly()
          Determines if this test case only supports durable topic subscribers.
protected  javax.jms.Message receive(MessageReceiver receiver)
          Helper to verify that a consumer receives a single message
protected  void receive(MessageReceiver[] receivers, int count)
          Helper to verify that each consumer receives the correct number of messages
protected  java.util.List receive(MessageReceiver receiver, int count)
          Helper to verify that a consumer receives the correct number of messages
protected  javax.jms.Message receive(TestContext context, MessageReceiver receiver)
          Helper to verify that a consumer receives a single message
protected  void receive(TestContext context, MessageReceiver[] receivers, int count)
          Helper to verify that each consumer receives the correct number of messages
protected  java.util.List receive(TestContext context, MessageReceiver receiver, int count)
          Helper to verify that a consumer receives the correct number of messages
protected  MessageReceiver recreate(MessageReceiver receiver)
          Helper to recreate a MessageReceiver.
protected  void send(javax.jms.Destination destination, int count)
          Helper to send messages to a destination
protected  void send(javax.jms.Message message, javax.jms.Destination destination)
          Helper to send a message
protected  void send(MessageSender[] senders, javax.jms.Message message, int count)
          Helper to send messages to each destination
protected  void send(javax.jms.Message message, java.lang.String name)
          Helper to send a message
protected  void send(java.lang.String name, int count)
          Helper to send messages to a destination
protected  void send(TestContext context, javax.jms.Destination destination, int count)
          Helper to send messages to a destination
protected  void send(TestContext context, javax.jms.Message message, javax.jms.Destination destination, int count)
          Helper to send messages to a destination
protected  void send(TestContext context, java.lang.String name, int count)
          Helper to send messages to a destination
protected  javax.jms.Message sendReceive(javax.jms.Message message, javax.jms.Destination destination)
          Helper to send a message to a destination, and return a message from the same destination.
protected  javax.jms.Message sendReceive(javax.jms.Message message, java.lang.String name)
          Helper to send a message to a destination, and return a message from the same destination
 void setDestinations(java.util.Map destinations)
          Sets the pre-created destinations corresponding to those returned by getDestinations().
 
Methods inherited from class org.exolab.jmscts.core.AbstractMessageTestCase
getMessagePopulator, getMessageTypes, shouldCreateMessage, startConnection
 
Methods inherited from class org.exolab.jmscts.core.AbstractSessionTestCase
getAckTypes
 
Methods inherited from class org.exolab.jmscts.core.AbstractConnectionTestCase
setClientID
 
Methods inherited from class org.exolab.jmscts.core.AbstractConnectionFactoryTestCase
getConnectionFactoryTypes
 
Methods inherited from class org.exolab.jmscts.core.JMSTestCase
getContext, getRequirements, setContext, share
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.exolab.jmscts.core.MessageTestCase
getMessagePopulator, getMessageTypes, shouldCreateMessage, startConnection
 
Methods inherited from interface org.exolab.jmscts.core.SessionTestCase
getAckTypes
 
Methods inherited from interface org.exolab.jmscts.core.ConnectionTestCase
setClientID
 
Methods inherited from interface org.exolab.jmscts.core.ConnectionFactoryTestCase
getConnectionFactoryTypes
 
Methods inherited from interface org.exolab.jmscts.core.JMSTest
getContext, setContext, share
 
Methods inherited from interface junit.framework.Test
countTestCases, run
 

Constructor Detail

AbstractSendReceiveTestCase

public AbstractSendReceiveTestCase(java.lang.String name)
Construct an instance of this class for a specific test case
Parameters:
name - the name of test case
Method Detail

getDestinations

public java.lang.String[] getDestinations()
Returns the list of destination names used by this test case. These are used to pre-create destinations prior to running the test case.
Specified by:
getDestinations in interface SendReceiveTestCase
Returns:
this implementation returns null.

setDestinations

public void setDestinations(java.util.Map destinations)
Sets the pre-created destinations corresponding to those returned by getDestinations().
Specified by:
setDestinations in interface SendReceiveTestCase
Parameters:
destinations - a map of Destination instances keyed on their name

getDestination

public javax.jms.Destination getDestination(java.lang.String name)
Returns the named destination
Parameters:
name - the destination name
Returns:
the destination, or null if none exists with the specified name

getDeliveryTypes

public DeliveryTypes getDeliveryTypes()
Return the delivery types to run this test case against This implementation returns the values of any jmscts.delivery javadoc tags associated with the test case. The none are specified, returns DeliveryTypes.ALL
Specified by:
getDeliveryTypes in interface SendReceiveTestCase
Returns:
the delivery types to run this test case against

getDurableOnly

public boolean getDurableOnly()
Determines if this test case only supports durable topic subscribers. If false, it supports both durable and non-durable topic subscribers. Note that this does not prevent the test case from supporting queue consumers or browsers. This implementation returns the values of any jmscts.durableonly javadoc tags associated with the test case. The none are specified, returns false
Specified by:
getDurableOnly in interface SendReceiveTestCase
Returns:
true if this test only supports durable topic subcribers; otherwise false

send

protected void send(javax.jms.Message message,
                    javax.jms.Destination destination)
             throws java.lang.Exception
Helper to send a message
Parameters:
message - the message to send
destination - the destination
Throws:
java.lang.Exception - if the message cannot be sent.

send

protected void send(javax.jms.Message message,
                    java.lang.String name)
             throws java.lang.Exception
Helper to send a message
Parameters:
message - the message to send
name - the name of the destination
Throws:
java.lang.Exception - if the message cannot be sent.

send

protected void send(javax.jms.Destination destination,
                    int count)
             throws java.lang.Exception
Helper to send messages to a destination
Parameters:
destination - the destination
count - the no. of messages to send
Throws:
java.lang.Exception - if messages cannot be sent.

send

protected void send(java.lang.String name,
                    int count)
             throws java.lang.Exception
Helper to send messages to a destination
Parameters:
name - the destination name. This must correspond to a destination returned by getDestinations().
count - the no. of messages to send
Throws:
java.lang.Exception - if messages cannot be sent.

send

protected void send(TestContext context,
                    java.lang.String name,
                    int count)
             throws java.lang.Exception
Helper to send messages to a destination
Parameters:
context - the context to use
name - the destination name. This must correspond to a destination returned by getDestinations().
count - the no. of messages to send
Throws:
java.lang.Exception - if messages cannot be sent.

send

protected void send(TestContext context,
                    javax.jms.Destination destination,
                    int count)
             throws java.lang.Exception
Helper to send messages to a destination
Parameters:
context - the context to use
destination - the destination
count - the no. of messages to send
Throws:
java.lang.Exception - if messages cannot be sent.

send

protected 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
Parameters:
context - the context to use
message - the message to send
destination - the destination
count - the no. of messages to send
Throws:
java.lang.Exception - if messages cannot be sent.

sendReceive

protected javax.jms.Message sendReceive(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.

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:
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.

sendReceive

protected javax.jms.Message sendReceive(javax.jms.Message message,
                                        java.lang.String name)
                                 throws java.lang.Exception
Helper to send a message to a destination, and return a message from the same destination
Parameters:
message - the message to send
name - the destination name. This must correspond to a destination returned by getDestinations().
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.

createReceiver

protected MessageReceiver createReceiver(java.lang.String name)
                                  throws java.lang.Exception
Helper to create a MessageReceiver for a single destination returned by getDestination(java.lang.String), using the default test context
Parameters:
name - the destination name
Returns:
the receiver
Throws:
java.lang.Exception - for any error

createReceiver

protected MessageReceiver createReceiver(TestContext context,
                                         java.lang.String name)
                                  throws java.lang.Exception
Helper to create a MessageReceiver for a single destination returned by getDestination(java.lang.String), using the specified test context
Parameters:
context - the test context to use
name - the destination name
Returns:
the receiver
Throws:
java.lang.Exception - for any error

createReceivers

protected MessageReceiver[] createReceivers()
                                     throws java.lang.Exception
Helper to create MessageReceiver instances for each destination returned by getDestinations()
Returns:
a list of message receivers
Throws:
java.lang.Exception - for any error

createReceivers

protected MessageReceiver[] createReceivers(TestContext context)
                                     throws java.lang.Exception
Helper to create MessageReceiver instances for each destination returned by getDestinations()
Parameters:
context - the test context to use
Returns:
a list of message receivers
Throws:
java.lang.Exception - for any error

recreate

protected MessageReceiver recreate(MessageReceiver receiver)
                            throws java.lang.Exception
Helper to recreate a MessageReceiver. This closes the receiver, and recreates it to consume from the same destination, selector, and for durable topic subscribers, subscription and no-local value
Parameters:
receiver - the receiver to re-create
Returns:
the re-created receiver
Throws:
java.lang.Exception - for any error

createSender

protected MessageSender createSender(java.lang.String name)
                              throws java.lang.Exception
Helper to create a MessageSender for a single destination returned by getDestination(java.lang.String), using the default test context
Parameters:
name - the destination name
Returns:
the sender
Throws:
java.lang.Exception - for any error

createSender

protected MessageSender createSender(TestContext context,
                                     java.lang.String name)
                              throws java.lang.Exception
Helper to create a MessageSender for a single destination returned by getDestination(java.lang.String), using the specified test context
Parameters:
context - the test context to use
name - the destination name
Returns:
the sender
Throws:
java.lang.Exception - for any error

createSenders

protected MessageSender[] createSenders()
                                 throws java.lang.Exception
Helper to create MessageSender instances for each destination returned by getDestinations()
Returns:
a list of message senders
Throws:
java.lang.Exception - for any error

createSenders

protected MessageSender[] createSenders(TestContext context)
                                 throws java.lang.Exception
Helper to create MessageSender instances for each destination returned by getDestinations()
Parameters:
context - the test context to use
Returns:
a list of message senders
Throws:
java.lang.Exception - for any error

receive

protected void receive(MessageReceiver[] receivers,
                       int count)
                throws java.lang.Exception
Helper to verify that each consumer receives the correct number of messages
Parameters:
receivers - a list of MessageReceiver instances
count - the number of expected messages
Throws:
java.lang.Exception - for any error

receive

protected void receive(TestContext context,
                       MessageReceiver[] receivers,
                       int count)
                throws java.lang.Exception
Helper to verify that each consumer receives the correct number of messages
Parameters:
context - the test context to use
receivers - a list of MessageReceiver instances
count - the number of expected messages
Throws:
java.lang.Exception - for any error

receive

protected javax.jms.Message receive(MessageReceiver receiver)
                             throws java.lang.Exception
Helper to verify that a consumer receives a single message
Parameters:
receiver - the message receiver
Returns:
the received message
Throws:
java.lang.Exception - for any error

receive

protected javax.jms.Message receive(TestContext context,
                                    MessageReceiver receiver)
                             throws java.lang.Exception
Helper to verify that a consumer receives a single message
Parameters:
context - the test context to use
receiver - the message receiver
Returns:
the received message
Throws:
java.lang.Exception - for any error

receive

protected java.util.List receive(MessageReceiver receiver,
                                 int count)
                          throws java.lang.Exception
Helper to verify that a consumer receives the correct number of messages
Parameters:
receiver - the message receiver
count - the number of expected messages
Returns:
the list of messages received, or null, if none were expected
Throws:
java.lang.Exception - for any error

receive

protected java.util.List receive(TestContext context,
                                 MessageReceiver receiver,
                                 int count)
                          throws java.lang.Exception
Helper to verify that a consumer receives the correct number of messages
Parameters:
context - the test context to use
receiver - the message receiver
count - the number of expected messages
Returns:
the list of messages received, or null, if none were expected
Throws:
java.lang.Exception - for any error

send

protected void send(MessageSender[] senders,
                    javax.jms.Message message,
                    int count)
             throws java.lang.Exception
Helper to send messages to each destination
Parameters:
senders - a list of MessageSender instances
message - the message to send
count - the number of messages to send
Throws:
java.lang.Exception - for any error

close

protected void close(MessageReceiver[] receivers)
              throws java.lang.Exception
Helper to close a list of MessageReceivers The references are removed from the list.
Parameters:
receivers - a list of MessageReceiver instances
Throws:
java.lang.Exception - for any error

close

protected void close(MessageReceiver receiver)
              throws java.lang.Exception
Helper to close a MessageReceiver
Parameters:
receiver - the receiver
Throws:
java.lang.Exception - for any error

close

protected void close(MessageSender[] senders)
              throws java.lang.Exception
Helper to close a list of MessageSenders. The references are removed from the list.
Parameters:
senders - a list of MessageSender instances
Throws:
java.lang.Exception - for any error

close

protected void close(MessageSender sender)
              throws java.lang.Exception
Helper to close a MessageSender
Parameters:
sender - the sender
Throws:
java.lang.Exception - for any error


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