com.mockrunner.mock.jms
Class MockDestination

java.lang.Object
  extended by com.mockrunner.mock.jms.MockDestination
All Implemented Interfaces:
java.io.Serializable, javax.jms.Destination
Direct Known Subclasses:
MockQueue, MockTopic

public abstract class MockDestination
extends java.lang.Object
implements javax.jms.Destination, java.io.Serializable

Mock implementation of JMS Destination.

See Also:
Serialized Form

Constructor Summary
MockDestination()
           
 
Method Summary
protected  void acknowledgeMessage(javax.jms.Message message, MockSession session)
           
protected  void addCurrentMessage(javax.jms.Message message)
           
abstract  void addMessage(javax.jms.Message message)
          Adds a message and delivers it to the corresponding consumers.
protected  void addReceivedMessage(javax.jms.Message message)
           
 void addSession(javax.jms.Session session)
          Adds a Session.
 void clear()
          Clears all current messages.
 java.util.List getCurrentMessageList()
          Returns a List of all current messages.
 javax.jms.Message getMatchingMessage(org.activemq.filter.mockrunner.Filter filter)
          Returns the next message that matches the filter.
 javax.jms.Message getMessage()
          Returns the next message.
 java.util.List getReceivedMessageList()
          Returns a List of all received messages.
 boolean isEmpty()
          Returns if this destination contains messages.
 void loadMessage(javax.jms.Message message)
          Adds a message to the list of current messages in this destination.
 void removeSession(javax.jms.Session session)
          Removes a Session.
 void reset()
          Clears all current messages and resets the list of received messages.
 java.util.Set sessionSet()
          Return a Set of all sessions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockDestination

public MockDestination()
Method Detail

addMessage

public abstract void addMessage(javax.jms.Message message)
                         throws javax.jms.JMSException
Adds a message and delivers it to the corresponding consumers. Implemented by MockQueue and MockTopic.

Parameters:
message - the message
Throws:
javax.jms.JMSException

loadMessage

public void loadMessage(javax.jms.Message message)
Adds a message to the list of current messages in this destination. The message is not delivered to registered consumers. Can be used to preload destinations with test messages.

Parameters:
message - the message

isEmpty

public boolean isEmpty()
Returns if this destination contains messages.

Returns:
false if there's at least one message, true otherwise

clear

public void clear()
Clears all current messages.


reset

public void reset()
Clears all current messages and resets the list of received messages.


getMessage

public javax.jms.Message getMessage()
Returns the next message. The message will be removed from the list of current messages. If there's no message, null will be returned.

Returns:
the Message

getMatchingMessage

public javax.jms.Message getMatchingMessage(org.activemq.filter.mockrunner.Filter filter)
Returns the next message that matches the filter. The message will be removed from the list of current messages. If there's no matching message, null will be returned.

Parameters:
filter - the message filter
Returns:
the Message

getCurrentMessageList

public java.util.List getCurrentMessageList()
Returns a List of all current messages.

Returns:
the List of messages

getReceivedMessageList

public java.util.List getReceivedMessageList()
Returns a List of all received messages.

Returns:
the List of messages

addSession

public void addSession(javax.jms.Session session)
Adds a Session.

Parameters:
session - the session

removeSession

public void removeSession(javax.jms.Session session)
Removes a Session.

Parameters:
session - the session

sessionSet

public java.util.Set sessionSet()
Return a Set of all sessions.

Returns:
a Set of all sessions

addReceivedMessage

protected void addReceivedMessage(javax.jms.Message message)

addCurrentMessage

protected void addCurrentMessage(javax.jms.Message message)

acknowledgeMessage

protected void acknowledgeMessage(javax.jms.Message message,
                                  MockSession session)
                           throws javax.jms.JMSException
Throws:
javax.jms.JMSException