|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.mockrunner.mock.jms.MockSession
public class MockSession
Mock implementation of JMS Session.
Please note that this implementation does not
implement transaction isolation at the moment.
Messages are immediately sent. If acknowledge
mode is AUTO_ACKNOWLEDGE or DUPS_OK_ACKNOWLEDGE,
the message will be automatically acknowledged,
otherwise, it will not be acknowledged. According
to JMS specification, the acknowledged mode must
be ignored for transacted sessions. This is currently
not implemented, i.e. transacted sessions behave like
sessions with acknowledge mode AUTO_ACKNOWLEDGE.
Messages are acknowledged even if the transaction is
rolled back. However, the framework keeps track if a
transaction is committed or rolled back, so you can test
this and rely on the container for the rest.
You can set a MessageListener directly to
the session. This is an application server internal feature
and not meant for application use in JMS.
This mock session dispatches any message of any
known Queue and Topic to the
distinguished MessageListener, if such
a MessageListener is registered.
| Field Summary |
|---|
| Fields inherited from interface javax.jms.Session |
|---|
AUTO_ACKNOWLEDGE, CLIENT_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE, SESSION_TRANSACTED |
| Constructor Summary | |
|---|---|
MockSession(MockConnection connection,
boolean transacted,
int acknowledgeMode)
|
|
| Method Summary | |
|---|---|
void |
addSessionToQueue(javax.jms.Queue queue)
|
void |
addSessionToTopic(javax.jms.Topic topic)
|
void |
close()
|
void |
commit()
|
javax.jms.QueueBrowser |
createBrowser(javax.jms.Queue queue)
|
javax.jms.QueueBrowser |
createBrowser(javax.jms.Queue queue,
java.lang.String messageSelector)
|
javax.jms.BytesMessage |
createBytesMessage()
|
javax.jms.MessageConsumer |
createConsumer(javax.jms.Destination destination)
|
javax.jms.MessageConsumer |
createConsumer(javax.jms.Destination destination,
java.lang.String messageSelector)
|
javax.jms.MessageConsumer |
createConsumer(javax.jms.Destination destination,
java.lang.String messageSelector,
boolean noLocal)
|
javax.jms.TopicSubscriber |
createDurableSubscriber(javax.jms.Topic topic,
java.lang.String name)
|
javax.jms.TopicSubscriber |
createDurableSubscriber(javax.jms.Topic topic,
java.lang.String name,
java.lang.String messageSelector,
boolean noLocal)
|
javax.jms.MapMessage |
createMapMessage()
|
javax.jms.Message |
createMessage()
|
javax.jms.ObjectMessage |
createObjectMessage()
|
javax.jms.ObjectMessage |
createObjectMessage(java.io.Serializable object)
|
javax.jms.MessageProducer |
createProducer(javax.jms.Destination destination)
|
protected javax.jms.MessageProducer |
createProducerForNullDestination()
|
javax.jms.Queue |
createQueue(java.lang.String name)
|
javax.jms.StreamMessage |
createStreamMessage()
|
javax.jms.TemporaryQueue |
createTemporaryQueue()
|
javax.jms.TemporaryTopic |
createTemporaryTopic()
|
javax.jms.TextMessage |
createTextMessage()
|
javax.jms.TextMessage |
createTextMessage(java.lang.String text)
|
javax.jms.Topic |
createTopic(java.lang.String name)
|
int |
getAcknowledgeMode()
Note: Returns 0 if the session is transacted. |
protected MockConnection |
getConnection()
|
GenericTransmissionManager |
getGenericTransmissionManager()
Returns the GenericTransmissionManager. |
javax.jms.MessageListener |
getMessageListener()
|
MessageManager |
getMessageManager()
Returns the MessageManager for this session. |
int |
getNumberCommits()
Returns the number of commits. |
int |
getNumberRollbacks()
Returns the number of rollbacks. |
QueueTransmissionManager |
getQueueTransmissionManager()
Returns the QueueTransmissionManager. |
MockTemporaryQueue |
getTemporaryQueue(int index)
Returns a TemporaryQueue by its index. |
java.util.List |
getTemporaryQueueList()
Returns the list of temporary queues. |
MockTemporaryTopic |
getTemporaryTopic(int index)
Returns a TemporaryTopic by its index. |
java.util.List |
getTemporaryTopicList()
Returns the list of temporary topics. |
TopicTransmissionManager |
getTopicTransmissionManager()
Returns the TopicTransmissionManager. |
boolean |
getTransacted()
|
TransmissionManagerWrapper |
getTransmissionManager()
Deprecated. use getTransmissionManagerWrapper() |
TransmissionManagerWrapper |
getTransmissionManagerWrapper()
Returns the TransmissionManagerWrapper. |
boolean |
isAutoAcknowledge()
Returns if messages should be automatically acknowledged, i.e. if the acknowledge mode is not CLIENT_ACKNOWLEDGE. |
boolean |
isClosed()
Returns if this session was closed. |
boolean |
isCommitted()
Returns if the current transaction was committed. |
boolean |
isRecovered()
Returns if this session was recovered. |
boolean |
isRolledBack()
Returns if the current transaction was rolled back. |
void |
recover()
|
void |
rollback()
|
void |
run()
|
void |
setMessageListener(javax.jms.MessageListener messageListener)
|
void |
unsubscribe(java.lang.String name)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MockSession(MockConnection connection,
boolean transacted,
int acknowledgeMode)
| Method Detail |
|---|
public QueueTransmissionManager getQueueTransmissionManager()
QueueTransmissionManager.
QueueTransmissionManagerpublic TopicTransmissionManager getTopicTransmissionManager()
TopicTransmissionManager.
TopicTransmissionManagerpublic GenericTransmissionManager getGenericTransmissionManager()
GenericTransmissionManager.
GenericTransmissionManagerpublic TransmissionManagerWrapper getTransmissionManager()
getTransmissionManagerWrapper()
public TransmissionManagerWrapper getTransmissionManagerWrapper()
TransmissionManagerWrapper.
TransmissionManagerWrapperpublic MessageManager getMessageManager()
MessageManager for this session.
MessageManagerpublic java.util.List getTemporaryQueueList()
TemporaryQueue listpublic MockTemporaryQueue getTemporaryQueue(int index)
TemporaryQueue by its index. The
index represent the number of the queue. Returns null
if no such TemporaryQueue is present.
index - the index
TemporaryQueuepublic java.util.List getTemporaryTopicList()
TemporaryTopic listpublic MockTemporaryTopic getTemporaryTopic(int index)
TemporaryTopic by its index. The
index represent the number of the topic. Returns null
if no such TemporaryTopic is present.
index - the index
TemporaryTopicpublic boolean isClosed()
true if this session is closedpublic boolean isRecovered()
true if this session was recoveredpublic boolean isCommitted()
true if the transaction was committedpublic int getNumberCommits()
public boolean isRolledBack()
true if the transaction was rolled backpublic int getNumberRollbacks()
public boolean isAutoAcknowledge()
CLIENT_ACKNOWLEDGE.
true if messages are automatically acknowledged
public int getAcknowledgeMode()
throws javax.jms.JMSException
0 if the session is transacted.
This method does not exist in JMS 1.0.2. In JMS 1.1 it
should return Session.SESSION_TRANSACTED
which is specified as 0. In order to avoid
different versions for JMS 1.0.2 and 1.1
(Session.SESSION_TRANSACTED does not
exist in 1.0.2) this method returns hardcoded 0,
if the session is transacted.
getAcknowledgeMode in interface javax.jms.Sessionjavax.jms.JMSException
public boolean getTransacted()
throws javax.jms.JMSException
getTransacted in interface javax.jms.Sessionjavax.jms.JMSException
public javax.jms.BytesMessage createBytesMessage()
throws javax.jms.JMSException
createBytesMessage in interface javax.jms.Sessionjavax.jms.JMSException
public javax.jms.MapMessage createMapMessage()
throws javax.jms.JMSException
createMapMessage in interface javax.jms.Sessionjavax.jms.JMSException
public javax.jms.Message createMessage()
throws javax.jms.JMSException
createMessage in interface javax.jms.Sessionjavax.jms.JMSException
public javax.jms.ObjectMessage createObjectMessage()
throws javax.jms.JMSException
createObjectMessage in interface javax.jms.Sessionjavax.jms.JMSException
public javax.jms.ObjectMessage createObjectMessage(java.io.Serializable object)
throws javax.jms.JMSException
createObjectMessage in interface javax.jms.Sessionjavax.jms.JMSException
public javax.jms.StreamMessage createStreamMessage()
throws javax.jms.JMSException
createStreamMessage in interface javax.jms.Sessionjavax.jms.JMSException
public javax.jms.TextMessage createTextMessage()
throws javax.jms.JMSException
createTextMessage in interface javax.jms.Sessionjavax.jms.JMSException
public javax.jms.TextMessage createTextMessage(java.lang.String text)
throws javax.jms.JMSException
createTextMessage in interface javax.jms.Sessionjavax.jms.JMSException
public javax.jms.MessageListener getMessageListener()
throws javax.jms.JMSException
getMessageListener in interface javax.jms.Sessionjavax.jms.JMSException
public void setMessageListener(javax.jms.MessageListener messageListener)
throws javax.jms.JMSException
setMessageListener in interface javax.jms.Sessionjavax.jms.JMSExceptionpublic void run()
run in interface java.lang.Runnablerun in interface javax.jms.Session
public void commit()
throws javax.jms.JMSException
commit in interface javax.jms.Sessionjavax.jms.JMSException
public void rollback()
throws javax.jms.JMSException
rollback in interface javax.jms.Sessionjavax.jms.JMSException
public void close()
throws javax.jms.JMSException
close in interface javax.jms.Sessionjavax.jms.JMSException
public void recover()
throws javax.jms.JMSException
recover in interface javax.jms.Sessionjavax.jms.JMSException
public void unsubscribe(java.lang.String name)
throws javax.jms.JMSException
unsubscribe in interface javax.jms.Sessionjavax.jms.JMSException
public javax.jms.Queue createQueue(java.lang.String name)
throws javax.jms.JMSException
createQueue in interface javax.jms.Sessionjavax.jms.JMSException
public javax.jms.TemporaryQueue createTemporaryQueue()
throws javax.jms.JMSException
createTemporaryQueue in interface javax.jms.Sessionjavax.jms.JMSException
public javax.jms.Topic createTopic(java.lang.String name)
throws javax.jms.JMSException
createTopic in interface javax.jms.Sessionjavax.jms.JMSException
public javax.jms.TemporaryTopic createTemporaryTopic()
throws javax.jms.JMSException
createTemporaryTopic in interface javax.jms.Sessionjavax.jms.JMSException
public javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination)
throws javax.jms.JMSException
createConsumer in interface javax.jms.Sessionjavax.jms.JMSException
public javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination,
java.lang.String messageSelector)
throws javax.jms.JMSException
createConsumer in interface javax.jms.Sessionjavax.jms.JMSException
public javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination,
java.lang.String messageSelector,
boolean noLocal)
throws javax.jms.JMSException
createConsumer in interface javax.jms.Sessionjavax.jms.JMSException
public javax.jms.MessageProducer createProducer(javax.jms.Destination destination)
throws javax.jms.JMSException
createProducer in interface javax.jms.Sessionjavax.jms.JMSException
public javax.jms.QueueBrowser createBrowser(javax.jms.Queue queue)
throws javax.jms.JMSException
createBrowser in interface javax.jms.Sessionjavax.jms.JMSException
public javax.jms.QueueBrowser createBrowser(javax.jms.Queue queue,
java.lang.String messageSelector)
throws javax.jms.JMSException
createBrowser in interface javax.jms.Sessionjavax.jms.JMSException
public javax.jms.TopicSubscriber createDurableSubscriber(javax.jms.Topic topic,
java.lang.String name)
throws javax.jms.JMSException
createDurableSubscriber in interface javax.jms.Sessionjavax.jms.JMSException
public javax.jms.TopicSubscriber createDurableSubscriber(javax.jms.Topic topic,
java.lang.String name,
java.lang.String messageSelector,
boolean noLocal)
throws javax.jms.JMSException
createDurableSubscriber in interface javax.jms.Sessionjavax.jms.JMSExceptionprotected MockConnection getConnection()
public void addSessionToQueue(javax.jms.Queue queue)
public void addSessionToTopic(javax.jms.Topic topic)
protected javax.jms.MessageProducer createProducerForNullDestination()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||