001 package com.mockrunner.jms;
002
003 import java.util.Iterator;
004 import java.util.List;
005
006 import javax.jms.JMSException;
007 import javax.jms.MessageConsumer;
008 import javax.jms.MessageListener;
009 import javax.jms.Queue;
010 import javax.jms.Session;
011 import javax.jms.Topic;
012
013 import com.mockrunner.base.NestedApplicationException;
014 import com.mockrunner.base.VerifyFailedException;
015 import com.mockrunner.mock.jms.JMSMockObjectFactory;
016 import com.mockrunner.mock.jms.MockConnection;
017 import com.mockrunner.mock.jms.MockMessage;
018 import com.mockrunner.mock.jms.MockMessageConsumer;
019 import com.mockrunner.mock.jms.MockMessageProducer;
020 import com.mockrunner.mock.jms.MockQueue;
021 import com.mockrunner.mock.jms.MockQueueBrowser;
022 import com.mockrunner.mock.jms.MockQueueConnection;
023 import com.mockrunner.mock.jms.MockQueueConnectionFactory;
024 import com.mockrunner.mock.jms.MockQueueReceiver;
025 import com.mockrunner.mock.jms.MockQueueSender;
026 import com.mockrunner.mock.jms.MockQueueSession;
027 import com.mockrunner.mock.jms.MockSession;
028 import com.mockrunner.mock.jms.MockTemporaryQueue;
029 import com.mockrunner.mock.jms.MockTemporaryTopic;
030 import com.mockrunner.mock.jms.MockTopic;
031 import com.mockrunner.mock.jms.MockTopicConnection;
032 import com.mockrunner.mock.jms.MockTopicConnectionFactory;
033 import com.mockrunner.mock.jms.MockTopicPublisher;
034 import com.mockrunner.mock.jms.MockTopicSession;
035 import com.mockrunner.mock.jms.MockTopicSubscriber;
036
037 /**
038 * Module for JMS tests.
039 * Note that all indices are zero based.<br>
040 * Note for JMS 1.1:
041 * If you use {@link MockQueueConnectionFactory} for creating your
042 * connections and sessions, you have to use the methods with <code>Queue</code>
043 * in their name. Same with {@link MockTopicConnectionFactory}.
044 * The methods without <code>Queue</code> and <code>Topic</code>
045 * in the method name are for connections and sessions that were
046 * created using the {@link com.mockrunner.mock.jms.MockConnectionFactory}.
047 * {@link com.mockrunner.mock.jms.MockConnectionFactory}
048 * also implements the <code>QueueConnectionFactory</code> and
049 * <code>TopicConnectionFactory</code> interfaces and can be used to create
050 * queue and topic connections as well as generic JMS 1.1 connections.
051 * It is recommended to use {@link com.mockrunner.mock.jms.MockQueueConnectionFactory}
052 * if you only use queues and {@link com.mockrunner.mock.jms.MockTopicConnectionFactory}
053 * if you only use topics and are not interested in having one factory for both.
054 * It is possible to create a {@link MockQueueConnection} or a {@link MockTopicConnection}
055 * using the {@link com.mockrunner.mock.jms.MockConnectionFactory}.
056 * However, the <code>Queue</code> methods (e.g. {@link #verifyAllQueueReceiversClosed})
057 * only work, if you use {@link MockQueueConnectionFactory} and the
058 * <code>Topic</code> methods (e.g. {@link #verifyCreatedTopicMapMessageNotAcknowledged})
059 * only work, if you use {@link MockTopicConnectionFactory}.
060 */
061 public class JMSTestModule
062 {
063 private JMSMockObjectFactory mockFactory;
064 private int currentQueueConnectionIndex;
065 private int currentTopicConnectionIndex;
066 private int currentConnectionIndex;
067
068 public JMSTestModule(JMSMockObjectFactory mockFactory)
069 {
070 this.mockFactory = mockFactory;
071 currentQueueConnectionIndex = -1;
072 currentTopicConnectionIndex = -1;
073 currentConnectionIndex = -1;
074 }
075
076 /**
077 * Sets the index of the {@link MockQueueConnection} that should be used
078 * for the current test. Per default the latest created connection
079 * is used.
080 * @param connectionIndex the index of the connection
081 */
082 public void setCurrentQueueConnectionIndex(int connectionIndex)
083 {
084 this.currentQueueConnectionIndex = connectionIndex;
085 }
086
087 /**
088 * Returns the current {@link MockQueueConnection} based on its
089 * index or <code>null</code> if no queue connection
090 * was created. The connection has to be created using the
091 * {@link MockQueueConnectionFactory}.
092 * @return the queue connection
093 */
094 public MockQueueConnection getCurrentQueueConnection()
095 {
096 if(0 > currentQueueConnectionIndex)
097 {
098 return mockFactory.getMockQueueConnectionFactory().getLatestQueueConnection();
099 }
100 return mockFactory.getMockQueueConnectionFactory().getQueueConnection(currentQueueConnectionIndex);
101 }
102
103 /**
104 * Sets the index of the {@link MockTopicConnection} that should be used
105 * for the current test. Per default the latest created connection
106 * is used.
107 * @param connectionIndex the index of the connection
108 */
109 public void setCurrentTopicConnectionIndex(int connectionIndex)
110 {
111 this.currentTopicConnectionIndex = connectionIndex;
112 }
113
114 /**
115 * Returns the current {@link MockTopicConnection} based on its
116 * index or <code>null</code> if no topic connection
117 * was created. The connection has to be created using the
118 * {@link MockTopicConnectionFactory}.
119 * @return the topic connection
120 */
121 public MockTopicConnection getCurrentTopicConnection()
122 {
123 if(0 > currentTopicConnectionIndex)
124 {
125 return mockFactory.getMockTopicConnectionFactory().getLatestTopicConnection();
126 }
127 return mockFactory.getMockTopicConnectionFactory().getTopicConnection(currentTopicConnectionIndex);
128 }
129
130 /**
131 * Sets the index of the {@link MockConnection} that should be used
132 * for the current test. Per default the latest created connection
133 * is used.
134 * @param connectionIndex the index of the connection
135 */
136 public void setCurrentConnectionIndex(int connectionIndex)
137 {
138 this.currentConnectionIndex = connectionIndex;
139 }
140
141 /**
142 * Returns the current {@link MockConnection} based on its
143 * index or <code>null</code> if no connection
144 * was created. The connection has to be created using the
145 * {@link com.mockrunner.mock.jms.MockConnectionFactory}.
146 * @return the topic connection
147 */
148 public MockConnection getCurrentConnection()
149 {
150 if(0 > currentConnectionIndex)
151 {
152 return mockFactory.getMockConnectionFactory().getLatestConnection();
153 }
154 return mockFactory.getMockConnectionFactory().getConnection(currentConnectionIndex);
155 }
156
157 /**
158 * Creates a new connection and uses it for creating a new session and receiver.
159 * Registers the specified listener. Starts the connection for message
160 * receiving. This method is useful for creating test listeners when
161 * testing senders. It can be used to register message driven beans.
162 * Note that the created connection is the latest created
163 * connection and automatically becomes the default connection for the
164 * test module. The created session is transacted.
165 * This method uses the {@link MockQueueConnectionFactory} for
166 * creating the connection and the session. If you want to use the
167 * {@link com.mockrunner.mock.jms.MockConnectionFactory} you have to create the connection on your own
168 * and call {@link #registerTestMessageListenerForQueue(MockConnection, String, MessageListener)}.
169 * @param queueName the name of the queue used for message receiving
170 * @param listener the listener that should be registered
171 */
172 public void registerTestMessageListenerForQueue(String queueName, MessageListener listener)
173 {
174 try
175 {
176 MockQueueConnectionFactory factory = mockFactory.getMockQueueConnectionFactory();
177 MockQueueConnection connection = (MockQueueConnection)factory.createQueueConnection();
178 registerTestMessageListenerForQueue(connection, queueName, listener);
179 }
180 catch(JMSException exc)
181 {
182 throw new NestedApplicationException(exc);
183 }
184 }
185
186 /**
187 * Creates a new session and receiver using the specified connection and
188 * registers the specified listener. Starts the connection for message
189 * receiving. This method is useful for creating test listeners when
190 * testing senders. It can be used to register message driven beans.
191 * The created session is transacted.
192 * @param connection the connection used for creating the session
193 * @param queueName the name of the queue used for message receiving
194 * @param listener the listener that should be registered
195 */
196 public void registerTestMessageListenerForQueue(MockConnection connection, String queueName, MessageListener listener)
197 {
198 registerTestMessageListenerForQueue(connection, queueName, true, Session.AUTO_ACKNOWLEDGE, listener);
199 }
200
201 /**
202 * Creates a new session and receiver using the specified connection and
203 * registers the specified listener. Starts the connection for message
204 * receiving. This method is useful for creating test listeners when
205 * testing senders. It can be used to register message driven beans.
206 * @param connection the connection used for creating the session
207 * @param queueName the name of the queue used for message receiving
208 * @param transacted should the created session be transacted
209 * @param acknowledgeMode the acknowledge mode of the created session
210 * @param listener the listener that should be registered
211 */
212 public void registerTestMessageListenerForQueue(MockConnection connection, String queueName, boolean transacted, int acknowledgeMode, MessageListener listener)
213 {
214 registerTestMessageListenerForQueue(connection, queueName, transacted, acknowledgeMode, null, listener);
215 }
216
217 /**
218 * Creates a new session and receiver using the specified connection and
219 * registers the specified listener. Starts the connection for message
220 * receiving. This method is useful for creating test listeners when
221 * testing senders. It can be used to register message driven beans.
222 * @param connection the connection used for creating the session
223 * @param queueName the name of the queue used for message receiving
224 * @param transacted should the created session be transacted
225 * @param acknowledgeMode the acknowledge mode of the created session
226 * @param messageSelector the message selector
227 * @param listener the listener that should be registered
228 */
229 public void registerTestMessageListenerForQueue(MockConnection connection, String queueName, boolean transacted, int acknowledgeMode, String messageSelector, MessageListener listener)
230 {
231 try
232 {
233 Queue queue = getDestinationManager().getQueue(queueName);
234 MockSession session = (MockSession)connection.createSession(transacted, acknowledgeMode);
235 MessageConsumer consumer = session.createConsumer(queue, messageSelector);
236 consumer.setMessageListener(listener);
237 connection.start();
238 }
239 catch(JMSException exc)
240 {
241 throw new NestedApplicationException(exc);
242 }
243 }
244
245 /**
246 * Creates a new connection and uses it for creating a new session and subscriber.
247 * Registers the specified listener. Starts the connection for message
248 * receiving. This method is useful for creating test listeners when
249 * testing publishers. It can be used to resgister message driven beans.
250 * Note that the created connection is the latest created
251 * connection and automatically becomes the default connection for the
252 * test module. The created session is transacted.
253 * This method uses the {@link MockTopicConnectionFactory} for
254 * creating the connection and the session. If you want to use the
255 * {@link com.mockrunner.mock.jms.MockConnectionFactory} you have to create the connection on your own
256 * and call {@link #registerTestMessageListenerForTopic(MockConnection, String, MessageListener)}.
257 * @param topicName the name of the topic used for message receiving
258 * @param listener the listener that should be registered
259 */
260 public void registerTestMessageListenerForTopic(String topicName, MessageListener listener)
261 {
262 try
263 {
264 MockTopicConnectionFactory factory = mockFactory.getMockTopicConnectionFactory();
265 MockTopicConnection connection = (MockTopicConnection)factory.createTopicConnection();
266 registerTestMessageListenerForTopic(connection, topicName, listener);
267 }
268 catch(JMSException exc)
269 {
270 throw new NestedApplicationException(exc);
271 }
272 }
273
274 /**
275 * Creates a new session and subscriber using the specified connection and
276 * registers the specified listener. Starts the connection for message
277 * receiving. This method is useful for creating test listeners when
278 * testing publishers. It can be used to resgister message driven beans.
279 * The created session is transacted.
280 * @param connection the connection used for creating the session
281 * @param topicName the name of the topic used for message receiving
282 * @param listener the listener that should be registered
283 */
284 public void registerTestMessageListenerForTopic(MockConnection connection, String topicName, MessageListener listener)
285 {
286 registerTestMessageListenerForTopic(connection, topicName, true, Session.AUTO_ACKNOWLEDGE, listener);
287 }
288
289 /**
290 * Creates a new session and subscriber using the specified connection and
291 * registers the specified listener. Starts the connection for message
292 * receiving. This method is useful for creating test listeners when
293 * testing publishers. It can be used to resgister message driven beans.
294 * @param connection the connection used for creating the session
295 * @param topicName the name of the topic used for message receiving
296 * @param transacted should the created session be transacted
297 * @param acknowledgeMode the acknowledge mode of the created session
298 * @param listener the listener that should be registered
299 */
300 public void registerTestMessageListenerForTopic(MockConnection connection, String topicName, boolean transacted, int acknowledgeMode, MessageListener listener)
301 {
302 registerTestMessageListenerForTopic(connection, topicName, transacted, acknowledgeMode, null, listener);
303 }
304
305 /**
306 * Creates a new session and subscriber using the specified connection and
307 * registers the specified listener. Starts the connection for message
308 * receiving. This method is useful for creating test listeners when
309 * testing publishers. It can be used to resgister message driven beans.
310 * @param connection the connection used for creating the session
311 * @param topicName the name of the topic used for message receiving
312 * @param transacted should the created session be transacted
313 * @param acknowledgeMode the acknowledge mode of the created session
314 * @param messageSelector the message selector
315 * @param listener the listener that should be registered
316 */
317 public void registerTestMessageListenerForTopic(MockConnection connection, String topicName, boolean transacted, int acknowledgeMode, String messageSelector, MessageListener listener)
318 {
319 try
320 {
321 Topic topic = getDestinationManager().getTopic(topicName);
322 MockSession session = (MockSession)connection.createSession(transacted, acknowledgeMode);
323 MessageConsumer consumer = session.createConsumer(topic, messageSelector);
324 consumer.setMessageListener(listener);
325 connection.start();
326 }
327 catch(JMSException exc)
328 {
329 throw new NestedApplicationException(exc);
330 }
331 }
332
333 /**
334 * Returns the {@link DestinationManager}.
335 * @return the {@link DestinationManager}
336 */
337 public DestinationManager getDestinationManager()
338 {
339 return mockFactory.getDestinationManager();
340 }
341
342 /**
343 * Returns the {@link ConfigurationManager}.
344 * @return the {@link ConfigurationManager}
345 */
346 public ConfigurationManager getConfigurationManager()
347 {
348 return mockFactory.getConfigurationManager();
349 }
350
351 /**
352 * Returns the {@link MessageManager} for the specified session
353 * or <code>null</code> if the session does not exist. The returned
354 * {@link MessageManager} is used to keep track of messages sent
355 * to queues.
356 * The session has to be created using the current {@link MockQueueConnection}.
357 * @param indexOfSession the index of the session
358 * @return the {@link MessageManager}
359 */
360 public MessageManager getQueueMessageManager(int indexOfSession)
361 {
362 MockQueueSession session = getQueueSession(indexOfSession);
363 if(null == session) return null;
364 return session.getMessageManager();
365 }
366
367 /**
368 * Returns the {@link MessageManager} for the specified session
369 * or <code>null</code> if the session does not exist. The returned
370 * {@link MessageManager} is used to keep track of messages sent
371 * to topics.
372 * The session has to be created using the current {@link MockTopicConnection}.
373 * @param indexOfSession the index of the session
374 * @return the {@link MessageManager}
375 */
376 public MessageManager getTopicMessageManager(int indexOfSession)
377 {
378 MockTopicSession session = getTopicSession(indexOfSession);
379 if(null == session) return null;
380 return session.getMessageManager();
381 }
382
383 /**
384 * Returns the {@link MessageManager} for the specified session
385 * or <code>null</code> if the session does not exist. The returned
386 * {@link MessageManager} is used to keep track of messages sent
387 * to topics.
388 * The session has to be created using the current {@link MockConnection}.
389 * @param indexOfSession the index of the session
390 * @return the {@link MessageManager}
391 */
392 public MessageManager getMessageManager(int indexOfSession)
393 {
394 MockSession session = getSession(indexOfSession);
395 if(null == session) return null;
396 return session.getMessageManager();
397 }
398
399 /**
400 * Returns the {@link QueueTransmissionManager} for the specified session
401 * or <code>null</code> if the session does not exist.
402 * The session has to be created using the current {@link MockQueueConnection}.
403 * @param indexOfSession the index of the session
404 * @return the {@link QueueTransmissionManager}
405 */
406 public QueueTransmissionManager getQueueTransmissionManager(int indexOfSession)
407 {
408 MockQueueSession session = getQueueSession(indexOfSession);
409 if(null == session) return null;
410 return session.getQueueTransmissionManager();
411 }
412
413 /**
414 * Returns the {@link TopicTransmissionManager} for the specified session
415 * or <code>null</code> if the session does not exist.
416 * The session has to be created using the current {@link MockTopicConnection}.
417 * @param indexOfSession the index of the session
418 * @return the {@link TopicTransmissionManager}
419 */
420 public TopicTransmissionManager getTopicTransmissionManager(int indexOfSession)
421 {
422 MockTopicSession session = getTopicSession(indexOfSession);
423 if(null == session) return null;
424 return session.getTopicTransmissionManager();
425 }
426
427 /**
428 * @deprecated use {@link #getTransmissionManagerWrapper}
429 */
430 public TransmissionManagerWrapper getTransmissionManager(int indexOfSession)
431 {
432 return getTransmissionManagerWrapper(indexOfSession);
433 }
434
435 /**
436 * Returns the {@link TransmissionManagerWrapper} for the specified session
437 * or <code>null</code> if the session does not exist.
438 * The session has to be created using the current {@link MockConnection}.
439 * @param indexOfSession the index of the session
440 * @return the {@link TransmissionManagerWrapper}
441 */
442 public TransmissionManagerWrapper getTransmissionManagerWrapper(int indexOfSession)
443 {
444 MockSession session = getSession(indexOfSession);
445 if(null == session) return null;
446 return session.getTransmissionManagerWrapper();
447 }
448
449 /**
450 * Returns the {@link TransmissionManagerWrapper} for the specified session
451 * or <code>null</code> if the session does not exist.
452 * The session has to be created using the current {@link MockQueueConnection}.
453 * @param indexOfSession the index of the session
454 * @return the {@link TransmissionManagerWrapper}
455 */
456 public TransmissionManagerWrapper getQueueTransmissionManagerWrapper(int indexOfSession)
457 {
458 MockQueueSession session = getQueueSession(indexOfSession);
459 if(null == session) return null;
460 return session.getTransmissionManagerWrapper();
461 }
462
463 /**
464 * Returns the {@link TransmissionManagerWrapper} for the specified session
465 * or <code>null</code> if the session does not exist.
466 * The session has to be created using the current {@link MockTopicConnection}.
467 * @param indexOfSession the index of the session
468 * @return the {@link TransmissionManagerWrapper}
469 */
470 public TransmissionManagerWrapper getTopicTransmissionManagerWrapper(int indexOfSession)
471 {
472 MockTopicSession session = getTopicSession(indexOfSession);
473 if(null == session) return null;
474 return session.getTransmissionManagerWrapper();
475 }
476
477 /**
478 * Returns the list of {@link MockQueueSession} objects.
479 * The sessions have been created using the current {@link MockQueueConnection}.
480 * @return the {@link MockQueueSession} list
481 */
482 public List getQueueSessionList()
483 {
484 if(null == getCurrentQueueConnection()) return null;
485 return getCurrentQueueConnection().getQueueSessionList();
486 }
487
488 /**
489 * Returns the list of {@link MockTopicSession} objects.
490 * The sessions have been created using the current {@link MockTopicConnection}.
491 * @return the {@link MockTopicSession} list
492 */
493 public List getTopicSessionList()
494 {
495 if(null == getCurrentTopicConnection()) return null;
496 return getCurrentTopicConnection().getTopicSessionList();
497 }
498
499 /**
500 * Returns the list of {@link MockSession} objects.
501 * The sessions have been created using the current {@link MockConnection}.
502 * @return the {@link MockSession} list
503 */
504 public List getSessionList()
505 {
506 if(null == getCurrentConnection()) return null;
507 return getCurrentConnection().getSessionList();
508 }
509
510 /**
511 * Returns the {@link MockQueueSession} for the specified index
512 * or <code>null</code> if the session does not exist.
513 * The session has to be created using the current {@link MockQueueConnection}.
514 * @param indexOfSession the index of the session
515 * @return the {@link MockQueueSession}
516 */
517 public MockQueueSession getQueueSession(int indexOfSession)
518 {
519 if(null == getCurrentQueueConnection()) return null;
520 return getCurrentQueueConnection().getQueueSession(indexOfSession);
521 }
522
523 /**
524 * Returns the {@link MockTopicSession} for the specified index
525 * or <code>null</code> if the session does not exist.
526 * The session has to be created using the current {@link MockTopicConnection}.
527 * @param indexOfSession the index of the session
528 * @return the {@link MockTopicSession}
529 */
530 public MockTopicSession getTopicSession(int indexOfSession)
531 {
532 if(null == getCurrentTopicConnection()) return null;
533 return getCurrentTopicConnection().getTopicSession(indexOfSession);
534 }
535
536 /**
537 * Returns the {@link MockSession} for the specified index
538 * or <code>null</code> if the session does not exist.
539 * The session has to be created using the current {@link MockConnection}.
540 * @param indexOfSession the index of the session
541 * @return the {@link MockSession}
542 */
543 public MockSession getSession(int indexOfSession)
544 {
545 if(null == getCurrentConnection()) return null;
546 return getCurrentConnection().getSession(indexOfSession);
547 }
548
549 /**
550 * Returns the {@link MockQueue} with the specified name
551 * or <code>null</code> if no such queue exists.
552 * @param name the name of the queue
553 * @return the {@link MockQueue}
554 */
555 public MockQueue getQueue(String name)
556 {
557 return getDestinationManager().getQueue(name);
558 }
559
560 /**
561 * Returns the {@link MockTopic} with the specified name
562 * or <code>null</code> if no such topic exists.
563 * @param name the name of the topic
564 * @return the {@link MockTopic}
565 */
566 public MockTopic getTopic(String name)
567 {
568 return getDestinationManager().getTopic(name);
569 }
570
571 /**
572 * Returns the list of {@link MockTemporaryQueue} objects
573 * for the specified session. The session has to be created using
574 * the current {@link MockQueueConnection}.
575 * @param indexOfSession the index of the session
576 * @return the {@link MockTemporaryQueue} list
577 */
578 public List getTemporaryQueueList(int indexOfSession)
579 {
580 MockQueueSession session = getQueueSession(indexOfSession);
581 if(null == session) return null;
582 return session.getTemporaryQueueList();
583 }
584
585 /**
586 * Returns the list of {@link MockTemporaryTopic} objects
587 * for the specified session. The session has to be created using
588 * the current {@link MockTopicConnection}.
589 * @param indexOfSession the index of the session
590 * @return the {@link MockTemporaryTopic} list
591 */
592 public List getTemporaryTopicList(int indexOfSession)
593 {
594 MockTopicSession session = getTopicSession(indexOfSession);
595 if(null == session) return null;
596 return session.getTemporaryTopicList();
597 }
598
599 /**
600 * Returns the {@link MockTemporaryQueue} with the specified index
601 * for the specified session. Returns <code>null</code> if no such
602 * temporary queue exists. The session has to be created using
603 * the current {@link MockQueueConnection}.
604 * @param indexOfSession the index of the session
605 * @param indexOfQueue the index of the temporary queue
606 * @return the {@link MockTemporaryQueue}
607 */
608 public MockTemporaryQueue getTemporaryQueue(int indexOfSession, int indexOfQueue)
609 {
610 MockQueueSession session = getQueueSession(indexOfSession);
611 if(null == session) return null;
612 return session.getTemporaryQueue(indexOfQueue);
613 }
614
615 /**
616 * Returns the {@link MockTemporaryTopic} with the specified index
617 * for the specified session. Returns <code>null</code> if no such
618 * temporary queue exists. The session has to be created using
619 * the current {@link MockTopicConnection}.
620 * @param indexOfSession the index of the session
621 * @param indexOfTopic the index of the temporary queue
622 * @return the {@link MockTemporaryTopic}
623 */
624 public MockTemporaryTopic getTemporaryTopic(int indexOfSession, int indexOfTopic)
625 {
626 MockTopicSession session = getTopicSession(indexOfSession);
627 if(null == session) return null;
628 return session.getTemporaryTopic(indexOfTopic);
629 }
630
631 /**
632 * Returns the list of messages that are currently present in the queue
633 * or <code>null</code> if no such queue exists.
634 * @param name the name of the queue
635 * @return the list of messages
636 */
637 public List getCurrentMessageListFromQueue(String name)
638 {
639 MockQueue queue = getQueue(name);
640 if(null == queue) return null;
641 return queue.getCurrentMessageList();
642 }
643
644 /**
645 * Returns the list of messages that are currently present in the
646 * temporary queue or <code>null</code> if no such queue exists.
647 * The session has to be created using the current {@link MockQueueConnection}.
648 * @param indexOfSession the index of the session
649 * @param indexOfQueue the index of the temporary queue
650 * @return the list of messages
651 */
652 public List getCurrentMessageListFromTemporaryQueue(int indexOfSession, int indexOfQueue)
653 {
654 MockTemporaryQueue queue = getTemporaryQueue(indexOfSession, indexOfQueue);
655 if(null == queue) return null;
656 return queue.getCurrentMessageList();
657 }
658
659 /**
660 * Returns the list of messages that were received by the queue
661 * or <code>null</code> if no such queue exists.
662 * @param name the name of the queue
663 * @return the list of messages
664 */
665 public List getReceivedMessageListFromQueue(String name)
666 {
667 MockQueue queue = getQueue(name);
668 if(null == queue) return null;
669 return queue.getReceivedMessageList();
670 }
671
672 /**
673 * Returns the list of messages that were received by the
674 * temporary queue or <code>null</code> if no such queue exists.
675 * The session has to be created using the current {@link MockQueueConnection}.
676 * @param indexOfSession the index of the session
677 * @param indexOfQueue the index of the temporary queue
678 * @return the list of messages
679 */
680 public List getReceivedMessageListFromTemporaryQueue(int indexOfSession, int indexOfQueue)
681 {
682 MockTemporaryQueue queue = getTemporaryQueue(indexOfSession, indexOfQueue);
683 if(null == queue) return null;
684 return queue.getReceivedMessageList();
685 }
686
687 /**
688 * Returns the list of messages that are currently present in the topic
689 * or <code>null</code> if no such topic exists.
690 * @param name the name of the queue
691 * @return the list of messages
692 */
693 public List getCurrentMessageListFromTopic(String name)
694 {
695 MockTopic topic = getTopic(name);
696 if(null == topic) return null;
697 return topic.getCurrentMessageList();
698 }
699
700 /**
701 * Returns the list of messages that are currently present in the
702 * temporary topic or <code>null</code> if no such topic exists.
703 * The session has to be created using the current {@link MockTopicConnection}.
704 * @param indexOfSession the index of the session
705 * @param indexOfTopic the index of the temporary topic
706 * @return the list of messages
707 */
708 public List getCurrentMessageListFromTemporaryTopic(int indexOfSession, int indexOfTopic)
709 {
710 MockTemporaryTopic topic = getTemporaryTopic(indexOfSession, indexOfTopic);
711 if(null == topic) return null;
712 return topic.getCurrentMessageList();
713 }
714
715 /**
716 * Returns the list of messages that were received by the topic
717 * or <code>null</code> if no such topic exists.
718 * @param name the name of the topic
719 * @return the list of messages
720 */
721 public List getReceivedMessageListFromTopic(String name)
722 {
723 MockTopic topic = getTopic(name);
724 if(null == topic) return null;
725 return topic.getReceivedMessageList();
726 }
727
728 /**
729 * Returns the list of messages that were received by the
730 * temporary topic or <code>null</code> if no such topic exists.
731 * The session has to be created using the current {@link MockTopicConnection}.
732 * @param indexOfSession the index of the session
733 * @param indexOfTopic the index of the temporary topic
734 * @return the list of messages
735 */
736 public List getReceivedMessageListFromTemporaryTopic(int indexOfSession, int indexOfTopic)
737 {
738 MockTemporaryTopic topic = getTemporaryTopic(indexOfSession, indexOfTopic);
739 if(null == topic) return null;
740 return topic.getReceivedMessageList();
741 }
742
743 /**
744 * Verifies that the current {@link MockQueueConnection} is closed.
745 * The connection has to be created using the current {@link MockQueueConnectionFactory}.
746 * @throws VerifyFailedException if verification fails
747 */
748 public void verifyQueueConnectionClosed()
749 {
750 if(null == getCurrentQueueConnection())
751 {
752 throw new VerifyFailedException("No QueueConnection present.");
753 }
754 if(!getCurrentQueueConnection().isClosed())
755 {
756 throw new VerifyFailedException("QueueConnection is not closed.");
757 }
758 }
759
760 /**
761 * Verifies that the current {@link MockQueueConnection} is started.
762 * The connection has to be created using the current {@link MockQueueConnectionFactory}.
763 * @throws VerifyFailedException if verification fails
764 */
765 public void verifyQueueConnectionStarted()
766 {
767 if(null == getCurrentQueueConnection())
768 {
769 throw new VerifyFailedException("No QueueConnection present.");
770 }
771 if(!getCurrentQueueConnection().isStarted())
772 {
773 throw new VerifyFailedException("QueueConnection is not started.");
774 }
775 }
776
777 /**
778 * Verifies that the current {@link MockQueueConnection} is stopped.
779 * The connection has to be created using the current {@link MockQueueConnectionFactory}.
780 * @throws VerifyFailedException if verification fails
781 */
782 public void verifyQueueConnectionStopped()
783 {
784 if(null == getCurrentQueueConnection())
785 {
786 throw new VerifyFailedException("No QueueConnection present.");
787 }
788 if(!getCurrentQueueConnection().isStopped())
789 {
790 throw new VerifyFailedException("QueueConnection is not stopped.");
791 }
792 }
793
794 /**
795 * Verifies that the current {@link MockTopicConnection} is closed.
796 * The connection has to be created using the current {@link MockTopicConnectionFactory}.
797 * @throws VerifyFailedException if verification fails
798 */
799 public void verifyTopicConnectionClosed()
800 {
801 if(null == getCurrentTopicConnection())
802 {
803 throw new VerifyFailedException("No TopicConnection present.");
804 }
805 if(!getCurrentTopicConnection().isClosed())
806 {
807 throw new VerifyFailedException("TopicConnection is not closed.");
808 }
809 }
810
811 /**
812 * Verifies that the current {@link MockTopicConnection} is started.
813 * The connection has to be created using the current {@link MockTopicConnectionFactory}.
814 * @throws VerifyFailedException if verification fails
815 */
816 public void verifyTopicConnectionStarted()
817 {
818 if(null == getCurrentTopicConnection())
819 {
820 throw new VerifyFailedException("No TopicConnection present.");
821 }
822 if(!getCurrentTopicConnection().isStarted())
823 {
824 throw new VerifyFailedException("TopicConnection is not started.");
825 }
826 }
827
828 /**
829 * Verifies that the current {@link MockTopicConnection} is stopped.
830 * The connection has to be created using the current {@link MockTopicConnectionFactory}.
831 * @throws VerifyFailedException if verification fails
832 */
833 public void verifyTopicConnectionStopped()
834 {
835 if(null == getCurrentTopicConnection())
836 {
837 throw new VerifyFailedException("No TopicConnection present.");
838 }
839 if(!getCurrentTopicConnection().isStopped())
840 {
841 throw new VerifyFailedException("TopicConnection is not stopped.");
842 }
843 }
844
845 /**
846 * Verifies that the current {@link MockConnection} is closed.
847 * The connection has to be created using the current {@link com.mockrunner.mock.jms.MockConnectionFactory}.
848 * @throws VerifyFailedException if verification fails
849 */
850 public void verifyConnectionClosed()
851 {
852 if(null == getCurrentConnection())
853 {
854 throw new VerifyFailedException("No Connection present.");
855 }
856 if(!getCurrentConnection().isClosed())
857 {
858 throw new VerifyFailedException("Connection is not closed.");
859 }
860 }
861
862 /**
863 * Verifies that the current {@link MockConnection} is started.
864 * The connection has to be created using the current {@link com.mockrunner.mock.jms.MockConnectionFactory}.
865 * @throws VerifyFailedException if verification fails
866 */
867 public void verifyConnectionStarted()
868 {
869 if(null == getCurrentConnection())
870 {
871 throw new VerifyFailedException("No Connection present.");
872 }
873 if(!getCurrentConnection().isStarted())
874 {
875 throw new VerifyFailedException("Connection is not started.");
876 }
877 }
878
879 /**
880 * Verifies that the current {@link MockConnection} is stopped.
881 * The connection has to be created using the current {@link com.mockrunner.mock.jms.MockConnectionFactory}.
882 * @throws VerifyFailedException if verification fails
883 */
884 public void verifyConnectionStopped()
885 {
886 if(null == getCurrentConnection())
887 {
888 throw new VerifyFailedException("No Connection present.");
889 }
890 if(!getCurrentConnection().isStopped())
891 {
892 throw new VerifyFailedException("Connection is not stopped.");
893 }
894 }
895
896 /**
897 * Verifies that the queue session with the specified index is
898 * closed.
899 * The session has to be created using the current {@link MockQueueConnection}.
900 * @param indexOfSession the index of the session
901 * @throws VerifyFailedException if verification fails
902 */
903 public void verifyQueueSessionClosed(int indexOfSession)
904 {
905 MockQueueSession session = checkAndGetQueueSessionByIndex(indexOfSession);
906 if(!session.isClosed())
907 {
908 throw new VerifyFailedException("QueueSession with index " + indexOfSession + " is not closed.");
909 }
910 }
911
912 /**
913 * Verifies that the queue session with the specified index was
914 * committed.
915 * The session has to be created using the current {@link MockQueueConnection}.
916 * @param indexOfSession the index of the session
917 * @throws VerifyFailedException if verification fails
918 */
919 public void verifyQueueSessionCommitted(int indexOfSession)
920 {
921 MockQueueSession session = checkAndGetQueueSessionByIndex(indexOfSession);
922 if(!session.isCommitted())
923 {
924 throw new VerifyFailedException("QueueSession is not committed.");
925 }
926 }
927
928 /**
929 * Verifies that the queue session with the specified index was
930 * not committed.
931 * The session has to be created using the current {@link MockQueueConnection}.
932 * @param indexOfSession the index of the session
933 * @throws VerifyFailedException if verification fails
934 */
935 public void verifyQueueSessionNotCommitted(int indexOfSession)
936 {
937 MockQueueSession session = checkAndGetQueueSessionByIndex(indexOfSession);
938 if(session.isCommitted())
939 {
940 throw new VerifyFailedException("QueueSession is committed.");
941 }
942 }
943
944 /**
945 * Verifies the number of commits of the queue session with the specified index.
946 * The session has to be created using the current {@link MockQueueConnection}.
947 * @param indexOfSession the index of the session
948 * @param numberOfCommits the expected number of commits
949 * @throws VerifyFailedException if verification fails
950 */
951 public void verifyQueueSessionNumberCommits(int indexOfSession, int numberOfCommits)
952 {
953 MockQueueSession session = checkAndGetQueueSessionByIndex(indexOfSession);
954 if(numberOfCommits != session.getNumberCommits())
955 {
956 throw new VerifyFailedException("QueueSession was commited " + session.getNumberCommits() + " times, expected " + numberOfCommits + " times");
957 }
958 }
959
960 /**
961 * Verifies that the queue session with the specified index was
962 * rolled back.
963 * The session has to be created using the current {@link MockQueueConnection}.
964 * @param indexOfSession the index of the session
965 * @throws VerifyFailedException if verification fails
966 */
967 public void verifyQueueSessionRolledBack(int indexOfSession)
968 {
969 MockQueueSession session = checkAndGetQueueSessionByIndex(indexOfSession);
970 if(!session.isRolledBack())
971 {
972 throw new VerifyFailedException("QueueSession is not rolled back.");
973 }
974 }
975
976 /**
977 * Verifies that the queue session with the specified index was
978 * not rolled back.
979 * The session has to be created using the current {@link MockQueueConnection}.
980 * @param indexOfSession the index of the session
981 * @throws VerifyFailedException if verification fails
982 */
983 public void verifyQueueSessionNotRolledBack(int indexOfSession)
984 {
985 MockQueueSession session = checkAndGetQueueSessionByIndex(indexOfSession);
986 if(session.isRolledBack())
987 {
988 throw new VerifyFailedException("QueueSession is rolled back.");
989 }
990 }
991
992 /**
993 * Verifies the number of rollbacks of the queue session with the specified index.
994 * The session has to be created using the current {@link MockQueueConnection}.
995 * @param indexOfSession the index of the session
996 * @param numberOfRollbacks the expected number of rollbacks
997 * @throws VerifyFailedException if verification fails
998 */
999 public void verifyQueueSessionNumberRollbacks(int indexOfSession, int numberOfRollbacks)
1000 {
1001 MockQueueSession session = checkAndGetQueueSessionByIndex(indexOfSession);
1002 if(numberOfRollbacks != session.getNumberRollbacks())
1003 {
1004 throw new VerifyFailedException("QueueSession was rolled back " + session.getNumberRollbacks() + " times, expected " + numberOfRollbacks + " times");
1005 }
1006 }
1007
1008 /**
1009 * Verifies that the queue session with the specified index was
1010 * recovered.
1011 * The session has to be created using the current {@link MockQueueConnection}.
1012 * @param indexOfSession the index of the session
1013 * @throws VerifyFailedException if verification fails
1014 */
1015 public void verifyQueueSessionRecovered(int indexOfSession)
1016 {
1017 MockQueueSession session = checkAndGetQueueSessionByIndex(indexOfSession);
1018 if(!session.isRecovered())
1019 {
1020 throw new VerifyFailedException("QueueSession is not recovered.");
1021 }
1022 }
1023
1024 /**
1025 * Verifies that the queue session with the specified index was
1026 * not recovered.
1027 * The session has to be created using the current {@link MockQueueConnection}.
1028 * @param indexOfSession the index of the session
1029 * @throws VerifyFailedException if verification fails
1030 */
1031 public void verifyQueueSessionNotRecovered(int indexOfSession)
1032 {
1033 MockQueueSession session = checkAndGetQueueSessionByIndex(indexOfSession);
1034 if(session.isRecovered())
1035 {
1036 throw new VerifyFailedException("QueueSession is recovered.");
1037 }
1038 }
1039
1040 /**
1041 * Verifies that the topic session with the specified index is
1042 * closed.
1043 * The session has to be created using the current {@link MockTopicConnection}.
1044 * @param indexOfSession the index of the session
1045 * @throws VerifyFailedException if verification fails
1046 */
1047 public void verifyTopicSessionClosed(int indexOfSession)
1048 {
1049 MockTopicSession session = checkAndGetTopicSessionByIndex(indexOfSession);
1050 if(!session.isClosed())
1051 {
1052 throw new VerifyFailedException("TopicSession with index " + indexOfSession + " is not closed.");
1053 }
1054 }
1055
1056 /**
1057 * Verifies that the topic session with the specified index was
1058 * committed.
1059 * The session has to be created using the current {@link MockTopicConnection}.
1060 * @param indexOfSession the index of the session
1061 * @throws VerifyFailedException if verification fails
1062 */
1063 public void verifyTopicSessionCommitted(int indexOfSession)
1064 {
1065 MockTopicSession session = checkAndGetTopicSessionByIndex(indexOfSession);
1066 if(!session.isCommitted())
1067 {
1068 throw new VerifyFailedException("TopicSession is not committed.");
1069 }
1070 }
1071
1072 /**
1073 * Verifies that the topic session with the specified index was
1074 * not committed.
1075 * The session has to be created using the current {@link MockTopicConnection}.
1076 * @param indexOfSession the index of the session
1077 * @throws VerifyFailedException if verification fails
1078 */
1079 public void verifyTopicSessionNotCommitted(int indexOfSession)
1080 {
1081 MockTopicSession session = checkAndGetTopicSessionByIndex(indexOfSession);
1082 if(session.isCommitted())
1083 {
1084 throw new VerifyFailedException("TopicSession is committed.");
1085 }
1086 }
1087
1088 /**
1089 * Verifies the number of commits of the topic session with the specified index.
1090 * The session has to be created using the current {@link MockTopicConnection}.
1091 * @param indexOfSession the index of the session
1092 * @param numberOfCommits the expected number of commits
1093 * @throws VerifyFailedException if verification fails
1094 */
1095 public void verifyTopicSessionNumberCommits(int indexOfSession, int numberOfCommits)
1096 {
1097 MockTopicSession session = checkAndGetTopicSessionByIndex(indexOfSession);
1098 if(numberOfCommits != session.getNumberCommits())
1099 {
1100 throw new VerifyFailedException("TopicSession was commited " + session.getNumberCommits() + " times, expected " + numberOfCommits + " times");
1101 }
1102 }
1103
1104 /**
1105 * Verifies that the topic session with the specified index was
1106 * rolled back.
1107 * The session has to be created using the current {@link MockTopicConnection}.
1108 * @param indexOfSession the index of the session
1109 * @throws VerifyFailedException if verification fails
1110 */
1111 public void verifyTopicSessionRolledBack(int indexOfSession)
1112 {
1113 MockTopicSession session = checkAndGetTopicSessionByIndex(indexOfSession);
1114 if(!session.isRolledBack())
1115 {
1116 throw new VerifyFailedException("TopicSession is not rolled back.");
1117 }
1118 }
1119
1120 /**
1121 * Verifies that the topic session with the specified index was
1122 * not rolled back.
1123 * The session has to be created using the current {@link MockTopicConnection}.
1124 * @param indexOfSession the index of the session
1125 * @throws VerifyFailedException if verification fails
1126 */
1127 public void verifyTopicSessionNotRolledBack(int indexOfSession)
1128 {
1129 MockTopicSession session = checkAndGetTopicSessionByIndex(indexOfSession);
1130 if(session.isRolledBack())
1131 {
1132 throw new VerifyFailedException("TopicSession is rolled back.");
1133 }
1134 }
1135
1136 /**
1137 * Verifies the number of rollbacks of the topic session with the specified index.
1138 * The session has to be created using the current {@link MockTopicConnection}.
1139 * @param indexOfSession the index of the session
1140 * @param numberOfRollbacks the expected number of rollbacks
1141 * @throws VerifyFailedException if verification fails
1142 */
1143 public void verifyTopicSessionNumberRollbacks(int indexOfSession, int numberOfRollbacks)
1144 {
1145 MockTopicSession session = checkAndGetTopicSessionByIndex(indexOfSession);
1146 if(numberOfRollbacks != session.getNumberRollbacks())
1147 {
1148 throw new VerifyFailedException("TopicSession was rolled back " + session.getNumberRollbacks() + " times, expected " + numberOfRollbacks + " times");
1149 }
1150 }
1151
1152 /**
1153 * Verifies that the topic session with the specified index was
1154 * recovered.
1155 * The session has to be created using the current {@link MockTopicConnection}.
1156 * @param indexOfSession the index of the session
1157 * @throws VerifyFailedException if verification fails
1158 */
1159 public void verifyTopicSessionRecovered(int indexOfSession)
1160 {
1161 MockTopicSession session = checkAndGetTopicSessionByIndex(indexOfSession);
1162 if(!session.isRecovered())
1163 {
1164 throw new VerifyFailedException("TopicSession is not recovered.");
1165 }
1166 }
1167
1168 /**
1169 * Verifies that the topic session with the specified index was
1170 * not recovered.
1171 * The session has to be created using the current {@link MockTopicConnection}.
1172 * @param indexOfSession the index of the session
1173 * @throws VerifyFailedException if verification fails
1174 */
1175 public void verifyTopicSessionNotRecovered(int indexOfSession)
1176 {
1177 MockTopicSession session = checkAndGetTopicSessionByIndex(indexOfSession);
1178 if(session.isRecovered())
1179 {
1180 throw new VerifyFailedException("TopicSession is recovered.");
1181 }
1182 }
1183
1184 /**
1185 * Verifies that the session with the specified index is
1186 * closed.
1187 * The session has to be created using the current {@link MockConnection}.
1188 * @param indexOfSession the index of the session
1189 * @throws VerifyFailedException if verification fails
1190 */
1191 public void verifySessionClosed(int indexOfSession)
1192 {
1193 MockSession session = checkAndGetSessionByIndex(indexOfSession);
1194 if(!session.isClosed())
1195 {
1196 throw new VerifyFailedException("Session with index " + indexOfSession + " is not closed.");
1197 }
1198 }
1199
1200 /**
1201 * Verifies that the session with the specified index was
1202 * committed.
1203 * The session has to be created using the current {@link MockConnection}.
1204 * @param indexOfSession the index of the session
1205 * @throws VerifyFailedException if verification fails
1206 */
1207 public void verifySessionCommitted(int indexOfSession)
1208 {
1209 MockSession session = checkAndGetSessionByIndex(indexOfSession);
1210 if(!session.isCommitted())
1211 {
1212 throw new VerifyFailedException("Session is not committed.");
1213 }
1214 }
1215
1216 /**
1217 * Verifies that the session with the specified index was
1218 * not committed.
1219 * The session has to be created using the current {@link MockConnection}.
1220 * @param indexOfSession the index of the session
1221 * @throws VerifyFailedException if verification fails
1222 */
1223 public void verifySessionNotCommitted(int indexOfSession)
1224 {
1225 MockSession session = checkAndGetSessionByIndex(indexOfSession);
1226 if(session.isCommitted())
1227 {
1228 throw new VerifyFailedException("Session is committed.");
1229 }
1230 }
1231
1232 /**
1233 * Verifies the number of commits of session with the specified index.
1234 * The session has to be created using the current {@link MockConnection}.
1235 * @param indexOfSession the index of the session
1236 * @param numberOfCommits the expected number of commits
1237 * @throws VerifyFailedException if verification fails
1238 */
1239 public void verifySessionNumberCommits(int indexOfSession, int numberOfCommits)
1240 {
1241 MockSession session = checkAndGetSessionByIndex(indexOfSession);
1242 if(numberOfCommits != session.getNumberCommits())
1243 {
1244 throw new VerifyFailedException("Session was commited " + session.getNumberCommits() + " times, expected " + numberOfCommits + " times");
1245 }
1246 }
1247
1248 /**
1249 * Verifies that the session with the specified index was
1250 * rolled back.
1251 * The session has to be created using the current {@link MockConnection}.
1252 * @param indexOfSession the index of the session
1253 * @throws VerifyFailedException if verification fails
1254 */
1255 public void verifySessionRolledBack(int indexOfSession)
1256 {
1257 MockSession session = checkAndGetSessionByIndex(indexOfSession);
1258 if(!session.isRolledBack())
1259 {
1260 throw new VerifyFailedException("Session is not rolled back.");
1261 }
1262 }
1263
1264 /**
1265 * Verifies that the session with the specified index was
1266 * not rolled back.
1267 * The session has to be created using the current {@link MockConnection}.
1268 * @param indexOfSession the index of the session
1269 * @throws VerifyFailedException if verification fails
1270 */
1271 public void verifySessionNotRolledBack(int indexOfSession)
1272 {
1273 MockSession session = checkAndGetSessionByIndex(indexOfSession);
1274 if(session.isRolledBack())
1275 {
1276 throw new VerifyFailedException("Session is rolled back.");
1277 }
1278 }
1279
1280 /**
1281 * Verifies the number of rollbacks of session with the specified index.
1282 * The session has to be created using the current {@link MockConnection}.
1283 * @param indexOfSession the index of the session
1284 * @param numberOfRollbacks the expected number of rollbacks
1285 * @throws VerifyFailedException if verification fails
1286 */
1287 public void verifySessionNumberRollbacks(int indexOfSession, int numberOfRollbacks)
1288 {
1289 MockSession session = checkAndGetSessionByIndex(indexOfSession);
1290 if(numberOfRollbacks != session.getNumberRollbacks())
1291 {
1292 throw new VerifyFailedException("Session was rolled back " + session.getNumberRollbacks() + " times, expected " + numberOfRollbacks + " times");
1293 }
1294 }
1295
1296 /**
1297 * Verifies that the session with the specified index was
1298 * recovered.
1299 * The session has to be created using the current {@link MockConnection}.
1300 * @param indexOfSession the index of the session
1301 * @throws VerifyFailedException if verification fails
1302 */
1303 public void verifySessionRecovered(int indexOfSession)
1304 {
1305 MockSession session = checkAndGetSessionByIndex(indexOfSession);
1306 if(!session.isRecovered())
1307 {
1308 throw new VerifyFailedException("Session is not recovered.");
1309 }
1310 }
1311
1312 /**
1313 * Verifies that the session with the specified index was
1314 * not recovered.
1315 * The session has to be created using the current {@link MockConnection}.
1316 * @param indexOfSession the index of the session
1317 * @throws VerifyFailedException if verification fails
1318 */
1319 public void verifySessionNotRecovered(int indexOfSession)
1320 {
1321 MockSession session = checkAndGetSessionByIndex(indexOfSession);
1322 if(session.isRecovered())
1323 {
1324 throw new VerifyFailedException("Session is recovered.");
1325 }
1326 }
1327
1328 /**
1329 * Verifies that all queue sessions are closed.
1330 * The sessions have to be created using the current {@link MockQueueConnection}.
1331 * @throws VerifyFailedException if verification fails
1332 */
1333 public void verifyAllQueueSessionsClosed()
1334 {
1335 List queueSessions = getQueueSessionList();
1336 if(null == queueSessions) return;
1337 for(int ii = 0; ii < queueSessions.size(); ii++)
1338 {
1339 MockQueueSession currentSession = (MockQueueSession)queueSessions.get(ii);
1340 if(!currentSession.isClosed())
1341 {
1342 throw new VerifyFailedException("QueueSession with index " + ii + " is not closed.");
1343 }
1344 }
1345 }
1346
1347 /**
1348 * Verifies that all queue sessions are recovered.
1349 * The sessions have to be created using the current {@link MockQueueConnection}.
1350 * @throws VerifyFailedException if verification fails
1351 */
1352 public void verifyAllQueueSessionsRecovered()
1353 {
1354 List queueSessions = getQueueSessionList();
1355 if(null == queueSessions) return;
1356 for(int ii = 0; ii < queueSessions.size(); ii++)
1357 {
1358 MockQueueSession currentSession = (MockQueueSession)queueSessions.get(ii);
1359 if(!currentSession.isRecovered())
1360 {
1361 throw new VerifyFailedException("QueueSession with index " + ii + " is not recovered.");
1362 }
1363 }
1364 }
1365
1366 /**
1367 * Verifies that all queue sessions were commited.
1368 * The sessions have to be created using the current {@link MockQueueConnection}.
1369 * @throws VerifyFailedException if verification fails
1370 */
1371 public void verifyAllQueueSessionsCommitted()
1372 {
1373 List queueSessions = getQueueSessionList();
1374 if(null == queueSessions) return;
1375 for(int ii = 0; ii < queueSessions.size(); ii++)
1376 {
1377 MockQueueSession currentSession = (MockQueueSession)queueSessions.get(ii);
1378 if(!currentSession.isCommitted())
1379 {
1380 throw new VerifyFailedException("QueueSession with index " + ii + " is not committed.");
1381 }
1382 }
1383 }
1384
1385 /**
1386 * Verifies that all queue sessions were rolled back.
1387 * The sessions have to be created using the current {@link MockQueueConnection}.
1388 * @throws VerifyFailedException if verification fails
1389 */
1390 public void verifyAllQueueSessionsRolledBack()
1391 {
1392 List queueSessions = getQueueSessionList();
1393 if(null == queueSessions) return;
1394 for(int ii = 0; ii < queueSessions.size(); ii++)
1395 {
1396 MockQueueSession currentSession = (MockQueueSession)queueSessions.get(ii);
1397 if(!currentSession.isRolledBack())
1398 {
1399 throw new VerifyFailedException("QueueSession with index " + ii + " is not rolled back.");
1400 }
1401 }
1402 }
1403
1404 /**
1405 * Verifies that all topic sessions are closed.
1406 * The sessions have to be created using the current {@link MockTopicConnection}.
1407 * @throws VerifyFailedException if verification fails
1408 */
1409 public void verifyAllTopicSessionsClosed()
1410 {
1411 List topicSessions = getTopicSessionList();
1412 if(null == topicSessions) return;
1413 for(int ii = 0; ii < topicSessions.size(); ii++)
1414 {
1415 MockTopicSession currentSession = (MockTopicSession)topicSessions.get(ii);
1416 if(!currentSession.isClosed())
1417 {
1418 throw new VerifyFailedException("TopicSession with index " + ii + " is not closed.");
1419 }
1420 }
1421 }
1422
1423 /**
1424 * Verifies that all topic sessions are recovered.
1425 * The sessions have to be created using the current {@link MockTopicConnection}.
1426 * @throws VerifyFailedException if verification fails
1427 */
1428 public void verifyAllTopicSessionsRecovered()
1429 {
1430 List topicSessions = getTopicSessionList();
1431 if(null == topicSessions) return;
1432 for(int ii = 0; ii < topicSessions.size(); ii++)
1433 {
1434 MockTopicSession currentSession = (MockTopicSession)topicSessions.get(ii);
1435 if(!currentSession.isRecovered())
1436 {
1437 throw new VerifyFailedException("TopicSession with index " + ii + " is not recovered.");
1438 }
1439 }
1440 }
1441
1442 /**
1443 * Verifies that all topic sessions were commited.
1444 * The sessions have to be created using the current {@link MockTopicConnection}.
1445 * @throws VerifyFailedException if verification fails
1446 */
1447 public void verifyAllTopicSessionsCommitted()
1448 {
1449 List topicSessions = getTopicSessionList();
1450 if(null == topicSessions) return;
1451 for(int ii = 0; ii < topicSessions.size(); ii++)
1452 {
1453 MockTopicSession currentSession = (MockTopicSession)topicSessions.get(ii);
1454 if(!currentSession.isCommitted())
1455 {
1456 throw new VerifyFailedException("TopicSession with index " + ii + " is not committed.");
1457 }
1458 }
1459 }
1460
1461 /**
1462 * Verifies that all topic sessions were rolled back.
1463 * The sessions have to be created using the current {@link MockTopicConnection}.
1464 * @throws VerifyFailedException if verification fails
1465 */
1466 public void verifyAllTopicSessionsRolledBack()
1467 {
1468 List topicSessions = getTopicSessionList();
1469 if(null == topicSessions) return;
1470 for(int ii = 0; ii < topicSessions.size(); ii++)
1471 {
1472 MockTopicSession currentSession = (MockTopicSession)topicSessions.get(ii);
1473 if(!currentSession.isRolledBack())
1474 {
1475 throw new VerifyFailedException("TopicSession with index " + ii + " is not rolled back.");
1476 }
1477 }
1478 }
1479
1480 /**
1481 * Verifies that all sessions are closed.
1482 * The sessions have to be created using the current {@link MockConnection}.
1483 * @throws VerifyFailedException if verification fails
1484 */
1485 public void verifyAllSessionsClosed()
1486 {
1487 List sessions = getSessionList();
1488 if(null == sessions) return;
1489 for(int ii = 0; ii < sessions.size(); ii++)
1490 {
1491 MockSession currentSession = (MockSession)sessions.get(ii);
1492 if(!currentSession.isClosed())
1493 {
1494 throw new VerifyFailedException("Session with index " + ii + " is not closed.");
1495 }
1496 }
1497 }
1498
1499 /**
1500 * Verifies that all sessions are recovered.
1501 * The sessions have to be created using the current {@link MockConnection}.
1502 * @throws VerifyFailedException if verification fails
1503 */
1504 public void verifyAllSessionsRecovered()
1505 {
1506 List sessions = getSessionList();
1507 if(null == sessions) return;
1508 for(int ii = 0; ii < sessions.size(); ii++)
1509 {
1510 MockSession currentSession = (MockSession)sessions.get(ii);
1511 if(!currentSession.isRecovered())
1512 {
1513 throw new VerifyFailedException("Session with index " + ii + " is not recovered.");
1514 }
1515 }
1516 }
1517
1518 /**
1519 * Verifies that all sessions were commited.
1520 * The sessions have to be created using the current {@link MockConnection}.
1521 * @throws VerifyFailedException if verification fails
1522 */
1523 public void verifyAllSessionsCommitted()
1524 {
1525 List sessions = getSessionList();
1526 if(null == sessions) return;
1527 for(int ii = 0; ii < sessions.size(); ii++)
1528 {
1529 MockSession currentSession = (MockSession)sessions.get(ii);
1530 if(!currentSession.isCommitted())
1531 {
1532 throw new VerifyFailedException("Session with index " + ii + " is not committed.");
1533 }
1534 }
1535 }
1536
1537 /**
1538 * Verifies that all topic sessions were rolled back.
1539 * The sessions have to be created using the current {@link MockConnection}.
1540 * @throws VerifyFailedException if verification fails
1541 */
1542 public void verifyAllSessionsRolledBack()
1543 {
1544 List sessions = getSessionList();
1545 if(null == sessions) return;
1546 for(int ii = 0; ii < sessions.size(); ii++)
1547 {
1548 MockSession currentSession = (MockSession)sessions.get(ii);
1549 if(!currentSession.isRolledBack())
1550 {
1551 throw new VerifyFailedException("Session with index " + ii + " is not rolled back.");
1552 }
1553 }
1554 }
1555
1556 /**
1557 * Verifies the number of producers for the specified session.
1558 * The session has to be created using the current {@link MockConnection}.
1559 * @param indexOfSession the index of the session
1560 * @param numberOfProducers the expected number of producers
1561 * @throws VerifyFailedException if verification fails
1562 */
1563 public void verifyNumberMessageProducers(int indexOfSession, int numberOfProducers)
1564 {
1565 checkAndGetSessionByIndex(indexOfSession);
1566 TransmissionManagerWrapper manager = getTransmissionManagerWrapper(indexOfSession);
1567 if(numberOfProducers != manager.getMessageProducerList().size())
1568 {
1569 throw new VerifyFailedException("Expected " + numberOfProducers + " producers, actually " + manager.getMessageProducerList().size() + " producers present");
1570 }
1571 }
1572
1573 /**
1574 * Verifies that all producers for the specified session are closed.
1575 * The session has to be created using the current {@link MockConnection}.
1576 * @param indexOfSession the index of the session
1577 * @throws VerifyFailedException if verification fails
1578 */
1579 public void verifyAllMessageProducersClosed(int indexOfSession)
1580 {
1581 checkAndGetSessionByIndex(indexOfSession);
1582 TransmissionManagerWrapper manager = getTransmissionManagerWrapper(indexOfSession);
1583 List producers = manager.getMessageProducerList();
1584 for(int ii = 0; ii < producers.size(); ii++)
1585 {
1586 MockMessageProducer currentProducer = (MockMessageProducer)producers.get(ii);
1587 if(!currentProducer.isClosed())
1588 {
1589 throw new VerifyFailedException("MessageProducer with index " + ii + " not closed.");
1590 }
1591 }
1592 }
1593
1594 /**
1595 * Verifies the number of senders for the specified session.
1596 * The session has to be created using the current {@link MockQueueConnection}.
1597 * @param indexOfSession the index of the session
1598 * @param numberOfSenders the expected number of senders
1599 * @throws VerifyFailedException if verification fails
1600 */
1601 public void verifyNumberQueueSenders(int indexOfSession, int numberOfSenders)
1602 {
1603 checkAndGetQueueSessionByIndex(indexOfSession);
1604 TransmissionManagerWrapper manager = getQueueTransmissionManagerWrapper(indexOfSession);
1605 if(numberOfSenders != manager.getQueueSenderList().size())
1606 {
1607 throw new VerifyFailedException("Expected " + numberOfSenders + " senders, actually " + manager.getQueueSenderList().size() + " senders present");
1608 }
1609 }
1610
1611 /**
1612 * Verifies the number of senders for the specified session and
1613 * the specified queue name.
1614 * The session has to be created using the current {@link MockQueueConnection}.
1615 * @param indexOfSession the index of the session
1616 * @param queueName the name of the queue
1617 * @param numberOfSenders the expected number of senders
1618 * @throws VerifyFailedException if verification fails
1619 */
1620 public void verifyNumberQueueSenders(int indexOfSession, String queueName, int numberOfSenders)
1621 {
1622 checkAndGetQueueSessionByIndex(indexOfSession);
1623 checkQueueByName(queueName);
1624 QueueTransmissionManager manager = getQueueTransmissionManager(indexOfSession);
1625 if(numberOfSenders != manager.getQueueSenderList(queueName).size())
1626 {
1627 throw new VerifyFailedException("Expected " + numberOfSenders + " senders for queue " + queueName + ", actually " + manager.getQueueSenderList(queueName).size() + " senders present");
1628 }
1629 }
1630
1631 /**
1632 * Verifies that the specified sender is closed.
1633 * The session has to be created using the current {@link MockQueueConnection}.
1634 * @param indexOfSession the index of the session
1635 * @param queueName the name of the queue
1636 * @param indexOfSender the index of the sender
1637 * @throws VerifyFailedException if verification fails
1638 */
1639 public void verifyQueueSenderClosed(int indexOfSession, String queueName, int indexOfSender)
1640 {
1641 checkAndGetQueueSessionByIndex(indexOfSession);
1642 checkQueueByName(queueName);
1643 QueueTransmissionManager manager = getQueueTransmissionManager(indexOfSession);
1644 List senders = manager.getQueueSenderList(queueName);
1645 if(indexOfSender >= senders.size())
1646 {
1647 throw new VerifyFailedException("QueueSender with index " + indexOfSender + " is not present.");
1648 }
1649 MockQueueSender sender = (MockQueueSender)senders.get(indexOfSender);
1650 if(!sender.isClosed())
1651 {
1652 throw new VerifyFailedException("QueueSender of queue " + queueName + " with index " + indexOfSender + " not closed.");
1653 }
1654 }
1655
1656 /**
1657 * Verifies that all senders for the specified session are closed.
1658 * The session has to be created using the current {@link MockQueueConnection}.
1659 * @param indexOfSession the index of the session
1660 * @throws VerifyFailedException if verification fails
1661 */
1662 public void verifyAllQueueSendersClosed(int indexOfSession)
1663 {
1664 checkAndGetQueueSessionByIndex(indexOfSession);
1665 TransmissionManagerWrapper manager = getQueueTransmissionManagerWrapper(indexOfSession);
1666 List senders = manager.getQueueSenderList();
1667 for(int ii = 0; ii < senders.size(); ii++)
1668 {
1669 MockQueueSender currentSender = (MockQueueSender)senders.get(ii);
1670 if(!currentSender.isClosed())
1671 {
1672 throw new VerifyFailedException("QueueSender with index " + ii + " not closed.");
1673 }
1674 }
1675 }
1676
1677 /**
1678 * Verifies the number of publishers for the specified session.
1679 * The session has to be created using the current {@link MockTopicConnection}.
1680 * @param indexOfSession the index of the session
1681 * @param numberOfPublishers the expected number of publishers
1682 * @throws VerifyFailedException if verification fails
1683 */
1684 public void verifyNumberTopicPublishers(int indexOfSession, int numberOfPublishers)
1685 {
1686 checkAndGetTopicSessionByIndex(indexOfSession);
1687 TransmissionManagerWrapper manager = getTopicTransmissionManagerWrapper(indexOfSession);
1688 if(numberOfPublishers != manager.getTopicPublisherList().size())
1689 {
1690 throw new VerifyFailedException("Expected " + numberOfPublishers + " publishers, actually " + manager.getTopicPublisherList().size() + " publishers present");
1691 }
1692 }
1693
1694 /**
1695 * Verifies the number of publishers for the specified session and
1696 * the specified topic name.
1697 * The session has to be created using the current {@link MockTopicConnection}.
1698 * @param indexOfSession the index of the session
1699 * @param topicName the name of the topic
1700 * @param numberOfPublishers the expected number of publishers
1701 * @throws VerifyFailedException if verification fails
1702 */
1703 public void verifyNumberTopicPublishers(int indexOfSession, String topicName, int numberOfPublishers)
1704 {
1705 checkAndGetTopicSessionByIndex(indexOfSession);
1706 checkTopicByName(topicName);
1707 TopicTransmissionManager manager = getTopicTransmissionManager(indexOfSession);
1708 if(numberOfPublishers != manager.getTopicPublisherList(topicName).size())
1709 {
1710 throw new VerifyFailedException("Expected " + numberOfPublishers + " publishers for topic " + topicName + ", actually " + manager.getTopicPublisherList(topicName).size() + " publishers present");
1711 }
1712 }
1713
1714 /**
1715 * Verifies that the specified publisher is closed.
1716 * The session has to be created using the current {@link MockTopicConnection}.
1717 * @param indexOfSession the index of the session
1718 * @param topicName the name of the topic
1719 * @param indexOfPublisher the index of the publisher
1720 * @throws VerifyFailedException if verification fails
1721 */
1722 public void verifyTopicPublisherClosed(int indexOfSession, String topicName, int indexOfPublisher)
1723 {
1724 checkAndGetTopicSessionByIndex(indexOfSession);
1725 checkTopicByName(topicName);
1726 TopicTransmissionManager manager = getTopicTransmissionManager(indexOfSession);
1727 List publishers = manager.getTopicPublisherList(topicName);
1728 if(indexOfPublisher >= publishers.size())
1729 {
1730 throw new VerifyFailedException("TopicPublisher with index " + indexOfPublisher + " is not present.");
1731 }
1732 MockTopicPublisher publisher = (MockTopicPublisher)publishers.get(indexOfPublisher);
1733 if(!publisher.isClosed())
1734 {
1735 throw new VerifyFailedException("TopicPublisher of topic " + topicName + " with index " + indexOfPublisher + " not closed.");
1736 }
1737 }
1738
1739 /**
1740 * Verifies that all publishers for the specified session are closed.
1741 * The session has to be created using the current {@link MockTopicConnection}.
1742 * @param indexOfSession the index of the session
1743 * @throws VerifyFailedException if verification fails
1744 */
1745 public void verifyAllTopicPublishersClosed(int indexOfSession)
1746 {
1747 checkAndGetTopicSessionByIndex(indexOfSession);
1748 TransmissionManagerWrapper manager = getTopicTransmissionManagerWrapper(indexOfSession);
1749 List publishers = manager.getTopicPublisherList();
1750 for(int ii = 0; ii < publishers.size(); ii++)
1751 {
1752 MockTopicPublisher currentPublisher = (MockTopicPublisher)publishers.get(ii);
1753 if(!currentPublisher.isClosed())
1754 {
1755 throw new VerifyFailedException("TopicPublisher with index " + ii + " not closed.");
1756 }
1757 }
1758 }
1759
1760 /**
1761 * Verifies the number of consumers for the specified session.
1762 * The session has to be created using the current {@link MockConnection}.
1763 * @param indexOfSession the index of the session
1764 * @param numberOfConsumers the expected number of consumers
1765 * @throws VerifyFailedException if verification fails
1766 */
1767 public void verifyNumberMessageConsumers(int indexOfSession, int numberOfConsumers)
1768 {
1769 checkAndGetSessionByIndex(indexOfSession);
1770 TransmissionManagerWrapper manager = getTransmissionManagerWrapper(indexOfSession);
1771 if(numberOfConsumers != manager.getMessageConsumerList().size())
1772 {
1773 throw new VerifyFailedException("Expected " + numberOfConsumers + " consumers, actually " + manager.getMessageConsumerList().size() + " consumers present");
1774 }
1775 }
1776
1777 /**
1778 * Verifies that all consumers for the specified session are closed.
1779 * The session has to be created using the current {@link MockConnection}.
1780 * @param indexOfSession the index of the session
1781 * @throws VerifyFailedException if verification fails
1782 */
1783 public void verifyAllMessageConsumersClosed(int indexOfSession)
1784 {
1785 checkAndGetSessionByIndex(indexOfSession);
1786 TransmissionManagerWrapper manager = getTransmissionManagerWrapper(indexOfSession);
1787 List consumers = manager.getMessageConsumerList();
1788 for(int ii = 0; ii < consumers.size(); ii++)
1789 {
1790 MockMessageConsumer currentConsumer = (MockMessageConsumer)consumers.get(ii);
1791 if(!currentConsumer.isClosed())
1792 {
1793 throw new VerifyFailedException("MessageConsumer with index " + ii + " not closed.");
1794 }
1795 }
1796 }
1797
1798 /**
1799 * Verifies the number of receivers for the specified session.
1800 * The session has to be created using the current {@link MockQueueConnection}.
1801 * @param indexOfSession the index of the session
1802 * @param numberOfReceivers the expected number of receivers
1803 * @throws VerifyFailedException if verification fails
1804 */
1805 public void verifyNumberQueueReceivers(int indexOfSession, int numberOfReceivers)
1806 {
1807 checkAndGetQueueSessionByIndex(indexOfSession);
1808 QueueTransmissionManager manager = getQueueTransmissionManager(indexOfSession);
1809 if(numberOfReceivers != manager.getQueueReceiverList().size())
1810 {
1811 throw new VerifyFailedException("Expected " + numberOfReceivers + " receivers, actually " + manager.getQueueReceiverList().size() + " receivers present");
1812 }
1813 }
1814
1815 /**
1816 * Verifies the number of receivers for the specified session and
1817 * the specified queue name.
1818 * The session has to be created using the current {@link MockQueueConnection}.
1819 * @param indexOfSession the index of the session
1820 * @param queueName the name of the queue
1821 * @param numberOfReceivers the expected number of receivers
1822 * @throws VerifyFailedException if verification fails
1823 */
1824 public void verifyNumberQueueReceivers(int indexOfSession, String queueName, int numberOfReceivers)
1825 {
1826 checkAndGetQueueSessionByIndex(indexOfSession);
1827 checkQueueByName(queueName);
1828 QueueTransmissionManager manager = getQueueTransmissionManager(indexOfSession);
1829 if(numberOfReceivers != manager.getQueueReceiverList(queueName).size())
1830 {
1831 throw new VerifyFailedException("Expected " + numberOfReceivers + " receivers for queue " + queueName + ", actually " + manager.getQueueReceiverList(queueName).size() + " receivers present");
1832 }
1833 }
1834
1835 /**
1836 * Verifies that the specified receiver is closed.
1837 * The session has to be created using the current {@link MockQueueConnection}.
1838 * @param indexOfSession the index of the session
1839 * @param queueName the name of the queue
1840 * @param indexOfReceiver the index of the receiver
1841 * @throws VerifyFailedException if verification fails
1842 */
1843 public void verifyQueueReceiverClosed(int indexOfSession, String queueName, int indexOfReceiver)
1844 {
1845 checkAndGetQueueSessionByIndex(indexOfSession);
1846 checkQueueByName(queueName);
1847 QueueTransmissionManager manager = getQueueTransmissionManager(indexOfSession);
1848 List receivers = manager.getQueueReceiverList(queueName);
1849 if(indexOfReceiver >= receivers.size())
1850 {
1851 throw new VerifyFailedException("QueueReceiver with index " + indexOfReceiver + " is not present.");
1852 }
1853 MockQueueReceiver receiver = (MockQueueReceiver)receivers.get(indexOfReceiver);
1854 if(!receiver.isClosed())
1855 {
1856 throw new VerifyFailedException("QueueReceiver of queue " + queueName + " with index " + indexOfReceiver + " not closed.");
1857 }
1858 }
1859
1860 /**
1861 * Verifies that all receivers for the specified session are closed.
1862 * The session has to be created using the current {@link MockQueueConnection}.
1863 * @param indexOfSession the index of the session
1864 * @throws VerifyFailedException if verification fails
1865 */
1866 public void verifyAllQueueReceiversClosed(int indexOfSession)
1867 {
1868 checkAndGetQueueSessionByIndex(indexOfSession);
1869 QueueTransmissionManager manager = getQueueTransmissionManager(indexOfSession);
1870 List receivers = manager.getQueueReceiverList();
1871 for(int ii = 0; ii < receivers.size(); ii++)
1872 {
1873 MockQueueReceiver currentReceiver = (MockQueueReceiver)receivers.get(ii);
1874 if(!currentReceiver.isClosed())
1875 {
1876 throw new VerifyFailedException("QueueReceiver with index " + ii + " not closed.");
1877 }
1878 }
1879 }
1880
1881 /**
1882 * Verifies the number of subscribers for the specified session.
1883 * The session has to be created using the current {@link MockTopicConnection}.
1884 * @param indexOfSession the index of the session
1885 * @param numberOfSubscribers the expected number of subscribers
1886 * @throws VerifyFailedException if verification fails
1887 */
1888 public void verifyNumberTopicSubscribers(int indexOfSession, int numberOfSubscribers)
1889 {
1890 checkAndGetTopicSessionByIndex(indexOfSession);
1891 TopicTransmissionManager manager = getTopicTransmissionManager(indexOfSession);
1892 if(numberOfSubscribers != manager.getTopicSubscriberList().size())
1893 {
1894 throw new VerifyFailedException("Expected " + numberOfSubscribers + " subscribers, actually " + manager.getTopicSubscriberList().size() + " subscribers present");
1895 }
1896 }
1897
1898 /**
1899 * Verifies the number of subscribers for the specified session and
1900 * the specified topic name.
1901 * The session has to be created using the current {@link MockTopicConnection}.
1902 * @param indexOfSession the index of the session
1903 * @param topicName the name of the topic
1904 * @param numberOfSubscribers the expected number of subscribers
1905 * @throws VerifyFailedException if verification fails
1906 */
1907 public void verifyNumberTopicSubscribers(int indexOfSession, String topicName, int numberOfSubscribers)
1908 {
1909 checkAndGetTopicSessionByIndex(indexOfSession);
1910 checkTopicByName(topicName);
1911 TopicTransmissionManager manager = getTopicTransmissionManager(indexOfSession);
1912 if(numberOfSubscribers != manager.getTopicSubscriberList(topicName).size())
1913 {
1914 throw new VerifyFailedException("Expected " + numberOfSubscribers + " subscribers for topic " + topicName + ", actually " + manager.getTopicSubscriberList(topicName).size() + " subscribers present");
1915 }
1916 }
1917
1918 /**
1919 * Verifies that the specified subscriber is closed.
1920 * The session has to be created using the current {@link MockTopicConnection}.
1921 * @param indexOfSession the index of the session
1922 * @param topicName the name of the topic
1923 * @param indexOfSubscriber the index of the receiver
1924 * @throws VerifyFailedException if verification fails
1925 */
1926 public void verifyTopicSubscriberClosed(int indexOfSession, String topicName, int indexOfSubscriber)
1927 {
1928 checkAndGetTopicSessionByIndex(indexOfSession);
1929 checkTopicByName(topicName);
1930 TopicTransmissionManager manager = getTopicTransmissionManager(indexOfSession);
1931 List subscribers = manager.getTopicSubscriberList(topicName);
1932 if(indexOfSubscriber >= subscribers.size())
1933 {
1934 throw new VerifyFailedException("TopicSubscriber with index " + indexOfSubscriber + " is not present.");
1935 }
1936 MockTopicSubscriber subscriber = (MockTopicSubscriber)subscribers.get(indexOfSubscriber);
1937 if(!subscriber.isClosed())
1938 {
1939 throw new VerifyFailedException("TopicSubscriber of topic " + topicName + " with index " + indexOfSubscriber + " not closed.");
1940 }
1941 }
1942
1943 /**
1944 * Verifies that all subscribers for the specified session are closed.
1945 * The session has to be created using the current {@link MockTopicConnection}.
1946 * @param indexOfSession the index of the session
1947 * @throws VerifyFailedException if verification fails
1948 */
1949 public void verifyAllTopicSubscribersClosed(int indexOfSession)
1950 {
1951 checkAndGetTopicSessionByIndex(indexOfSession);
1952 TopicTransmissionManager manager = getTopicTransmissionManager(indexOfSession);
1953 List subscribers = manager.getTopicSubscriberList();
1954 for(int ii = 0; ii < subscribers.size(); ii++)
1955 {
1956 MockTopicSubscriber currentSubscriber = (MockTopicSubscriber)subscribers.get(ii);
1957 if(!currentSubscriber.isClosed())
1958 {
1959 throw new VerifyFailedException("TopicSubscriber with index " + ii + " not closed.");
1960 }
1961 }
1962 }
1963
1964 /**
1965 * Verifies the number of browsers for the specified session.
1966 * The session has to be created using the current {@link MockQueueConnection}.
1967 * @param indexOfSession the index of the session
1968 * @param numberOfBrowsers the expected number of browsers
1969 * @throws VerifyFailedException if verification fails
1970 */
1971 public void verifyNumberQueueBrowsers(int indexOfSession, int numberOfBrowsers)
1972 {
1973 checkAndGetQueueSessionByIndex(indexOfSession);
1974 QueueTransmissionManager manager = getQueueTransmissionManager(indexOfSession);
1975 if(numberOfBrowsers != manager.getQueueBrowserList().size())
1976 {
1977 throw new VerifyFailedException("Expected " + numberOfBrowsers + " browsers, actually " + manager.getQueueBrowserList().size() + " browsers present");
1978 }
1979 }
1980
1981 /**
1982 * Verifies the number of browsers for the specified session and
1983 * the specified queue name.
1984 * The session has to be created using the current {@link MockQueueConnection}.
1985 * @param indexOfSession the index of the session
1986 * @param queueName the name of the queue
1987 * @param numberOfBrowsers the expected number of browsers
1988 * @throws VerifyFailedException if verification fails
1989 */
1990 public void verifyNumberQueueBrowsers(int indexOfSession, String queueName, int numberOfBrowsers)
1991 {
1992 checkAndGetQueueSessionByIndex(indexOfSession);
1993 checkQueueByName(queueName);
1994 QueueTransmissionManager manager = getQueueTransmissionManager(indexOfSession);
1995 if(numberOfBrowsers != manager.getQueueBrowserList(queueName).size())
1996 {
1997 throw new VerifyFailedException("Expected " + numberOfBrowsers + " browsers for queue " + queueName + ", actually " + manager.getQueueBrowserList(queueName).size() + " browsers present");
1998 }
1999 }
2000
2001 /**
2002 * Verifies that the specified browser is closed.
2003 * The session has to be created using the current {@link MockQueueConnection}.
2004 * @param indexOfSession the index of the session
2005 * @param queueName the name of the queue
2006 * @param indexOfBrowser the index of the browser
2007 * @throws VerifyFailedException if verification fails
2008 */
2009 public void verifyQueueBrowserClosed(int indexOfSession, String queueName, int indexOfBrowser)
2010 {
2011 checkAndGetQueueSessionByIndex(indexOfSession);
2012 checkQueueByName(queueName);
2013 QueueTransmissionManager manager = getQueueTransmissionManager(indexOfSession);
2014 List browsers = manager.getQueueBrowserList(queueName);
2015 if(indexOfBrowser >= browsers.size())
2016 {
2017 throw new VerifyFailedException("QueueBrowser with index " + indexOfBrowser + " is not present.");
2018 }
2019 MockQueueBrowser browser = (MockQueueBrowser)browsers.get(indexOfBrowser);
2020 if(!browser.isClosed())
2021 {
2022 throw new VerifyFailedException("QueueBrowser of queue " + queueName + " with index " + indexOfBrowser + " not closed.");
2023 }
2024 }
2025
2026 /**
2027 * Verifies that all browsers for the specified session are closed.
2028 * The session has to be created using the current {@link MockQueueConnection}.
2029 * @param indexOfSession the index of the session
2030 * @throws VerifyFailedException if verification fails
2031 */
2032 public void verifyAllQueueBrowsersClosed(int indexOfSession)
2033 {
2034 checkAndGetQueueSessionByIndex(indexOfSession);
2035 QueueTransmissionManager manager = getQueueTransmissionManager(indexOfSession);
2036 List browsers = manager.getQueueBrowserList();
2037 for(int ii = 0; ii < browsers.size(); ii++)
2038 {
2039 MockQueueBrowser currentBrowser = (MockQueueBrowser)browsers.get(ii);
2040 if(!currentBrowser.isClosed())
2041 {
2042 throw new VerifyFailedException("QueueBrowser with index " + ii + " not closed.");
2043 }
2044 }
2045 }
2046
2047 /**
2048 * Verifies that a durable subscriber exists.
2049 * The session has to be created using the current {@link MockTopicConnection}.
2050 * @param indexOfSession the index of the session
2051 * @param name the name of the subscription
2052 * @throws VerifyFailedException if verification fails
2053 */
2054 public void verifyDurableTopicSubscriberPresent(int indexOfSession, String name)
2055 {
2056 checkAndGetTopicSessionByIndex(indexOfSession);
2057 TopicTransmissionManager manager = getTopicTransmissionManager(indexOfSession);
2058 if(null == manager.getDurableTopicSubscriber(name))
2059 {
2060 throw new VerifyFailedException("Durable subscriber with subscription name " + name + " not present.");
2061 }
2062 }
2063
2064 /**
2065 * Verifies the number of durable subscribers for the specified session.
2066 * The session has to be created using the current {@link MockTopicConnection}.
2067 * @param indexOfSession the index of the session
2068 * @param numberOfSubscribers the expected number of durable subscribers
2069 * @throws VerifyFailedException if verification fails
2070 */
2071 public void verifyNumberDurableTopicSubscribers(int indexOfSession, int numberOfSubscribers)
2072 {
2073 checkAndGetTopicSessionByIndex(indexOfSession);
2074 TopicTransmissionManager manager = getTopicTransmissionManager(indexOfSession);
2075 if(numberOfSubscribers != manager.getDurableTopicSubscriberMap().size())
2076 {
2077 throw new VerifyFailedException("Expected " + numberOfSubscribers + " durable subscribers, actually " + manager.getDurableTopicSubscriberMap().size() + " durable subscribers present");
2078 }
2079 }
2080
2081 /**
2082 * Verifies the number of durable subscribers for the specified session and
2083 * the specified topic name.
2084 * The session has to be created using the current {@link MockTopicConnection}.
2085 * @param indexOfSession the index of the session
2086 * @param topicName the name of the topic
2087 * @param numberOfSubscribers the expected number of durable subscribers
2088 * @throws VerifyFailedException if verification fails
2089 */
2090 public void verifyNumberDurableTopicSubscribers(int indexOfSession, String topicName, int numberOfSubscribers)
2091 {
2092 checkAndGetTopicSessionByIndex(indexOfSession);
2093 checkTopicByName(topicName);
2094 TopicTransmissionManager manager = getTopicTransmissionManager(indexOfSession);
2095 if(numberOfSubscribers != manager.getDurableTopicSubscriberMap(topicName).size())
2096 {
2097 throw new VerifyFailedException("Expected " + numberOfSubscribers + " durable subscribers for topic " + topicName + ", actually " + manager.getDurableTopicSubscriberMap(topicName).size() + " durable subscribers present");
2098 }
2099 }
2100
2101 /**
2102 * Verifies that the specified durable subscriber is closed.
2103 * The session has to be created using the current {@link MockTopicConnection}.
2104 * @param indexOfSession the index of the session
2105 * @param name the name of the subscription
2106 * @throws VerifyFailedException if verification fails
2107 */
2108 public void verifyDurableTopicSubscriberClosed(int indexOfSession, String name)
2109 {
2110 checkAndGetTopicSessionByIndex(indexOfSession);
2111 TopicTransmissionManager manager = getTopicTransmissionManager(indexOfSession);
2112 MockTopicSubscriber subscriber = (MockTopicSubscriber)manager.getDurableTopicSubscriber(name);
2113 if(null == subscriber)
2114 {
2115 throw new VerifyFailedException("Durable TopicSubscriber with subscription name " + name + " not present.");
2116 }
2117 if(!subscriber.isClosed())
2118 {
2119 throw new VerifyFailedException("Durable TopicSubscriber with subscription name " + name + " not closed.");
2120 }
2121 }
2122
2123 /**
2124 * Verifies that all durable subscribers for the specified session are closed.
2125 * The session has to be created using the current {@link MockTopicConnection}.
2126 * @param indexOfSession the index of the session
2127 * @throws VerifyFailedException if verification fails
2128 */
2129 public void verifyAllDurableTopicSubscribersClosed(int indexOfSession)
2130 {
2131 checkAndGetTopicSessionByIndex(indexOfSession);
2132 TopicTransmissionManager manager = getTopicTransmissionManager(indexOfSession);
2133 Iterator keys = manager.getDurableTopicSubscriberMap().keySet().iterator();
2134 while(keys.hasNext())
2135 {
2136 MockTopicSubscriber currentSubscriber = (MockTopicSubscriber)manager.getDurableTopicSubscriberMap().get(keys.next());
2137 if(!currentSubscriber.isClosed())
2138 {
2139 throw new VerifyFailedException("Durable TopicSubscriber with name " + currentSubscriber.getName() + " not closed.");
2140 }
2141 }
2142 }
2143
2144 /**
2145 * Verifies the number of queue sessions.
2146 * The sessions have to be created using the current {@link MockQueueConnection}.
2147 * @param number the expected number of queue sessions
2148 * @throws VerifyFailedException if verification fails
2149 */
2150 public void verifyNumberQueueSessions(int number)
2151 {
2152 if(number != getQueueSessionList().size())
2153 {
2154 throw new VerifyFailedException("Expected " + number + " queue sessions, actually " + getQueueSessionList().size() + " sessions present");
2155 }
2156 }
2157
2158 /**
2159 * Verifies the number of topic sessions.
2160 * The sessions have to be created using the current {@link MockTopicConnection}.
2161 * @param number the expected number of topic sessions
2162 * @throws VerifyFailedException if verification fails
2163 */
2164 public void verifyNumberTopicSessions(int number)
2165 {
2166 if(number != getTopicSessionList().size())
2167 {
2168 throw new VerifyFailedException("Expected " + number + " topic sessions, actually " + getTopicSessionList().size() + " sessions present");
2169 }
2170 }
2171
2172 /**
2173 * Verifies the number of sessions.
2174 * The sessions have to be created using the current {@link MockConnection}.
2175 * @param number the expected number of sessions
2176 * @throws VerifyFailedException if verification fails
2177 */
2178 public void verifyNumberSessions(int number)
2179 {
2180 if(number != getSessionList().size())
2181 {
2182 throw new VerifyFailedException("Expected " + number + " sessions, actually " + getSessionList().size() + " sessions present");
2183 }
2184 }
2185
2186 /**
2187 * Verifies the number of temporary queues.
2188 * The session has to be created using the current {@link MockQueueConnection}.
2189 * @param indexOfSession the index of the session
2190 * @param numberQueues the expected number of temporary queues
2191 * @throws VerifyFailedException if verification fails
2192 */
2193 public void verifyNumberTemporaryQueues(int indexOfSession, int numberQueues)
2194 {
2195 checkAndGetQueueSessionByIndex(indexOfSession);
2196 if(numberQueues != getTemporaryQueueList(indexOfSession).size())
2197 {
2198 throw new VerifyFailedException("Expected " + numberQueues + " temporary queues, actually " + getTemporaryQueueList(indexOfSession).size() + " temporary queues present");
2199 }
2200 }
2201
2202 /**
2203 * Verifies the number of temporary topics.
2204 * The session has to be created using the current {@link MockTopicConnection}.
2205 * @param indexOfSession the index of the session
2206 * @param numberTopics the expected number of temporary topics
2207 * @throws VerifyFailedException if verification fails
2208 */
2209 public void verifyNumberTemporaryTopics(int indexOfSession, int numberTopics)
2210 {
2211 checkAndGetTopicSessionByIndex(indexOfSession);
2212 if(numberTopics != getTemporaryTopicList(indexOfSession).size())
2213 {
2214 throw new VerifyFailedException("Expected " + numberTopics + " temporary topics, actually " + getTemporaryTopicList(indexOfSession).size() + " temporary topics present");
2215 }
2216 }
2217
2218 /**
2219 * Verifies that the temporary queue with the specified index
2220 * was deleted.
2221 * The session has to be created using the current {@link MockQueueConnection}.
2222 * @param indexOfSession the index of the session
2223 * @param indexOfQueue the index of the queue
2224 * @throws VerifyFailedException if verification fails
2225 */
2226 public void verifyTemporaryQueueDeleted(int indexOfSession, int indexOfQueue)
2227 {
2228 checkAndGetQueueSessionByIndex(indexOfSession);
2229 MockTemporaryQueue queue = getTemporaryQueue(indexOfSession, indexOfQueue);
2230 if(null == queue)
2231 {
2232 throw new VerifyFailedException("TemporaryQueue with index " + indexOfQueue + " is not present.");
2233 }
2234 if(!queue.isDeleted())
2235 {
2236 throw new VerifyFailedException("TemporaryQueue with index " + indexOfQueue + " not deleted.");
2237 }
2238 }
2239
2240 /**
2241 * Verifies that all temporary queues were deleted.
2242 * The session has to be created using the current {@link MockQueueConnection}.
2243 * @param indexOfSession the index of the session
2244 * @throws VerifyFailedException if verification fails
2245 */
2246 public void verifyAllTemporaryQueuesDeleted(int indexOfSession)
2247 {
2248 checkAndGetQueueSessionByIndex(indexOfSession);
2249 List queueList = getTemporaryQueueList(indexOfSession);
2250 for(int ii = 0; ii < queueList.size(); ii++)
2251 {
2252 MockTemporaryQueue currentQueue = (MockTemporaryQueue)queueList.get(ii);
2253 if(!currentQueue.isDeleted())
2254 {
2255 throw new VerifyFailedException("TemporaryQueue with index " + ii + " not deleted.");
2256 }
2257 }
2258 }
2259
2260 /**
2261 * Verifies that the temporary topic with the specified index
2262 * was closed.
2263 * The session has to be created using the current {@link MockTopicConnection}.
2264 * @param indexOfSession the index of the session
2265 * @param indexOfTopic the index of the topic
2266 * @throws VerifyFailedException if verification fails
2267 */
2268 public void verifyTemporaryTopicDeleted(int indexOfSession, int indexOfTopic)
2269 {
2270 checkAndGetTopicSessionByIndex(indexOfSession);
2271 MockTemporaryTopic topic = getTemporaryTopic(indexOfSession, indexOfTopic);
2272 if(null == topic)
2273 {
2274 throw new VerifyFailedException("TemporaryTopic with index " + indexOfTopic + " is not present.");
2275 }
2276 if(!topic.isDeleted())
2277 {
2278 throw new VerifyFailedException("TemporaryTopic with index " + indexOfTopic + " not deleted.");
2279 }
2280 }
2281
2282 /**
2283 * Verifies that all temporary topics were deleted.
2284 * The session has to be created using the current {@link MockTopicConnection}.
2285 * @param indexOfSession the index of the session
2286 * @throws VerifyFailedException if verification fails
2287 */
2288 public void verifyAllTemporaryTopicsDeleted(int indexOfSession)
2289 {
2290 checkAndGetTopicSessionByIndex(indexOfSession);
2291 List topicList = getTemporaryTopicList(indexOfSession);
2292 for(int ii = 0; ii < topicList.size(); ii++)
2293 {
2294 MockTemporaryTopic currentTopic = (MockTemporaryTopic)topicList.get(ii);
2295 if(!currentTopic.isDeleted())
2296 {
2297 throw new VerifyFailedException("TemporaryTopic with index " + ii + " not deleted.");
2298 }
2299 }
2300 }
2301
2302 /**
2303 * Verifies that the specified messages are equal by calling the
2304 * <code>equals()</code> method. All mock messages provide a
2305 * suitable implementation of <code>equals()</code>.
2306 * @param message1 the first message
2307 * @param message2 the second message
2308 * @throws VerifyFailedException if verification fails
2309 */
2310 public void verifyMessageEquals(MockMessage message1, MockMessage message2)
2311 {
2312 if(null == message1)
2313 {
2314 throw new VerifyFailedException("message1 is null");
2315 }
2316 if(null == message2)
2317 {
2318 throw new VerifyFailedException("message2 is null");
2319 }
2320 if(!message1.equals(message2))
2321 {
2322 throw new VerifyFailedException("messages not equal: message1: " + message1.toString() + ", message2: " + message2.toString());
2323 }
2324 }
2325
2326 /**
2327 * Verifies that a message in the specified queue is equal to
2328 * the specified message by calling the <code>equals()</code> method.
2329 * All mock messages provide a suitable implementation of <code>equals()</code>.
2330 * @param nameOfQueue the name of the queue
2331 * @param indexOfSourceMessage the index of the message in the queue
2332 * @param targetMessage the message that will be used for comparison
2333 * @throws VerifyFailedException if verification fails
2334 */
2335 public void verifyCurrentQueueMessageEquals(String nameOfQueue, int indexOfSourceMessage, MockMessage targetMessage)
2336 {
2337 checkQueueByName(nameOfQueue);
2338 List messageList = getCurrentMessageListFromQueue(nameOfQueue);
2339 if(indexOfSourceMessage >= messageList.size())
2340 {
2341 throw new VerifyFailedException("Queue " + nameOfQueue + " contains only " + messageList.size() + " messages");
2342 }
2343 MockMessage sourceMessage = (MockMessage)messageList.get(indexOfSourceMessage);
2344 verifyMessageEquals(sourceMessage, targetMessage);
2345 }
2346
2347 /**
2348 * Verifies that a received message is equal to the specified message
2349 * by calling the <code>equals()</code> method.
2350 * All mock messages provide a suitable implementation of <code>equals()</code>.
2351 * @param nameOfQueue the name of the queue
2352 * @param indexOfSourceMessage the index of the received message
2353 * @param targetMessage the message that will be used for comparison
2354 * @throws VerifyFailedException if verification fails
2355 */
2356 public void verifyReceivedQueueMessageEquals(String nameOfQueue, int indexOfSourceMessage, MockMessage targetMessage)
2357 {
2358 checkQueueByName(nameOfQueue);
2359 List messageList = getReceivedMessageListFromQueue(nameOfQueue);
2360 if(indexOfSourceMessage >= messageList.size())
2361 {
2362 throw new VerifyFailedException("Queue " + nameOfQueue + " received only " + messageList.size() + " messages");
2363 }
2364 MockMessage sourceMessage = (MockMessage)messageList.get(indexOfSourceMessage);
2365 verifyMessageEquals(sourceMessage, targetMessage);
2366 }
2367
2368 /**
2369 * Verifies that a message in the specified temporary queue is equal to
2370 * the specified message by calling the <code>equals()</code> method.
2371 * All mock messages provide a suitable implementation of <code>equals()</code>.
2372 * The session has to be created using the current {@link MockQueueConnection}.
2373 * @param indexOfSession the index of the session
2374 * @param indexOfQueue the index of the temporary queue
2375 * @param indexOfSourceMessage the index of the message in the queue
2376 * @param targetMessage the message that will be used for comparison
2377 * @throws VerifyFailedException if verification fails
2378 */
2379 public void verifyCurrentQueueMessageEquals(int indexOfSession, int indexOfQueue, int indexOfSourceMessage, MockMessage targetMessage)
2380 {
2381 checkAndGetQueueSessionByIndex(indexOfSession);
2382 List messageList = getCurrentMessageListFromTemporaryQueue(indexOfSession, indexOfQueue);
2383 if(null == messageList)
2384 {
2385 throw new VerifyFailedException("Temporary queue with index " + indexOfQueue + " of session with index " + indexOfSession + " does not exist");
2386 }
2387 if(indexOfSourceMessage >= messageList.size())
2388 {
2389 throw new VerifyFailedException("Temporary queue with index " + indexOfQueue + " contains only " + messageList.size() + " messages");
2390 }
2391 MockMessage sourceMessage = (MockMessage)messageList.get(indexOfSourceMessage);
2392 verifyMessageEquals(sourceMessage, targetMessage);
2393 }
2394
2395 /**
2396 * Verifies that a message received by a temporary queue is equal to the specified message
2397 * by calling the <code>equals()</code> method.
2398 * All mock messages provide a suitable implementation of <code>equals()</code>.
2399 * The session has to be created using the current {@link MockQueueConnection}.
2400 * @param indexOfSession the index of the session
2401 * @param indexOfQueue the index of the temporary queue
2402 * @param indexOfSourceMessage the index of the received message
2403 * @param targetMessage the message that will be used for comparison
2404 * @throws VerifyFailedException if verification fails
2405 */
2406 public void verifyReceivedQueueMessageEquals(int indexOfSession, int indexOfQueue, int indexOfSourceMessage, MockMessage targetMessage)
2407 {
2408 checkAndGetQueueSessionByIndex(indexOfSession);
2409 List messageList = getReceivedMessageListFromTemporaryQueue(indexOfSession, indexOfQueue);
2410 if(null == messageList)
2411 {
2412 throw new VerifyFailedException("Temporary queue with index " + indexOfQueue + " of session with index " + indexOfSession + " does not exist");
2413 }
2414 if(indexOfSourceMessage >= messageList.size())
2415 {
2416 throw new VerifyFailedException("Temporary queue with index " + indexOfQueue + " received only " + messageList.size() + " messages");
2417 }
2418 MockMessage sourceMessage = (MockMessage)messageList.get(indexOfSourceMessage);
2419 verifyMessageEquals(sourceMessage, targetMessage);
2420 }
2421
2422 /**
2423 * Verifies the number of messages in a queue.
2424 * @param nameOfQueue the name of the queue
2425 * @param numberOfMessages the expected number of messages
2426 * @throws VerifyFailedException if verification fails
2427 */
2428 public void verifyNumberOfCurrentQueueMessages(String nameOfQueue, int numberOfMessages)
2429 {
2430 checkQueueByName(nameOfQueue);
2431 List list = getCurrentMessageListFromQueue(nameOfQueue);
2432 if(numberOfMessages != list.size())
2433 {
2434 throw new VerifyFailedException("Expected " + numberOfMessages + " messages in queue " + nameOfQueue + ", received " + list.size() + " messages");
2435 }
2436 }
2437
2438 /**
2439 * Verifies the number of messages received by a queue.
2440 * @param nameOfQueue the name of the queue
2441 * @param numberOfMessages the expected number of messages
2442 * @throws VerifyFailedException if verification fails
2443 */
2444 public void verifyNumberOfReceivedQueueMessages(String nameOfQueue, int numberOfMessages)
2445 {
2446 checkQueueByName(nameOfQueue);
2447 List list = getReceivedMessageListFromQueue(nameOfQueue);
2448 if(numberOfMessages != list.size())
2449 {
2450 throw new VerifyFailedException("Expected " + numberOfMessages + " messages received by queue " + nameOfQueue + ", received " + list.size() + " messages");
2451 }
2452 }
2453
2454 /**
2455 * Verifies the number of messages in a temporary queue.
2456 * The session has to be created using the current {@link MockQueueConnection}.
2457 * @param indexOfSession the index of the session
2458 * @param indexOfQueue the index of the temporary queue
2459 * @param numberOfMessages the expected number of messages
2460 * @throws VerifyFailedException if verification fails
2461 */
2462 public void verifyNumberOfCurrentQueueMessages(int indexOfSession, int indexOfQueue, int numberOfMessages)
2463 {
2464 checkAndGetQueueSessionByIndex(indexOfSession);
2465 List list = getCurrentMessageListFromTemporaryQueue(indexOfSession, indexOfQueue);
2466 if(null == list)
2467 {
2468 throw new VerifyFailedException("Temporary queue with index " + indexOfQueue + " of session with index " + indexOfSession + " does not exist");
2469 }
2470 if(numberOfMessages != list.size())
2471 {
2472 throw new VerifyFailedException("Expected " + numberOfMessages + " messages, received " + list.size() + " messages");
2473 }
2474 }
2475
2476 /**
2477 * Verifies the number of messages received by a temporary queue.
2478 * The session has to be created using the current {@link MockQueueConnection}.
2479 * @param indexOfSession the index of the session
2480 * @param indexOfQueue the index of the temporary queue
2481 * @param numberOfMessages the expected number of messages
2482 * @throws VerifyFailedException if verification fails
2483 */
2484 public void verifyNumberOfReceivedQueueMessages(int indexOfSession, int indexOfQueue, int numberOfMessages)
2485 {
2486 checkAndGetQueueSessionByIndex(indexOfSession);
2487 List list = getReceivedMessageListFromTemporaryQueue(indexOfSession, indexOfQueue);
2488 if(null == list)
2489 {
2490 throw new VerifyFailedException("Temporary queue with index " + indexOfQueue + " of session with index " + indexOfSession + " does not exist");
2491 }
2492 if(numberOfMessages != list.size())
2493 {
2494 throw new VerifyFailedException("Expected " + numberOfMessages + " messages, received " + list.size() + " messages");
2495 }
2496 }
2497
2498 /**
2499 * Verifies that all received messages of the specified queue
2500 * are acknowledged.
2501 * @param nameOfQueue the name of the queue
2502 * @throws VerifyFailedException if verification fails
2503 */
2504 public void verifyAllReceivedQueueMessagesAcknowledged(String nameOfQueue)
2505 {
2506 checkQueueByName(nameOfQueue);
2507 List messageList = getReceivedMessageListFromQueue(nameOfQueue);
2508 for(int ii = 0; ii < messageList.size(); ii++)
2509 {
2510 MockMessage currentMessage = (MockMessage)messageList.get(ii);
2511 if(!currentMessage.isAcknowledged())
2512 {
2513 throw new VerifyFailedException("Message " + ii + " of queue " + nameOfQueue + " is not acknowledged");
2514 }
2515 }
2516 }
2517
2518 /**
2519 * Verifies that all received messages of the specified temporary queue
2520 * are acknowledged.
2521 * The session has to be created using the current {@link MockQueueConnection}.
2522 * @param indexOfSession the index of the session
2523 * @param indexOfQueue the index of the temporary queue
2524 * @throws VerifyFailedException if verification fails
2525 */
2526 public void verifyAllReceivedQueueMessagesAcknowledged(int indexOfSession, int indexOfQueue)
2527 {
2528 checkAndGetQueueSessionByIndex(indexOfSession);
2529 List messageList = getReceivedMessageListFromTemporaryQueue(indexOfSession, indexOfQueue);
2530 if(null == messageList)
2531 {
2532 throw new VerifyFailedException("Temporary queue with index " + indexOfQueue + " of session with index " + indexOfSession + " does not exist");
2533 }
2534 for(int ii = 0; ii < messageList.size(); ii++)
2535 {
2536 MockMessage currentMessage = (MockMessage)messageList.get(ii);
2537 if(!currentMessage.isAcknowledged())
2538 {
2539 throw new VerifyFailedException("Message " + ii + " of temporary queue " + indexOfQueue + " is not acknowledged");
2540 }
2541 }
2542 }
2543
2544 /**
2545 * Verifies that a received message is acknowledged.
2546 * @param nameOfQueue the name of the queue
2547 * @param indexOfMessage the index of the received message
2548 * @throws VerifyFailedException if verification fails
2549 */
2550 public void verifyReceivedQueueMessageAcknowledged(String nameOfQueue, int indexOfMessage)
2551 {
2552 checkQueueByName(nameOfQueue);
2553 List messageList = getReceivedMessageListFromQueue(nameOfQueue);
2554 if(indexOfMessage >= messageList.size())
2555 {
2556 throw new VerifyFailedException("Queue " + nameOfQueue + " received only " + messageList.size() + " messages");
2557 }
2558 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
2559 if(!message.isAcknowledged())
2560 {
2561 throw new VerifyFailedException("Message " + indexOfMessage + " of queue " + nameOfQueue + " is not acknowledged");
2562 }
2563 }
2564
2565 /**
2566 * Verifies that a received message is not acknowledged.
2567 * @param nameOfQueue the name of the queue
2568 * @param indexOfMessage the index of the received message
2569 * @throws VerifyFailedException if verification fails
2570 */
2571 public void verifyReceivedQueueMessageNotAcknowledged(String nameOfQueue, int indexOfMessage)
2572 {
2573 checkQueueByName(nameOfQueue);
2574 List messageList = getReceivedMessageListFromQueue(nameOfQueue);
2575 if(indexOfMessage >= messageList.size())
2576 {
2577 throw new VerifyFailedException("Queue " + nameOfQueue + " received only " + messageList.size() + " messages");
2578 }
2579 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
2580 if(message.isAcknowledged())
2581 {
2582 throw new VerifyFailedException("Message " + indexOfMessage + " of queue " + nameOfQueue + " is acknowledged");
2583 }
2584 }
2585
2586 /**
2587 * Verifies that message received by a temporary queue is acknowledged.
2588 * The session has to be created using the current {@link MockQueueConnection}.
2589 * @param indexOfSession the index of the session
2590 * @param indexOfQueue the index of the temporary queue
2591 * @param indexOfMessage the index of the received message
2592 * @throws VerifyFailedException if verification fails
2593 */
2594 public void verifyReceivedQueueMessageAcknowledged(int indexOfSession, int indexOfQueue, int indexOfMessage)
2595 {
2596 checkAndGetQueueSessionByIndex(indexOfSession);
2597 List messageList = getReceivedMessageListFromTemporaryQueue(indexOfSession, indexOfQueue);
2598 if(null == messageList)
2599 {
2600 throw new VerifyFailedException("Temporary queue with index " + indexOfQueue + " of session with index " + indexOfSession + " does not exist");
2601 }
2602 if(indexOfMessage >= messageList.size())
2603 {
2604 throw new VerifyFailedException("Temporary queue with index " + indexOfQueue + " received only " + messageList.size() + " messages");
2605 }
2606 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
2607 if(!message.isAcknowledged())
2608 {
2609 throw new VerifyFailedException("Message " + indexOfMessage + " of temporary queue " + indexOfQueue + " is not acknowledged");
2610 }
2611 }
2612
2613 /**
2614 * Verifies that a received by a temporary queue is not acknowledged.
2615 * The session has to be created using the current {@link MockQueueConnection}.
2616 * @param indexOfSession the index of the session
2617 * @param indexOfQueue the index of the temporary queue
2618 * @param indexOfMessage the index of the received message
2619 * @throws VerifyFailedException if verification fails
2620 */
2621 public void verifyReceivedQueueMessageNotAcknowledged(int indexOfSession, int indexOfQueue, int indexOfMessage)
2622 {
2623 checkAndGetQueueSessionByIndex(indexOfSession);
2624 List messageList = getReceivedMessageListFromTemporaryQueue(indexOfSession, indexOfQueue);
2625 if(null == messageList)
2626 {
2627 throw new VerifyFailedException("Temporary queue with index " + indexOfQueue + " of session with index " + indexOfSession + " does not exist");
2628 }
2629 if(indexOfMessage >= messageList.size())
2630 {
2631 throw new VerifyFailedException("Temporary queue with index " + indexOfQueue + " received only " + messageList.size() + " messages");
2632 }
2633 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
2634 if(message.isAcknowledged())
2635 {
2636 throw new VerifyFailedException("Message " + indexOfMessage + " of temporary queue " + indexOfQueue + " is acknowledged");
2637 }
2638 }
2639
2640 /**
2641 * Verifies the number of messages created with
2642 * {@link MockQueueSession#createMessage}.
2643 * The session has to be created using the current {@link MockQueueConnection}.
2644 * @param indexOfSession the index of the session
2645 * @param number the expected number of messages
2646 * @throws VerifyFailedException if verification fails
2647 */
2648 public void verifyNumberOfCreatedQueueMessages(int indexOfSession, int number)
2649 {
2650 checkAndGetQueueSessionByIndex(indexOfSession);
2651 if(number != getQueueMessageManager(indexOfSession).getMessageList().size())
2652 {
2653 throw new VerifyFailedException("Expected " + number + " messages, received " + getQueueMessageManager(indexOfSession).getMessageList().size() + " messages");
2654 }
2655 }
2656
2657 /**
2658 * Verifies the number of bytes messages created with
2659 * {@link MockQueueSession#createBytesMessage}.
2660 * The session has to be created using the current {@link MockQueueConnection}.
2661 * @param indexOfSession the index of the session
2662 * @param number the expected number of bytes messages
2663 * @throws VerifyFailedException if verification fails
2664 */
2665 public void verifyNumberOfCreatedQueueBytesMessages(int indexOfSession, int number)
2666 {
2667 checkAndGetQueueSessionByIndex(indexOfSession);
2668 if(number != getQueueMessageManager(indexOfSession).getBytesMessageList().size())
2669 {
2670 throw new VerifyFailedException("Expected " + number + " bytes messages, received " + getQueueMessageManager(indexOfSession).getBytesMessageList().size() + " bytes messages");
2671 }
2672 }
2673
2674 /**
2675 * Verifies the number of map messages created with
2676 * {@link MockQueueSession#createMapMessage}.
2677 * The session has to be created using the current {@link MockQueueConnection}.
2678 * @param indexOfSession the index of the session
2679 * @param number the expected number of map messages
2680 * @throws VerifyFailedException if verification fails
2681 */
2682 public void verifyNumberOfCreatedQueueMapMessages(int indexOfSession, int number)
2683 {
2684 checkAndGetQueueSessionByIndex(indexOfSession);
2685 if(number != getQueueMessageManager(indexOfSession).getMapMessageList().size())
2686 {
2687 throw new VerifyFailedException("Expected " + number + " map messages, received " + getQueueMessageManager(indexOfSession).getMapMessageList().size() + " map messages");
2688 }
2689 }
2690
2691 /**
2692 * Verifies the number of text messages created with
2693 * {@link MockQueueSession#createTextMessage}.
2694 * The session has to be created using the current {@link MockQueueConnection}.
2695 * @param indexOfSession the index of the session
2696 * @param number the expected number of text messages
2697 * @throws VerifyFailedException if verification fails
2698 */
2699 public void verifyNumberOfCreatedQueueTextMessages(int indexOfSession, int number)
2700 {
2701 checkAndGetQueueSessionByIndex(indexOfSession);
2702 if(number != getQueueMessageManager(indexOfSession).getTextMessageList().size())
2703 {
2704 throw new VerifyFailedException("Expected " + number + " text messages, received " + getQueueMessageManager(indexOfSession).getTextMessageList().size() + " text messages");
2705 }
2706 }
2707
2708 /**
2709 * Verifies the number of stream messages created with
2710 * {@link MockQueueSession#createStreamMessage}.
2711 * The session has to be created using the current {@link MockQueueConnection}.
2712 * @param indexOfSession the index of the session
2713 * @param number the expected number of stream messages
2714 * @throws VerifyFailedException if verification fails
2715 */
2716 public void verifyNumberOfCreatedQueueStreamMessages(int indexOfSession, int number)
2717 {
2718 checkAndGetQueueSessionByIndex(indexOfSession);
2719 if(number != getQueueMessageManager(indexOfSession).getStreamMessageList().size())
2720 {
2721 throw new VerifyFailedException("Expected " + number + " stream messages, received " + getQueueMessageManager(indexOfSession).getStreamMessageList().size() + " stream messages");
2722 }
2723 }
2724
2725 /**
2726 * Verifies the number of object messages created with
2727 * {@link MockQueueSession#createObjectMessage}.
2728 * The session has to be created using the current {@link MockQueueConnection}.
2729 * @param indexOfSession the index of the session
2730 * @param number the expected number of object messages
2731 * @throws VerifyFailedException if verification fails
2732 */
2733 public void verifyNumberOfCreatedQueueObjectMessages(int indexOfSession, int number)
2734 {
2735 checkAndGetQueueSessionByIndex(indexOfSession);
2736 if(number != getQueueMessageManager(indexOfSession).getObjectMessageList().size())
2737 {
2738 throw new VerifyFailedException("Expected " + number + " object messages, received " + getQueueMessageManager(indexOfSession).getObjectMessageList().size() + " object messages");
2739 }
2740 }
2741
2742 /**
2743 * Verifies that a message created with {@link MockQueueSession#createMessage}
2744 * is acknowledged.
2745 * This method makes sense if messages are not cloned
2746 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
2747 * If messages are cloned, the cloned message is acknowledged instead of
2748 * the created message.
2749 * The session has to be created using the current {@link MockQueueConnection}.
2750 * @param indexOfSession the index of the session
2751 * @param indexOfMessage the index of the message
2752 * @throws VerifyFailedException if verification fails
2753 */
2754 public void verifyCreatedQueueMessageAcknowledged(int indexOfSession, int indexOfMessage)
2755 {
2756 checkAndGetQueueSessionByIndex(indexOfSession);
2757 List messageList = getQueueMessageManager(indexOfSession).getMessageList();
2758 if(indexOfMessage >= messageList.size())
2759 {
2760 throw new VerifyFailedException("Only " + messageList.size() + " messages created for session " + indexOfSession);
2761 }
2762 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
2763 if(!message.isAcknowledged())
2764 {
2765 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is not acknowledged");
2766 }
2767 }
2768
2769 /**
2770 * Verifies that a message created with {@link MockQueueSession#createMessage}
2771 * is not acknowledged.
2772 * This method makes sense if messages are not cloned
2773 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
2774 * If messages are cloned, the cloned message is acknowledged instead of
2775 * the created message.
2776 * The session has to be created using the current {@link MockQueueConnection}.
2777 * @param indexOfSession the index of the session
2778 * @param indexOfMessage the index of the message
2779 * @throws VerifyFailedException if verification fails
2780 */
2781 public void verifyCreatedQueueMessageNotAcknowledged(int indexOfSession, int indexOfMessage)
2782 {
2783 checkAndGetQueueSessionByIndex(indexOfSession);
2784 List messageList = getQueueMessageManager(indexOfSession).getMessageList();
2785 if(indexOfMessage >= messageList.size())
2786 {
2787 throw new VerifyFailedException("Only " + messageList.size() + " messages created for session " + indexOfSession);
2788 }
2789 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
2790 if(message.isAcknowledged())
2791 {
2792 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is acknowledged");
2793 }
2794 }
2795
2796 /**
2797 * Verifies that a bytes message created with {@link MockQueueSession#createMessage}
2798 * is acknowledged.
2799 * This method makes sense if messages are not cloned
2800 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
2801 * If messages are cloned, the cloned message is acknowledged instead of
2802 * the created message.
2803 * The session has to be created using the current {@link MockQueueConnection}.
2804 * @param indexOfSession the index of the session
2805 * @param indexOfMessage the index of the message
2806 * @throws VerifyFailedException if verification fails
2807 */
2808 public void verifyCreatedQueueBytesMessageAcknowledged(int indexOfSession, int indexOfMessage)
2809 {
2810 checkAndGetQueueSessionByIndex(indexOfSession);
2811 List messageList = getQueueMessageManager(indexOfSession).getBytesMessageList();
2812 if(indexOfMessage >= messageList.size())
2813 {
2814 throw new VerifyFailedException("Only " + messageList.size() + " bytes messages created for session " + indexOfSession);
2815 }
2816 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
2817 if(!message.isAcknowledged())
2818 {
2819 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is not acknowledged");
2820 }
2821 }
2822
2823 /**
2824 * Verifies that a bytes message created with {@link MockQueueSession#createMessage}
2825 * is not acknowledged.
2826 * This method makes sense if messages are not cloned
2827 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
2828 * If messages are cloned, the cloned message is acknowledged instead of
2829 * the created message.
2830 * The session has to be created using the current {@link MockQueueConnection}.
2831 * @param indexOfSession the index of the session
2832 * @param indexOfMessage the index of the message
2833 * @throws VerifyFailedException if verification fails
2834 */
2835 public void verifyCreatedQueueBytesMessageNotAcknowledged(int indexOfSession, int indexOfMessage)
2836 {
2837 checkAndGetQueueSessionByIndex(indexOfSession);
2838 List messageList = getQueueMessageManager(indexOfSession).getBytesMessageList();
2839 if(indexOfMessage >= messageList.size())
2840 {
2841 throw new VerifyFailedException("Only " + messageList.size() + " bytes messages created for session " + indexOfSession);
2842 }
2843 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
2844 if(message.isAcknowledged())
2845 {
2846 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is acknowledged");
2847 }
2848 }
2849
2850 /**
2851 * Verifies that a map message created with {@link MockQueueSession#createMessage}
2852 * is acknowledged.
2853 * This method makes sense if messages are not cloned
2854 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
2855 * If messages are cloned, the cloned message is acknowledged instead of
2856 * the created message.
2857 * The session has to be created using the current {@link MockQueueConnection}.
2858 * @param indexOfSession the index of the session
2859 * @param indexOfMessage the index of the message
2860 * @throws VerifyFailedException if verification fails
2861 */
2862 public void verifyCreatedQueueMapMessageAcknowledged(int indexOfSession, int indexOfMessage)
2863 {
2864 checkAndGetQueueSessionByIndex(indexOfSession);
2865 List messageList = getQueueMessageManager(indexOfSession).getMapMessageList();
2866 if(indexOfMessage >= messageList.size())
2867 {
2868 throw new VerifyFailedException("Only " + messageList.size() + " map messages created for session " + indexOfSession);
2869 }
2870 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
2871 if(!message.isAcknowledged())
2872 {
2873 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is not acknowledged");
2874 }
2875 }
2876
2877 /**
2878 * Verifies that a map message created with {@link MockQueueSession#createMessage}
2879 * is not acknowledged.
2880 * This method makes sense if messages are not cloned
2881 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
2882 * If messages are cloned, the cloned message is acknowledged instead of
2883 * the created message.
2884 * The session has to be created using the current {@link MockQueueConnection}.
2885 * @param indexOfSession the index of the session
2886 * @param indexOfMessage the index of the message
2887 * @throws VerifyFailedException if verification fails
2888 */
2889 public void verifyCreatedQueueMapMessageNotAcknowledged(int indexOfSession, int indexOfMessage)
2890 {
2891 checkAndGetQueueSessionByIndex(indexOfSession);
2892 List messageList = getQueueMessageManager(indexOfSession).getMapMessageList();
2893 if(indexOfMessage >= messageList.size())
2894 {
2895 throw new VerifyFailedException("Only " + messageList.size() + " map messages created for session " + indexOfSession);
2896 }
2897 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
2898 if(message.isAcknowledged())
2899 {
2900 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is acknowledged");
2901 }
2902 }
2903
2904 /**
2905 * Verifies that a text message created with {@link MockQueueSession#createMessage}
2906 * is acknowledged.
2907 * This method makes sense if messages are not cloned
2908 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
2909 * If messages are cloned, the cloned message is acknowledged instead of
2910 * the created message.
2911 * The session has to be created using the current {@link MockQueueConnection}.
2912 * @param indexOfSession the index of the session
2913 * @param indexOfMessage the index of the message
2914 * @throws VerifyFailedException if verification fails
2915 */
2916 public void verifyCreatedQueueTextMessageAcknowledged(int indexOfSession, int indexOfMessage)
2917 {
2918 checkAndGetQueueSessionByIndex(indexOfSession);
2919 List messageList = getQueueMessageManager(indexOfSession).getTextMessageList();
2920 if(indexOfMessage >= messageList.size())
2921 {
2922 throw new VerifyFailedException("Only " + messageList.size() + " text messages created for session " + indexOfSession);
2923 }
2924 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
2925 if(!message.isAcknowledged())
2926 {
2927 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is not acknowledged");
2928 }
2929 }
2930
2931 /**
2932 * Verifies that a text message created with {@link MockQueueSession#createMessage}
2933 * is not acknowledged.
2934 * This method makes sense if messages are not cloned
2935 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
2936 * If messages are cloned, the cloned message is acknowledged instead of
2937 * the created message.
2938 * The session has to be created using the current {@link MockQueueConnection}.
2939 * @param indexOfSession the index of the session
2940 * @param indexOfMessage the index of the message
2941 * @throws VerifyFailedException if verification fails
2942 */
2943 public void verifyCreatedQueueTextMessageNotAcknowledged(int indexOfSession, int indexOfMessage)
2944 {
2945 checkAndGetQueueSessionByIndex(indexOfSession);
2946 List messageList = getQueueMessageManager(indexOfSession).getTextMessageList();
2947 if(indexOfMessage >= messageList.size())
2948 {
2949 throw new VerifyFailedException("Only " + messageList.size() + " text messages created for session " + indexOfSession);
2950 }
2951 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
2952 if(message.isAcknowledged())
2953 {
2954 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is acknowledged");
2955 }
2956 }
2957
2958 /**
2959 * Verifies that a stream message created with {@link MockQueueSession#createMessage}
2960 * is acknowledged.
2961 * This method makes sense if messages are not cloned
2962 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
2963 * If messages are cloned, the cloned message is acknowledged instead of
2964 * the created message.
2965 * The session has to be created using the current {@link MockQueueConnection}.
2966 * @param indexOfSession the index of the session
2967 * @param indexOfMessage the index of the message
2968 * @throws VerifyFailedException if verification fails
2969 */
2970 public void verifyCreatedQueueStreamMessageAcknowledged(int indexOfSession, int indexOfMessage)
2971 {
2972 checkAndGetQueueSessionByIndex(indexOfSession);
2973 List messageList = getQueueMessageManager(indexOfSession).getStreamMessageList();
2974 if(indexOfMessage >= messageList.size())
2975 {
2976 throw new VerifyFailedException("Only " + messageList.size() + " stream messages created for session " + indexOfSession);
2977 }
2978 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
2979 if(!message.isAcknowledged())
2980 {
2981 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is not acknowledged");
2982 }
2983 }
2984
2985 /**
2986 * Verifies that a stream message created with {@link MockQueueSession#createMessage}
2987 * is not acknowledged.
2988 * This method makes sense if messages are not cloned
2989 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
2990 * If messages are cloned, the cloned message is acknowledged instead of
2991 * the created message.
2992 * The session has to be created using the current {@link MockQueueConnection}.
2993 * @param indexOfSession the index of the session
2994 * @param indexOfMessage the index of the message
2995 * @throws VerifyFailedException if verification fails
2996 */
2997 public void verifyCreatedQueueStreamMessageNotAcknowledged(int indexOfSession, int indexOfMessage)
2998 {
2999 checkAndGetQueueSessionByIndex(indexOfSession);
3000 List messageList = getQueueMessageManager(indexOfSession).getStreamMessageList();
3001 if(indexOfMessage >= messageList.size())
3002 {
3003 throw new VerifyFailedException("Only " + messageList.size() + " stream messages created for session " + indexOfSession);
3004 }
3005 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
3006 if(message.isAcknowledged())
3007 {
3008 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is acknowledged");
3009 }
3010 }
3011
3012 /**
3013 * Verifies that a object message created with {@link MockQueueSession#createMessage}
3014 * is acknowledged.
3015 * This method makes sense if messages are not cloned
3016 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3017 * If messages are cloned, the cloned message is acknowledged instead of
3018 * the created message.
3019 * The session has to be created using the current {@link MockQueueConnection}.
3020 * @param indexOfSession the index of the session
3021 * @param indexOfMessage the index of the message
3022 * @throws VerifyFailedException if verification fails
3023 */
3024 public void verifyCreatedQueueObjectMessageAcknowledged(int indexOfSession, int indexOfMessage)
3025 {
3026 checkAndGetQueueSessionByIndex(indexOfSession);
3027 List messageList = getQueueMessageManager(indexOfSession).getObjectMessageList();
3028 if(indexOfMessage >= messageList.size())
3029 {
3030 throw new VerifyFailedException("Only " + messageList.size() + " object messages created for session " + indexOfSession);
3031 }
3032 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
3033 if(!message.isAcknowledged())
3034 {
3035 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is not acknowledged");
3036 }
3037 }
3038
3039 /**
3040 * Verifies that a object message created with {@link MockQueueSession#createMessage}
3041 * is not acknowledged.
3042 * This method makes sense if messages are not cloned
3043 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3044 * If messages are cloned, the cloned message is acknowledged instead of
3045 * the created message.
3046 * The session has to be created using the current {@link MockQueueConnection}.
3047 * @param indexOfSession the index of the session
3048 * @param indexOfMessage the index of the message
3049 * @throws VerifyFailedException if verification fails
3050 */
3051 public void verifyCreatedQueueObjectMessageNotAcknowledged(int indexOfSession, int indexOfMessage)
3052 {
3053 checkAndGetQueueSessionByIndex(indexOfSession);
3054 List messageList = getQueueMessageManager(indexOfSession).getObjectMessageList();
3055 if(indexOfMessage >= messageList.size())
3056 {
3057 throw new VerifyFailedException("Only " + messageList.size() + " object messages created for session " + indexOfSession);
3058 }
3059 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
3060 if(message.isAcknowledged())
3061 {
3062 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is acknowledged");
3063 }
3064 }
3065
3066 /**
3067 * Verifies that a message in the specified topic is equal to
3068 * the specified message by calling the <code>equals()</code> method.
3069 * All mock messages provide a suitable implementation of <code>equals()</code>.
3070 * @param nameOfTopic the name of the topic
3071 * @param indexOfSourceMessage the index of the message in the topic
3072 * @param targetMessage the message that will be used for comparison
3073 * @throws VerifyFailedException if verification fails
3074 */
3075 public void verifyCurrentTopicMessageEquals(String nameOfTopic, int indexOfSourceMessage, MockMessage targetMessage)
3076 {
3077 checkTopicByName(nameOfTopic);
3078 List messageList = getCurrentMessageListFromTopic(nameOfTopic);
3079 if(indexOfSourceMessage >= messageList.size())
3080 {
3081 throw new VerifyFailedException("Topic " + nameOfTopic + " contains only " + messageList.size() + " messages");
3082 }
3083 MockMessage sourceMessage = (MockMessage)messageList.get(indexOfSourceMessage);
3084 verifyMessageEquals(sourceMessage, targetMessage);
3085 }
3086
3087 /**
3088 * Verifies that a received message is equal to the specified message
3089 * by calling the <code>equals()</code> method.
3090 * All mock messages provide a suitable implementation of <code>equals()</code>.
3091 * @param nameOfTopic the name of the topic
3092 * @param indexOfSourceMessage the index of the received message
3093 * @param targetMessage the message that will be used for comparison
3094 * @throws VerifyFailedException if verification fails
3095 */
3096 public void verifyReceivedTopicMessageEquals(String nameOfTopic, int indexOfSourceMessage, MockMessage targetMessage)
3097 {
3098 checkTopicByName(nameOfTopic);
3099 List messageList = getReceivedMessageListFromTopic(nameOfTopic);
3100 if(indexOfSourceMessage >= messageList.size())
3101 {
3102 throw new VerifyFailedException("Topic " + nameOfTopic + " received only " + messageList.size() + " messages");
3103 }
3104 MockMessage sourceMessage = (MockMessage)messageList.get(indexOfSourceMessage);
3105 verifyMessageEquals(sourceMessage, targetMessage);
3106 }
3107
3108 /**
3109 * Verifies that a message in the specified temporary topic is equal to
3110 * the specified message by calling the <code>equals()</code> method.
3111 * All mock messages provide a suitable implementation of <code>equals()</code>.
3112 * The session has to be created using the current {@link MockTopicConnection}.
3113 * @param indexOfSession the index of the session
3114 * @param indexOfTopic the index of the temporary topic
3115 * @param indexOfSourceMessage the index of the message in the topic
3116 * @param targetMessage the message that will be used for comparison
3117 * @throws VerifyFailedException if verification fails
3118 */
3119 public void verifyCurrentTopicMessageEquals(int indexOfSession, int indexOfTopic, int indexOfSourceMessage, MockMessage targetMessage)
3120 {
3121 checkAndGetTopicSessionByIndex(indexOfSession);
3122 List messageList = getCurrentMessageListFromTemporaryTopic(indexOfSession, indexOfTopic);
3123 if(null == messageList)
3124 {
3125 throw new VerifyFailedException("Temporary topic with index " + indexOfTopic + " of session with index " + indexOfSession + " does not exist");
3126 }
3127 if(indexOfSourceMessage >= messageList.size())
3128 {
3129 throw new VerifyFailedException("Temporary topic with index " + indexOfTopic + " contains only " + messageList.size() + " messages");
3130 }
3131 MockMessage sourceMessage = (MockMessage)messageList.get(indexOfSourceMessage);
3132 verifyMessageEquals(sourceMessage, targetMessage);
3133 }
3134
3135 /**
3136 * Verifies that a message received by a temporary topic is equal to the specified message
3137 * by calling the <code>equals()</code> method.
3138 * All mock messages provide a suitable implementation of <code>equals()</code>.
3139 * The session has to be created using the current {@link MockTopicConnection}.
3140 * @param indexOfSession the index of the session
3141 * @param indexOfTopic the index of the temporary topic
3142 * @param indexOfSourceMessage the index of the received message
3143 * @param targetMessage the message that will be used for comparison
3144 * @throws VerifyFailedException if verification fails
3145 */
3146 public void verifyReceivedTopicMessageEquals(int indexOfSession, int indexOfTopic, int indexOfSourceMessage, MockMessage targetMessage)
3147 {
3148 checkAndGetTopicSessionByIndex(indexOfSession);
3149 List messageList = getReceivedMessageListFromTemporaryTopic(indexOfSession, indexOfTopic);
3150 if(null == messageList)
3151 {
3152 throw new VerifyFailedException("Temporary topic with index " + indexOfTopic + " of session with index " + indexOfSession + " does not exist");
3153 }
3154 if(indexOfSourceMessage >= messageList.size())
3155 {
3156 throw new VerifyFailedException("Temporary topic with index " + indexOfTopic + " received only " + messageList.size() + " messages");
3157 }
3158 MockMessage sourceMessage = (MockMessage)messageList.get(indexOfSourceMessage);
3159 verifyMessageEquals(sourceMessage, targetMessage);
3160 }
3161
3162 /**
3163 * Verifies the number of messages in a topic.
3164 * @param nameOfTopic the name of the topic
3165 * @param numberOfMessages the expected number of messages
3166 * @throws VerifyFailedException if verification fails
3167 */
3168 public void verifyNumberOfCurrentTopicMessages(String nameOfTopic, int numberOfMessages)
3169 {
3170 checkTopicByName(nameOfTopic);
3171 List list = getCurrentMessageListFromTopic(nameOfTopic);
3172 if(numberOfMessages != list.size())
3173 {
3174 throw new VerifyFailedException("Expected " + numberOfMessages + " messages in topic " + nameOfTopic + ", received " + list.size() + " messages");
3175 }
3176 }
3177
3178 /**
3179 * Verifies the number of messages received by a topic.
3180 * @param nameOfTopic the name of the topic
3181 * @param numberOfMessages the expected number of messages
3182 * @throws VerifyFailedException if verification fails
3183 */
3184 public void verifyNumberOfReceivedTopicMessages(String nameOfTopic, int numberOfMessages)
3185 {
3186 checkTopicByName(nameOfTopic);
3187 List list = getReceivedMessageListFromTopic(nameOfTopic);
3188 if(numberOfMessages != list.size())
3189 {
3190 throw new VerifyFailedException("Expected " + numberOfMessages + " messages received by topic " + nameOfTopic + ", received " + list.size() + " messages");
3191 }
3192 }
3193
3194 /**
3195 * Verifies the number of messages in a temporary topic.
3196 * The session has to be created using the current {@link MockTopicConnection}.
3197 * @param indexOfSession the index of the session
3198 * @param indexOfTopic the index of the temporary topic
3199 * @param numberOfMessages the expected number of messages
3200 * @throws VerifyFailedException if verification fails
3201 */
3202 public void verifyNumberOfCurrentTopicMessages(int indexOfSession, int indexOfTopic, int numberOfMessages)
3203 {
3204 checkAndGetTopicSessionByIndex(indexOfSession);
3205 List list = getCurrentMessageListFromTemporaryTopic(indexOfSession, indexOfTopic);
3206 if(null == list)
3207 {
3208 throw new VerifyFailedException("Temporary topic with index " + indexOfTopic + " of session with index " + indexOfSession + " does not exist");
3209 }
3210 if(numberOfMessages != list.size())
3211 {
3212 throw new VerifyFailedException("Expected " + numberOfMessages + " messages, received " + list.size() + " messages");
3213 }
3214 }
3215
3216 /**
3217 * Verifies the number of messages received by a temporary topic.
3218 * The session has to be created using the current {@link MockTopicConnection}.
3219 * @param indexOfSession the index of the session
3220 * @param indexOfTopic the index of the temporary topic
3221 * @param numberOfMessages the expected number of messages
3222 * @throws VerifyFailedException if verification fails
3223 */
3224 public void verifyNumberOfReceivedTopicMessages(int indexOfSession, int indexOfTopic, int numberOfMessages)
3225 {
3226 checkAndGetTopicSessionByIndex(indexOfSession);
3227 List list = getReceivedMessageListFromTemporaryTopic(indexOfSession, indexOfTopic);
3228 if(null == list)
3229 {
3230 throw new VerifyFailedException("Temporary topic with index " + indexOfTopic + " of session with index " + indexOfSession + " does not exist");
3231 }
3232 if(numberOfMessages != list.size())
3233 {
3234 throw new VerifyFailedException("Expected " + numberOfMessages + " messages, received " + list.size() + " messages");
3235 }
3236 }
3237
3238 /**
3239 * Verifies that all received messages of the specified topic
3240 * are acknowledged.
3241 * @param nameOfTopic the name of the topic
3242 * @throws VerifyFailedException if verification fails
3243 */
3244 public void verifyAllReceivedTopicMessagesAcknowledged(String nameOfTopic)
3245 {
3246 checkTopicByName(nameOfTopic);
3247 List messageList = getReceivedMessageListFromTopic(nameOfTopic);
3248 for(int ii = 0; ii < messageList.size(); ii++)
3249 {
3250 MockMessage currentMessage = (MockMessage)messageList.get(ii);
3251 if(!currentMessage.isAcknowledged())
3252 {
3253 throw new VerifyFailedException("Message " + ii + " of topic " + nameOfTopic + " is not acknowledged");
3254 }
3255 }
3256 }
3257
3258 /**
3259 * Verifies that all received messages of the specified temporary topic
3260 * are acknowledged.
3261 * The session has to be created using the current {@link MockTopicConnection}.
3262 * @param indexOfSession the index of the session
3263 * @param indexOfTopic the index of the temporary topic
3264 * @throws VerifyFailedException if verification fails
3265 */
3266 public void verifyAllReceivedTopicMessagesAcknowledged(int indexOfSession, int indexOfTopic)
3267 {
3268 checkAndGetTopicSessionByIndex(indexOfSession);
3269 List messageList = getReceivedMessageListFromTemporaryTopic(indexOfSession, indexOfTopic);
3270 if(null == messageList)
3271 {
3272 throw new VerifyFailedException("Temporary topic with index " + indexOfTopic + " of session with index " + indexOfSession + " does not exist");
3273 }
3274 for(int ii = 0; ii < messageList.size(); ii++)
3275 {
3276 MockMessage currentMessage = (MockMessage)messageList.get(ii);
3277 if(!currentMessage.isAcknowledged())
3278 {
3279 throw new VerifyFailedException("Message " + ii + " of temporary topic " + indexOfTopic + " is not acknowledged");
3280 }
3281 }
3282 }
3283
3284 /**
3285 * Verifies that a received message is acknowledged.
3286 * @param nameOfTopic the name of the topic
3287 * @param indexOfMessage the index of the received message
3288 * @throws VerifyFailedException if verification fails
3289 */
3290 public void verifyReceivedTopicMessageAcknowledged(String nameOfTopic, int indexOfMessage)
3291 {
3292 checkTopicByName(nameOfTopic);
3293 List messageList = getReceivedMessageListFromTopic(nameOfTopic);
3294 if(indexOfMessage >= messageList.size())
3295 {
3296 throw new VerifyFailedException("Topic " + nameOfTopic + " received only " + messageList.size() + " messages");
3297 }
3298 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
3299 if(!message.isAcknowledged())
3300 {
3301 throw new VerifyFailedException("Message " + indexOfMessage + " of topic " + nameOfTopic + " is not acknowledged");
3302 }
3303 }
3304
3305 /**
3306 * Verifies that a received message is not acknowledged.
3307 * @param nameOfTopic the name of the topic
3308 * @param indexOfMessage the index of the received message
3309 * @throws VerifyFailedException if verification fails
3310 */
3311 public void verifyReceivedTopicMessageNotAcknowledged(String nameOfTopic, int indexOfMessage)
3312 {
3313 checkTopicByName(nameOfTopic);
3314 List messageList = getReceivedMessageListFromTopic(nameOfTopic);
3315 if(indexOfMessage >= messageList.size())
3316 {
3317 throw new VerifyFailedException("Topic " + nameOfTopic + " received only " + messageList.size() + " messages");
3318 }
3319 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
3320 if(message.isAcknowledged())
3321 {
3322 throw new VerifyFailedException("Message " + indexOfMessage + " of topic " + nameOfTopic + " is acknowledged");
3323 }
3324 }
3325
3326 /**
3327 * Verifies that a message received by a temporary topic is acknowledged.
3328 * The session has to be created using the current {@link MockTopicConnection}.
3329 * @param indexOfSession the index of the session
3330 * @param indexOfTopic the index of the temporary topic
3331 * @param indexOfMessage the index of the received message
3332 * @throws VerifyFailedException if verification fails
3333 */
3334 public void verifyReceivedTopicMessageAcknowledged(int indexOfSession, int indexOfTopic, int indexOfMessage)
3335 {
3336 checkAndGetTopicSessionByIndex(indexOfSession);
3337 List messageList = getReceivedMessageListFromTemporaryTopic(indexOfSession, indexOfTopic);
3338 if(null == messageList)
3339 {
3340 throw new VerifyFailedException("Temporary topic with index " + indexOfTopic + " of session with index " + indexOfSession + " does not exist");
3341 }
3342 if(indexOfMessage >= messageList.size())
3343 {
3344 throw new VerifyFailedException("Temporary topic with index " + indexOfTopic + " received only " + messageList.size() + " messages");
3345 }
3346 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
3347 if(!message.isAcknowledged())
3348 {
3349 throw new VerifyFailedException("Message " + indexOfMessage + " of temporary topic " + indexOfTopic + " is not acknowledged");
3350 }
3351 }
3352
3353 /**
3354 * Verifies that a message received by a temporary topic is not acknowledged.
3355 * The session has to be created using the current {@link MockTopicConnection}.
3356 * @param indexOfSession the index of the session
3357 * @param indexOfTopic the index of the temporary topic
3358 * @param indexOfMessage the index of the received message
3359 * @throws VerifyFailedException if verification fails
3360 */
3361 public void verifyReceivedTopicMessageNotAcknowledged(int indexOfSession, int indexOfTopic, int indexOfMessage)
3362 {
3363 checkAndGetTopicSessionByIndex(indexOfSession);
3364 List messageList = getReceivedMessageListFromTemporaryTopic(indexOfSession, indexOfTopic);
3365 if(null == messageList)
3366 {
3367 throw new VerifyFailedException("Temporary topic with index " + indexOfTopic + " of session with index " + indexOfSession + " does not exist");
3368 }
3369 if(indexOfMessage >= messageList.size())
3370 {
3371 throw new VerifyFailedException("Temporary topic with index " + indexOfTopic + " received only " + messageList.size() + " messages");
3372 }
3373 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
3374 if(message.isAcknowledged())
3375 {
3376 throw new VerifyFailedException("Message " + indexOfMessage + " of temporary topic " + indexOfTopic + " is acknowledged");
3377 }
3378 }
3379
3380 /**
3381 * Verifies the number of messages created with
3382 * {@link MockTopicSession#createMessage}.
3383 * The session has to be created using the current {@link MockTopicConnection}.
3384 * @param indexOfSession the index of the session
3385 * @param number the expected number of messages
3386 * @throws VerifyFailedException if verification fails
3387 */
3388 public void verifyNumberOfCreatedTopicMessages(int indexOfSession, int number)
3389 {
3390 checkAndGetTopicSessionByIndex(indexOfSession);
3391 if(number != getTopicMessageManager(indexOfSession).getMessageList().size())
3392 {
3393 throw new VerifyFailedException("Expected " + number + " messages, received " + getTopicMessageManager(indexOfSession).getMessageList().size() + " messages");
3394 }
3395 }
3396
3397 /**
3398 * Verifies the number of bytes messages created with
3399 * {@link MockTopicSession#createBytesMessage}.
3400 * The session has to be created using the current {@link MockTopicConnection}.
3401 * @param indexOfSession the index of the session
3402 * @param number the expected number of bytes messages
3403 * @throws VerifyFailedException if verification fails
3404 */
3405 public void verifyNumberOfCreatedTopicBytesMessages(int indexOfSession, int number)
3406 {
3407 checkAndGetTopicSessionByIndex(indexOfSession);
3408 if(number != getTopicMessageManager(indexOfSession).getBytesMessageList().size())
3409 {
3410 throw new VerifyFailedException("Expected " + number + " bytes messages, received " + getTopicMessageManager(indexOfSession).getBytesMessageList().size() + " bytes messages");
3411 }
3412 }
3413
3414 /**
3415 * Verifies the number of map messages created with
3416 * {@link MockTopicSession#createMapMessage}.
3417 * The session has to be created using the current {@link MockTopicConnection}.
3418 * @param indexOfSession the index of the session
3419 * @param number the expected number of map messages
3420 * @throws VerifyFailedException if verification fails
3421 */
3422 public void verifyNumberOfCreatedTopicMapMessages(int indexOfSession, int number)
3423 {
3424 checkAndGetTopicSessionByIndex(indexOfSession);
3425 if(number != getTopicMessageManager(indexOfSession).getMapMessageList().size())
3426 {
3427 throw new VerifyFailedException("Expected " + number + " map messages, received " + getTopicMessageManager(indexOfSession).getMapMessageList().size() + " map messages");
3428 }
3429 }
3430
3431 /**
3432 * Verifies the number of text messages created with
3433 * {@link MockTopicSession#createTextMessage}.
3434 * The session has to be created using the current {@link MockTopicConnection}.
3435 * @param indexOfSession the index of the session
3436 * @param number the expected number of text messages
3437 * @throws VerifyFailedException if verification fails
3438 */
3439 public void verifyNumberOfCreatedTopicTextMessages(int indexOfSession, int number)
3440 {
3441 checkAndGetTopicSessionByIndex(indexOfSession);
3442 if(number != getTopicMessageManager(indexOfSession).getTextMessageList().size())
3443 {
3444 throw new VerifyFailedException("Expected " + number + " text messages, received " + getTopicMessageManager(indexOfSession).getTextMessageList().size() + " text messages");
3445 }
3446 }
3447
3448 /**
3449 * Verifies the number of stream messages created with
3450 * {@link MockTopicSession#createStreamMessage}.
3451 * The session has to be created using the current {@link MockTopicConnection}.
3452 * @param indexOfSession the index of the session
3453 * @param number the expected number of stream messages
3454 * @throws VerifyFailedException if verification fails
3455 */
3456 public void verifyNumberOfCreatedTopicStreamMessages(int indexOfSession, int number)
3457 {
3458 checkAndGetTopicSessionByIndex(indexOfSession);
3459 if(number != getTopicMessageManager(indexOfSession).getStreamMessageList().size())
3460 {
3461 throw new VerifyFailedException("Expected " + number + " stream messages, received " + getTopicMessageManager(indexOfSession).getStreamMessageList().size() + " stream messages");
3462 }
3463 }
3464
3465 /**
3466 * Verifies the number of object messages created with
3467 * {@link MockTopicSession#createObjectMessage}.
3468 * The session has to be created using the current {@link MockTopicConnection}.
3469 * @param indexOfSession the index of the session
3470 * @param number the expected number of object messages
3471 * @throws VerifyFailedException if verification fails
3472 */
3473 public void verifyNumberOfCreatedTopicObjectMessages(int indexOfSession, int number)
3474 {
3475 checkAndGetTopicSessionByIndex(indexOfSession);
3476 if(number != getTopicMessageManager(indexOfSession).getObjectMessageList().size())
3477 {
3478 throw new VerifyFailedException("Expected " + number + " object messages, received " + getTopicMessageManager(indexOfSession).getObjectMessageList().size() + " object messages");
3479 }
3480 }
3481
3482 /**
3483 * Verifies that a message created with {@link MockTopicSession#createMessage}
3484 * is acknowledged. This method makes sense if messages are not cloned
3485 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3486 * If messages are cloned, the cloned message is acknowledged instead of
3487 * the created message.
3488 * The session has to be created using the current {@link MockTopicConnection}.
3489 * @param indexOfSession the index of the session
3490 * @param indexOfMessage the index of the message
3491 * @throws VerifyFailedException if verification fails
3492 */
3493 public void verifyCreatedTopicMessageAcknowledged(int indexOfSession, int indexOfMessage)
3494 {
3495 checkAndGetTopicSessionByIndex(indexOfSession);
3496 List messageList = getTopicMessageManager(indexOfSession).getMessageList();
3497 if(indexOfMessage >= messageList.size())
3498 {
3499 throw new VerifyFailedException("Only " + messageList.size() + " messages created for session " + indexOfSession);
3500 }
3501 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
3502 if(!message.isAcknowledged())
3503 {
3504 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is not acknowledged");
3505 }
3506 }
3507
3508 /**
3509 * Verifies that a message created with {@link MockTopicSession#createMessage}
3510 * is not acknowledged. This method makes sense if messages are not cloned
3511 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3512 * If messages are cloned, the cloned message is acknowledged instead of
3513 * the created message.
3514 * The session has to be created using the current {@link MockTopicConnection}.
3515 * @param indexOfSession the index of the session
3516 * @param indexOfMessage the index of the message
3517 * @throws VerifyFailedException if verification fails
3518 */
3519 public void verifyCreatedTopicMessageNotAcknowledged(int indexOfSession, int indexOfMessage)
3520 {
3521 checkAndGetTopicSessionByIndex(indexOfSession);
3522 List messageList = getTopicMessageManager(indexOfSession).getMessageList();
3523 if(indexOfMessage >= messageList.size())
3524 {
3525 throw new VerifyFailedException("Only " + messageList.size() + " messages created for session " + indexOfSession);
3526 }
3527 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
3528 if(message.isAcknowledged())
3529 {
3530 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is acknowledged");
3531 }
3532 }
3533
3534 /**
3535 * Verifies that a bytes message created with {@link MockTopicSession#createMessage}
3536 * is acknowledged. This method makes sense if messages are not cloned
3537 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3538 * If messages are cloned, the cloned message is acknowledged instead of
3539 * the created message.
3540 * The session has to be created using the current {@link MockTopicConnection}.
3541 * @param indexOfSession the index of the session
3542 * @param indexOfMessage the index of the message
3543 * @throws VerifyFailedException if verification fails
3544 */
3545 public void verifyCreatedTopicBytesMessageAcknowledged(int indexOfSession, int indexOfMessage)
3546 {
3547 checkAndGetTopicSessionByIndex(indexOfSession);
3548 List messageList = getTopicMessageManager(indexOfSession).getBytesMessageList();
3549 if(indexOfMessage >= messageList.size())
3550 {
3551 throw new VerifyFailedException("Only " + messageList.size() + " bytes messages created for session " + indexOfSession);
3552 }
3553 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
3554 if(!message.isAcknowledged())
3555 {
3556 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is not acknowledged");
3557 }
3558 }
3559
3560 /**
3561 * Verifies that a bytes message created with {@link MockTopicSession#createMessage}
3562 * is not acknowledged. This method makes sense if messages are not cloned
3563 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3564 * If messages are cloned, the cloned message is acknowledged instead of
3565 * the created message.
3566 * The session has to be created using the current {@link MockTopicConnection}.
3567 * @param indexOfSession the index of the session
3568 * @param indexOfMessage the index of the message
3569 * @throws VerifyFailedException if verification fails
3570 */
3571 public void verifyCreatedTopicBytesMessageNotAcknowledged(int indexOfSession, int indexOfMessage)
3572 {
3573 checkAndGetTopicSessionByIndex(indexOfSession);
3574 List messageList = getTopicMessageManager(indexOfSession).getBytesMessageList();
3575 if(indexOfMessage >= messageList.size())
3576 {
3577 throw new VerifyFailedException("Only " + messageList.size() + " bytes messages created for session " + indexOfSession);
3578 }
3579 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
3580 if(message.isAcknowledged())
3581 {
3582 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is acknowledged");
3583 }
3584 }
3585
3586 /**
3587 * Verifies that a map message created with {@link MockTopicSession#createMessage}
3588 * is acknowledged. This method makes sense if messages are not cloned
3589 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3590 * If messages are cloned, the cloned message is acknowledged instead of
3591 * the created message.
3592 * The session has to be created using the current {@link MockTopicConnection}.
3593 * @param indexOfSession the index of the session
3594 * @param indexOfMessage the index of the message
3595 * @throws VerifyFailedException if verification fails
3596 */
3597 public void verifyCreatedTopicMapMessageAcknowledged(int indexOfSession, int indexOfMessage)
3598 {
3599 checkAndGetTopicSessionByIndex(indexOfSession);
3600 List messageList = getTopicMessageManager(indexOfSession).getMapMessageList();
3601 if(indexOfMessage >= messageList.size())
3602 {
3603 throw new VerifyFailedException("Only " + messageList.size() + " map messages created for session " + indexOfSession);
3604 }
3605 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
3606 if(!message.isAcknowledged())
3607 {
3608 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is not acknowledged");
3609 }
3610 }
3611
3612 /**
3613 * Verifies that a map message created with {@link MockTopicSession#createMessage}
3614 * is not acknowledged. This method makes sense if messages are not cloned
3615 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3616 * If messages are cloned, the cloned message is acknowledged instead of
3617 * the created message.
3618 * The session has to be created using the current {@link MockTopicConnection}.
3619 * @param indexOfSession the index of the session
3620 * @param indexOfMessage the index of the message
3621 * @throws VerifyFailedException if verification fails
3622 */
3623 public void verifyCreatedTopicMapMessageNotAcknowledged(int indexOfSession, int indexOfMessage)
3624 {
3625 checkAndGetTopicSessionByIndex(indexOfSession);
3626 List messageList = getTopicMessageManager(indexOfSession).getMapMessageList();
3627 if(indexOfMessage >= messageList.size())
3628 {
3629 throw new VerifyFailedException("Only " + messageList.size() + " map messages created for session " + indexOfSession);
3630 }
3631 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
3632 if(message.isAcknowledged())
3633 {
3634 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is acknowledged");
3635 }
3636 }
3637
3638 /**
3639 * Verifies that a text message created with {@link MockTopicSession#createMessage}
3640 * is acknowledged. This method makes sense if messages are not cloned
3641 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3642 * If messages are cloned, the cloned message is acknowledged instead of
3643 * the created message.
3644 * The session has to be created using the current {@link MockTopicConnection}.
3645 * @param indexOfSession the index of the session
3646 * @param indexOfMessage the index of the message
3647 * @throws VerifyFailedException if verification fails
3648 */
3649 public void verifyCreatedTopicTextMessageAcknowledged(int indexOfSession, int indexOfMessage)
3650 {
3651 checkAndGetTopicSessionByIndex(indexOfSession);
3652 List messageList = getTopicMessageManager(indexOfSession).getTextMessageList();
3653 if(indexOfMessage >= messageList.size())
3654 {
3655 throw new VerifyFailedException("Only " + messageList.size() + " text messages created for session " + indexOfSession);
3656 }
3657 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
3658 if(!message.isAcknowledged())
3659 {
3660 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is not acknowledged");
3661 }
3662 }
3663
3664 /**
3665 * Verifies that a text message created with {@link MockTopicSession#createMessage}
3666 * is not acknowledged. This method makes sense if messages are not cloned
3667 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3668 * If messages are cloned, the cloned message is acknowledged instead of
3669 * the created message.
3670 * The session has to be created using the current {@link MockTopicConnection}.
3671 * @param indexOfSession the index of the session
3672 * @param indexOfMessage the index of the message
3673 * @throws VerifyFailedException if verification fails
3674 */
3675 public void verifyCreatedTopicTextMessageNotAcknowledged(int indexOfSession, int indexOfMessage)
3676 {
3677 checkAndGetTopicSessionByIndex(indexOfSession);
3678 List messageList = getTopicMessageManager(indexOfSession).getTextMessageList();
3679 if(indexOfMessage >= messageList.size())
3680 {
3681 throw new VerifyFailedException("Only " + messageList.size() + " text messages created for session " + indexOfSession);
3682 }
3683 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
3684 if(message.isAcknowledged())
3685 {
3686 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is acknowledged");
3687 }
3688 }
3689
3690 /**
3691 * Verifies that a stream message created with {@link MockTopicSession#createMessage}
3692 * is acknowledged. This method makes sense if messages are not cloned
3693 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3694 * If messages are cloned, the cloned message is acknowledged instead of
3695 * the created message.
3696 * The session has to be created using the current {@link MockTopicConnection}.
3697 * @param indexOfSession the index of the session
3698 * @param indexOfMessage the index of the message
3699 * @throws VerifyFailedException if verification fails
3700 */
3701 public void verifyCreatedTopicStreamMessageAcknowledged(int indexOfSession, int indexOfMessage)
3702 {
3703 checkAndGetTopicSessionByIndex(indexOfSession);
3704 List messageList = getTopicMessageManager(indexOfSession).getStreamMessageList();
3705 if(indexOfMessage >= messageList.size())
3706 {
3707 throw new VerifyFailedException("Only " + messageList.size() + " stream messages created for session " + indexOfSession);
3708 }
3709 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
3710 if(!message.isAcknowledged())
3711 {
3712 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is not acknowledged");
3713 }
3714 }
3715
3716 /**
3717 * Verifies that a stream message created with {@link MockTopicSession#createMessage}
3718 * is not acknowledged. This method makes sense if messages are not cloned
3719 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3720 * If messages are cloned, the cloned message is acknowledged instead of
3721 * the created message.
3722 * The session has to be created using the current {@link MockTopicConnection}.
3723 * @param indexOfSession the index of the session
3724 * @param indexOfMessage the index of the message
3725 * @throws VerifyFailedException if verification fails
3726 */
3727 public void verifyCreatedTopicStreamMessageNotAcknowledged(int indexOfSession, int indexOfMessage)
3728 {
3729 checkAndGetTopicSessionByIndex(indexOfSession);
3730 List messageList = getTopicMessageManager(indexOfSession).getStreamMessageList();
3731 if(indexOfMessage >= messageList.size())
3732 {
3733 throw new VerifyFailedException("Only " + messageList.size() + " stream messages created for session " + indexOfSession);
3734 }
3735 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
3736 if(message.isAcknowledged())
3737 {
3738 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is acknowledged");
3739 }
3740 }
3741
3742 /**
3743 * Verifies that a object message created with {@link MockTopicSession#createMessage}
3744 * is acknowledged. This method makes sense if messages are not cloned
3745 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3746 * If messages are cloned, the cloned message is acknowledged instead of
3747 * the created message.
3748 * The session has to be created using the current {@link MockTopicConnection}.
3749 * @param indexOfSession the index of the session
3750 * @param indexOfMessage the index of the message
3751 * @throws VerifyFailedException if verification fails
3752 */
3753 public void verifyCreatedTopicObjectMessageAcknowledged(int indexOfSession, int indexOfMessage)
3754 {
3755 checkAndGetTopicSessionByIndex(indexOfSession);
3756 List messageList = getTopicMessageManager(indexOfSession).getObjectMessageList();
3757 if(indexOfMessage >= messageList.size())
3758 {
3759 throw new VerifyFailedException("Only " + messageList.size() + " object messages created for session " + indexOfSession);
3760 }
3761 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
3762 if(!message.isAcknowledged())
3763 {
3764 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is not acknowledged");
3765 }
3766 }
3767
3768 /**
3769 * Verifies that a object message created with {@link MockTopicSession#createMessage}
3770 * is not acknowledged. This method makes sense if messages are not cloned
3771 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3772 * If messages are cloned, the cloned message is acknowledged instead of
3773 * the created message.
3774 * The session has to be created using the current {@link MockTopicConnection}.
3775 * @param indexOfSession the index of the session
3776 * @param indexOfMessage the index of the message
3777 * @throws VerifyFailedException if verification fails
3778 */
3779 public void verifyCreatedTopicObjectMessageNotAcknowledged(int indexOfSession, int indexOfMessage)
3780 {
3781 checkAndGetTopicSessionByIndex(indexOfSession);
3782 List messageList = getTopicMessageManager(indexOfSession).getObjectMessageList();
3783 if(indexOfMessage >= messageList.size())
3784 {
3785 throw new VerifyFailedException("Only " + messageList.size() + " object messages created for session " + indexOfSession);
3786 }
3787 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
3788 if(message.isAcknowledged())
3789 {
3790 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is acknowledged");
3791 }
3792 }
3793
3794 /**
3795 * Verifies the number of messages created with
3796 * {@link MockSession#createMessage}.
3797 * The session has to be created using the current {@link MockConnection}.
3798 * @param indexOfSession the index of the session
3799 * @param number the expected number of messages
3800 * @throws VerifyFailedException if verification fails
3801 */
3802 public void verifyNumberOfCreatedMessages(int indexOfSession, int number)
3803 {
3804 checkAndGetSessionByIndex(indexOfSession);
3805 if(number != getMessageManager(indexOfSession).getMessageList().size())
3806 {
3807 throw new VerifyFailedException("Expected " + number + " messages, received " + getMessageManager(indexOfSession).getMessageList().size() + " messages");
3808 }
3809 }
3810
3811 /**
3812 * Verifies the number of bytes messages created with
3813 * {@link MockSession#createBytesMessage}.
3814 * The session has to be created using the current {@link MockConnection}.
3815 * @param indexOfSession the index of the session
3816 * @param number the expected number of bytes messages
3817 * @throws VerifyFailedException if verification fails
3818 */
3819 public void verifyNumberOfCreatedBytesMessages(int indexOfSession, int number)
3820 {
3821 checkAndGetSessionByIndex(indexOfSession);
3822 if(number != getMessageManager(indexOfSession).getBytesMessageList().size())
3823 {
3824 throw new VerifyFailedException("Expected " + number + " bytes messages, received " + getMessageManager(indexOfSession).getBytesMessageList().size() + " bytes messages");
3825 }
3826 }
3827
3828 /**
3829 * Verifies the number of map messages created with
3830 * {@link MockSession#createMapMessage}.
3831 * The session has to be created using the current {@link MockConnection}.
3832 * @param indexOfSession the index of the session
3833 * @param number the expected number of map messages
3834 * @throws VerifyFailedException if verification fails
3835 */
3836 public void verifyNumberOfCreatedMapMessages(int indexOfSession, int number)
3837 {
3838 checkAndGetSessionByIndex(indexOfSession);
3839 if(number != getMessageManager(indexOfSession).getMapMessageList().size())
3840 {
3841 throw new VerifyFailedException("Expected " + number + " map messages, received " + getMessageManager(indexOfSession).getMapMessageList().size() + " map messages");
3842 }
3843 }
3844
3845 /**
3846 * Verifies the number of text messages created with
3847 * {@link MockSession#createTextMessage}.
3848 * The session has to be created using the current {@link MockConnection}.
3849 * @param indexOfSession the index of the session
3850 * @param number the expected number of text messages
3851 * @throws VerifyFailedException if verification fails
3852 */
3853 public void verifyNumberOfCreatedTextMessages(int indexOfSession, int number)
3854 {
3855 checkAndGetSessionByIndex(indexOfSession);
3856 if(number != getMessageManager(indexOfSession).getTextMessageList().size())
3857 {
3858 throw new VerifyFailedException("Expected " + number + " text messages, received " + getMessageManager(indexOfSession).getTextMessageList().size() + " text messages");
3859 }
3860 }
3861
3862 /**
3863 * Verifies the number of stream messages created with
3864 * {@link MockSession#createStreamMessage}.
3865 * The session has to be created using the current {@link MockConnection}.
3866 * @param indexOfSession the index of the session
3867 * @param number the expected number of stream messages
3868 * @throws VerifyFailedException if verification fails
3869 */
3870 public void verifyNumberOfCreatedStreamMessages(int indexOfSession, int number)
3871 {
3872 checkAndGetSessionByIndex(indexOfSession);
3873 if(number != getMessageManager(indexOfSession).getStreamMessageList().size())
3874 {
3875 throw new VerifyFailedException("Expected " + number + " stream messages, received " + getMessageManager(indexOfSession).getStreamMessageList().size() + " stream messages");
3876 }
3877 }
3878
3879 /**
3880 * Verifies the number of object messages created with
3881 * {@link MockSession#createObjectMessage}.
3882 * The session has to be created using the current {@link MockConnection}.
3883 * @param indexOfSession the index of the session
3884 * @param number the expected number of object messages
3885 * @throws VerifyFailedException if verification fails
3886 */
3887 public void verifyNumberOfCreatedObjectMessages(int indexOfSession, int number)
3888 {
3889 checkAndGetSessionByIndex(indexOfSession);
3890 if(number != getMessageManager(indexOfSession).getObjectMessageList().size())
3891 {
3892 throw new VerifyFailedException("Expected " + number + " object messages, received " + getMessageManager(indexOfSession).getObjectMessageList().size() + " object messages");
3893 }
3894 }
3895
3896 /**
3897 * Verifies that a message created with {@link MockSession#createMessage}
3898 * is acknowledged. This method makes sense if messages are not cloned
3899 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3900 * If messages are cloned, the cloned message is acknowledged instead of
3901 * the created message.
3902 * The session has to be created using the current {@link MockConnection}.
3903 * @param indexOfSession the index of the session
3904 * @param indexOfMessage the index of the message
3905 * @throws VerifyFailedException if verification fails
3906 */
3907 public void verifyCreatedMessageAcknowledged(int indexOfSession, int indexOfMessage)
3908 {
3909 checkAndGetSessionByIndex(indexOfSession);
3910 List messageList = getMessageManager(indexOfSession).getMessageList();
3911 if(indexOfMessage >= messageList.size())
3912 {
3913 throw new VerifyFailedException("Only " + messageList.size() + " messages created for session " + indexOfSession);
3914 }
3915 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
3916 if(!message.isAcknowledged())
3917 {
3918 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is not acknowledged");
3919 }
3920 }
3921
3922 /**
3923 * Verifies that a message created with {@link MockSession#createMessage}
3924 * is not acknowledged. This method makes sense if messages are not cloned
3925 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3926 * If messages are cloned, the cloned message is acknowledged instead of
3927 * the created message.
3928 * The session has to be created using the current {@link MockConnection}.
3929 * @param indexOfSession the index of the session
3930 * @param indexOfMessage the index of the message
3931 * @throws VerifyFailedException if verification fails
3932 */
3933 public void verifyCreatedMessageNotAcknowledged(int indexOfSession, int indexOfMessage)
3934 {
3935 checkAndGetSessionByIndex(indexOfSession);
3936 List messageList = getMessageManager(indexOfSession).getMessageList();
3937 if(indexOfMessage >= messageList.size())
3938 {
3939 throw new VerifyFailedException("Only " + messageList.size() + " messages created for session " + indexOfSession);
3940 }
3941 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
3942 if(message.isAcknowledged())
3943 {
3944 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is acknowledged");
3945 }
3946 }
3947
3948 /**
3949 * Verifies that a bytes message created with {@link MockSession#createMessage}
3950 * is acknowledged. This method makes sense if messages are not cloned
3951 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3952 * If messages are cloned, the cloned message is acknowledged instead of
3953 * the created message.
3954 * The session has to be created using the current {@link MockConnection}.
3955 * @param indexOfSession the index of the session
3956 * @param indexOfMessage the index of the message
3957 * @throws VerifyFailedException if verification fails
3958 */
3959 public void verifyCreatedBytesMessageAcknowledged(int indexOfSession, int indexOfMessage)
3960 {
3961 checkAndGetSessionByIndex(indexOfSession);
3962 List messageList = getMessageManager(indexOfSession).getBytesMessageList();
3963 if(indexOfMessage >= messageList.size())
3964 {
3965 throw new VerifyFailedException("Only " + messageList.size() + " bytes messages created for session " + indexOfSession);
3966 }
3967 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
3968 if(!message.isAcknowledged())
3969 {
3970 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is not acknowledged");
3971 }
3972 }
3973
3974 /**
3975 * Verifies that a bytes message created with {@link MockSession#createMessage}
3976 * is not acknowledged. This method makes sense if messages are not cloned
3977 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3978 * If messages are cloned, the cloned message is acknowledged instead of
3979 * the created message.
3980 * The session has to be created using the current {@link MockConnection}.
3981 * @param indexOfSession the index of the session
3982 * @param indexOfMessage the index of the message
3983 * @throws VerifyFailedException if verification fails
3984 */
3985 public void verifyCreatedBytesMessageNotAcknowledged(int indexOfSession, int indexOfMessage)
3986 {
3987 checkAndGetSessionByIndex(indexOfSession);
3988 List messageList = getMessageManager(indexOfSession).getBytesMessageList();
3989 if(indexOfMessage >= messageList.size())
3990 {
3991 throw new VerifyFailedException("Only " + messageList.size() + " bytes messages created for session " + indexOfSession);
3992 }
3993 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
3994 if(message.isAcknowledged())
3995 {
3996 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is acknowledged");
3997 }
3998 }
3999
4000 /**
4001 * Verifies that a map message created with {@link MockSession#createMessage}
4002 * is acknowledged. This method makes sense if messages are not cloned
4003 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
4004 * If messages are cloned, the cloned message is acknowledged instead of
4005 * the created message.
4006 * The session has to be created using the current {@link MockConnection}.
4007 * @param indexOfSession the index of the session
4008 * @param indexOfMessage the index of the message
4009 * @throws VerifyFailedException if verification fails
4010 */
4011 public void verifyCreatedMapMessageAcknowledged(int indexOfSession, int indexOfMessage)
4012 {
4013 checkAndGetSessionByIndex(indexOfSession);
4014 List messageList = getMessageManager(indexOfSession).getMapMessageList();
4015 if(indexOfMessage >= messageList.size())
4016 {
4017 throw new VerifyFailedException("Only " + messageList.size() + " map messages created for session " + indexOfSession);
4018 }
4019 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
4020 if(!message.isAcknowledged())
4021 {
4022 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is not acknowledged");
4023 }
4024 }
4025
4026 /**
4027 * Verifies that a map message created with {@link MockSession#createMessage}
4028 * is not acknowledged. This method makes sense if messages are not cloned
4029 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
4030 * If messages are cloned, the cloned message is acknowledged instead of
4031 * the created message.
4032 * The session has to be created using the current {@link MockConnection}.
4033 * @param indexOfSession the index of the session
4034 * @param indexOfMessage the index of the message
4035 * @throws VerifyFailedException if verification fails
4036 */
4037 public void verifyCreatedMapMessageNotAcknowledged(int indexOfSession, int indexOfMessage)
4038 {
4039 checkAndGetSessionByIndex(indexOfSession);
4040 List messageList = getMessageManager(indexOfSession).getMapMessageList();
4041 if(indexOfMessage >= messageList.size())
4042 {
4043 throw new VerifyFailedException("Only " + messageList.size() + " map messages created for session " + indexOfSession);
4044 }
4045 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
4046 if(message.isAcknowledged())
4047 {
4048 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is acknowledged");
4049 }
4050 }
4051
4052 /**
4053 * Verifies that a text message created with {@link MockSession#createMessage}
4054 * is acknowledged. This method makes sense if messages are not cloned
4055 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
4056 * If messages are cloned, the cloned message is acknowledged instead of
4057 * the created message.
4058 * The session has to be created using the current {@link MockConnection}.
4059 * @param indexOfSession the index of the session
4060 * @param indexOfMessage the index of the message
4061 * @throws VerifyFailedException if verification fails
4062 */
4063 public void verifyCreatedTextMessageAcknowledged(int indexOfSession, int indexOfMessage)
4064 {
4065 checkAndGetSessionByIndex(indexOfSession);
4066 List messageList = getMessageManager(indexOfSession).getTextMessageList();
4067 if(indexOfMessage >= messageList.size())
4068 {
4069 throw new VerifyFailedException("Only " + messageList.size() + " text messages created for session " + indexOfSession);
4070 }
4071 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
4072 if(!message.isAcknowledged())
4073 {
4074 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is not acknowledged");
4075 }
4076 }
4077
4078 /**
4079 * Verifies that a text message created with {@link MockSession#createMessage}
4080 * is not acknowledged. This method makes sense if messages are not cloned
4081 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
4082 * If messages are cloned, the cloned message is acknowledged instead of
4083 * the created message.
4084 * The session has to be created using the current {@link MockConnection}.
4085 * @param indexOfSession the index of the session
4086 * @param indexOfMessage the index of the message
4087 * @throws VerifyFailedException if verification fails
4088 */
4089 public void verifyCreatedTextMessageNotAcknowledged(int indexOfSession, int indexOfMessage)
4090 {
4091 checkAndGetSessionByIndex(indexOfSession);
4092 List messageList = getMessageManager(indexOfSession).getTextMessageList();
4093 if(indexOfMessage >= messageList.size())
4094 {
4095 throw new VerifyFailedException("Only " + messageList.size() + " text messages created for session " + indexOfSession);
4096 }
4097 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
4098 if(message.isAcknowledged())
4099 {
4100 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is acknowledged");
4101 }
4102 }
4103
4104 /**
4105 * Verifies that a stream message created with {@link MockSession#createMessage}
4106 * is acknowledged. This method makes sense if messages are not cloned
4107 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
4108 * If messages are cloned, the cloned message is acknowledged instead of
4109 * the created message.
4110 * The session has to be created using the current {@link MockConnection}.
4111 * @param indexOfSession the index of the session
4112 * @param indexOfMessage the index of the message
4113 * @throws VerifyFailedException if verification fails
4114 */
4115 public void verifyCreatedStreamMessageAcknowledged(int indexOfSession, int indexOfMessage)
4116 {
4117 checkAndGetSessionByIndex(indexOfSession);
4118 List messageList = getMessageManager(indexOfSession).getStreamMessageList();
4119 if(indexOfMessage >= messageList.size())
4120 {
4121 throw new VerifyFailedException("Only " + messageList.size() + " stream messages created for session " + indexOfSession);
4122 }
4123 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
4124 if(!message.isAcknowledged())
4125 {
4126 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is not acknowledged");
4127 }
4128 }
4129
4130 /**
4131 * Verifies that a stream message created with {@link MockSession#createMessage}
4132 * is not acknowledged. This method makes sense if messages are not cloned
4133 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
4134 * If messages are cloned, the cloned message is acknowledged instead of
4135 * the created message.
4136 * The session has to be created using the current {@link MockConnection}.
4137 * @param indexOfSession the index of the session
4138 * @param indexOfMessage the index of the message
4139 * @throws VerifyFailedException if verification fails
4140 */
4141 public void verifyCreatedStreamMessageNotAcknowledged(int indexOfSession, int indexOfMessage)
4142 {
4143 checkAndGetSessionByIndex(indexOfSession);
4144 List messageList = getMessageManager(indexOfSession).getStreamMessageList();
4145 if(indexOfMessage >= messageList.size())
4146 {
4147 throw new VerifyFailedException("Only " + messageList.size() + " stream messages created for session " + indexOfSession);
4148 }
4149 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
4150 if(message.isAcknowledged())
4151 {
4152 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is acknowledged");
4153 }
4154 }
4155
4156 /**
4157 * Verifies that a object message created with {@link MockSession#createMessage}
4158 * is acknowledged. This method makes sense if messages are not cloned
4159 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
4160 * If messages are cloned, the cloned message is acknowledged instead of
4161 * the created message.
4162 * The session has to be created using the current {@link MockConnection}.
4163 * @param indexOfSession the index of the session
4164 * @param indexOfMessage the index of the message
4165 * @throws VerifyFailedException if verification fails
4166 */
4167 public void verifyCreatedObjectMessageAcknowledged(int indexOfSession, int indexOfMessage)
4168 {
4169 checkAndGetSessionByIndex(indexOfSession);
4170 List messageList = getMessageManager(indexOfSession).getObjectMessageList();
4171 if(indexOfMessage >= messageList.size())
4172 {
4173 throw new VerifyFailedException("Only " + messageList.size() + " object messages created for session " + indexOfSession);
4174 }
4175 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
4176 if(!message.isAcknowledged())
4177 {
4178 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is not acknowledged");
4179 }
4180 }
4181
4182 /**
4183 * Verifies that a object message created with {@link MockSession#createMessage}
4184 * is not acknowledged. This method makes sense if messages are not cloned
4185 * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
4186 * If messages are cloned, the cloned message is acknowledged instead of
4187 * the created message.
4188 * The session has to be created using the current {@link MockConnection}.
4189 * @param indexOfSession the index of the session
4190 * @param indexOfMessage the index of the message
4191 * @throws VerifyFailedException if verification fails
4192 */
4193 public void verifyCreatedObjectMessageNotAcknowledged(int indexOfSession, int indexOfMessage)
4194 {
4195 checkAndGetSessionByIndex(indexOfSession);
4196 List messageList = getMessageManager(indexOfSession).getObjectMessageList();
4197 if(indexOfMessage >= messageList.size())
4198 {
4199 throw new VerifyFailedException("Only " + messageList.size() + " object messages created for session " + indexOfSession);
4200 }
4201 MockMessage message = (MockMessage)messageList.get(indexOfMessage);
4202 if(message.isAcknowledged())
4203 {
4204 throw new VerifyFailedException("Message " + indexOfMessage + " of session " + indexOfSession + " is acknowledged");
4205 }
4206 }
4207
4208 private MockQueueSession checkAndGetQueueSessionByIndex(int indexOfSession)
4209 {
4210 if(null == getCurrentQueueConnection())
4211 {
4212 throw new VerifyFailedException("No QueueConnection present.");
4213 }
4214 MockQueueSession session = getQueueSession(indexOfSession);
4215 if(null == session)
4216 {
4217 throw new VerifyFailedException("QueueSession with index " + indexOfSession + " does not exist.");
4218 }
4219 return session;
4220 }
4221
4222 private MockTopicSession checkAndGetTopicSessionByIndex(int indexOfSession)
4223 {
4224 if(null == getCurrentTopicConnection())
4225 {
4226 throw new VerifyFailedException("No TopicConnection present.");
4227 }
4228 MockTopicSession session = getTopicSession(indexOfSession);
4229 if(null == session)
4230 {
4231 throw new VerifyFailedException("TopicSession with index " + indexOfSession + " does not exist.");
4232 }
4233 return session;
4234 }
4235
4236 private MockSession checkAndGetSessionByIndex(int indexOfSession)
4237 {
4238 if(null == getCurrentConnection())
4239 {
4240 throw new VerifyFailedException("No Connection present.");
4241 }
4242 MockSession session = getSession(indexOfSession);
4243 if(null == session)
4244 {
4245 throw new VerifyFailedException("Session with index " + indexOfSession + " does not exist.");
4246 }
4247 return session;
4248 }
4249
4250 private void checkQueueByName(String queueName)
4251 {
4252 DestinationManager destinationManager = getDestinationManager();
4253 if(null == destinationManager.getQueue(queueName))
4254 {
4255 throw new VerifyFailedException("Queue with name " + queueName + " is not present.");
4256 }
4257 }
4258
4259 private void checkTopicByName(String topicName)
4260 {
4261 DestinationManager destinationManager = getDestinationManager();
4262 if(null == destinationManager.getTopic(topicName))
4263 {
4264 throw new VerifyFailedException("Topic with name " + topicName + " is not present.");
4265 }
4266 }
4267 }