org.exolab.jmscts.test.producer.ttl
Class TopicPublisherTest

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
                                                  |
                                                  +--org.exolab.jmscts.test.producer.ttl.TimeToLiveTestCase
                                                        |
                                                        +--org.exolab.jmscts.test.producer.ttl.TopicPublisherTest
All Implemented Interfaces:
ConnectionFactoryTestCase, ConnectionTestCase, JMSTest, MessageTestCase, SendReceiveTestCase, SessionTestCase, junit.framework.Test

public class TopicPublisherTest
extends org.exolab.jmscts.test.producer.ttl.TimeToLiveTestCase

This class tests the behaviour of the time-to-live methods and their affect on the JMSExpiration, for TopicPublishers

Version:
$Revision: 1.3 $
Author:
Tim Anderson

Constructor Summary
TopicPublisherTest(java.lang.String name)
          Construct a new TopicPublisherTest
 
Method Summary
protected  void checkExpiration(javax.jms.Message message, long start, long end, long timeToLive)
          Verifies that a message's JMSExpiration property falls in an expected range
protected  void checkSameExpiration(javax.jms.Message message, MessageReceiver receiver)
          Verifies that a message received via the supplied MessageReceiver has the same JMSExpiration as that of a message.
 java.lang.String[] getDestinations()
          Returns the list of destination names used by this test case.
static junit.framework.Test suite()
          Sets up the test suite
 void testDefaultTTL()
          Verifies that the default time-to-live for a publisher equals 0, and that the JMSExpiration property is set to 0 on send and receive when the default time-to-live is used.
 void testDefaultTTLForAnonTopic()
          Verifies that the default time-to-live for a publisher constructed with no destination equals 0, and that the JMSExpiration property is set to 0 on send and receive when the default time-to-live is used.
 void testPublishWithTTL()
          Verifies that the time-to-live set at publication is used when a message is sent, and that the JMSExpiration property on the received message equals that sent.
 void testPublishWithTTLAndAnonTopic()
          Verifies that the time-to-live set at publication is used when a message is sent, using a TopicPublisher created with no default topic, and that the JMSExpiration property on the received message equals that sent.
 void testSetTTL()
          Verifies that the time-to-live can be set on a publisher, that the value is used when no time-to-live is provided when a message is sent, and that the JMSExpiration property on the received message equals that sent.
 void testSetTTLWithAnonTopic()
          Verifies that the time-to-live can be set on a publisher created with no default topic, that the value is used when no time-to-live is provided when a message is sent, and that the JMSExpiration property on the received message equals that sent.
protected  void verifyPublish(javax.jms.TopicPublisher publisher, javax.jms.Message message, long timeToLive)
          Publishes a message using the TopicPublisher.publish(Message) method and verifies that the JMSExpiration property is set correctly on publish, and is the same on receipt
protected  void verifyPublishWithTopic(javax.jms.TopicPublisher publisher, javax.jms.Topic topic, javax.jms.Message message, long timeToLive)
          Publishes a message using the TopicPublisher.publish(Topic, Message) method and verifies that the JMSExpiration property is set correctly
 
Methods inherited from class org.exolab.jmscts.core.AbstractSendReceiveTestCase
close, close, close, close, createReceiver, createReceiver, createReceivers, createReceivers, createSender, createSender, createSenders, createSenders, getDeliveryTypes, getDestination, getDurableOnly, receive, receive, receive, receive, receive, receive, recreate, send, send, send, send, send, send, send, send, sendReceive, sendReceive, setDestinations
 
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

TopicPublisherTest

public TopicPublisherTest(java.lang.String name)
Construct a new TopicPublisherTest
Parameters:
name - the name of test case
Method Detail

suite

public static junit.framework.Test suite()
Sets up the test suite
Returns:
an instance of this class that may be run by JMSTestRunner

getDestinations

public java.lang.String[] getDestinations()
Returns the list of destination names used by this test case. These are used to pre-administer destinations prior to running the test case.
Overrides:
getDestinations in class AbstractSendReceiveTestCase
Returns:
the list of destinations used by this test case

testDefaultTTL

public void testDefaultTTL()
                    throws java.lang.Exception
Verifies that the default time-to-live for a publisher equals 0, and that the JMSExpiration property is set to 0 on send and receive when the default time-to-live is used.
Throws:
java.lang.Exception - for any error

testDefaultTTLForAnonTopic

public void testDefaultTTLForAnonTopic()
                                throws java.lang.Exception
Verifies that the default time-to-live for a publisher constructed with no destination equals 0, and that the JMSExpiration property is set to 0 on send and receive when the default time-to-live is used.
Throws:
java.lang.Exception - for any error

testSetTTL

public void testSetTTL()
                throws java.lang.Exception
Verifies that the time-to-live can be set on a publisher, that the value is used when no time-to-live is provided when a message is sent, and that the JMSExpiration property on the received message equals that sent.
Throws:
java.lang.Exception - for any error

testSetTTLWithAnonTopic

public void testSetTTLWithAnonTopic()
                             throws java.lang.Exception
Verifies that the time-to-live can be set on a publisher created with no default topic, that the value is used when no time-to-live is provided when a message is sent, and that the JMSExpiration property on the received message equals that sent.
Throws:
java.lang.Exception - for any error

testPublishWithTTL

public void testPublishWithTTL()
                        throws java.lang.Exception
Verifies that the time-to-live set at publication is used when a message is sent, and that the JMSExpiration property on the received message equals that sent.
Throws:
java.lang.Exception - for any error

testPublishWithTTLAndAnonTopic

public void testPublishWithTTLAndAnonTopic()
                                    throws java.lang.Exception
Verifies that the time-to-live set at publication is used when a message is sent, using a TopicPublisher created with no default topic, and that the JMSExpiration property on the received message equals that sent.
Throws:
java.lang.Exception - for any error

verifyPublish

protected void verifyPublish(javax.jms.TopicPublisher publisher,
                             javax.jms.Message message,
                             long timeToLive)
                      throws java.lang.Exception
Publishes a message using the TopicPublisher.publish(Message) method and verifies that the JMSExpiration property is set correctly on publish, and is the same on receipt
Parameters:
publisher - the publisher
message - the message to publish
timeToLive - the expected time-to-live
Throws:
java.lang.Exception - for any error

verifyPublishWithTopic

protected void verifyPublishWithTopic(javax.jms.TopicPublisher publisher,
                                      javax.jms.Topic topic,
                                      javax.jms.Message message,
                                      long timeToLive)
                               throws java.lang.Exception
Publishes a message using the TopicPublisher.publish(Topic, Message) method and verifies that the JMSExpiration property is set correctly
Parameters:
publisher - the publisher
topic - the topic to publish to
message - the message to publish
timeToLive - the expected time-to-live
Throws:
java.lang.Exception - for any error

checkExpiration

protected void checkExpiration(javax.jms.Message message,
                               long start,
                               long end,
                               long timeToLive)
                        throws java.lang.Exception
Verifies that a message's JMSExpiration property falls in an expected range
Parameters:
message - the message to check
start - the time just prior to the message being sent
end - the time just after to the message being sent
timeToLive - the time-to-live used to publish the message
Throws:
java.lang.Exception - for any error

checkSameExpiration

protected void checkSameExpiration(javax.jms.Message message,
                                   MessageReceiver receiver)
                            throws java.lang.Exception
Verifies that a message received via the supplied MessageReceiver has the same JMSExpiration as that of a message. If the session is transacted, it will be committed prior to proceeding
Parameters:
message - the sent message to compare with
receiver - the receiver used to receive a message
Throws:
java.lang.Exception - for any error


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