Source Code Cross Referenced for JMSTestModule.java in  » Testing » mockrunner-0.4 » com » mockrunner » jms » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » mockrunner 0.4 » com.mockrunner.jms 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        package com.mockrunner.jms;
0002:
0003:        import java.util.Iterator;
0004:        import java.util.List;
0005:
0006:        import javax.jms.JMSException;
0007:        import javax.jms.MessageConsumer;
0008:        import javax.jms.MessageListener;
0009:        import javax.jms.Queue;
0010:        import javax.jms.Session;
0011:        import javax.jms.Topic;
0012:
0013:        import com.mockrunner.base.NestedApplicationException;
0014:        import com.mockrunner.base.VerifyFailedException;
0015:        import com.mockrunner.mock.jms.JMSMockObjectFactory;
0016:        import com.mockrunner.mock.jms.MockConnection;
0017:        import com.mockrunner.mock.jms.MockMessage;
0018:        import com.mockrunner.mock.jms.MockMessageConsumer;
0019:        import com.mockrunner.mock.jms.MockMessageProducer;
0020:        import com.mockrunner.mock.jms.MockQueue;
0021:        import com.mockrunner.mock.jms.MockQueueBrowser;
0022:        import com.mockrunner.mock.jms.MockQueueConnection;
0023:        import com.mockrunner.mock.jms.MockQueueConnectionFactory;
0024:        import com.mockrunner.mock.jms.MockQueueReceiver;
0025:        import com.mockrunner.mock.jms.MockQueueSender;
0026:        import com.mockrunner.mock.jms.MockQueueSession;
0027:        import com.mockrunner.mock.jms.MockSession;
0028:        import com.mockrunner.mock.jms.MockTemporaryQueue;
0029:        import com.mockrunner.mock.jms.MockTemporaryTopic;
0030:        import com.mockrunner.mock.jms.MockTopic;
0031:        import com.mockrunner.mock.jms.MockTopicConnection;
0032:        import com.mockrunner.mock.jms.MockTopicConnectionFactory;
0033:        import com.mockrunner.mock.jms.MockTopicPublisher;
0034:        import com.mockrunner.mock.jms.MockTopicSession;
0035:        import com.mockrunner.mock.jms.MockTopicSubscriber;
0036:
0037:        /**
0038:         * Module for JMS tests.
0039:         * Note that all indices are zero based.<br>
0040:         * Note for JMS 1.1:
0041:         * If you use {@link MockQueueConnectionFactory} for creating your
0042:         * connections and sessions, you have to use the methods with <code>Queue</code>
0043:         * in their name. Same with {@link MockTopicConnectionFactory}.
0044:         * The methods without <code>Queue</code> and <code>Topic</code>
0045:         * in the method name are for connections and sessions that were
0046:         * created using the {@link com.mockrunner.mock.jms.MockConnectionFactory}.
0047:         * {@link com.mockrunner.mock.jms.MockConnectionFactory}
0048:         * also implements the <code>QueueConnectionFactory</code> and
0049:         * <code>TopicConnectionFactory</code> interfaces and can be used to create 
0050:         * queue and topic connections as well as generic JMS 1.1 connections. 
0051:         * It is recommended to use {@link com.mockrunner.mock.jms.MockQueueConnectionFactory}
0052:         * if you only use queues and  {@link com.mockrunner.mock.jms.MockTopicConnectionFactory}
0053:         * if you only use topics and are not interested in having one factory for both.
0054:         * It is possible to create a {@link MockQueueConnection} or a {@link MockTopicConnection}
0055:         * using the {@link com.mockrunner.mock.jms.MockConnectionFactory}.
0056:         * However, the <code>Queue</code> methods (e.g. {@link #verifyAllQueueReceiversClosed})
0057:         * only work, if you use {@link MockQueueConnectionFactory} and the 
0058:         * <code>Topic</code> methods (e.g. {@link #verifyCreatedTopicMapMessageNotAcknowledged})
0059:         * only work, if you use {@link MockTopicConnectionFactory}.
0060:         */
0061:        public class JMSTestModule {
0062:            private JMSMockObjectFactory mockFactory;
0063:            private int currentQueueConnectionIndex;
0064:            private int currentTopicConnectionIndex;
0065:            private int currentConnectionIndex;
0066:
0067:            public JMSTestModule(JMSMockObjectFactory mockFactory) {
0068:                this .mockFactory = mockFactory;
0069:                currentQueueConnectionIndex = -1;
0070:                currentTopicConnectionIndex = -1;
0071:                currentConnectionIndex = -1;
0072:            }
0073:
0074:            /**
0075:             * Sets the index of the {@link MockQueueConnection} that should be used
0076:             * for the current test. Per default the latest created connection
0077:             * is used.
0078:             * @param connectionIndex the index of the connection
0079:             */
0080:            public void setCurrentQueueConnectionIndex(int connectionIndex) {
0081:                this .currentQueueConnectionIndex = connectionIndex;
0082:            }
0083:
0084:            /**
0085:             * Returns the current {@link MockQueueConnection} based on its
0086:             * index or <code>null</code> if no queue connection
0087:             * was created. The connection has to be created using the
0088:             * {@link MockQueueConnectionFactory}.
0089:             * @return the queue connection
0090:             */
0091:            public MockQueueConnection getCurrentQueueConnection() {
0092:                if (0 > currentQueueConnectionIndex) {
0093:                    return mockFactory.getMockQueueConnectionFactory()
0094:                            .getLatestQueueConnection();
0095:                }
0096:                return mockFactory.getMockQueueConnectionFactory()
0097:                        .getQueueConnection(currentQueueConnectionIndex);
0098:            }
0099:
0100:            /**
0101:             * Sets the index of the {@link MockTopicConnection} that should be used
0102:             * for the current test. Per default the latest created connection
0103:             * is used. 
0104:             * @param connectionIndex the index of the connection
0105:             */
0106:            public void setCurrentTopicConnectionIndex(int connectionIndex) {
0107:                this .currentTopicConnectionIndex = connectionIndex;
0108:            }
0109:
0110:            /**
0111:             * Returns the current {@link MockTopicConnection} based on its
0112:             * index or <code>null</code> if no topic connection
0113:             * was created. The connection has to be created using the
0114:             * {@link MockTopicConnectionFactory}.
0115:             * @return the topic connection
0116:             */
0117:            public MockTopicConnection getCurrentTopicConnection() {
0118:                if (0 > currentTopicConnectionIndex) {
0119:                    return mockFactory.getMockTopicConnectionFactory()
0120:                            .getLatestTopicConnection();
0121:                }
0122:                return mockFactory.getMockTopicConnectionFactory()
0123:                        .getTopicConnection(currentTopicConnectionIndex);
0124:            }
0125:
0126:            /**
0127:             * Sets the index of the {@link MockConnection} that should be used
0128:             * for the current test. Per default the latest created connection
0129:             * is used.
0130:             * @param connectionIndex the index of the connection
0131:             */
0132:            public void setCurrentConnectionIndex(int connectionIndex) {
0133:                this .currentConnectionIndex = connectionIndex;
0134:            }
0135:
0136:            /**
0137:             * Returns the current {@link MockConnection} based on its
0138:             * index or <code>null</code> if no connection
0139:             * was created. The connection has to be created using the
0140:             * {@link com.mockrunner.mock.jms.MockConnectionFactory}.
0141:             * @return the topic connection
0142:             */
0143:            public MockConnection getCurrentConnection() {
0144:                if (0 > currentConnectionIndex) {
0145:                    return mockFactory.getMockConnectionFactory()
0146:                            .getLatestConnection();
0147:                }
0148:                return mockFactory.getMockConnectionFactory().getConnection(
0149:                        currentConnectionIndex);
0150:            }
0151:
0152:            /**
0153:             * Creates a new connection and uses it for creating a new session and receiver.
0154:             * Registers the specified listener. Starts the connection for message
0155:             * receiving. This method is useful for creating test listeners when
0156:             * testing senders. It can be used to register message driven beans.
0157:             * Note that the created connection is the latest created
0158:             * connection and automatically becomes the default connection for the
0159:             * test module. The created session is transacted.
0160:             * This method uses the {@link MockQueueConnectionFactory} for
0161:             * creating the connection and the session. If you want to use the
0162:             * {@link com.mockrunner.mock.jms.MockConnectionFactory} you have to create the connection on your own
0163:             * and call {@link #registerTestMessageListenerForQueue(MockConnection, String, MessageListener)}.
0164:             * @param queueName the name of the queue used for message receiving
0165:             * @param listener the listener that should be registered
0166:             */
0167:            public void registerTestMessageListenerForQueue(String queueName,
0168:                    MessageListener listener) {
0169:                try {
0170:                    MockQueueConnectionFactory factory = mockFactory
0171:                            .getMockQueueConnectionFactory();
0172:                    MockQueueConnection connection = (MockQueueConnection) factory
0173:                            .createQueueConnection();
0174:                    registerTestMessageListenerForQueue(connection, queueName,
0175:                            listener);
0176:                } catch (JMSException exc) {
0177:                    throw new NestedApplicationException(exc);
0178:                }
0179:            }
0180:
0181:            /**
0182:             * Creates a new session and receiver using the specified connection and
0183:             * registers the specified listener. Starts the connection for message
0184:             * receiving. This method is useful for creating test listeners when
0185:             * testing senders. It can be used to register message driven beans.
0186:             * The created session is transacted.
0187:             * @param connection the connection used for creating the session
0188:             * @param queueName the name of the queue used for message receiving
0189:             * @param listener the listener that should be registered
0190:             */
0191:            public void registerTestMessageListenerForQueue(
0192:                    MockConnection connection, String queueName,
0193:                    MessageListener listener) {
0194:                registerTestMessageListenerForQueue(connection, queueName,
0195:                        true, Session.AUTO_ACKNOWLEDGE, listener);
0196:            }
0197:
0198:            /**
0199:             * Creates a new session and receiver using the specified connection and
0200:             * registers the specified listener. Starts the connection for message
0201:             * receiving. This method is useful for creating test listeners when
0202:             * testing senders. It can be used to register message driven beans.
0203:             * @param connection the connection used for creating the session
0204:             * @param queueName the name of the queue used for message receiving
0205:             * @param transacted should the created session be transacted
0206:             * @param acknowledgeMode the acknowledge mode of the created session
0207:             * @param listener the listener that should be registered
0208:             */
0209:            public void registerTestMessageListenerForQueue(
0210:                    MockConnection connection, String queueName,
0211:                    boolean transacted, int acknowledgeMode,
0212:                    MessageListener listener) {
0213:                registerTestMessageListenerForQueue(connection, queueName,
0214:                        transacted, acknowledgeMode, null, listener);
0215:            }
0216:
0217:            /**
0218:             * Creates a new session and receiver using the specified connection and
0219:             * registers the specified listener. Starts the connection for message
0220:             * receiving. This method is useful for creating test listeners when
0221:             * testing senders. It can be used to register message driven beans.
0222:             * @param connection the connection used for creating the session
0223:             * @param queueName the name of the queue used for message receiving
0224:             * @param transacted should the created session be transacted
0225:             * @param acknowledgeMode the acknowledge mode of the created session
0226:             * @param messageSelector the message selector
0227:             * @param listener the listener that should be registered
0228:             */
0229:            public void registerTestMessageListenerForQueue(
0230:                    MockConnection connection, String queueName,
0231:                    boolean transacted, int acknowledgeMode,
0232:                    String messageSelector, MessageListener listener) {
0233:                try {
0234:                    Queue queue = getDestinationManager().getQueue(queueName);
0235:                    MockSession session = (MockSession) connection
0236:                            .createSession(transacted, acknowledgeMode);
0237:                    MessageConsumer consumer = session.createConsumer(queue,
0238:                            messageSelector);
0239:                    consumer.setMessageListener(listener);
0240:                    connection.start();
0241:                } catch (JMSException exc) {
0242:                    throw new NestedApplicationException(exc);
0243:                }
0244:            }
0245:
0246:            /**
0247:             * Creates a new connection and uses it for creating a new session and subscriber.
0248:             * Registers the specified listener. Starts the connection for message
0249:             * receiving. This method is useful for creating test listeners when
0250:             * testing publishers. It can be used to resgister message driven beans.
0251:             * Note that the created connection is the latest created
0252:             * connection and automatically becomes the default connection for the
0253:             * test module. The created session is transacted.
0254:             * This method uses the {@link MockTopicConnectionFactory} for
0255:             * creating the connection and the session. If you want to use the
0256:             * {@link com.mockrunner.mock.jms.MockConnectionFactory} you have to create the connection on your own
0257:             * and call {@link #registerTestMessageListenerForTopic(MockConnection, String, MessageListener)}.
0258:             * @param topicName the name of the topic used for message receiving
0259:             * @param listener the listener that should be registered
0260:             */
0261:            public void registerTestMessageListenerForTopic(String topicName,
0262:                    MessageListener listener) {
0263:                try {
0264:                    MockTopicConnectionFactory factory = mockFactory
0265:                            .getMockTopicConnectionFactory();
0266:                    MockTopicConnection connection = (MockTopicConnection) factory
0267:                            .createTopicConnection();
0268:                    registerTestMessageListenerForTopic(connection, topicName,
0269:                            listener);
0270:                } catch (JMSException exc) {
0271:                    throw new NestedApplicationException(exc);
0272:                }
0273:            }
0274:
0275:            /**
0276:             * Creates a new session and subscriber using the specified connection and
0277:             * registers the specified listener. Starts the connection for message
0278:             * receiving. This method is useful for creating test listeners when
0279:             * testing publishers. It can be used to resgister message driven beans.
0280:             * The created session is transacted.
0281:             * @param connection the connection used for creating the session
0282:             * @param topicName the name of the topic used for message receiving
0283:             * @param listener the listener that should be registered
0284:             */
0285:            public void registerTestMessageListenerForTopic(
0286:                    MockConnection connection, String topicName,
0287:                    MessageListener listener) {
0288:                registerTestMessageListenerForTopic(connection, topicName,
0289:                        true, Session.AUTO_ACKNOWLEDGE, listener);
0290:            }
0291:
0292:            /**
0293:             * Creates a new session and subscriber using the specified connection and
0294:             * registers the specified listener. Starts the connection for message
0295:             * receiving. This method is useful for creating test listeners when
0296:             * testing publishers. It can be used to resgister message driven beans.
0297:             * @param connection the connection used for creating the session
0298:             * @param topicName the name of the topic used for message receiving
0299:             * @param transacted should the created session be transacted
0300:             * @param acknowledgeMode the acknowledge mode of the created session
0301:             * @param listener the listener that should be registered
0302:             */
0303:            public void registerTestMessageListenerForTopic(
0304:                    MockConnection connection, String topicName,
0305:                    boolean transacted, int acknowledgeMode,
0306:                    MessageListener listener) {
0307:                registerTestMessageListenerForTopic(connection, topicName,
0308:                        transacted, acknowledgeMode, null, listener);
0309:            }
0310:
0311:            /**
0312:             * Creates a new session and subscriber using the specified connection and
0313:             * registers the specified listener. Starts the connection for message
0314:             * receiving. This method is useful for creating test listeners when
0315:             * testing publishers. It can be used to resgister message driven beans.
0316:             * @param connection the connection used for creating the session
0317:             * @param topicName the name of the topic used for message receiving
0318:             * @param transacted should the created session be transacted
0319:             * @param acknowledgeMode the acknowledge mode of the created session
0320:             * @param messageSelector the message selector
0321:             * @param listener the listener that should be registered
0322:             */
0323:            public void registerTestMessageListenerForTopic(
0324:                    MockConnection connection, String topicName,
0325:                    boolean transacted, int acknowledgeMode,
0326:                    String messageSelector, MessageListener listener) {
0327:                try {
0328:                    Topic topic = getDestinationManager().getTopic(topicName);
0329:                    MockSession session = (MockSession) connection
0330:                            .createSession(transacted, acknowledgeMode);
0331:                    MessageConsumer consumer = session.createConsumer(topic,
0332:                            messageSelector);
0333:                    consumer.setMessageListener(listener);
0334:                    connection.start();
0335:                } catch (JMSException exc) {
0336:                    throw new NestedApplicationException(exc);
0337:                }
0338:            }
0339:
0340:            /**
0341:             * Returns the {@link DestinationManager}.
0342:             * @return the {@link DestinationManager}
0343:             */
0344:            public DestinationManager getDestinationManager() {
0345:                return mockFactory.getDestinationManager();
0346:            }
0347:
0348:            /**
0349:             * Returns the {@link ConfigurationManager}.
0350:             * @return the {@link ConfigurationManager}
0351:             */
0352:            public ConfigurationManager getConfigurationManager() {
0353:                return mockFactory.getConfigurationManager();
0354:            }
0355:
0356:            /**
0357:             * Returns the {@link MessageManager} for the specified session
0358:             * or <code>null</code> if the session does not exist. The returned
0359:             * {@link MessageManager} is used to keep track of messages sent
0360:             * to queues.
0361:             * The session has to be created using the current {@link MockQueueConnection}.
0362:             * @param indexOfSession the index of the session
0363:             * @return the {@link MessageManager}
0364:             */
0365:            public MessageManager getQueueMessageManager(int indexOfSession) {
0366:                MockQueueSession session = getQueueSession(indexOfSession);
0367:                if (null == session)
0368:                    return null;
0369:                return session.getMessageManager();
0370:            }
0371:
0372:            /**
0373:             * Returns the {@link MessageManager} for the specified session
0374:             * or <code>null</code> if the session does not exist. The returned
0375:             * {@link MessageManager} is used to keep track of messages sent
0376:             * to topics.
0377:             * The session has to be created using the current {@link MockTopicConnection}.
0378:             * @param indexOfSession the index of the session
0379:             * @return the {@link MessageManager}
0380:             */
0381:            public MessageManager getTopicMessageManager(int indexOfSession) {
0382:                MockTopicSession session = getTopicSession(indexOfSession);
0383:                if (null == session)
0384:                    return null;
0385:                return session.getMessageManager();
0386:            }
0387:
0388:            /**
0389:             * Returns the {@link MessageManager} for the specified session
0390:             * or <code>null</code> if the session does not exist. The returned
0391:             * {@link MessageManager} is used to keep track of messages sent
0392:             * to topics.
0393:             * The session has to be created using the current {@link MockConnection}.
0394:             * @param indexOfSession the index of the session
0395:             * @return the {@link MessageManager}
0396:             */
0397:            public MessageManager getMessageManager(int indexOfSession) {
0398:                MockSession session = getSession(indexOfSession);
0399:                if (null == session)
0400:                    return null;
0401:                return session.getMessageManager();
0402:            }
0403:
0404:            /**
0405:             * Returns the {@link QueueTransmissionManager} for the specified session
0406:             * or <code>null</code> if the session does not exist.
0407:             * The session has to be created using the current {@link MockQueueConnection}.
0408:             * @param indexOfSession the index of the session
0409:             * @return the {@link QueueTransmissionManager}
0410:             */
0411:            public QueueTransmissionManager getQueueTransmissionManager(
0412:                    int indexOfSession) {
0413:                MockQueueSession session = getQueueSession(indexOfSession);
0414:                if (null == session)
0415:                    return null;
0416:                return session.getQueueTransmissionManager();
0417:            }
0418:
0419:            /**
0420:             * Returns the {@link TopicTransmissionManager} for the specified session
0421:             * or <code>null</code> if the session does not exist.
0422:             * The session has to be created using the current {@link MockTopicConnection}.
0423:             * @param indexOfSession the index of the session
0424:             * @return the {@link TopicTransmissionManager}
0425:             */
0426:            public TopicTransmissionManager getTopicTransmissionManager(
0427:                    int indexOfSession) {
0428:                MockTopicSession session = getTopicSession(indexOfSession);
0429:                if (null == session)
0430:                    return null;
0431:                return session.getTopicTransmissionManager();
0432:            }
0433:
0434:            /**
0435:             * @deprecated use {@link #getTransmissionManagerWrapper}
0436:             */
0437:            public TransmissionManagerWrapper getTransmissionManager(
0438:                    int indexOfSession) {
0439:                return getTransmissionManagerWrapper(indexOfSession);
0440:            }
0441:
0442:            /**
0443:             * Returns the {@link TransmissionManagerWrapper} for the specified session
0444:             * or <code>null</code> if the session does not exist.
0445:             * The session has to be created using the current {@link MockConnection}.
0446:             * @param indexOfSession the index of the session
0447:             * @return the {@link TransmissionManagerWrapper}
0448:             */
0449:            public TransmissionManagerWrapper getTransmissionManagerWrapper(
0450:                    int indexOfSession) {
0451:                MockSession session = getSession(indexOfSession);
0452:                if (null == session)
0453:                    return null;
0454:                return session.getTransmissionManagerWrapper();
0455:            }
0456:
0457:            /**
0458:             * Returns the {@link TransmissionManagerWrapper} for the specified session
0459:             * or <code>null</code> if the session does not exist.
0460:             * The session has to be created using the current {@link MockQueueConnection}.
0461:             * @param indexOfSession the index of the session
0462:             * @return the {@link TransmissionManagerWrapper}
0463:             */
0464:            public TransmissionManagerWrapper getQueueTransmissionManagerWrapper(
0465:                    int indexOfSession) {
0466:                MockQueueSession session = getQueueSession(indexOfSession);
0467:                if (null == session)
0468:                    return null;
0469:                return session.getTransmissionManagerWrapper();
0470:            }
0471:
0472:            /**
0473:             * Returns the {@link TransmissionManagerWrapper} for the specified session
0474:             * or <code>null</code> if the session does not exist.
0475:             * The session has to be created using the current {@link MockTopicConnection}.
0476:             * @param indexOfSession the index of the session
0477:             * @return the {@link TransmissionManagerWrapper}
0478:             */
0479:            public TransmissionManagerWrapper getTopicTransmissionManagerWrapper(
0480:                    int indexOfSession) {
0481:                MockTopicSession session = getTopicSession(indexOfSession);
0482:                if (null == session)
0483:                    return null;
0484:                return session.getTransmissionManagerWrapper();
0485:            }
0486:
0487:            /**
0488:             * Returns the list of {@link MockQueueSession} objects.
0489:             * The sessions have been created using the current {@link MockQueueConnection}.
0490:             * @return the {@link MockQueueSession} list
0491:             */
0492:            public List getQueueSessionList() {
0493:                if (null == getCurrentQueueConnection())
0494:                    return null;
0495:                return getCurrentQueueConnection().getQueueSessionList();
0496:            }
0497:
0498:            /**
0499:             * Returns the list of {@link MockTopicSession} objects.
0500:             * The sessions have been created using the current {@link MockTopicConnection}.
0501:             * @return the {@link MockTopicSession} list
0502:             */
0503:            public List getTopicSessionList() {
0504:                if (null == getCurrentTopicConnection())
0505:                    return null;
0506:                return getCurrentTopicConnection().getTopicSessionList();
0507:            }
0508:
0509:            /**
0510:             * Returns the list of {@link MockSession} objects.
0511:             * The sessions have been created using the current {@link MockConnection}.
0512:             * @return the {@link MockSession} list
0513:             */
0514:            public List getSessionList() {
0515:                if (null == getCurrentConnection())
0516:                    return null;
0517:                return getCurrentConnection().getSessionList();
0518:            }
0519:
0520:            /**
0521:             * Returns the {@link MockQueueSession} for the specified index
0522:             * or <code>null</code> if the session does not exist.
0523:             * The session has to be created using the current {@link MockQueueConnection}.
0524:             * @param indexOfSession the index of the session
0525:             * @return the {@link MockQueueSession}
0526:             */
0527:            public MockQueueSession getQueueSession(int indexOfSession) {
0528:                if (null == getCurrentQueueConnection())
0529:                    return null;
0530:                return getCurrentQueueConnection().getQueueSession(
0531:                        indexOfSession);
0532:            }
0533:
0534:            /**
0535:             * Returns the {@link MockTopicSession} for the specified index
0536:             * or <code>null</code> if the session does not exist.
0537:             * The session has to be created using the current {@link MockTopicConnection}.
0538:             * @param indexOfSession the index of the session
0539:             * @return the {@link MockTopicSession}
0540:             */
0541:            public MockTopicSession getTopicSession(int indexOfSession) {
0542:                if (null == getCurrentTopicConnection())
0543:                    return null;
0544:                return getCurrentTopicConnection().getTopicSession(
0545:                        indexOfSession);
0546:            }
0547:
0548:            /**
0549:             * Returns the {@link MockSession} for the specified index
0550:             * or <code>null</code> if the session does not exist.
0551:             * The session has to be created using the current {@link MockConnection}.
0552:             * @param indexOfSession the index of the session
0553:             * @return the {@link MockSession}
0554:             */
0555:            public MockSession getSession(int indexOfSession) {
0556:                if (null == getCurrentConnection())
0557:                    return null;
0558:                return getCurrentConnection().getSession(indexOfSession);
0559:            }
0560:
0561:            /**
0562:             * Returns the {@link MockQueue} with the specified name
0563:             * or <code>null</code> if no such queue exists.
0564:             * @param name the name of the queue
0565:             * @return the {@link MockQueue}
0566:             */
0567:            public MockQueue getQueue(String name) {
0568:                return getDestinationManager().getQueue(name);
0569:            }
0570:
0571:            /**
0572:             * Returns the {@link MockTopic} with the specified name
0573:             * or <code>null</code> if no such topic exists.
0574:             * @param name the name of the topic
0575:             * @return the {@link MockTopic}
0576:             */
0577:            public MockTopic getTopic(String name) {
0578:                return getDestinationManager().getTopic(name);
0579:            }
0580:
0581:            /**
0582:             * Returns the list of {@link MockTemporaryQueue} objects
0583:             * for the specified session. The session has to be created using
0584:             * the current {@link MockQueueConnection}.
0585:             * @param indexOfSession the index of the session
0586:             * @return the {@link MockTemporaryQueue} list
0587:             */
0588:            public List getTemporaryQueueList(int indexOfSession) {
0589:                MockQueueSession session = getQueueSession(indexOfSession);
0590:                if (null == session)
0591:                    return null;
0592:                return session.getTemporaryQueueList();
0593:            }
0594:
0595:            /**
0596:             * Returns the list of {@link MockTemporaryTopic} objects
0597:             * for the specified session. The session has to be created using
0598:             * the current {@link MockTopicConnection}.
0599:             * @param indexOfSession the index of the session
0600:             * @return the {@link MockTemporaryTopic} list
0601:             */
0602:            public List getTemporaryTopicList(int indexOfSession) {
0603:                MockTopicSession session = getTopicSession(indexOfSession);
0604:                if (null == session)
0605:                    return null;
0606:                return session.getTemporaryTopicList();
0607:            }
0608:
0609:            /**
0610:             * Returns the {@link MockTemporaryQueue} with the specified index
0611:             * for the specified session. Returns <code>null</code> if no such
0612:             * temporary queue exists. The session has to be created using
0613:             * the current {@link MockQueueConnection}.
0614:             * @param indexOfSession the index of the session
0615:             * @param indexOfQueue the index of the temporary queue
0616:             * @return the {@link MockTemporaryQueue}
0617:             */
0618:            public MockTemporaryQueue getTemporaryQueue(int indexOfSession,
0619:                    int indexOfQueue) {
0620:                MockQueueSession session = getQueueSession(indexOfSession);
0621:                if (null == session)
0622:                    return null;
0623:                return session.getTemporaryQueue(indexOfQueue);
0624:            }
0625:
0626:            /**
0627:             * Returns the {@link MockTemporaryTopic} with the specified index
0628:             * for the specified session. Returns <code>null</code> if no such
0629:             * temporary queue exists. The session has to be created using
0630:             * the current {@link MockTopicConnection}.
0631:             * @param indexOfSession the index of the session
0632:             * @param indexOfTopic the index of the temporary queue
0633:             * @return the {@link MockTemporaryTopic}
0634:             */
0635:            public MockTemporaryTopic getTemporaryTopic(int indexOfSession,
0636:                    int indexOfTopic) {
0637:                MockTopicSession session = getTopicSession(indexOfSession);
0638:                if (null == session)
0639:                    return null;
0640:                return session.getTemporaryTopic(indexOfTopic);
0641:            }
0642:
0643:            /**
0644:             * Returns the list of messages that are currently present in the queue
0645:             * or <code>null</code> if no such queue exists.
0646:             * @param name the name of the queue
0647:             * @return the list of messages
0648:             */
0649:            public List getCurrentMessageListFromQueue(String name) {
0650:                MockQueue queue = getQueue(name);
0651:                if (null == queue)
0652:                    return null;
0653:                return queue.getCurrentMessageList();
0654:            }
0655:
0656:            /**
0657:             * Returns the list of messages that are currently present in the 
0658:             * temporary queue or <code>null</code> if no such queue exists.
0659:             * The session has to be created using the current {@link MockQueueConnection}.
0660:             * @param indexOfSession the index of the session
0661:             * @param indexOfQueue the index of the temporary queue
0662:             * @return the list of messages
0663:             */
0664:            public List getCurrentMessageListFromTemporaryQueue(
0665:                    int indexOfSession, int indexOfQueue) {
0666:                MockTemporaryQueue queue = getTemporaryQueue(indexOfSession,
0667:                        indexOfQueue);
0668:                if (null == queue)
0669:                    return null;
0670:                return queue.getCurrentMessageList();
0671:            }
0672:
0673:            /**
0674:             * Returns the list of messages that were received by the queue
0675:             * or <code>null</code> if no such queue exists.
0676:             * @param name the name of the queue
0677:             * @return the list of messages
0678:             */
0679:            public List getReceivedMessageListFromQueue(String name) {
0680:                MockQueue queue = getQueue(name);
0681:                if (null == queue)
0682:                    return null;
0683:                return queue.getReceivedMessageList();
0684:            }
0685:
0686:            /**
0687:             * Returns the list of messages that were received by the 
0688:             * temporary queue or <code>null</code> if no such queue exists.
0689:             * The session has to be created using the current {@link MockQueueConnection}.
0690:             * @param indexOfSession the index of the session
0691:             * @param indexOfQueue the index of the temporary queue
0692:             * @return the list of messages
0693:             */
0694:            public List getReceivedMessageListFromTemporaryQueue(
0695:                    int indexOfSession, int indexOfQueue) {
0696:                MockTemporaryQueue queue = getTemporaryQueue(indexOfSession,
0697:                        indexOfQueue);
0698:                if (null == queue)
0699:                    return null;
0700:                return queue.getReceivedMessageList();
0701:            }
0702:
0703:            /**
0704:             * Returns the list of messages that are currently present in the topic
0705:             * or <code>null</code> if no such topic exists.
0706:             * @param name the name of the queue
0707:             * @return the list of messages
0708:             */
0709:            public List getCurrentMessageListFromTopic(String name) {
0710:                MockTopic topic = getTopic(name);
0711:                if (null == topic)
0712:                    return null;
0713:                return topic.getCurrentMessageList();
0714:            }
0715:
0716:            /**
0717:             * Returns the list of messages that are currently present in the 
0718:             * temporary topic or <code>null</code> if no such topic exists.
0719:             * The session has to be created using the current {@link MockTopicConnection}.
0720:             * @param indexOfSession the index of the session
0721:             * @param indexOfTopic the index of the temporary topic
0722:             * @return the list of messages
0723:             */
0724:            public List getCurrentMessageListFromTemporaryTopic(
0725:                    int indexOfSession, int indexOfTopic) {
0726:                MockTemporaryTopic topic = getTemporaryTopic(indexOfSession,
0727:                        indexOfTopic);
0728:                if (null == topic)
0729:                    return null;
0730:                return topic.getCurrentMessageList();
0731:            }
0732:
0733:            /**
0734:             * Returns the list of messages that were received by the topic
0735:             * or <code>null</code> if no such topic exists.
0736:             * @param name the name of the topic
0737:             * @return the list of messages
0738:             */
0739:            public List getReceivedMessageListFromTopic(String name) {
0740:                MockTopic topic = getTopic(name);
0741:                if (null == topic)
0742:                    return null;
0743:                return topic.getReceivedMessageList();
0744:            }
0745:
0746:            /**
0747:             * Returns the list of messages that were received by the 
0748:             * temporary topic or <code>null</code> if no such topic exists.
0749:             * The session has to be created using the current {@link MockTopicConnection}.
0750:             * @param indexOfSession the index of the session
0751:             * @param indexOfTopic the index of the temporary topic
0752:             * @return the list of messages
0753:             */
0754:            public List getReceivedMessageListFromTemporaryTopic(
0755:                    int indexOfSession, int indexOfTopic) {
0756:                MockTemporaryTopic topic = getTemporaryTopic(indexOfSession,
0757:                        indexOfTopic);
0758:                if (null == topic)
0759:                    return null;
0760:                return topic.getReceivedMessageList();
0761:            }
0762:
0763:            /**
0764:             * Verifies that the current {@link MockQueueConnection} is closed.
0765:             * The connection has to be created using the current {@link MockQueueConnectionFactory}.
0766:             * @throws VerifyFailedException if verification fails
0767:             */
0768:            public void verifyQueueConnectionClosed() {
0769:                if (null == getCurrentQueueConnection()) {
0770:                    throw new VerifyFailedException(
0771:                            "No QueueConnection present.");
0772:                }
0773:                if (!getCurrentQueueConnection().isClosed()) {
0774:                    throw new VerifyFailedException(
0775:                            "QueueConnection is not closed.");
0776:                }
0777:            }
0778:
0779:            /**
0780:             * Verifies that the current {@link MockQueueConnection} is started.
0781:             * The connection has to be created using the current {@link MockQueueConnectionFactory}.
0782:             * @throws VerifyFailedException if verification fails
0783:             */
0784:            public void verifyQueueConnectionStarted() {
0785:                if (null == getCurrentQueueConnection()) {
0786:                    throw new VerifyFailedException(
0787:                            "No QueueConnection present.");
0788:                }
0789:                if (!getCurrentQueueConnection().isStarted()) {
0790:                    throw new VerifyFailedException(
0791:                            "QueueConnection is not started.");
0792:                }
0793:            }
0794:
0795:            /**
0796:             * Verifies that the current {@link MockQueueConnection} is stopped.
0797:             * The connection has to be created using the current {@link MockQueueConnectionFactory}.
0798:             * @throws VerifyFailedException if verification fails
0799:             */
0800:            public void verifyQueueConnectionStopped() {
0801:                if (null == getCurrentQueueConnection()) {
0802:                    throw new VerifyFailedException(
0803:                            "No QueueConnection present.");
0804:                }
0805:                if (!getCurrentQueueConnection().isStopped()) {
0806:                    throw new VerifyFailedException(
0807:                            "QueueConnection is not stopped.");
0808:                }
0809:            }
0810:
0811:            /**
0812:             * Verifies that the current {@link MockTopicConnection} is closed.
0813:             * The connection has to be created using the current {@link MockTopicConnectionFactory}.
0814:             * @throws VerifyFailedException if verification fails
0815:             */
0816:            public void verifyTopicConnectionClosed() {
0817:                if (null == getCurrentTopicConnection()) {
0818:                    throw new VerifyFailedException(
0819:                            "No TopicConnection present.");
0820:                }
0821:                if (!getCurrentTopicConnection().isClosed()) {
0822:                    throw new VerifyFailedException(
0823:                            "TopicConnection is not closed.");
0824:                }
0825:            }
0826:
0827:            /**
0828:             * Verifies that the current {@link MockTopicConnection} is started.
0829:             * The connection has to be created using the current {@link MockTopicConnectionFactory}.
0830:             * @throws VerifyFailedException if verification fails
0831:             */
0832:            public void verifyTopicConnectionStarted() {
0833:                if (null == getCurrentTopicConnection()) {
0834:                    throw new VerifyFailedException(
0835:                            "No TopicConnection present.");
0836:                }
0837:                if (!getCurrentTopicConnection().isStarted()) {
0838:                    throw new VerifyFailedException(
0839:                            "TopicConnection is not started.");
0840:                }
0841:            }
0842:
0843:            /**
0844:             * Verifies that the current {@link MockTopicConnection} is stopped.
0845:             * The connection has to be created using the current {@link MockTopicConnectionFactory}.
0846:             * @throws VerifyFailedException if verification fails
0847:             */
0848:            public void verifyTopicConnectionStopped() {
0849:                if (null == getCurrentTopicConnection()) {
0850:                    throw new VerifyFailedException(
0851:                            "No TopicConnection present.");
0852:                }
0853:                if (!getCurrentTopicConnection().isStopped()) {
0854:                    throw new VerifyFailedException(
0855:                            "TopicConnection is not stopped.");
0856:                }
0857:            }
0858:
0859:            /**
0860:             * Verifies that the current {@link MockConnection} is closed.
0861:             * The connection has to be created using the current {@link com.mockrunner.mock.jms.MockConnectionFactory}.
0862:             * @throws VerifyFailedException if verification fails
0863:             */
0864:            public void verifyConnectionClosed() {
0865:                if (null == getCurrentConnection()) {
0866:                    throw new VerifyFailedException("No Connection present.");
0867:                }
0868:                if (!getCurrentConnection().isClosed()) {
0869:                    throw new VerifyFailedException("Connection is not closed.");
0870:                }
0871:            }
0872:
0873:            /**
0874:             * Verifies that the current {@link MockConnection} is started.
0875:             * The connection has to be created using the current {@link com.mockrunner.mock.jms.MockConnectionFactory}.
0876:             * @throws VerifyFailedException if verification fails
0877:             */
0878:            public void verifyConnectionStarted() {
0879:                if (null == getCurrentConnection()) {
0880:                    throw new VerifyFailedException("No Connection present.");
0881:                }
0882:                if (!getCurrentConnection().isStarted()) {
0883:                    throw new VerifyFailedException(
0884:                            "Connection is not started.");
0885:                }
0886:            }
0887:
0888:            /**
0889:             * Verifies that the current {@link MockConnection} is stopped.
0890:             * The connection has to be created using the current {@link com.mockrunner.mock.jms.MockConnectionFactory}.
0891:             * @throws VerifyFailedException if verification fails
0892:             */
0893:            public void verifyConnectionStopped() {
0894:                if (null == getCurrentConnection()) {
0895:                    throw new VerifyFailedException("No Connection present.");
0896:                }
0897:                if (!getCurrentConnection().isStopped()) {
0898:                    throw new VerifyFailedException(
0899:                            "Connection is not stopped.");
0900:                }
0901:            }
0902:
0903:            /**
0904:             * Verifies that the queue session with the specified index is
0905:             * closed.
0906:             * The session has to be created using the current {@link MockQueueConnection}.
0907:             * @param indexOfSession the index of the session
0908:             * @throws VerifyFailedException if verification fails
0909:             */
0910:            public void verifyQueueSessionClosed(int indexOfSession) {
0911:                MockQueueSession session = checkAndGetQueueSessionByIndex(indexOfSession);
0912:                if (!session.isClosed()) {
0913:                    throw new VerifyFailedException("QueueSession with index "
0914:                            + indexOfSession + " is not closed.");
0915:                }
0916:            }
0917:
0918:            /**
0919:             * Verifies that the queue session with the specified index was
0920:             * committed.
0921:             * The session has to be created using the current {@link MockQueueConnection}.
0922:             * @param indexOfSession the index of the session
0923:             * @throws VerifyFailedException if verification fails
0924:             */
0925:            public void verifyQueueSessionCommitted(int indexOfSession) {
0926:                MockQueueSession session = checkAndGetQueueSessionByIndex(indexOfSession);
0927:                if (!session.isCommitted()) {
0928:                    throw new VerifyFailedException(
0929:                            "QueueSession is not committed.");
0930:                }
0931:            }
0932:
0933:            /**
0934:             * Verifies that the queue session with the specified index was
0935:             * not committed.
0936:             * The session has to be created using the current {@link MockQueueConnection}.
0937:             * @param indexOfSession the index of the session
0938:             * @throws VerifyFailedException if verification fails
0939:             */
0940:            public void verifyQueueSessionNotCommitted(int indexOfSession) {
0941:                MockQueueSession session = checkAndGetQueueSessionByIndex(indexOfSession);
0942:                if (session.isCommitted()) {
0943:                    throw new VerifyFailedException(
0944:                            "QueueSession is committed.");
0945:                }
0946:            }
0947:
0948:            /**
0949:             * Verifies the number of commits of the queue session with the specified index.
0950:             * The session has to be created using the current {@link MockQueueConnection}.
0951:             * @param indexOfSession the index of the session
0952:             * @param numberOfCommits the expected number of commits
0953:             * @throws VerifyFailedException if verification fails
0954:             */
0955:            public void verifyQueueSessionNumberCommits(int indexOfSession,
0956:                    int numberOfCommits) {
0957:                MockQueueSession session = checkAndGetQueueSessionByIndex(indexOfSession);
0958:                if (numberOfCommits != session.getNumberCommits()) {
0959:                    throw new VerifyFailedException(
0960:                            "QueueSession was commited "
0961:                                    + session.getNumberCommits()
0962:                                    + " times, expected " + numberOfCommits
0963:                                    + " times");
0964:                }
0965:            }
0966:
0967:            /**
0968:             * Verifies that the queue session with the specified index was
0969:             * rolled back.
0970:             * The session has to be created using the current {@link MockQueueConnection}.
0971:             * @param indexOfSession the index of the session
0972:             * @throws VerifyFailedException if verification fails
0973:             */
0974:            public void verifyQueueSessionRolledBack(int indexOfSession) {
0975:                MockQueueSession session = checkAndGetQueueSessionByIndex(indexOfSession);
0976:                if (!session.isRolledBack()) {
0977:                    throw new VerifyFailedException(
0978:                            "QueueSession is not rolled back.");
0979:                }
0980:            }
0981:
0982:            /**
0983:             * Verifies that the queue session with the specified index was
0984:             * not rolled back.
0985:             * The session has to be created using the current {@link MockQueueConnection}.
0986:             * @param indexOfSession the index of the session
0987:             * @throws VerifyFailedException if verification fails
0988:             */
0989:            public void verifyQueueSessionNotRolledBack(int indexOfSession) {
0990:                MockQueueSession session = checkAndGetQueueSessionByIndex(indexOfSession);
0991:                if (session.isRolledBack()) {
0992:                    throw new VerifyFailedException(
0993:                            "QueueSession is rolled back.");
0994:                }
0995:            }
0996:
0997:            /**
0998:             * Verifies the number of rollbacks of the queue session with the specified index.
0999:             * The session has to be created using the current {@link MockQueueConnection}.
1000:             * @param indexOfSession the index of the session
1001:             * @param numberOfRollbacks the expected number of rollbacks
1002:             * @throws VerifyFailedException if verification fails
1003:             */
1004:            public void verifyQueueSessionNumberRollbacks(int indexOfSession,
1005:                    int numberOfRollbacks) {
1006:                MockQueueSession session = checkAndGetQueueSessionByIndex(indexOfSession);
1007:                if (numberOfRollbacks != session.getNumberRollbacks()) {
1008:                    throw new VerifyFailedException(
1009:                            "QueueSession was rolled back "
1010:                                    + session.getNumberRollbacks()
1011:                                    + " times, expected " + numberOfRollbacks
1012:                                    + " times");
1013:                }
1014:            }
1015:
1016:            /**
1017:             * Verifies that the queue session with the specified index was
1018:             * recovered.
1019:             * The session has to be created using the current {@link MockQueueConnection}.
1020:             * @param indexOfSession the index of the session
1021:             * @throws VerifyFailedException if verification fails
1022:             */
1023:            public void verifyQueueSessionRecovered(int indexOfSession) {
1024:                MockQueueSession session = checkAndGetQueueSessionByIndex(indexOfSession);
1025:                if (!session.isRecovered()) {
1026:                    throw new VerifyFailedException(
1027:                            "QueueSession is not recovered.");
1028:                }
1029:            }
1030:
1031:            /**
1032:             * Verifies that the queue session with the specified index was
1033:             * not recovered.
1034:             * The session has to be created using the current {@link MockQueueConnection}.
1035:             * @param indexOfSession the index of the session
1036:             * @throws VerifyFailedException if verification fails
1037:             */
1038:            public void verifyQueueSessionNotRecovered(int indexOfSession) {
1039:                MockQueueSession session = checkAndGetQueueSessionByIndex(indexOfSession);
1040:                if (session.isRecovered()) {
1041:                    throw new VerifyFailedException(
1042:                            "QueueSession is recovered.");
1043:                }
1044:            }
1045:
1046:            /**
1047:             * Verifies that the topic session with the specified index is
1048:             * closed.
1049:             * The session has to be created using the current {@link MockTopicConnection}.
1050:             * @param indexOfSession the index of the session
1051:             * @throws VerifyFailedException if verification fails
1052:             */
1053:            public void verifyTopicSessionClosed(int indexOfSession) {
1054:                MockTopicSession session = checkAndGetTopicSessionByIndex(indexOfSession);
1055:                if (!session.isClosed()) {
1056:                    throw new VerifyFailedException("TopicSession with index "
1057:                            + indexOfSession + " is not closed.");
1058:                }
1059:            }
1060:
1061:            /**
1062:             * Verifies that the topic session with the specified index was
1063:             * committed.
1064:             * The session has to be created using the current {@link MockTopicConnection}.
1065:             * @param indexOfSession the index of the session
1066:             * @throws VerifyFailedException if verification fails
1067:             */
1068:            public void verifyTopicSessionCommitted(int indexOfSession) {
1069:                MockTopicSession session = checkAndGetTopicSessionByIndex(indexOfSession);
1070:                if (!session.isCommitted()) {
1071:                    throw new VerifyFailedException(
1072:                            "TopicSession is not committed.");
1073:                }
1074:            }
1075:
1076:            /**
1077:             * Verifies that the topic session with the specified index was
1078:             * not committed.
1079:             * The session has to be created using the current {@link MockTopicConnection}.
1080:             * @param indexOfSession the index of the session
1081:             * @throws VerifyFailedException if verification fails
1082:             */
1083:            public void verifyTopicSessionNotCommitted(int indexOfSession) {
1084:                MockTopicSession session = checkAndGetTopicSessionByIndex(indexOfSession);
1085:                if (session.isCommitted()) {
1086:                    throw new VerifyFailedException(
1087:                            "TopicSession is committed.");
1088:                }
1089:            }
1090:
1091:            /**
1092:             * Verifies the number of commits of the topic session with the specified index.
1093:             * The session has to be created using the current {@link MockTopicConnection}.
1094:             * @param indexOfSession the index of the session
1095:             * @param numberOfCommits the expected number of commits
1096:             * @throws VerifyFailedException if verification fails
1097:             */
1098:            public void verifyTopicSessionNumberCommits(int indexOfSession,
1099:                    int numberOfCommits) {
1100:                MockTopicSession session = checkAndGetTopicSessionByIndex(indexOfSession);
1101:                if (numberOfCommits != session.getNumberCommits()) {
1102:                    throw new VerifyFailedException(
1103:                            "TopicSession was commited "
1104:                                    + session.getNumberCommits()
1105:                                    + " times, expected " + numberOfCommits
1106:                                    + " times");
1107:                }
1108:            }
1109:
1110:            /**
1111:             * Verifies that the topic session with the specified index was
1112:             * rolled back.
1113:             * The session has to be created using the current {@link MockTopicConnection}.
1114:             * @param indexOfSession the index of the session
1115:             * @throws VerifyFailedException if verification fails
1116:             */
1117:            public void verifyTopicSessionRolledBack(int indexOfSession) {
1118:                MockTopicSession session = checkAndGetTopicSessionByIndex(indexOfSession);
1119:                if (!session.isRolledBack()) {
1120:                    throw new VerifyFailedException(
1121:                            "TopicSession is not rolled back.");
1122:                }
1123:            }
1124:
1125:            /**
1126:             * Verifies that the topic session with the specified index was
1127:             * not rolled back.
1128:             * The session has to be created using the current {@link MockTopicConnection}.
1129:             * @param indexOfSession the index of the session
1130:             * @throws VerifyFailedException if verification fails
1131:             */
1132:            public void verifyTopicSessionNotRolledBack(int indexOfSession) {
1133:                MockTopicSession session = checkAndGetTopicSessionByIndex(indexOfSession);
1134:                if (session.isRolledBack()) {
1135:                    throw new VerifyFailedException(
1136:                            "TopicSession is rolled back.");
1137:                }
1138:            }
1139:
1140:            /**
1141:             * Verifies the number of rollbacks of the topic session with the specified index.
1142:             * The session has to be created using the current {@link MockTopicConnection}.
1143:             * @param indexOfSession the index of the session
1144:             * @param numberOfRollbacks the expected number of rollbacks
1145:             * @throws VerifyFailedException if verification fails
1146:             */
1147:            public void verifyTopicSessionNumberRollbacks(int indexOfSession,
1148:                    int numberOfRollbacks) {
1149:                MockTopicSession session = checkAndGetTopicSessionByIndex(indexOfSession);
1150:                if (numberOfRollbacks != session.getNumberRollbacks()) {
1151:                    throw new VerifyFailedException(
1152:                            "TopicSession was rolled back "
1153:                                    + session.getNumberRollbacks()
1154:                                    + " times, expected " + numberOfRollbacks
1155:                                    + " times");
1156:                }
1157:            }
1158:
1159:            /**
1160:             * Verifies that the topic session with the specified index was
1161:             * recovered.
1162:             * The session has to be created using the current {@link MockTopicConnection}.
1163:             * @param indexOfSession the index of the session
1164:             * @throws VerifyFailedException if verification fails
1165:             */
1166:            public void verifyTopicSessionRecovered(int indexOfSession) {
1167:                MockTopicSession session = checkAndGetTopicSessionByIndex(indexOfSession);
1168:                if (!session.isRecovered()) {
1169:                    throw new VerifyFailedException(
1170:                            "TopicSession is not recovered.");
1171:                }
1172:            }
1173:
1174:            /**
1175:             * Verifies that the topic session with the specified index was
1176:             * not recovered.
1177:             * The session has to be created using the current {@link MockTopicConnection}.
1178:             * @param indexOfSession the index of the session
1179:             * @throws VerifyFailedException if verification fails
1180:             */
1181:            public void verifyTopicSessionNotRecovered(int indexOfSession) {
1182:                MockTopicSession session = checkAndGetTopicSessionByIndex(indexOfSession);
1183:                if (session.isRecovered()) {
1184:                    throw new VerifyFailedException(
1185:                            "TopicSession is recovered.");
1186:                }
1187:            }
1188:
1189:            /**
1190:             * Verifies that the session with the specified index is
1191:             * closed.
1192:             * The session has to be created using the current {@link MockConnection}.
1193:             * @param indexOfSession the index of the session
1194:             * @throws VerifyFailedException if verification fails
1195:             */
1196:            public void verifySessionClosed(int indexOfSession) {
1197:                MockSession session = checkAndGetSessionByIndex(indexOfSession);
1198:                if (!session.isClosed()) {
1199:                    throw new VerifyFailedException("Session with index "
1200:                            + indexOfSession + " is not closed.");
1201:                }
1202:            }
1203:
1204:            /**
1205:             * Verifies that the session with the specified index was
1206:             * committed.
1207:             * The session has to be created using the current {@link MockConnection}.
1208:             * @param indexOfSession the index of the session
1209:             * @throws VerifyFailedException if verification fails
1210:             */
1211:            public void verifySessionCommitted(int indexOfSession) {
1212:                MockSession session = checkAndGetSessionByIndex(indexOfSession);
1213:                if (!session.isCommitted()) {
1214:                    throw new VerifyFailedException("Session is not committed.");
1215:                }
1216:            }
1217:
1218:            /**
1219:             * Verifies that the session with the specified index was
1220:             * not committed.
1221:             * The session has to be created using the current {@link MockConnection}.
1222:             * @param indexOfSession the index of the session
1223:             * @throws VerifyFailedException if verification fails
1224:             */
1225:            public void verifySessionNotCommitted(int indexOfSession) {
1226:                MockSession session = checkAndGetSessionByIndex(indexOfSession);
1227:                if (session.isCommitted()) {
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,
1240:                    int numberOfCommits) {
1241:                MockSession session = checkAndGetSessionByIndex(indexOfSession);
1242:                if (numberOfCommits != session.getNumberCommits()) {
1243:                    throw new VerifyFailedException("Session was commited "
1244:                            + session.getNumberCommits() + " times, expected "
1245:                            + numberOfCommits + " times");
1246:                }
1247:            }
1248:
1249:            /**
1250:             * Verifies that the session with the specified index was
1251:             * rolled back.
1252:             * The session has to be created using the current {@link MockConnection}.
1253:             * @param indexOfSession the index of the session
1254:             * @throws VerifyFailedException if verification fails
1255:             */
1256:            public void verifySessionRolledBack(int indexOfSession) {
1257:                MockSession session = checkAndGetSessionByIndex(indexOfSession);
1258:                if (!session.isRolledBack()) {
1259:                    throw new VerifyFailedException(
1260:                            "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:                MockSession session = checkAndGetSessionByIndex(indexOfSession);
1273:                if (session.isRolledBack()) {
1274:                    throw new VerifyFailedException("Session is rolled back.");
1275:                }
1276:            }
1277:
1278:            /**
1279:             * Verifies the number of rollbacks of session with the specified index.
1280:             * The session has to be created using the current {@link MockConnection}.
1281:             * @param indexOfSession the index of the session
1282:             * @param numberOfRollbacks the expected number of rollbacks
1283:             * @throws VerifyFailedException if verification fails
1284:             */
1285:            public void verifySessionNumberRollbacks(int indexOfSession,
1286:                    int numberOfRollbacks) {
1287:                MockSession session = checkAndGetSessionByIndex(indexOfSession);
1288:                if (numberOfRollbacks != session.getNumberRollbacks()) {
1289:                    throw new VerifyFailedException("Session was rolled back "
1290:                            + session.getNumberRollbacks()
1291:                            + " times, expected " + numberOfRollbacks
1292:                            + " 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:                MockSession session = checkAndGetSessionByIndex(indexOfSession);
1305:                if (!session.isRecovered()) {
1306:                    throw new VerifyFailedException("Session is not recovered.");
1307:                }
1308:            }
1309:
1310:            /**
1311:             * Verifies that the session with the specified index was
1312:             * not recovered.
1313:             * The session has to be created using the current {@link MockConnection}.
1314:             * @param indexOfSession the index of the session
1315:             * @throws VerifyFailedException if verification fails
1316:             */
1317:            public void verifySessionNotRecovered(int indexOfSession) {
1318:                MockSession session = checkAndGetSessionByIndex(indexOfSession);
1319:                if (session.isRecovered()) {
1320:                    throw new VerifyFailedException("Session is recovered.");
1321:                }
1322:            }
1323:
1324:            /**
1325:             * Verifies that all queue sessions are closed.
1326:             * The sessions have to be created using the current {@link MockQueueConnection}.
1327:             * @throws VerifyFailedException if verification fails
1328:             */
1329:            public void verifyAllQueueSessionsClosed() {
1330:                List queueSessions = getQueueSessionList();
1331:                if (null == queueSessions)
1332:                    return;
1333:                for (int ii = 0; ii < queueSessions.size(); ii++) {
1334:                    MockQueueSession currentSession = (MockQueueSession) queueSessions
1335:                            .get(ii);
1336:                    if (!currentSession.isClosed()) {
1337:                        throw new VerifyFailedException(
1338:                                "QueueSession with index " + ii
1339:                                        + " is not closed.");
1340:                    }
1341:                }
1342:            }
1343:
1344:            /**
1345:             * Verifies that all queue sessions are recovered.
1346:             * The sessions have to be created using the current {@link MockQueueConnection}.
1347:             * @throws VerifyFailedException if verification fails
1348:             */
1349:            public void verifyAllQueueSessionsRecovered() {
1350:                List queueSessions = getQueueSessionList();
1351:                if (null == queueSessions)
1352:                    return;
1353:                for (int ii = 0; ii < queueSessions.size(); ii++) {
1354:                    MockQueueSession currentSession = (MockQueueSession) queueSessions
1355:                            .get(ii);
1356:                    if (!currentSession.isRecovered()) {
1357:                        throw new VerifyFailedException(
1358:                                "QueueSession with index " + ii
1359:                                        + " is not recovered.");
1360:                    }
1361:                }
1362:            }
1363:
1364:            /**
1365:             * Verifies that all queue sessions were commited.
1366:             * The sessions have to be created using the current {@link MockQueueConnection}.
1367:             * @throws VerifyFailedException if verification fails
1368:             */
1369:            public void verifyAllQueueSessionsCommitted() {
1370:                List queueSessions = getQueueSessionList();
1371:                if (null == queueSessions)
1372:                    return;
1373:                for (int ii = 0; ii < queueSessions.size(); ii++) {
1374:                    MockQueueSession currentSession = (MockQueueSession) queueSessions
1375:                            .get(ii);
1376:                    if (!currentSession.isCommitted()) {
1377:                        throw new VerifyFailedException(
1378:                                "QueueSession with index " + ii
1379:                                        + " is not committed.");
1380:                    }
1381:                }
1382:            }
1383:
1384:            /**
1385:             * Verifies that all queue sessions were rolled back.
1386:             * The sessions have to be created using the current {@link MockQueueConnection}.
1387:             * @throws VerifyFailedException if verification fails
1388:             */
1389:            public void verifyAllQueueSessionsRolledBack() {
1390:                List queueSessions = getQueueSessionList();
1391:                if (null == queueSessions)
1392:                    return;
1393:                for (int ii = 0; ii < queueSessions.size(); ii++) {
1394:                    MockQueueSession currentSession = (MockQueueSession) queueSessions
1395:                            .get(ii);
1396:                    if (!currentSession.isRolledBack()) {
1397:                        throw new VerifyFailedException(
1398:                                "QueueSession with index " + ii
1399:                                        + " 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:                List topicSessions = getTopicSessionList();
1411:                if (null == topicSessions)
1412:                    return;
1413:                for (int ii = 0; ii < topicSessions.size(); ii++) {
1414:                    MockTopicSession currentSession = (MockTopicSession) topicSessions
1415:                            .get(ii);
1416:                    if (!currentSession.isClosed()) {
1417:                        throw new VerifyFailedException(
1418:                                "TopicSession with index " + ii
1419:                                        + " is not closed.");
1420:                    }
1421:                }
1422:            }
1423:
1424:            /**
1425:             * Verifies that all topic sessions are recovered.
1426:             * The sessions have to be created using the current {@link MockTopicConnection}.
1427:             * @throws VerifyFailedException if verification fails
1428:             */
1429:            public void verifyAllTopicSessionsRecovered() {
1430:                List topicSessions = getTopicSessionList();
1431:                if (null == topicSessions)
1432:                    return;
1433:                for (int ii = 0; ii < topicSessions.size(); ii++) {
1434:                    MockTopicSession currentSession = (MockTopicSession) topicSessions
1435:                            .get(ii);
1436:                    if (!currentSession.isRecovered()) {
1437:                        throw new VerifyFailedException(
1438:                                "TopicSession with index " + ii
1439:                                        + " is not recovered.");
1440:                    }
1441:                }
1442:            }
1443:
1444:            /**
1445:             * Verifies that all topic sessions were commited.
1446:             * The sessions have to be created using the current {@link MockTopicConnection}.
1447:             * @throws VerifyFailedException if verification fails
1448:             */
1449:            public void verifyAllTopicSessionsCommitted() {
1450:                List topicSessions = getTopicSessionList();
1451:                if (null == topicSessions)
1452:                    return;
1453:                for (int ii = 0; ii < topicSessions.size(); ii++) {
1454:                    MockTopicSession currentSession = (MockTopicSession) topicSessions
1455:                            .get(ii);
1456:                    if (!currentSession.isCommitted()) {
1457:                        throw new VerifyFailedException(
1458:                                "TopicSession with index " + ii
1459:                                        + " is not committed.");
1460:                    }
1461:                }
1462:            }
1463:
1464:            /**
1465:             * Verifies that all topic sessions were rolled back.
1466:             * The sessions have to be created using the current {@link MockTopicConnection}.
1467:             * @throws VerifyFailedException if verification fails
1468:             */
1469:            public void verifyAllTopicSessionsRolledBack() {
1470:                List topicSessions = getTopicSessionList();
1471:                if (null == topicSessions)
1472:                    return;
1473:                for (int ii = 0; ii < topicSessions.size(); ii++) {
1474:                    MockTopicSession currentSession = (MockTopicSession) topicSessions
1475:                            .get(ii);
1476:                    if (!currentSession.isRolledBack()) {
1477:                        throw new VerifyFailedException(
1478:                                "TopicSession with index " + ii
1479:                                        + " is not rolled back.");
1480:                    }
1481:                }
1482:            }
1483:
1484:            /**
1485:             * Verifies that all sessions are closed.
1486:             * The sessions have to be created using the current {@link MockConnection}.
1487:             * @throws VerifyFailedException if verification fails
1488:             */
1489:            public void verifyAllSessionsClosed() {
1490:                List sessions = getSessionList();
1491:                if (null == sessions)
1492:                    return;
1493:                for (int ii = 0; ii < sessions.size(); ii++) {
1494:                    MockSession currentSession = (MockSession) sessions.get(ii);
1495:                    if (!currentSession.isClosed()) {
1496:                        throw new VerifyFailedException("Session with index "
1497:                                + ii + " is not closed.");
1498:                    }
1499:                }
1500:            }
1501:
1502:            /**
1503:             * Verifies that all sessions are recovered.
1504:             * The sessions have to be created using the current {@link MockConnection}.
1505:             * @throws VerifyFailedException if verification fails
1506:             */
1507:            public void verifyAllSessionsRecovered() {
1508:                List sessions = getSessionList();
1509:                if (null == sessions)
1510:                    return;
1511:                for (int ii = 0; ii < sessions.size(); ii++) {
1512:                    MockSession currentSession = (MockSession) sessions.get(ii);
1513:                    if (!currentSession.isRecovered()) {
1514:                        throw new VerifyFailedException("Session with index "
1515:                                + ii + " is not recovered.");
1516:                    }
1517:                }
1518:            }
1519:
1520:            /**
1521:             * Verifies that all sessions were commited.
1522:             * The sessions have to be created using the current {@link MockConnection}.
1523:             * @throws VerifyFailedException if verification fails
1524:             */
1525:            public void verifyAllSessionsCommitted() {
1526:                List sessions = getSessionList();
1527:                if (null == sessions)
1528:                    return;
1529:                for (int ii = 0; ii < sessions.size(); ii++) {
1530:                    MockSession currentSession = (MockSession) sessions.get(ii);
1531:                    if (!currentSession.isCommitted()) {
1532:                        throw new VerifyFailedException("Session with index "
1533:                                + ii + " is not committed.");
1534:                    }
1535:                }
1536:            }
1537:
1538:            /**
1539:             * Verifies that all topic sessions were rolled back.
1540:             * The sessions have to be created using the current {@link MockConnection}.
1541:             * @throws VerifyFailedException if verification fails
1542:             */
1543:            public void verifyAllSessionsRolledBack() {
1544:                List sessions = getSessionList();
1545:                if (null == sessions)
1546:                    return;
1547:                for (int ii = 0; ii < sessions.size(); ii++) {
1548:                    MockSession currentSession = (MockSession) sessions.get(ii);
1549:                    if (!currentSession.isRolledBack()) {
1550:                        throw new VerifyFailedException("Session with index "
1551:                                + 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,
1564:                    int numberOfProducers) {
1565:                checkAndGetSessionByIndex(indexOfSession);
1566:                TransmissionManagerWrapper manager = getTransmissionManagerWrapper(indexOfSession);
1567:                if (numberOfProducers != manager.getMessageProducerList()
1568:                        .size()) {
1569:                    throw new VerifyFailedException("Expected "
1570:                            + numberOfProducers + " producers, actually "
1571:                            + manager.getMessageProducerList().size()
1572:                            + " producers present");
1573:                }
1574:            }
1575:
1576:            /**
1577:             * Verifies that all producers for the specified session are closed.
1578:             * The session has to be created using the current {@link MockConnection}.
1579:             * @param indexOfSession the index of the session
1580:             * @throws VerifyFailedException if verification fails
1581:             */
1582:            public void verifyAllMessageProducersClosed(int indexOfSession) {
1583:                checkAndGetSessionByIndex(indexOfSession);
1584:                TransmissionManagerWrapper manager = getTransmissionManagerWrapper(indexOfSession);
1585:                List producers = manager.getMessageProducerList();
1586:                for (int ii = 0; ii < producers.size(); ii++) {
1587:                    MockMessageProducer currentProducer = (MockMessageProducer) producers
1588:                            .get(ii);
1589:                    if (!currentProducer.isClosed()) {
1590:                        throw new VerifyFailedException(
1591:                                "MessageProducer with index " + ii
1592:                                        + " not closed.");
1593:                    }
1594:                }
1595:            }
1596:
1597:            /**
1598:             * Verifies the number of senders for the specified session.
1599:             * The session has to be created using the current {@link MockQueueConnection}.
1600:             * @param indexOfSession the index of the session
1601:             * @param numberOfSenders the expected number of senders
1602:             * @throws VerifyFailedException if verification fails
1603:             */
1604:            public void verifyNumberQueueSenders(int indexOfSession,
1605:                    int numberOfSenders) {
1606:                checkAndGetQueueSessionByIndex(indexOfSession);
1607:                TransmissionManagerWrapper manager = getQueueTransmissionManagerWrapper(indexOfSession);
1608:                if (numberOfSenders != manager.getQueueSenderList().size()) {
1609:                    throw new VerifyFailedException("Expected "
1610:                            + numberOfSenders + " senders, actually "
1611:                            + manager.getQueueSenderList().size()
1612:                            + " senders present");
1613:                }
1614:            }
1615:
1616:            /**
1617:             * Verifies the number of senders for the specified session and
1618:             * the specified queue name.
1619:             * The session has to be created using the current {@link MockQueueConnection}.
1620:             * @param indexOfSession the index of the session
1621:             * @param queueName the name of the queue
1622:             * @param numberOfSenders the expected number of senders
1623:             * @throws VerifyFailedException if verification fails
1624:             */
1625:            public void verifyNumberQueueSenders(int indexOfSession,
1626:                    String queueName, int numberOfSenders) {
1627:                checkAndGetQueueSessionByIndex(indexOfSession);
1628:                checkQueueByName(queueName);
1629:                QueueTransmissionManager manager = getQueueTransmissionManager(indexOfSession);
1630:                if (numberOfSenders != manager.getQueueSenderList(queueName)
1631:                        .size()) {
1632:                    throw new VerifyFailedException("Expected "
1633:                            + numberOfSenders + " senders for queue "
1634:                            + queueName + ", actually "
1635:                            + manager.getQueueSenderList(queueName).size()
1636:                            + " senders present");
1637:                }
1638:            }
1639:
1640:            /**
1641:             * Verifies that the specified sender is closed.
1642:             * The session has to be created using the current {@link MockQueueConnection}.
1643:             * @param indexOfSession the index of the session
1644:             * @param queueName the name of the queue
1645:             * @param indexOfSender the index of the sender
1646:             * @throws VerifyFailedException if verification fails
1647:             */
1648:            public void verifyQueueSenderClosed(int indexOfSession,
1649:                    String queueName, int indexOfSender) {
1650:                checkAndGetQueueSessionByIndex(indexOfSession);
1651:                checkQueueByName(queueName);
1652:                QueueTransmissionManager manager = getQueueTransmissionManager(indexOfSession);
1653:                List senders = manager.getQueueSenderList(queueName);
1654:                if (indexOfSender >= senders.size()) {
1655:                    throw new VerifyFailedException("QueueSender with index "
1656:                            + indexOfSender + " is not present.");
1657:                }
1658:                MockQueueSender sender = (MockQueueSender) senders
1659:                        .get(indexOfSender);
1660:                if (!sender.isClosed()) {
1661:                    throw new VerifyFailedException("QueueSender of queue "
1662:                            + queueName + " with index " + indexOfSender
1663:                            + " not closed.");
1664:                }
1665:            }
1666:
1667:            /**
1668:             * Verifies that all senders for the specified session are closed.
1669:             * The session has to be created using the current {@link MockQueueConnection}.
1670:             * @param indexOfSession the index of the session
1671:             * @throws VerifyFailedException if verification fails
1672:             */
1673:            public void verifyAllQueueSendersClosed(int indexOfSession) {
1674:                checkAndGetQueueSessionByIndex(indexOfSession);
1675:                TransmissionManagerWrapper manager = getQueueTransmissionManagerWrapper(indexOfSession);
1676:                List senders = manager.getQueueSenderList();
1677:                for (int ii = 0; ii < senders.size(); ii++) {
1678:                    MockQueueSender currentSender = (MockQueueSender) senders
1679:                            .get(ii);
1680:                    if (!currentSender.isClosed()) {
1681:                        throw new VerifyFailedException(
1682:                                "QueueSender with index " + ii + " not closed.");
1683:                    }
1684:                }
1685:            }
1686:
1687:            /**
1688:             * Verifies the number of publishers for the specified session.
1689:             * The session has to be created using the current {@link MockTopicConnection}.
1690:             * @param indexOfSession the index of the session
1691:             * @param numberOfPublishers the expected number of publishers
1692:             * @throws VerifyFailedException if verification fails
1693:             */
1694:            public void verifyNumberTopicPublishers(int indexOfSession,
1695:                    int numberOfPublishers) {
1696:                checkAndGetTopicSessionByIndex(indexOfSession);
1697:                TransmissionManagerWrapper manager = getTopicTransmissionManagerWrapper(indexOfSession);
1698:                if (numberOfPublishers != manager.getTopicPublisherList()
1699:                        .size()) {
1700:                    throw new VerifyFailedException("Expected "
1701:                            + numberOfPublishers + " publishers, actually "
1702:                            + manager.getTopicPublisherList().size()
1703:                            + " publishers present");
1704:                }
1705:            }
1706:
1707:            /**
1708:             * Verifies the number of publishers for the specified session and
1709:             * the specified topic name.
1710:             * The session has to be created using the current {@link MockTopicConnection}.
1711:             * @param indexOfSession the index of the session
1712:             * @param topicName the name of the topic
1713:             * @param numberOfPublishers the expected number of publishers
1714:             * @throws VerifyFailedException if verification fails
1715:             */
1716:            public void verifyNumberTopicPublishers(int indexOfSession,
1717:                    String topicName, int numberOfPublishers) {
1718:                checkAndGetTopicSessionByIndex(indexOfSession);
1719:                checkTopicByName(topicName);
1720:                TopicTransmissionManager manager = getTopicTransmissionManager(indexOfSession);
1721:                if (numberOfPublishers != manager.getTopicPublisherList(
1722:                        topicName).size()) {
1723:                    throw new VerifyFailedException("Expected "
1724:                            + numberOfPublishers + " publishers for topic "
1725:                            + topicName + ", actually "
1726:                            + manager.getTopicPublisherList(topicName).size()
1727:                            + " publishers present");
1728:                }
1729:            }
1730:
1731:            /**
1732:             * Verifies that the specified publisher is closed.
1733:             * The session has to be created using the current {@link MockTopicConnection}.
1734:             * @param indexOfSession the index of the session
1735:             * @param topicName the name of the topic
1736:             * @param indexOfPublisher the index of the publisher
1737:             * @throws VerifyFailedException if verification fails
1738:             */
1739:            public void verifyTopicPublisherClosed(int indexOfSession,
1740:                    String topicName, int indexOfPublisher) {
1741:                checkAndGetTopicSessionByIndex(indexOfSession);
1742:                checkTopicByName(topicName);
1743:                TopicTransmissionManager manager = getTopicTransmissionManager(indexOfSession);
1744:                List publishers = manager.getTopicPublisherList(topicName);
1745:                if (indexOfPublisher >= publishers.size()) {
1746:                    throw new VerifyFailedException(
1747:                            "TopicPublisher with index " + indexOfPublisher
1748:                                    + " is not present.");
1749:                }
1750:                MockTopicPublisher publisher = (MockTopicPublisher) publishers
1751:                        .get(indexOfPublisher);
1752:                if (!publisher.isClosed()) {
1753:                    throw new VerifyFailedException("TopicPublisher of topic "
1754:                            + topicName + " with index " + indexOfPublisher
1755:                            + " not closed.");
1756:                }
1757:            }
1758:
1759:            /**
1760:             * Verifies that all publishers for the specified session are closed.
1761:             * The session has to be created using the current {@link MockTopicConnection}.
1762:             * @param indexOfSession the index of the session
1763:             * @throws VerifyFailedException if verification fails
1764:             */
1765:            public void verifyAllTopicPublishersClosed(int indexOfSession) {
1766:                checkAndGetTopicSessionByIndex(indexOfSession);
1767:                TransmissionManagerWrapper manager = getTopicTransmissionManagerWrapper(indexOfSession);
1768:                List publishers = manager.getTopicPublisherList();
1769:                for (int ii = 0; ii < publishers.size(); ii++) {
1770:                    MockTopicPublisher currentPublisher = (MockTopicPublisher) publishers
1771:                            .get(ii);
1772:                    if (!currentPublisher.isClosed()) {
1773:                        throw new VerifyFailedException(
1774:                                "TopicPublisher with index " + ii
1775:                                        + " not closed.");
1776:                    }
1777:                }
1778:            }
1779:
1780:            /**
1781:             * Verifies the number of consumers for the specified session.
1782:             * The session has to be created using the current {@link MockConnection}.
1783:             * @param indexOfSession the index of the session
1784:             * @param numberOfConsumers the expected number of consumers
1785:             * @throws VerifyFailedException if verification fails
1786:             */
1787:            public void verifyNumberMessageConsumers(int indexOfSession,
1788:                    int numberOfConsumers) {
1789:                checkAndGetSessionByIndex(indexOfSession);
1790:                TransmissionManagerWrapper manager = getTransmissionManagerWrapper(indexOfSession);
1791:                if (numberOfConsumers != manager.getMessageConsumerList()
1792:                        .size()) {
1793:                    throw new VerifyFailedException("Expected "
1794:                            + numberOfConsumers + " consumers, actually "
1795:                            + manager.getMessageConsumerList().size()
1796:                            + " consumers present");
1797:                }
1798:            }
1799:
1800:            /**
1801:             * Verifies that all consumers for the specified session are closed.
1802:             * The session has to be created using the current {@link MockConnection}.
1803:             * @param indexOfSession the index of the session
1804:             * @throws VerifyFailedException if verification fails
1805:             */
1806:            public void verifyAllMessageConsumersClosed(int indexOfSession) {
1807:                checkAndGetSessionByIndex(indexOfSession);
1808:                TransmissionManagerWrapper manager = getTransmissionManagerWrapper(indexOfSession);
1809:                List consumers = manager.getMessageConsumerList();
1810:                for (int ii = 0; ii < consumers.size(); ii++) {
1811:                    MockMessageConsumer currentConsumer = (MockMessageConsumer) consumers
1812:                            .get(ii);
1813:                    if (!currentConsumer.isClosed()) {
1814:                        throw new VerifyFailedException(
1815:                                "MessageConsumer with index " + ii
1816:                                        + " not closed.");
1817:                    }
1818:                }
1819:            }
1820:
1821:            /**
1822:             * Verifies the number of receivers for the specified session.
1823:             * The session has to be created using the current {@link MockQueueConnection}.
1824:             * @param indexOfSession the index of the session
1825:             * @param numberOfReceivers the expected number of receivers
1826:             * @throws VerifyFailedException if verification fails
1827:             */
1828:            public void verifyNumberQueueReceivers(int indexOfSession,
1829:                    int numberOfReceivers) {
1830:                checkAndGetQueueSessionByIndex(indexOfSession);
1831:                QueueTransmissionManager manager = getQueueTransmissionManager(indexOfSession);
1832:                if (numberOfReceivers != manager.getQueueReceiverList().size()) {
1833:                    throw new VerifyFailedException("Expected "
1834:                            + numberOfReceivers + " receivers, actually "
1835:                            + manager.getQueueReceiverList().size()
1836:                            + " receivers present");
1837:                }
1838:            }
1839:
1840:            /**
1841:             * Verifies the number of receivers for the specified session and
1842:             * the specified queue name.
1843:             * The session has to be created using the current {@link MockQueueConnection}.
1844:             * @param indexOfSession the index of the session
1845:             * @param queueName the name of the queue
1846:             * @param numberOfReceivers the expected number of receivers
1847:             * @throws VerifyFailedException if verification fails
1848:             */
1849:            public void verifyNumberQueueReceivers(int indexOfSession,
1850:                    String queueName, int numberOfReceivers) {
1851:                checkAndGetQueueSessionByIndex(indexOfSession);
1852:                checkQueueByName(queueName);
1853:                QueueTransmissionManager manager = getQueueTransmissionManager(indexOfSession);
1854:                if (numberOfReceivers != manager
1855:                        .getQueueReceiverList(queueName).size()) {
1856:                    throw new VerifyFailedException("Expected "
1857:                            + numberOfReceivers + " receivers for queue "
1858:                            + queueName + ", actually "
1859:                            + manager.getQueueReceiverList(queueName).size()
1860:                            + " receivers present");
1861:                }
1862:            }
1863:
1864:            /**
1865:             * Verifies that the specified receiver is closed.
1866:             * The session has to be created using the current {@link MockQueueConnection}.
1867:             * @param indexOfSession the index of the session
1868:             * @param queueName the name of the queue
1869:             * @param indexOfReceiver the index of the receiver
1870:             * @throws VerifyFailedException if verification fails
1871:             */
1872:            public void verifyQueueReceiverClosed(int indexOfSession,
1873:                    String queueName, int indexOfReceiver) {
1874:                checkAndGetQueueSessionByIndex(indexOfSession);
1875:                checkQueueByName(queueName);
1876:                QueueTransmissionManager manager = getQueueTransmissionManager(indexOfSession);
1877:                List receivers = manager.getQueueReceiverList(queueName);
1878:                if (indexOfReceiver >= receivers.size()) {
1879:                    throw new VerifyFailedException("QueueReceiver with index "
1880:                            + indexOfReceiver + " is not present.");
1881:                }
1882:                MockQueueReceiver receiver = (MockQueueReceiver) receivers
1883:                        .get(indexOfReceiver);
1884:                if (!receiver.isClosed()) {
1885:                    throw new VerifyFailedException("QueueReceiver of queue "
1886:                            + queueName + " with index " + indexOfReceiver
1887:                            + " not closed.");
1888:                }
1889:            }
1890:
1891:            /**
1892:             * Verifies that all receivers for the specified session are closed.
1893:             * The session has to be created using the current {@link MockQueueConnection}.
1894:             * @param indexOfSession the index of the session
1895:             * @throws VerifyFailedException if verification fails
1896:             */
1897:            public void verifyAllQueueReceiversClosed(int indexOfSession) {
1898:                checkAndGetQueueSessionByIndex(indexOfSession);
1899:                QueueTransmissionManager manager = getQueueTransmissionManager(indexOfSession);
1900:                List receivers = manager.getQueueReceiverList();
1901:                for (int ii = 0; ii < receivers.size(); ii++) {
1902:                    MockQueueReceiver currentReceiver = (MockQueueReceiver) receivers
1903:                            .get(ii);
1904:                    if (!currentReceiver.isClosed()) {
1905:                        throw new VerifyFailedException(
1906:                                "QueueReceiver with index " + ii
1907:                                        + " not closed.");
1908:                    }
1909:                }
1910:            }
1911:
1912:            /**
1913:             * Verifies the number of subscribers for the specified session.
1914:             * The session has to be created using the current {@link MockTopicConnection}.
1915:             * @param indexOfSession the index of the session
1916:             * @param numberOfSubscribers the expected number of subscribers
1917:             * @throws VerifyFailedException if verification fails
1918:             */
1919:            public void verifyNumberTopicSubscribers(int indexOfSession,
1920:                    int numberOfSubscribers) {
1921:                checkAndGetTopicSessionByIndex(indexOfSession);
1922:                TopicTransmissionManager manager = getTopicTransmissionManager(indexOfSession);
1923:                if (numberOfSubscribers != manager.getTopicSubscriberList()
1924:                        .size()) {
1925:                    throw new VerifyFailedException("Expected "
1926:                            + numberOfSubscribers + " subscribers, actually "
1927:                            + manager.getTopicSubscriberList().size()
1928:                            + " subscribers present");
1929:                }
1930:            }
1931:
1932:            /**
1933:             * Verifies the number of subscribers for the specified session and
1934:             * the specified topic name.
1935:             * The session has to be created using the current {@link MockTopicConnection}.
1936:             * @param indexOfSession the index of the session
1937:             * @param topicName the name of the topic
1938:             * @param numberOfSubscribers the expected number of subscribers
1939:             * @throws VerifyFailedException if verification fails
1940:             */
1941:            public void verifyNumberTopicSubscribers(int indexOfSession,
1942:                    String topicName, int numberOfSubscribers) {
1943:                checkAndGetTopicSessionByIndex(indexOfSession);
1944:                checkTopicByName(topicName);
1945:                TopicTransmissionManager manager = getTopicTransmissionManager(indexOfSession);
1946:                if (numberOfSubscribers != manager.getTopicSubscriberList(
1947:                        topicName).size()) {
1948:                    throw new VerifyFailedException("Expected "
1949:                            + numberOfSubscribers + " subscribers for topic "
1950:                            + topicName + ", actually "
1951:                            + manager.getTopicSubscriberList(topicName).size()
1952:                            + " subscribers present");
1953:                }
1954:            }
1955:
1956:            /**
1957:             * Verifies that the specified subscriber is closed.
1958:             * The session has to be created using the current {@link MockTopicConnection}.
1959:             * @param indexOfSession the index of the session
1960:             * @param topicName the name of the topic
1961:             * @param indexOfSubscriber the index of the receiver
1962:             * @throws VerifyFailedException if verification fails
1963:             */
1964:            public void verifyTopicSubscriberClosed(int indexOfSession,
1965:                    String topicName, int indexOfSubscriber) {
1966:                checkAndGetTopicSessionByIndex(indexOfSession);
1967:                checkTopicByName(topicName);
1968:                TopicTransmissionManager manager = getTopicTransmissionManager(indexOfSession);
1969:                List subscribers = manager.getTopicSubscriberList(topicName);
1970:                if (indexOfSubscriber >= subscribers.size()) {
1971:                    throw new VerifyFailedException(
1972:                            "TopicSubscriber with index " + indexOfSubscriber
1973:                                    + " is not present.");
1974:                }
1975:                MockTopicSubscriber subscriber = (MockTopicSubscriber) subscribers
1976:                        .get(indexOfSubscriber);
1977:                if (!subscriber.isClosed()) {
1978:                    throw new VerifyFailedException("TopicSubscriber of topic "
1979:                            + topicName + " with index " + indexOfSubscriber
1980:                            + " not closed.");
1981:                }
1982:            }
1983:
1984:            /**
1985:             * Verifies that all subscribers for the specified session are closed.
1986:             * The session has to be created using the current {@link MockTopicConnection}.
1987:             * @param indexOfSession the index of the session
1988:             * @throws VerifyFailedException if verification fails
1989:             */
1990:            public void verifyAllTopicSubscribersClosed(int indexOfSession) {
1991:                checkAndGetTopicSessionByIndex(indexOfSession);
1992:                TopicTransmissionManager manager = getTopicTransmissionManager(indexOfSession);
1993:                List subscribers = manager.getTopicSubscriberList();
1994:                for (int ii = 0; ii < subscribers.size(); ii++) {
1995:                    MockTopicSubscriber currentSubscriber = (MockTopicSubscriber) subscribers
1996:                            .get(ii);
1997:                    if (!currentSubscriber.isClosed()) {
1998:                        throw new VerifyFailedException(
1999:                                "TopicSubscriber with index " + ii
2000:                                        + " not closed.");
2001:                    }
2002:                }
2003:            }
2004:
2005:            /**
2006:             * Verifies the number of browsers for the specified session.
2007:             * The session has to be created using the current {@link MockQueueConnection}.
2008:             * @param indexOfSession the index of the session
2009:             * @param numberOfBrowsers the expected number of browsers
2010:             * @throws VerifyFailedException if verification fails
2011:             */
2012:            public void verifyNumberQueueBrowsers(int indexOfSession,
2013:                    int numberOfBrowsers) {
2014:                checkAndGetQueueSessionByIndex(indexOfSession);
2015:                QueueTransmissionManager manager = getQueueTransmissionManager(indexOfSession);
2016:                if (numberOfBrowsers != manager.getQueueBrowserList().size()) {
2017:                    throw new VerifyFailedException("Expected "
2018:                            + numberOfBrowsers + " browsers, actually "
2019:                            + manager.getQueueBrowserList().size()
2020:                            + " browsers present");
2021:                }
2022:            }
2023:
2024:            /**
2025:             * Verifies the number of browsers for the specified session and
2026:             * the specified queue name.
2027:             * The session has to be created using the current {@link MockQueueConnection}.
2028:             * @param indexOfSession the index of the session
2029:             * @param queueName the name of the queue
2030:             * @param numberOfBrowsers the expected number of browsers
2031:             * @throws VerifyFailedException if verification fails
2032:             */
2033:            public void verifyNumberQueueBrowsers(int indexOfSession,
2034:                    String queueName, int numberOfBrowsers) {
2035:                checkAndGetQueueSessionByIndex(indexOfSession);
2036:                checkQueueByName(queueName);
2037:                QueueTransmissionManager manager = getQueueTransmissionManager(indexOfSession);
2038:                if (numberOfBrowsers != manager.getQueueBrowserList(queueName)
2039:                        .size()) {
2040:                    throw new VerifyFailedException("Expected "
2041:                            + numberOfBrowsers + " browsers for queue "
2042:                            + queueName + ", actually "
2043:                            + manager.getQueueBrowserList(queueName).size()
2044:                            + " browsers present");
2045:                }
2046:            }
2047:
2048:            /**
2049:             * Verifies that the specified browser is closed.
2050:             * The session has to be created using the current {@link MockQueueConnection}.
2051:             * @param indexOfSession the index of the session
2052:             * @param queueName the name of the queue
2053:             * @param indexOfBrowser the index of the browser
2054:             * @throws VerifyFailedException if verification fails
2055:             */
2056:            public void verifyQueueBrowserClosed(int indexOfSession,
2057:                    String queueName, int indexOfBrowser) {
2058:                checkAndGetQueueSessionByIndex(indexOfSession);
2059:                checkQueueByName(queueName);
2060:                QueueTransmissionManager manager = getQueueTransmissionManager(indexOfSession);
2061:                List browsers = manager.getQueueBrowserList(queueName);
2062:                if (indexOfBrowser >= browsers.size()) {
2063:                    throw new VerifyFailedException("QueueBrowser with index "
2064:                            + indexOfBrowser + " is not present.");
2065:                }
2066:                MockQueueBrowser browser = (MockQueueBrowser) browsers
2067:                        .get(indexOfBrowser);
2068:                if (!browser.isClosed()) {
2069:                    throw new VerifyFailedException("QueueBrowser of queue "
2070:                            + queueName + " with index " + indexOfBrowser
2071:                            + " not closed.");
2072:                }
2073:            }
2074:
2075:            /**
2076:             * Verifies that all browsers for the specified session are closed.
2077:             * The session has to be created using the current {@link MockQueueConnection}.
2078:             * @param indexOfSession the index of the session
2079:             * @throws VerifyFailedException if verification fails
2080:             */
2081:            public void verifyAllQueueBrowsersClosed(int indexOfSession) {
2082:                checkAndGetQueueSessionByIndex(indexOfSession);
2083:                QueueTransmissionManager manager = getQueueTransmissionManager(indexOfSession);
2084:                List browsers = manager.getQueueBrowserList();
2085:                for (int ii = 0; ii < browsers.size(); ii++) {
2086:                    MockQueueBrowser currentBrowser = (MockQueueBrowser) browsers
2087:                            .get(ii);
2088:                    if (!currentBrowser.isClosed()) {
2089:                        throw new VerifyFailedException(
2090:                                "QueueBrowser with index " + ii
2091:                                        + " not closed.");
2092:                    }
2093:                }
2094:            }
2095:
2096:            /**
2097:             * Verifies that a durable subscriber exists.
2098:             * The session has to be created using the current {@link MockTopicConnection}.
2099:             * @param indexOfSession the index of the session
2100:             * @param name the name of the subscription
2101:             * @throws VerifyFailedException if verification fails
2102:             */
2103:            public void verifyDurableTopicSubscriberPresent(int indexOfSession,
2104:                    String name) {
2105:                checkAndGetTopicSessionByIndex(indexOfSession);
2106:                TopicTransmissionManager manager = getTopicTransmissionManager(indexOfSession);
2107:                if (null == manager.getDurableTopicSubscriber(name)) {
2108:                    throw new VerifyFailedException(
2109:                            "Durable subscriber with subscription name " + name
2110:                                    + " not present.");
2111:                }
2112:            }
2113:
2114:            /**
2115:             * Verifies the number of durable subscribers for the specified session.
2116:             * The session has to be created using the current {@link MockTopicConnection}.
2117:             * @param indexOfSession the index of the session
2118:             * @param numberOfSubscribers the expected number of durable subscribers
2119:             * @throws VerifyFailedException if verification fails
2120:             */
2121:            public void verifyNumberDurableTopicSubscribers(int indexOfSession,
2122:                    int numberOfSubscribers) {
2123:                checkAndGetTopicSessionByIndex(indexOfSession);
2124:                TopicTransmissionManager manager = getTopicTransmissionManager(indexOfSession);
2125:                if (numberOfSubscribers != manager
2126:                        .getDurableTopicSubscriberMap().size()) {
2127:                    throw new VerifyFailedException("Expected "
2128:                            + numberOfSubscribers
2129:                            + " durable subscribers, actually "
2130:                            + manager.getDurableTopicSubscriberMap().size()
2131:                            + " durable subscribers present");
2132:                }
2133:            }
2134:
2135:            /**
2136:             * Verifies the number of durable subscribers for the specified session and
2137:             * the specified topic name.
2138:             * The session has to be created using the current {@link MockTopicConnection}.
2139:             * @param indexOfSession the index of the session
2140:             * @param topicName the name of the topic
2141:             * @param numberOfSubscribers the expected number of durable subscribers
2142:             * @throws VerifyFailedException if verification fails
2143:             */
2144:            public void verifyNumberDurableTopicSubscribers(int indexOfSession,
2145:                    String topicName, int numberOfSubscribers) {
2146:                checkAndGetTopicSessionByIndex(indexOfSession);
2147:                checkTopicByName(topicName);
2148:                TopicTransmissionManager manager = getTopicTransmissionManager(indexOfSession);
2149:                if (numberOfSubscribers != manager
2150:                        .getDurableTopicSubscriberMap(topicName).size()) {
2151:                    throw new VerifyFailedException("Expected "
2152:                            + numberOfSubscribers
2153:                            + " durable subscribers for topic "
2154:                            + topicName
2155:                            + ", actually "
2156:                            + manager.getDurableTopicSubscriberMap(topicName)
2157:                                    .size() + " durable subscribers present");
2158:                }
2159:            }
2160:
2161:            /**
2162:             * Verifies that the specified durable subscriber is closed.
2163:             * The session has to be created using the current {@link MockTopicConnection}.
2164:             * @param indexOfSession the index of the session
2165:             * @param name the name of the subscription
2166:             * @throws VerifyFailedException if verification fails
2167:             */
2168:            public void verifyDurableTopicSubscriberClosed(int indexOfSession,
2169:                    String name) {
2170:                checkAndGetTopicSessionByIndex(indexOfSession);
2171:                TopicTransmissionManager manager = getTopicTransmissionManager(indexOfSession);
2172:                MockTopicSubscriber subscriber = (MockTopicSubscriber) manager
2173:                        .getDurableTopicSubscriber(name);
2174:                if (null == subscriber) {
2175:                    throw new VerifyFailedException(
2176:                            "Durable TopicSubscriber with subscription name "
2177:                                    + name + " not present.");
2178:                }
2179:                if (!subscriber.isClosed()) {
2180:                    throw new VerifyFailedException(
2181:                            "Durable TopicSubscriber with subscription name "
2182:                                    + name + " not closed.");
2183:                }
2184:            }
2185:
2186:            /**
2187:             * Verifies that all durable subscribers for the specified session are closed.
2188:             * The session has to be created using the current {@link MockTopicConnection}.
2189:             * @param indexOfSession the index of the session
2190:             * @throws VerifyFailedException if verification fails
2191:             */
2192:            public void verifyAllDurableTopicSubscribersClosed(
2193:                    int indexOfSession) {
2194:                checkAndGetTopicSessionByIndex(indexOfSession);
2195:                TopicTransmissionManager manager = getTopicTransmissionManager(indexOfSession);
2196:                Iterator keys = manager.getDurableTopicSubscriberMap().keySet()
2197:                        .iterator();
2198:                while (keys.hasNext()) {
2199:                    MockTopicSubscriber currentSubscriber = (MockTopicSubscriber) manager
2200:                            .getDurableTopicSubscriberMap().get(keys.next());
2201:                    if (!currentSubscriber.isClosed()) {
2202:                        throw new VerifyFailedException(
2203:                                "Durable TopicSubscriber with name "
2204:                                        + currentSubscriber.getName()
2205:                                        + " not closed.");
2206:                    }
2207:                }
2208:            }
2209:
2210:            /**
2211:             * Verifies the number of queue sessions.
2212:             * The sessions have to be created using the current {@link MockQueueConnection}.
2213:             * @param number the expected number of queue sessions
2214:             * @throws VerifyFailedException if verification fails
2215:             */
2216:            public void verifyNumberQueueSessions(int number) {
2217:                if (number != getQueueSessionList().size()) {
2218:                    throw new VerifyFailedException("Expected " + number
2219:                            + " queue sessions, actually "
2220:                            + getQueueSessionList().size()
2221:                            + " sessions present");
2222:                }
2223:            }
2224:
2225:            /**
2226:             * Verifies the number of topic sessions.
2227:             * The sessions have to be created using the current {@link MockTopicConnection}.
2228:             * @param number the expected number of topic sessions
2229:             * @throws VerifyFailedException if verification fails
2230:             */
2231:            public void verifyNumberTopicSessions(int number) {
2232:                if (number != getTopicSessionList().size()) {
2233:                    throw new VerifyFailedException("Expected " + number
2234:                            + " topic sessions, actually "
2235:                            + getTopicSessionList().size()
2236:                            + " sessions present");
2237:                }
2238:            }
2239:
2240:            /**
2241:             * Verifies the number of sessions.
2242:             * The sessions have to be created using the current {@link MockConnection}.
2243:             * @param number the expected number of sessions
2244:             * @throws VerifyFailedException if verification fails
2245:             */
2246:            public void verifyNumberSessions(int number) {
2247:                if (number != getSessionList().size()) {
2248:                    throw new VerifyFailedException("Expected " + number
2249:                            + " sessions, actually " + getSessionList().size()
2250:                            + " sessions present");
2251:                }
2252:            }
2253:
2254:            /**
2255:             * Verifies the number of temporary queues.
2256:             * The session has to be created using the current {@link MockQueueConnection}.
2257:             * @param indexOfSession the index of the session
2258:             * @param numberQueues the expected number of temporary queues
2259:             * @throws VerifyFailedException if verification fails
2260:             */
2261:            public void verifyNumberTemporaryQueues(int indexOfSession,
2262:                    int numberQueues) {
2263:                checkAndGetQueueSessionByIndex(indexOfSession);
2264:                if (numberQueues != getTemporaryQueueList(indexOfSession)
2265:                        .size()) {
2266:                    throw new VerifyFailedException("Expected " + numberQueues
2267:                            + " temporary queues, actually "
2268:                            + getTemporaryQueueList(indexOfSession).size()
2269:                            + " temporary queues present");
2270:                }
2271:            }
2272:
2273:            /**
2274:             * Verifies the number of temporary topics.
2275:             * The session has to be created using the current {@link MockTopicConnection}.
2276:             * @param indexOfSession the index of the session
2277:             * @param numberTopics the expected number of temporary topics
2278:             * @throws VerifyFailedException if verification fails
2279:             */
2280:            public void verifyNumberTemporaryTopics(int indexOfSession,
2281:                    int numberTopics) {
2282:                checkAndGetTopicSessionByIndex(indexOfSession);
2283:                if (numberTopics != getTemporaryTopicList(indexOfSession)
2284:                        .size()) {
2285:                    throw new VerifyFailedException("Expected " + numberTopics
2286:                            + " temporary topics, actually "
2287:                            + getTemporaryTopicList(indexOfSession).size()
2288:                            + " temporary topics present");
2289:                }
2290:            }
2291:
2292:            /**
2293:             * Verifies that the temporary queue with the specified index
2294:             * was deleted.
2295:             * The session has to be created using the current {@link MockQueueConnection}.
2296:             * @param indexOfSession the index of the session
2297:             * @param indexOfQueue the index of the queue
2298:             * @throws VerifyFailedException if verification fails
2299:             */
2300:            public void verifyTemporaryQueueDeleted(int indexOfSession,
2301:                    int indexOfQueue) {
2302:                checkAndGetQueueSessionByIndex(indexOfSession);
2303:                MockTemporaryQueue queue = getTemporaryQueue(indexOfSession,
2304:                        indexOfQueue);
2305:                if (null == queue) {
2306:                    throw new VerifyFailedException(
2307:                            "TemporaryQueue with index " + indexOfQueue
2308:                                    + " is not present.");
2309:                }
2310:                if (!queue.isDeleted()) {
2311:                    throw new VerifyFailedException(
2312:                            "TemporaryQueue with index " + indexOfQueue
2313:                                    + " not deleted.");
2314:                }
2315:            }
2316:
2317:            /**
2318:             * Verifies that all temporary queues were deleted.
2319:             * The session has to be created using the current {@link MockQueueConnection}.
2320:             * @param indexOfSession the index of the session
2321:             * @throws VerifyFailedException if verification fails
2322:             */
2323:            public void verifyAllTemporaryQueuesDeleted(int indexOfSession) {
2324:                checkAndGetQueueSessionByIndex(indexOfSession);
2325:                List queueList = getTemporaryQueueList(indexOfSession);
2326:                for (int ii = 0; ii < queueList.size(); ii++) {
2327:                    MockTemporaryQueue currentQueue = (MockTemporaryQueue) queueList
2328:                            .get(ii);
2329:                    if (!currentQueue.isDeleted()) {
2330:                        throw new VerifyFailedException(
2331:                                "TemporaryQueue with index " + ii
2332:                                        + " not deleted.");
2333:                    }
2334:                }
2335:            }
2336:
2337:            /**
2338:             * Verifies that the temporary topic with the specified index
2339:             * was closed.
2340:             * The session has to be created using the current {@link MockTopicConnection}.
2341:             * @param indexOfSession the index of the session
2342:             * @param indexOfTopic the index of the topic
2343:             * @throws VerifyFailedException if verification fails
2344:             */
2345:            public void verifyTemporaryTopicDeleted(int indexOfSession,
2346:                    int indexOfTopic) {
2347:                checkAndGetTopicSessionByIndex(indexOfSession);
2348:                MockTemporaryTopic topic = getTemporaryTopic(indexOfSession,
2349:                        indexOfTopic);
2350:                if (null == topic) {
2351:                    throw new VerifyFailedException(
2352:                            "TemporaryTopic with index " + indexOfTopic
2353:                                    + " is not present.");
2354:                }
2355:                if (!topic.isDeleted()) {
2356:                    throw new VerifyFailedException(
2357:                            "TemporaryTopic with index " + indexOfTopic
2358:                                    + " not deleted.");
2359:                }
2360:            }
2361:
2362:            /**
2363:             * Verifies that all temporary topics were deleted.
2364:             * The session has to be created using the current {@link MockTopicConnection}.
2365:             * @param indexOfSession the index of the session
2366:             * @throws VerifyFailedException if verification fails
2367:             */
2368:            public void verifyAllTemporaryTopicsDeleted(int indexOfSession) {
2369:                checkAndGetTopicSessionByIndex(indexOfSession);
2370:                List topicList = getTemporaryTopicList(indexOfSession);
2371:                for (int ii = 0; ii < topicList.size(); ii++) {
2372:                    MockTemporaryTopic currentTopic = (MockTemporaryTopic) topicList
2373:                            .get(ii);
2374:                    if (!currentTopic.isDeleted()) {
2375:                        throw new VerifyFailedException(
2376:                                "TemporaryTopic with index " + ii
2377:                                        + " not deleted.");
2378:                    }
2379:                }
2380:            }
2381:
2382:            /**
2383:             * Verifies that the specified messages are equal by calling the
2384:             * <code>equals()</code> method. All mock messages provide a
2385:             * suitable implementation of <code>equals()</code>.
2386:             * @param message1 the first message
2387:             * @param message2 the second message
2388:             * @throws VerifyFailedException if verification fails
2389:             */
2390:            public void verifyMessageEquals(MockMessage message1,
2391:                    MockMessage message2) {
2392:                if (null == message1) {
2393:                    throw new VerifyFailedException("message1 is null");
2394:                }
2395:                if (null == message2) {
2396:                    throw new VerifyFailedException("message2 is null");
2397:                }
2398:                if (!message1.equals(message2)) {
2399:                    throw new VerifyFailedException(
2400:                            "messages not equal: message1: "
2401:                                    + message1.toString() + ", message2: "
2402:                                    + message2.toString());
2403:                }
2404:            }
2405:
2406:            /**
2407:             * Verifies that a message in the specified queue is equal to
2408:             * the specified message by calling the <code>equals()</code> method. 
2409:             * All mock messages provide a suitable implementation of <code>equals()</code>.
2410:             * @param nameOfQueue the name of the queue
2411:             * @param indexOfSourceMessage the index of the message in the queue
2412:             * @param targetMessage the message that will be used for comparison
2413:             * @throws VerifyFailedException if verification fails
2414:             */
2415:            public void verifyCurrentQueueMessageEquals(String nameOfQueue,
2416:                    int indexOfSourceMessage, MockMessage targetMessage) {
2417:                checkQueueByName(nameOfQueue);
2418:                List messageList = getCurrentMessageListFromQueue(nameOfQueue);
2419:                if (indexOfSourceMessage >= messageList.size()) {
2420:                    throw new VerifyFailedException("Queue " + nameOfQueue
2421:                            + " contains only " + messageList.size()
2422:                            + " messages");
2423:                }
2424:                MockMessage sourceMessage = (MockMessage) messageList
2425:                        .get(indexOfSourceMessage);
2426:                verifyMessageEquals(sourceMessage, targetMessage);
2427:            }
2428:
2429:            /**
2430:             * Verifies that a received message is equal to the specified message 
2431:             * by calling the <code>equals()</code> method. 
2432:             * All mock messages provide a suitable implementation of <code>equals()</code>.
2433:             * @param nameOfQueue the name of the queue
2434:             * @param indexOfSourceMessage the index of the received message
2435:             * @param targetMessage the message that will be used for comparison
2436:             * @throws VerifyFailedException if verification fails
2437:             */
2438:            public void verifyReceivedQueueMessageEquals(String nameOfQueue,
2439:                    int indexOfSourceMessage, MockMessage targetMessage) {
2440:                checkQueueByName(nameOfQueue);
2441:                List messageList = getReceivedMessageListFromQueue(nameOfQueue);
2442:                if (indexOfSourceMessage >= messageList.size()) {
2443:                    throw new VerifyFailedException("Queue " + nameOfQueue
2444:                            + " received only " + messageList.size()
2445:                            + " messages");
2446:                }
2447:                MockMessage sourceMessage = (MockMessage) messageList
2448:                        .get(indexOfSourceMessage);
2449:                verifyMessageEquals(sourceMessage, targetMessage);
2450:            }
2451:
2452:            /**
2453:             * Verifies that a message in the specified temporary queue is equal to
2454:             * the specified message by calling the <code>equals()</code> method. 
2455:             * All mock messages provide a suitable implementation of <code>equals()</code>.
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 indexOfSourceMessage the index of the message in the queue
2460:             * @param targetMessage the message that will be used for comparison
2461:             * @throws VerifyFailedException if verification fails
2462:             */
2463:            public void verifyCurrentQueueMessageEquals(int indexOfSession,
2464:                    int indexOfQueue, int indexOfSourceMessage,
2465:                    MockMessage targetMessage) {
2466:                checkAndGetQueueSessionByIndex(indexOfSession);
2467:                List messageList = getCurrentMessageListFromTemporaryQueue(
2468:                        indexOfSession, indexOfQueue);
2469:                if (null == messageList) {
2470:                    throw new VerifyFailedException(
2471:                            "Temporary queue with index " + indexOfQueue
2472:                                    + " of session with index "
2473:                                    + indexOfSession + " does not exist");
2474:                }
2475:                if (indexOfSourceMessage >= messageList.size()) {
2476:                    throw new VerifyFailedException(
2477:                            "Temporary queue with index " + indexOfQueue
2478:                                    + " contains only " + messageList.size()
2479:                                    + " messages");
2480:                }
2481:                MockMessage sourceMessage = (MockMessage) messageList
2482:                        .get(indexOfSourceMessage);
2483:                verifyMessageEquals(sourceMessage, targetMessage);
2484:            }
2485:
2486:            /**
2487:             * Verifies that a message received by a temporary queue is equal to the specified message 
2488:             * by calling the <code>equals()</code> method. 
2489:             * All mock messages provide a suitable implementation of <code>equals()</code>.
2490:             * The session has to be created using the current {@link MockQueueConnection}.
2491:             * @param indexOfSession the index of the session
2492:             * @param indexOfQueue the index of the temporary queue
2493:             * @param indexOfSourceMessage the index of the received message
2494:             * @param targetMessage the message that will be used for comparison
2495:             * @throws VerifyFailedException if verification fails
2496:             */
2497:            public void verifyReceivedQueueMessageEquals(int indexOfSession,
2498:                    int indexOfQueue, int indexOfSourceMessage,
2499:                    MockMessage targetMessage) {
2500:                checkAndGetQueueSessionByIndex(indexOfSession);
2501:                List messageList = getReceivedMessageListFromTemporaryQueue(
2502:                        indexOfSession, indexOfQueue);
2503:                if (null == messageList) {
2504:                    throw new VerifyFailedException(
2505:                            "Temporary queue with index " + indexOfQueue
2506:                                    + " of session with index "
2507:                                    + indexOfSession + " does not exist");
2508:                }
2509:                if (indexOfSourceMessage >= messageList.size()) {
2510:                    throw new VerifyFailedException(
2511:                            "Temporary queue with index " + indexOfQueue
2512:                                    + " received only " + messageList.size()
2513:                                    + " messages");
2514:                }
2515:                MockMessage sourceMessage = (MockMessage) messageList
2516:                        .get(indexOfSourceMessage);
2517:                verifyMessageEquals(sourceMessage, targetMessage);
2518:            }
2519:
2520:            /**
2521:             * Verifies the number of messages in a queue.
2522:             * @param nameOfQueue the name of the queue
2523:             * @param numberOfMessages the expected number of messages
2524:             * @throws VerifyFailedException if verification fails
2525:             */
2526:            public void verifyNumberOfCurrentQueueMessages(String nameOfQueue,
2527:                    int numberOfMessages) {
2528:                checkQueueByName(nameOfQueue);
2529:                List list = getCurrentMessageListFromQueue(nameOfQueue);
2530:                if (numberOfMessages != list.size()) {
2531:                    throw new VerifyFailedException("Expected "
2532:                            + numberOfMessages + " messages in queue "
2533:                            + nameOfQueue + ", received " + list.size()
2534:                            + " messages");
2535:                }
2536:            }
2537:
2538:            /**
2539:             * Verifies the number of messages received by a queue.
2540:             * @param nameOfQueue the name of the queue
2541:             * @param numberOfMessages the expected number of messages
2542:             * @throws VerifyFailedException if verification fails
2543:             */
2544:            public void verifyNumberOfReceivedQueueMessages(String nameOfQueue,
2545:                    int numberOfMessages) {
2546:                checkQueueByName(nameOfQueue);
2547:                List list = getReceivedMessageListFromQueue(nameOfQueue);
2548:                if (numberOfMessages != list.size()) {
2549:                    throw new VerifyFailedException("Expected "
2550:                            + numberOfMessages + " messages received by queue "
2551:                            + nameOfQueue + ", received " + list.size()
2552:                            + " messages");
2553:                }
2554:            }
2555:
2556:            /**
2557:             * Verifies the number of messages in a temporary queue.
2558:             * The session has to be created using the current {@link MockQueueConnection}.
2559:             * @param indexOfSession the index of the session
2560:             * @param indexOfQueue the index of the temporary queue
2561:             * @param numberOfMessages the expected number of messages
2562:             * @throws VerifyFailedException if verification fails
2563:             */
2564:            public void verifyNumberOfCurrentQueueMessages(int indexOfSession,
2565:                    int indexOfQueue, int numberOfMessages) {
2566:                checkAndGetQueueSessionByIndex(indexOfSession);
2567:                List list = getCurrentMessageListFromTemporaryQueue(
2568:                        indexOfSession, indexOfQueue);
2569:                if (null == list) {
2570:                    throw new VerifyFailedException(
2571:                            "Temporary queue with index " + indexOfQueue
2572:                                    + " of session with index "
2573:                                    + indexOfSession + " does not exist");
2574:                }
2575:                if (numberOfMessages != list.size()) {
2576:                    throw new VerifyFailedException("Expected "
2577:                            + numberOfMessages + " messages, received "
2578:                            + list.size() + " messages");
2579:                }
2580:            }
2581:
2582:            /**
2583:             * Verifies the number of messages received by a temporary queue.
2584:             * The session has to be created using the current {@link MockQueueConnection}.
2585:             * @param indexOfSession the index of the session
2586:             * @param indexOfQueue the index of the temporary queue
2587:             * @param numberOfMessages the expected number of messages
2588:             * @throws VerifyFailedException if verification fails
2589:             */
2590:            public void verifyNumberOfReceivedQueueMessages(int indexOfSession,
2591:                    int indexOfQueue, int numberOfMessages) {
2592:                checkAndGetQueueSessionByIndex(indexOfSession);
2593:                List list = getReceivedMessageListFromTemporaryQueue(
2594:                        indexOfSession, indexOfQueue);
2595:                if (null == list) {
2596:                    throw new VerifyFailedException(
2597:                            "Temporary queue with index " + indexOfQueue
2598:                                    + " of session with index "
2599:                                    + indexOfSession + " does not exist");
2600:                }
2601:                if (numberOfMessages != list.size()) {
2602:                    throw new VerifyFailedException("Expected "
2603:                            + numberOfMessages + " messages, received "
2604:                            + list.size() + " messages");
2605:                }
2606:            }
2607:
2608:            /**
2609:             * Verifies that all received messages of the specified queue 
2610:             * are acknowledged.
2611:             * @param nameOfQueue the name of the queue
2612:             * @throws VerifyFailedException if verification fails
2613:             */
2614:            public void verifyAllReceivedQueueMessagesAcknowledged(
2615:                    String nameOfQueue) {
2616:                checkQueueByName(nameOfQueue);
2617:                List messageList = getReceivedMessageListFromQueue(nameOfQueue);
2618:                for (int ii = 0; ii < messageList.size(); ii++) {
2619:                    MockMessage currentMessage = (MockMessage) messageList
2620:                            .get(ii);
2621:                    if (!currentMessage.isAcknowledged()) {
2622:                        throw new VerifyFailedException("Message " + ii
2623:                                + " of queue " + nameOfQueue
2624:                                + " is not acknowledged");
2625:                    }
2626:                }
2627:            }
2628:
2629:            /**
2630:             * Verifies that all received messages of the specified temporary queue 
2631:             * are acknowledged.
2632:             * The session has to be created using the current {@link MockQueueConnection}.
2633:             * @param indexOfSession the index of the session
2634:             * @param indexOfQueue the index of the temporary queue
2635:             * @throws VerifyFailedException if verification fails
2636:             */
2637:            public void verifyAllReceivedQueueMessagesAcknowledged(
2638:                    int indexOfSession, int indexOfQueue) {
2639:                checkAndGetQueueSessionByIndex(indexOfSession);
2640:                List messageList = getReceivedMessageListFromTemporaryQueue(
2641:                        indexOfSession, indexOfQueue);
2642:                if (null == messageList) {
2643:                    throw new VerifyFailedException(
2644:                            "Temporary queue with index " + indexOfQueue
2645:                                    + " of session with index "
2646:                                    + indexOfSession + " does not exist");
2647:                }
2648:                for (int ii = 0; ii < messageList.size(); ii++) {
2649:                    MockMessage currentMessage = (MockMessage) messageList
2650:                            .get(ii);
2651:                    if (!currentMessage.isAcknowledged()) {
2652:                        throw new VerifyFailedException("Message " + ii
2653:                                + " of temporary queue " + indexOfQueue
2654:                                + " is not acknowledged");
2655:                    }
2656:                }
2657:            }
2658:
2659:            /**
2660:             * Verifies that a received message is acknowledged.
2661:             * @param nameOfQueue the name of the queue
2662:             * @param indexOfMessage the index of the received message
2663:             * @throws VerifyFailedException if verification fails
2664:             */
2665:            public void verifyReceivedQueueMessageAcknowledged(
2666:                    String nameOfQueue, int indexOfMessage) {
2667:                checkQueueByName(nameOfQueue);
2668:                List messageList = getReceivedMessageListFromQueue(nameOfQueue);
2669:                if (indexOfMessage >= messageList.size()) {
2670:                    throw new VerifyFailedException("Queue " + nameOfQueue
2671:                            + " received only " + messageList.size()
2672:                            + " messages");
2673:                }
2674:                MockMessage message = (MockMessage) messageList
2675:                        .get(indexOfMessage);
2676:                if (!message.isAcknowledged()) {
2677:                    throw new VerifyFailedException("Message " + indexOfMessage
2678:                            + " of queue " + nameOfQueue
2679:                            + " is not acknowledged");
2680:                }
2681:            }
2682:
2683:            /**
2684:             * Verifies that a received message is not acknowledged.
2685:             * @param nameOfQueue the name of the queue
2686:             * @param indexOfMessage the index of the received message
2687:             * @throws VerifyFailedException if verification fails
2688:             */
2689:            public void verifyReceivedQueueMessageNotAcknowledged(
2690:                    String nameOfQueue, int indexOfMessage) {
2691:                checkQueueByName(nameOfQueue);
2692:                List messageList = getReceivedMessageListFromQueue(nameOfQueue);
2693:                if (indexOfMessage >= messageList.size()) {
2694:                    throw new VerifyFailedException("Queue " + nameOfQueue
2695:                            + " received only " + messageList.size()
2696:                            + " messages");
2697:                }
2698:                MockMessage message = (MockMessage) messageList
2699:                        .get(indexOfMessage);
2700:                if (message.isAcknowledged()) {
2701:                    throw new VerifyFailedException("Message " + indexOfMessage
2702:                            + " of queue " + nameOfQueue + " is acknowledged");
2703:                }
2704:            }
2705:
2706:            /**
2707:             * Verifies that message received by a temporary queue is acknowledged.
2708:             * The session has to be created using the current {@link MockQueueConnection}.
2709:             * @param indexOfSession the index of the session
2710:             * @param indexOfQueue the index of the temporary queue
2711:             * @param indexOfMessage the index of the received message
2712:             * @throws VerifyFailedException if verification fails
2713:             */
2714:            public void verifyReceivedQueueMessageAcknowledged(
2715:                    int indexOfSession, int indexOfQueue, int indexOfMessage) {
2716:                checkAndGetQueueSessionByIndex(indexOfSession);
2717:                List messageList = getReceivedMessageListFromTemporaryQueue(
2718:                        indexOfSession, indexOfQueue);
2719:                if (null == messageList) {
2720:                    throw new VerifyFailedException(
2721:                            "Temporary queue with index " + indexOfQueue
2722:                                    + " of session with index "
2723:                                    + indexOfSession + " does not exist");
2724:                }
2725:                if (indexOfMessage >= messageList.size()) {
2726:                    throw new VerifyFailedException(
2727:                            "Temporary queue with index " + indexOfQueue
2728:                                    + " received only " + messageList.size()
2729:                                    + " messages");
2730:                }
2731:                MockMessage message = (MockMessage) messageList
2732:                        .get(indexOfMessage);
2733:                if (!message.isAcknowledged()) {
2734:                    throw new VerifyFailedException("Message " + indexOfMessage
2735:                            + " of temporary queue " + indexOfQueue
2736:                            + " is not acknowledged");
2737:                }
2738:            }
2739:
2740:            /**
2741:             * Verifies that a received by a temporary queue is not acknowledged.
2742:             * The session has to be created using the current {@link MockQueueConnection}.
2743:             * @param indexOfSession the index of the session
2744:             * @param indexOfQueue the index of the temporary queue
2745:             * @param indexOfMessage the index of the received message
2746:             * @throws VerifyFailedException if verification fails
2747:             */
2748:            public void verifyReceivedQueueMessageNotAcknowledged(
2749:                    int indexOfSession, int indexOfQueue, int indexOfMessage) {
2750:                checkAndGetQueueSessionByIndex(indexOfSession);
2751:                List messageList = getReceivedMessageListFromTemporaryQueue(
2752:                        indexOfSession, indexOfQueue);
2753:                if (null == messageList) {
2754:                    throw new VerifyFailedException(
2755:                            "Temporary queue with index " + indexOfQueue
2756:                                    + " of session with index "
2757:                                    + indexOfSession + " does not exist");
2758:                }
2759:                if (indexOfMessage >= messageList.size()) {
2760:                    throw new VerifyFailedException(
2761:                            "Temporary queue with index " + indexOfQueue
2762:                                    + " received only " + messageList.size()
2763:                                    + " messages");
2764:                }
2765:                MockMessage message = (MockMessage) messageList
2766:                        .get(indexOfMessage);
2767:                if (message.isAcknowledged()) {
2768:                    throw new VerifyFailedException("Message " + indexOfMessage
2769:                            + " of temporary queue " + indexOfQueue
2770:                            + " is acknowledged");
2771:                }
2772:            }
2773:
2774:            /**
2775:             * Verifies the number of messages created with
2776:             * {@link MockQueueSession#createMessage}.
2777:             * The session has to be created using the current {@link MockQueueConnection}.
2778:             * @param indexOfSession the index of the session
2779:             * @param number the expected number of messages
2780:             * @throws VerifyFailedException if verification fails
2781:             */
2782:            public void verifyNumberOfCreatedQueueMessages(int indexOfSession,
2783:                    int number) {
2784:                checkAndGetQueueSessionByIndex(indexOfSession);
2785:                if (number != getQueueMessageManager(indexOfSession)
2786:                        .getMessageList().size()) {
2787:                    throw new VerifyFailedException("Expected "
2788:                            + number
2789:                            + " messages, received "
2790:                            + getQueueMessageManager(indexOfSession)
2791:                                    .getMessageList().size() + " messages");
2792:                }
2793:            }
2794:
2795:            /**
2796:             * Verifies the number of bytes messages created with
2797:             * {@link MockQueueSession#createBytesMessage}.
2798:             * The session has to be created using the current {@link MockQueueConnection}.
2799:             * @param indexOfSession the index of the session
2800:             * @param number the expected number of bytes messages
2801:             * @throws VerifyFailedException if verification fails
2802:             */
2803:            public void verifyNumberOfCreatedQueueBytesMessages(
2804:                    int indexOfSession, int number) {
2805:                checkAndGetQueueSessionByIndex(indexOfSession);
2806:                if (number != getQueueMessageManager(indexOfSession)
2807:                        .getBytesMessageList().size()) {
2808:                    throw new VerifyFailedException("Expected "
2809:                            + number
2810:                            + " bytes messages, received "
2811:                            + getQueueMessageManager(indexOfSession)
2812:                                    .getBytesMessageList().size()
2813:                            + " bytes messages");
2814:                }
2815:            }
2816:
2817:            /**
2818:             * Verifies the number of map messages created with
2819:             * {@link MockQueueSession#createMapMessage}.
2820:             * The session has to be created using the current {@link MockQueueConnection}.
2821:             * @param indexOfSession the index of the session
2822:             * @param number the expected number of map messages
2823:             * @throws VerifyFailedException if verification fails
2824:             */
2825:            public void verifyNumberOfCreatedQueueMapMessages(
2826:                    int indexOfSession, int number) {
2827:                checkAndGetQueueSessionByIndex(indexOfSession);
2828:                if (number != getQueueMessageManager(indexOfSession)
2829:                        .getMapMessageList().size()) {
2830:                    throw new VerifyFailedException("Expected "
2831:                            + number
2832:                            + " map messages, received "
2833:                            + getQueueMessageManager(indexOfSession)
2834:                                    .getMapMessageList().size()
2835:                            + " map messages");
2836:                }
2837:            }
2838:
2839:            /**
2840:             * Verifies the number of text messages created with
2841:             * {@link MockQueueSession#createTextMessage}.
2842:             * The session has to be created using the current {@link MockQueueConnection}.
2843:             * @param indexOfSession the index of the session
2844:             * @param number the expected number of text messages
2845:             * @throws VerifyFailedException if verification fails
2846:             */
2847:            public void verifyNumberOfCreatedQueueTextMessages(
2848:                    int indexOfSession, int number) {
2849:                checkAndGetQueueSessionByIndex(indexOfSession);
2850:                if (number != getQueueMessageManager(indexOfSession)
2851:                        .getTextMessageList().size()) {
2852:                    throw new VerifyFailedException("Expected "
2853:                            + number
2854:                            + " text messages, received "
2855:                            + getQueueMessageManager(indexOfSession)
2856:                                    .getTextMessageList().size()
2857:                            + " text messages");
2858:                }
2859:            }
2860:
2861:            /**
2862:             * Verifies the number of stream messages created with
2863:             * {@link MockQueueSession#createStreamMessage}.
2864:             * The session has to be created using the current {@link MockQueueConnection}.
2865:             * @param indexOfSession the index of the session
2866:             * @param number the expected number of stream messages
2867:             * @throws VerifyFailedException if verification fails
2868:             */
2869:            public void verifyNumberOfCreatedQueueStreamMessages(
2870:                    int indexOfSession, int number) {
2871:                checkAndGetQueueSessionByIndex(indexOfSession);
2872:                if (number != getQueueMessageManager(indexOfSession)
2873:                        .getStreamMessageList().size()) {
2874:                    throw new VerifyFailedException("Expected "
2875:                            + number
2876:                            + " stream messages, received "
2877:                            + getQueueMessageManager(indexOfSession)
2878:                                    .getStreamMessageList().size()
2879:                            + " stream messages");
2880:                }
2881:            }
2882:
2883:            /**
2884:             * Verifies the number of object messages created with
2885:             * {@link MockQueueSession#createObjectMessage}.
2886:             * The session has to be created using the current {@link MockQueueConnection}.
2887:             * @param indexOfSession the index of the session
2888:             * @param number the expected number of object messages
2889:             * @throws VerifyFailedException if verification fails
2890:             */
2891:            public void verifyNumberOfCreatedQueueObjectMessages(
2892:                    int indexOfSession, int number) {
2893:                checkAndGetQueueSessionByIndex(indexOfSession);
2894:                if (number != getQueueMessageManager(indexOfSession)
2895:                        .getObjectMessageList().size()) {
2896:                    throw new VerifyFailedException("Expected "
2897:                            + number
2898:                            + " object messages, received "
2899:                            + getQueueMessageManager(indexOfSession)
2900:                                    .getObjectMessageList().size()
2901:                            + " object messages");
2902:                }
2903:            }
2904:
2905:            /**
2906:             * Verifies that a message created with {@link MockQueueSession#createMessage} 
2907:             * is acknowledged.
2908:             * This method makes sense if messages are not cloned
2909:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
2910:             * If messages are cloned, the cloned message is acknowledged instead of
2911:             * the created message.
2912:             * The session has to be created using the current {@link MockQueueConnection}.
2913:             * @param indexOfSession the index of the session
2914:             * @param indexOfMessage the index of the message
2915:             * @throws VerifyFailedException if verification fails
2916:             */
2917:            public void verifyCreatedQueueMessageAcknowledged(
2918:                    int indexOfSession, int indexOfMessage) {
2919:                checkAndGetQueueSessionByIndex(indexOfSession);
2920:                List messageList = getQueueMessageManager(indexOfSession)
2921:                        .getMessageList();
2922:                if (indexOfMessage >= messageList.size()) {
2923:                    throw new VerifyFailedException("Only "
2924:                            + messageList.size()
2925:                            + " messages created for session " + indexOfSession);
2926:                }
2927:                MockMessage message = (MockMessage) messageList
2928:                        .get(indexOfMessage);
2929:                if (!message.isAcknowledged()) {
2930:                    throw new VerifyFailedException("Message " + indexOfMessage
2931:                            + " of session " + indexOfSession
2932:                            + " is not acknowledged");
2933:                }
2934:            }
2935:
2936:            /**
2937:             * Verifies that a message created with {@link MockQueueSession#createMessage} 
2938:             * is not acknowledged.
2939:             * This method makes sense if messages are not cloned
2940:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
2941:             * If messages are cloned, the cloned message is acknowledged instead of
2942:             * the created message.
2943:             * The session has to be created using the current {@link MockQueueConnection}.
2944:             * @param indexOfSession the index of the session
2945:             * @param indexOfMessage the index of the message
2946:             * @throws VerifyFailedException if verification fails
2947:             */
2948:            public void verifyCreatedQueueMessageNotAcknowledged(
2949:                    int indexOfSession, int indexOfMessage) {
2950:                checkAndGetQueueSessionByIndex(indexOfSession);
2951:                List messageList = getQueueMessageManager(indexOfSession)
2952:                        .getMessageList();
2953:                if (indexOfMessage >= messageList.size()) {
2954:                    throw new VerifyFailedException("Only "
2955:                            + messageList.size()
2956:                            + " messages created for session " + indexOfSession);
2957:                }
2958:                MockMessage message = (MockMessage) messageList
2959:                        .get(indexOfMessage);
2960:                if (message.isAcknowledged()) {
2961:                    throw new VerifyFailedException("Message " + indexOfMessage
2962:                            + " of session " + indexOfSession
2963:                            + " is acknowledged");
2964:                }
2965:            }
2966:
2967:            /**
2968:             * Verifies that a bytes message created with {@link MockQueueSession#createMessage} 
2969:             * is acknowledged.
2970:             * This method makes sense if messages are not cloned
2971:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
2972:             * If messages are cloned, the cloned message is acknowledged instead of
2973:             * the created message.
2974:             * The session has to be created using the current {@link MockQueueConnection}.
2975:             * @param indexOfSession the index of the session
2976:             * @param indexOfMessage the index of the message
2977:             * @throws VerifyFailedException if verification fails
2978:             */
2979:            public void verifyCreatedQueueBytesMessageAcknowledged(
2980:                    int indexOfSession, int indexOfMessage) {
2981:                checkAndGetQueueSessionByIndex(indexOfSession);
2982:                List messageList = getQueueMessageManager(indexOfSession)
2983:                        .getBytesMessageList();
2984:                if (indexOfMessage >= messageList.size()) {
2985:                    throw new VerifyFailedException("Only "
2986:                            + messageList.size()
2987:                            + " bytes messages created for session "
2988:                            + indexOfSession);
2989:                }
2990:                MockMessage message = (MockMessage) messageList
2991:                        .get(indexOfMessage);
2992:                if (!message.isAcknowledged()) {
2993:                    throw new VerifyFailedException("Message " + indexOfMessage
2994:                            + " of session " + indexOfSession
2995:                            + " is not acknowledged");
2996:                }
2997:            }
2998:
2999:            /**
3000:             * Verifies that a bytes message created with {@link MockQueueSession#createMessage} 
3001:             * is not acknowledged.
3002:             * This method makes sense if messages are not cloned
3003:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3004:             * If messages are cloned, the cloned message is acknowledged instead of
3005:             * the created message.
3006:             * The session has to be created using the current {@link MockQueueConnection}.
3007:             * @param indexOfSession the index of the session
3008:             * @param indexOfMessage the index of the message
3009:             * @throws VerifyFailedException if verification fails
3010:             */
3011:            public void verifyCreatedQueueBytesMessageNotAcknowledged(
3012:                    int indexOfSession, int indexOfMessage) {
3013:                checkAndGetQueueSessionByIndex(indexOfSession);
3014:                List messageList = getQueueMessageManager(indexOfSession)
3015:                        .getBytesMessageList();
3016:                if (indexOfMessage >= messageList.size()) {
3017:                    throw new VerifyFailedException("Only "
3018:                            + messageList.size()
3019:                            + " bytes messages created for session "
3020:                            + indexOfSession);
3021:                }
3022:                MockMessage message = (MockMessage) messageList
3023:                        .get(indexOfMessage);
3024:                if (message.isAcknowledged()) {
3025:                    throw new VerifyFailedException("Message " + indexOfMessage
3026:                            + " of session " + indexOfSession
3027:                            + " is acknowledged");
3028:                }
3029:            }
3030:
3031:            /**
3032:             * Verifies that a map message created with {@link MockQueueSession#createMessage} 
3033:             * is acknowledged.
3034:             * This method makes sense if messages are not cloned
3035:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3036:             * If messages are cloned, the cloned message is acknowledged instead of
3037:             * the created message.
3038:             * The session has to be created using the current {@link MockQueueConnection}.
3039:             * @param indexOfSession the index of the session
3040:             * @param indexOfMessage the index of the message
3041:             * @throws VerifyFailedException if verification fails
3042:             */
3043:            public void verifyCreatedQueueMapMessageAcknowledged(
3044:                    int indexOfSession, int indexOfMessage) {
3045:                checkAndGetQueueSessionByIndex(indexOfSession);
3046:                List messageList = getQueueMessageManager(indexOfSession)
3047:                        .getMapMessageList();
3048:                if (indexOfMessage >= messageList.size()) {
3049:                    throw new VerifyFailedException("Only "
3050:                            + messageList.size()
3051:                            + " map messages created for session "
3052:                            + indexOfSession);
3053:                }
3054:                MockMessage message = (MockMessage) messageList
3055:                        .get(indexOfMessage);
3056:                if (!message.isAcknowledged()) {
3057:                    throw new VerifyFailedException("Message " + indexOfMessage
3058:                            + " of session " + indexOfSession
3059:                            + " is not acknowledged");
3060:                }
3061:            }
3062:
3063:            /**
3064:             * Verifies that a map message created with {@link MockQueueSession#createMessage} 
3065:             * is not acknowledged.
3066:             * This method makes sense if messages are not cloned
3067:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3068:             * If messages are cloned, the cloned message is acknowledged instead of
3069:             * the created message.
3070:             * The session has to be created using the current {@link MockQueueConnection}.
3071:             * @param indexOfSession the index of the session
3072:             * @param indexOfMessage the index of the message
3073:             * @throws VerifyFailedException if verification fails
3074:             */
3075:            public void verifyCreatedQueueMapMessageNotAcknowledged(
3076:                    int indexOfSession, int indexOfMessage) {
3077:                checkAndGetQueueSessionByIndex(indexOfSession);
3078:                List messageList = getQueueMessageManager(indexOfSession)
3079:                        .getMapMessageList();
3080:                if (indexOfMessage >= messageList.size()) {
3081:                    throw new VerifyFailedException("Only "
3082:                            + messageList.size()
3083:                            + " map messages created for session "
3084:                            + indexOfSession);
3085:                }
3086:                MockMessage message = (MockMessage) messageList
3087:                        .get(indexOfMessage);
3088:                if (message.isAcknowledged()) {
3089:                    throw new VerifyFailedException("Message " + indexOfMessage
3090:                            + " of session " + indexOfSession
3091:                            + " is acknowledged");
3092:                }
3093:            }
3094:
3095:            /**
3096:             * Verifies that a text message created with {@link MockQueueSession#createMessage} 
3097:             * is acknowledged.
3098:             * This method makes sense if messages are not cloned
3099:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3100:             * If messages are cloned, the cloned message is acknowledged instead of
3101:             * the created message.
3102:             * The session has to be created using the current {@link MockQueueConnection}.
3103:             * @param indexOfSession the index of the session
3104:             * @param indexOfMessage the index of the message
3105:             * @throws VerifyFailedException if verification fails
3106:             */
3107:            public void verifyCreatedQueueTextMessageAcknowledged(
3108:                    int indexOfSession, int indexOfMessage) {
3109:                checkAndGetQueueSessionByIndex(indexOfSession);
3110:                List messageList = getQueueMessageManager(indexOfSession)
3111:                        .getTextMessageList();
3112:                if (indexOfMessage >= messageList.size()) {
3113:                    throw new VerifyFailedException("Only "
3114:                            + messageList.size()
3115:                            + " text messages created for session "
3116:                            + indexOfSession);
3117:                }
3118:                MockMessage message = (MockMessage) messageList
3119:                        .get(indexOfMessage);
3120:                if (!message.isAcknowledged()) {
3121:                    throw new VerifyFailedException("Message " + indexOfMessage
3122:                            + " of session " + indexOfSession
3123:                            + " is not acknowledged");
3124:                }
3125:            }
3126:
3127:            /**
3128:             * Verifies that a text message created with {@link MockQueueSession#createMessage} 
3129:             * is not acknowledged.
3130:             * This method makes sense if messages are not cloned
3131:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3132:             * If messages are cloned, the cloned message is acknowledged instead of
3133:             * the created message.
3134:             * The session has to be created using the current {@link MockQueueConnection}.
3135:             * @param indexOfSession the index of the session
3136:             * @param indexOfMessage the index of the message
3137:             * @throws VerifyFailedException if verification fails
3138:             */
3139:            public void verifyCreatedQueueTextMessageNotAcknowledged(
3140:                    int indexOfSession, int indexOfMessage) {
3141:                checkAndGetQueueSessionByIndex(indexOfSession);
3142:                List messageList = getQueueMessageManager(indexOfSession)
3143:                        .getTextMessageList();
3144:                if (indexOfMessage >= messageList.size()) {
3145:                    throw new VerifyFailedException("Only "
3146:                            + messageList.size()
3147:                            + " text messages created for session "
3148:                            + indexOfSession);
3149:                }
3150:                MockMessage message = (MockMessage) messageList
3151:                        .get(indexOfMessage);
3152:                if (message.isAcknowledged()) {
3153:                    throw new VerifyFailedException("Message " + indexOfMessage
3154:                            + " of session " + indexOfSession
3155:                            + " is acknowledged");
3156:                }
3157:            }
3158:
3159:            /**
3160:             * Verifies that a stream message created with {@link MockQueueSession#createMessage} 
3161:             * is acknowledged.
3162:             * This method makes sense if messages are not cloned
3163:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3164:             * If messages are cloned, the cloned message is acknowledged instead of
3165:             * the created message.
3166:             * The session has to be created using the current {@link MockQueueConnection}.
3167:             * @param indexOfSession the index of the session
3168:             * @param indexOfMessage the index of the message
3169:             * @throws VerifyFailedException if verification fails
3170:             */
3171:            public void verifyCreatedQueueStreamMessageAcknowledged(
3172:                    int indexOfSession, int indexOfMessage) {
3173:                checkAndGetQueueSessionByIndex(indexOfSession);
3174:                List messageList = getQueueMessageManager(indexOfSession)
3175:                        .getStreamMessageList();
3176:                if (indexOfMessage >= messageList.size()) {
3177:                    throw new VerifyFailedException("Only "
3178:                            + messageList.size()
3179:                            + " stream messages created for session "
3180:                            + indexOfSession);
3181:                }
3182:                MockMessage message = (MockMessage) messageList
3183:                        .get(indexOfMessage);
3184:                if (!message.isAcknowledged()) {
3185:                    throw new VerifyFailedException("Message " + indexOfMessage
3186:                            + " of session " + indexOfSession
3187:                            + " is not acknowledged");
3188:                }
3189:            }
3190:
3191:            /**
3192:             * Verifies that a stream message created with {@link MockQueueSession#createMessage} 
3193:             * is not acknowledged.
3194:             * This method makes sense if messages are not cloned
3195:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3196:             * If messages are cloned, the cloned message is acknowledged instead of
3197:             * the created message.
3198:             * The session has to be created using the current {@link MockQueueConnection}.
3199:             * @param indexOfSession the index of the session
3200:             * @param indexOfMessage the index of the message
3201:             * @throws VerifyFailedException if verification fails
3202:             */
3203:            public void verifyCreatedQueueStreamMessageNotAcknowledged(
3204:                    int indexOfSession, int indexOfMessage) {
3205:                checkAndGetQueueSessionByIndex(indexOfSession);
3206:                List messageList = getQueueMessageManager(indexOfSession)
3207:                        .getStreamMessageList();
3208:                if (indexOfMessage >= messageList.size()) {
3209:                    throw new VerifyFailedException("Only "
3210:                            + messageList.size()
3211:                            + " stream messages created for session "
3212:                            + indexOfSession);
3213:                }
3214:                MockMessage message = (MockMessage) messageList
3215:                        .get(indexOfMessage);
3216:                if (message.isAcknowledged()) {
3217:                    throw new VerifyFailedException("Message " + indexOfMessage
3218:                            + " of session " + indexOfSession
3219:                            + " is acknowledged");
3220:                }
3221:            }
3222:
3223:            /**
3224:             * Verifies that a object message created with {@link MockQueueSession#createMessage} 
3225:             * is acknowledged.
3226:             * This method makes sense if messages are not cloned
3227:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3228:             * If messages are cloned, the cloned message is acknowledged instead of
3229:             * the created message.
3230:             * The session has to be created using the current {@link MockQueueConnection}.
3231:             * @param indexOfSession the index of the session
3232:             * @param indexOfMessage the index of the message
3233:             * @throws VerifyFailedException if verification fails
3234:             */
3235:            public void verifyCreatedQueueObjectMessageAcknowledged(
3236:                    int indexOfSession, int indexOfMessage) {
3237:                checkAndGetQueueSessionByIndex(indexOfSession);
3238:                List messageList = getQueueMessageManager(indexOfSession)
3239:                        .getObjectMessageList();
3240:                if (indexOfMessage >= messageList.size()) {
3241:                    throw new VerifyFailedException("Only "
3242:                            + messageList.size()
3243:                            + " object messages created for session "
3244:                            + indexOfSession);
3245:                }
3246:                MockMessage message = (MockMessage) messageList
3247:                        .get(indexOfMessage);
3248:                if (!message.isAcknowledged()) {
3249:                    throw new VerifyFailedException("Message " + indexOfMessage
3250:                            + " of session " + indexOfSession
3251:                            + " is not acknowledged");
3252:                }
3253:            }
3254:
3255:            /**
3256:             * Verifies that a object message created with {@link MockQueueSession#createMessage} 
3257:             * is not acknowledged.
3258:             * This method makes sense if messages are not cloned
3259:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3260:             * If messages are cloned, the cloned message is acknowledged instead of
3261:             * the created message.
3262:             * The session has to be created using the current {@link MockQueueConnection}.
3263:             * @param indexOfSession the index of the session
3264:             * @param indexOfMessage the index of the message
3265:             * @throws VerifyFailedException if verification fails
3266:             */
3267:            public void verifyCreatedQueueObjectMessageNotAcknowledged(
3268:                    int indexOfSession, int indexOfMessage) {
3269:                checkAndGetQueueSessionByIndex(indexOfSession);
3270:                List messageList = getQueueMessageManager(indexOfSession)
3271:                        .getObjectMessageList();
3272:                if (indexOfMessage >= messageList.size()) {
3273:                    throw new VerifyFailedException("Only "
3274:                            + messageList.size()
3275:                            + " object messages created for session "
3276:                            + indexOfSession);
3277:                }
3278:                MockMessage message = (MockMessage) messageList
3279:                        .get(indexOfMessage);
3280:                if (message.isAcknowledged()) {
3281:                    throw new VerifyFailedException("Message " + indexOfMessage
3282:                            + " of session " + indexOfSession
3283:                            + " is acknowledged");
3284:                }
3285:            }
3286:
3287:            /**
3288:             * Verifies that a message in the specified topic is equal to
3289:             * the specified message by calling the <code>equals()</code> method. 
3290:             * All mock messages provide a suitable implementation of <code>equals()</code>.
3291:             * @param nameOfTopic the name of the topic
3292:             * @param indexOfSourceMessage the index of the message in the topic
3293:             * @param targetMessage the message that will be used for comparison
3294:             * @throws VerifyFailedException if verification fails
3295:             */
3296:            public void verifyCurrentTopicMessageEquals(String nameOfTopic,
3297:                    int indexOfSourceMessage, MockMessage targetMessage) {
3298:                checkTopicByName(nameOfTopic);
3299:                List messageList = getCurrentMessageListFromTopic(nameOfTopic);
3300:                if (indexOfSourceMessage >= messageList.size()) {
3301:                    throw new VerifyFailedException("Topic " + nameOfTopic
3302:                            + " contains only " + messageList.size()
3303:                            + " messages");
3304:                }
3305:                MockMessage sourceMessage = (MockMessage) messageList
3306:                        .get(indexOfSourceMessage);
3307:                verifyMessageEquals(sourceMessage, targetMessage);
3308:            }
3309:
3310:            /**
3311:             * Verifies that a received message is equal to the specified message 
3312:             * by calling the <code>equals()</code> method. 
3313:             * All mock messages provide a suitable implementation of <code>equals()</code>.
3314:             * @param nameOfTopic the name of the topic
3315:             * @param indexOfSourceMessage the index of the received message
3316:             * @param targetMessage the message that will be used for comparison
3317:             * @throws VerifyFailedException if verification fails
3318:             */
3319:            public void verifyReceivedTopicMessageEquals(String nameOfTopic,
3320:                    int indexOfSourceMessage, MockMessage targetMessage) {
3321:                checkTopicByName(nameOfTopic);
3322:                List messageList = getReceivedMessageListFromTopic(nameOfTopic);
3323:                if (indexOfSourceMessage >= messageList.size()) {
3324:                    throw new VerifyFailedException("Topic " + nameOfTopic
3325:                            + " received only " + messageList.size()
3326:                            + " messages");
3327:                }
3328:                MockMessage sourceMessage = (MockMessage) messageList
3329:                        .get(indexOfSourceMessage);
3330:                verifyMessageEquals(sourceMessage, targetMessage);
3331:            }
3332:
3333:            /**
3334:             * Verifies that a message in the specified temporary topic is equal to
3335:             * the specified message by calling the <code>equals()</code> method. 
3336:             * All mock messages provide a suitable implementation of <code>equals()</code>.
3337:             * The session has to be created using the current {@link MockTopicConnection}.
3338:             * @param indexOfSession the index of the session
3339:             * @param indexOfTopic the index of the temporary topic
3340:             * @param indexOfSourceMessage the index of the message in the topic
3341:             * @param targetMessage the message that will be used for comparison
3342:             * @throws VerifyFailedException if verification fails
3343:             */
3344:            public void verifyCurrentTopicMessageEquals(int indexOfSession,
3345:                    int indexOfTopic, int indexOfSourceMessage,
3346:                    MockMessage targetMessage) {
3347:                checkAndGetTopicSessionByIndex(indexOfSession);
3348:                List messageList = getCurrentMessageListFromTemporaryTopic(
3349:                        indexOfSession, indexOfTopic);
3350:                if (null == messageList) {
3351:                    throw new VerifyFailedException(
3352:                            "Temporary topic with index " + indexOfTopic
3353:                                    + " of session with index "
3354:                                    + indexOfSession + " does not exist");
3355:                }
3356:                if (indexOfSourceMessage >= messageList.size()) {
3357:                    throw new VerifyFailedException(
3358:                            "Temporary topic with index " + indexOfTopic
3359:                                    + " contains only " + messageList.size()
3360:                                    + " messages");
3361:                }
3362:                MockMessage sourceMessage = (MockMessage) messageList
3363:                        .get(indexOfSourceMessage);
3364:                verifyMessageEquals(sourceMessage, targetMessage);
3365:            }
3366:
3367:            /**
3368:             * Verifies that a message received by a temporary topic is equal to the specified message 
3369:             * by calling the <code>equals()</code> method. 
3370:             * All mock messages provide a suitable implementation of <code>equals()</code>.
3371:             * The session has to be created using the current {@link MockTopicConnection}.
3372:             * @param indexOfSession the index of the session
3373:             * @param indexOfTopic the index of the temporary topic
3374:             * @param indexOfSourceMessage the index of the received message
3375:             * @param targetMessage the message that will be used for comparison
3376:             * @throws VerifyFailedException if verification fails
3377:             */
3378:            public void verifyReceivedTopicMessageEquals(int indexOfSession,
3379:                    int indexOfTopic, int indexOfSourceMessage,
3380:                    MockMessage targetMessage) {
3381:                checkAndGetTopicSessionByIndex(indexOfSession);
3382:                List messageList = getReceivedMessageListFromTemporaryTopic(
3383:                        indexOfSession, indexOfTopic);
3384:                if (null == messageList) {
3385:                    throw new VerifyFailedException(
3386:                            "Temporary topic with index " + indexOfTopic
3387:                                    + " of session with index "
3388:                                    + indexOfSession + " does not exist");
3389:                }
3390:                if (indexOfSourceMessage >= messageList.size()) {
3391:                    throw new VerifyFailedException(
3392:                            "Temporary topic with index " + indexOfTopic
3393:                                    + " received only " + messageList.size()
3394:                                    + " messages");
3395:                }
3396:                MockMessage sourceMessage = (MockMessage) messageList
3397:                        .get(indexOfSourceMessage);
3398:                verifyMessageEquals(sourceMessage, targetMessage);
3399:            }
3400:
3401:            /**
3402:             * Verifies the number of messages in a topic.
3403:             * @param nameOfTopic the name of the topic
3404:             * @param numberOfMessages the expected number of messages
3405:             * @throws VerifyFailedException if verification fails
3406:             */
3407:            public void verifyNumberOfCurrentTopicMessages(String nameOfTopic,
3408:                    int numberOfMessages) {
3409:                checkTopicByName(nameOfTopic);
3410:                List list = getCurrentMessageListFromTopic(nameOfTopic);
3411:                if (numberOfMessages != list.size()) {
3412:                    throw new VerifyFailedException("Expected "
3413:                            + numberOfMessages + " messages in topic "
3414:                            + nameOfTopic + ", received " + list.size()
3415:                            + " messages");
3416:                }
3417:            }
3418:
3419:            /**
3420:             * Verifies the number of messages received by a topic.
3421:             * @param nameOfTopic the name of the topic
3422:             * @param numberOfMessages the expected number of messages
3423:             * @throws VerifyFailedException if verification fails
3424:             */
3425:            public void verifyNumberOfReceivedTopicMessages(String nameOfTopic,
3426:                    int numberOfMessages) {
3427:                checkTopicByName(nameOfTopic);
3428:                List list = getReceivedMessageListFromTopic(nameOfTopic);
3429:                if (numberOfMessages != list.size()) {
3430:                    throw new VerifyFailedException("Expected "
3431:                            + numberOfMessages + " messages received by topic "
3432:                            + nameOfTopic + ", received " + list.size()
3433:                            + " messages");
3434:                }
3435:            }
3436:
3437:            /**
3438:             * Verifies the number of messages in a temporary topic.
3439:             * The session has to be created using the current {@link MockTopicConnection}.
3440:             * @param indexOfSession the index of the session
3441:             * @param indexOfTopic the index of the temporary topic
3442:             * @param numberOfMessages the expected number of messages
3443:             * @throws VerifyFailedException if verification fails
3444:             */
3445:            public void verifyNumberOfCurrentTopicMessages(int indexOfSession,
3446:                    int indexOfTopic, int numberOfMessages) {
3447:                checkAndGetTopicSessionByIndex(indexOfSession);
3448:                List list = getCurrentMessageListFromTemporaryTopic(
3449:                        indexOfSession, indexOfTopic);
3450:                if (null == list) {
3451:                    throw new VerifyFailedException(
3452:                            "Temporary topic with index " + indexOfTopic
3453:                                    + " of session with index "
3454:                                    + indexOfSession + " does not exist");
3455:                }
3456:                if (numberOfMessages != list.size()) {
3457:                    throw new VerifyFailedException("Expected "
3458:                            + numberOfMessages + " messages, received "
3459:                            + list.size() + " messages");
3460:                }
3461:            }
3462:
3463:            /**
3464:             * Verifies the number of messages received by a temporary topic.
3465:             * The session has to be created using the current {@link MockTopicConnection}.
3466:             * @param indexOfSession the index of the session
3467:             * @param indexOfTopic the index of the temporary topic
3468:             * @param numberOfMessages the expected number of messages
3469:             * @throws VerifyFailedException if verification fails
3470:             */
3471:            public void verifyNumberOfReceivedTopicMessages(int indexOfSession,
3472:                    int indexOfTopic, int numberOfMessages) {
3473:                checkAndGetTopicSessionByIndex(indexOfSession);
3474:                List list = getReceivedMessageListFromTemporaryTopic(
3475:                        indexOfSession, indexOfTopic);
3476:                if (null == list) {
3477:                    throw new VerifyFailedException(
3478:                            "Temporary topic with index " + indexOfTopic
3479:                                    + " of session with index "
3480:                                    + indexOfSession + " does not exist");
3481:                }
3482:                if (numberOfMessages != list.size()) {
3483:                    throw new VerifyFailedException("Expected "
3484:                            + numberOfMessages + " messages, received "
3485:                            + list.size() + " messages");
3486:                }
3487:            }
3488:
3489:            /**
3490:             * Verifies that all received messages of the specified topic 
3491:             * are acknowledged.
3492:             * @param nameOfTopic the name of the topic
3493:             * @throws VerifyFailedException if verification fails
3494:             */
3495:            public void verifyAllReceivedTopicMessagesAcknowledged(
3496:                    String nameOfTopic) {
3497:                checkTopicByName(nameOfTopic);
3498:                List messageList = getReceivedMessageListFromTopic(nameOfTopic);
3499:                for (int ii = 0; ii < messageList.size(); ii++) {
3500:                    MockMessage currentMessage = (MockMessage) messageList
3501:                            .get(ii);
3502:                    if (!currentMessage.isAcknowledged()) {
3503:                        throw new VerifyFailedException("Message " + ii
3504:                                + " of topic " + nameOfTopic
3505:                                + " is not acknowledged");
3506:                    }
3507:                }
3508:            }
3509:
3510:            /**
3511:             * Verifies that all received messages of the specified temporary topic 
3512:             * are acknowledged.
3513:             * The session has to be created using the current {@link MockTopicConnection}.
3514:             * @param indexOfSession the index of the session
3515:             * @param indexOfTopic the index of the temporary topic
3516:             * @throws VerifyFailedException if verification fails
3517:             */
3518:            public void verifyAllReceivedTopicMessagesAcknowledged(
3519:                    int indexOfSession, int indexOfTopic) {
3520:                checkAndGetTopicSessionByIndex(indexOfSession);
3521:                List messageList = getReceivedMessageListFromTemporaryTopic(
3522:                        indexOfSession, indexOfTopic);
3523:                if (null == messageList) {
3524:                    throw new VerifyFailedException(
3525:                            "Temporary topic with index " + indexOfTopic
3526:                                    + " of session with index "
3527:                                    + indexOfSession + " does not exist");
3528:                }
3529:                for (int ii = 0; ii < messageList.size(); ii++) {
3530:                    MockMessage currentMessage = (MockMessage) messageList
3531:                            .get(ii);
3532:                    if (!currentMessage.isAcknowledged()) {
3533:                        throw new VerifyFailedException("Message " + ii
3534:                                + " of temporary topic " + indexOfTopic
3535:                                + " is not acknowledged");
3536:                    }
3537:                }
3538:            }
3539:
3540:            /**
3541:             * Verifies that a received message is acknowledged.
3542:             * @param nameOfTopic the name of the topic
3543:             * @param indexOfMessage the index of the received message
3544:             * @throws VerifyFailedException if verification fails
3545:             */
3546:            public void verifyReceivedTopicMessageAcknowledged(
3547:                    String nameOfTopic, int indexOfMessage) {
3548:                checkTopicByName(nameOfTopic);
3549:                List messageList = getReceivedMessageListFromTopic(nameOfTopic);
3550:                if (indexOfMessage >= messageList.size()) {
3551:                    throw new VerifyFailedException("Topic " + nameOfTopic
3552:                            + " received only " + messageList.size()
3553:                            + " messages");
3554:                }
3555:                MockMessage message = (MockMessage) messageList
3556:                        .get(indexOfMessage);
3557:                if (!message.isAcknowledged()) {
3558:                    throw new VerifyFailedException("Message " + indexOfMessage
3559:                            + " of topic " + nameOfTopic
3560:                            + " is not acknowledged");
3561:                }
3562:            }
3563:
3564:            /**
3565:             * Verifies that a received message is not acknowledged. 
3566:             * @param nameOfTopic the name of the topic
3567:             * @param indexOfMessage the index of the received message
3568:             * @throws VerifyFailedException if verification fails
3569:             */
3570:            public void verifyReceivedTopicMessageNotAcknowledged(
3571:                    String nameOfTopic, int indexOfMessage) {
3572:                checkTopicByName(nameOfTopic);
3573:                List messageList = getReceivedMessageListFromTopic(nameOfTopic);
3574:                if (indexOfMessage >= messageList.size()) {
3575:                    throw new VerifyFailedException("Topic " + nameOfTopic
3576:                            + " received only " + messageList.size()
3577:                            + " messages");
3578:                }
3579:                MockMessage message = (MockMessage) messageList
3580:                        .get(indexOfMessage);
3581:                if (message.isAcknowledged()) {
3582:                    throw new VerifyFailedException("Message " + indexOfMessage
3583:                            + " of topic " + nameOfTopic + " is acknowledged");
3584:                }
3585:            }
3586:
3587:            /**
3588:             * Verifies that a message received by a temporary topic is acknowledged.
3589:             * The session has to be created using the current {@link MockTopicConnection}.
3590:             * @param indexOfSession the index of the session
3591:             * @param indexOfTopic the index of the temporary topic
3592:             * @param indexOfMessage the index of the received message
3593:             * @throws VerifyFailedException if verification fails
3594:             */
3595:            public void verifyReceivedTopicMessageAcknowledged(
3596:                    int indexOfSession, int indexOfTopic, int indexOfMessage) {
3597:                checkAndGetTopicSessionByIndex(indexOfSession);
3598:                List messageList = getReceivedMessageListFromTemporaryTopic(
3599:                        indexOfSession, indexOfTopic);
3600:                if (null == messageList) {
3601:                    throw new VerifyFailedException(
3602:                            "Temporary topic with index " + indexOfTopic
3603:                                    + " of session with index "
3604:                                    + indexOfSession + " does not exist");
3605:                }
3606:                if (indexOfMessage >= messageList.size()) {
3607:                    throw new VerifyFailedException(
3608:                            "Temporary topic with index " + indexOfTopic
3609:                                    + " received only " + messageList.size()
3610:                                    + " messages");
3611:                }
3612:                MockMessage message = (MockMessage) messageList
3613:                        .get(indexOfMessage);
3614:                if (!message.isAcknowledged()) {
3615:                    throw new VerifyFailedException("Message " + indexOfMessage
3616:                            + " of temporary topic " + indexOfTopic
3617:                            + " is not acknowledged");
3618:                }
3619:            }
3620:
3621:            /**
3622:             * Verifies that a message received by a temporary topic is not acknowledged.
3623:             * The session has to be created using the current {@link MockTopicConnection}.
3624:             * @param indexOfSession the index of the session
3625:             * @param indexOfTopic the index of the temporary topic
3626:             * @param indexOfMessage the index of the received message
3627:             * @throws VerifyFailedException if verification fails
3628:             */
3629:            public void verifyReceivedTopicMessageNotAcknowledged(
3630:                    int indexOfSession, int indexOfTopic, int indexOfMessage) {
3631:                checkAndGetTopicSessionByIndex(indexOfSession);
3632:                List messageList = getReceivedMessageListFromTemporaryTopic(
3633:                        indexOfSession, indexOfTopic);
3634:                if (null == messageList) {
3635:                    throw new VerifyFailedException(
3636:                            "Temporary topic with index " + indexOfTopic
3637:                                    + " of session with index "
3638:                                    + indexOfSession + " does not exist");
3639:                }
3640:                if (indexOfMessage >= messageList.size()) {
3641:                    throw new VerifyFailedException(
3642:                            "Temporary topic with index " + indexOfTopic
3643:                                    + " received only " + messageList.size()
3644:                                    + " messages");
3645:                }
3646:                MockMessage message = (MockMessage) messageList
3647:                        .get(indexOfMessage);
3648:                if (message.isAcknowledged()) {
3649:                    throw new VerifyFailedException("Message " + indexOfMessage
3650:                            + " of temporary topic " + indexOfTopic
3651:                            + " is acknowledged");
3652:                }
3653:            }
3654:
3655:            /**
3656:             * Verifies the number of messages created with 
3657:             * {@link MockTopicSession#createMessage}.
3658:             * The session has to be created using the current {@link MockTopicConnection}.
3659:             * @param indexOfSession the index of the session
3660:             * @param number the expected number of messages
3661:             * @throws VerifyFailedException if verification fails
3662:             */
3663:            public void verifyNumberOfCreatedTopicMessages(int indexOfSession,
3664:                    int number) {
3665:                checkAndGetTopicSessionByIndex(indexOfSession);
3666:                if (number != getTopicMessageManager(indexOfSession)
3667:                        .getMessageList().size()) {
3668:                    throw new VerifyFailedException("Expected "
3669:                            + number
3670:                            + " messages, received "
3671:                            + getTopicMessageManager(indexOfSession)
3672:                                    .getMessageList().size() + " messages");
3673:                }
3674:            }
3675:
3676:            /**
3677:             * Verifies the number of bytes messages created with
3678:             * {@link MockTopicSession#createBytesMessage}.
3679:             * The session has to be created using the current {@link MockTopicConnection}.
3680:             * @param indexOfSession the index of the session
3681:             * @param number the expected number of bytes messages
3682:             * @throws VerifyFailedException if verification fails
3683:             */
3684:            public void verifyNumberOfCreatedTopicBytesMessages(
3685:                    int indexOfSession, int number) {
3686:                checkAndGetTopicSessionByIndex(indexOfSession);
3687:                if (number != getTopicMessageManager(indexOfSession)
3688:                        .getBytesMessageList().size()) {
3689:                    throw new VerifyFailedException("Expected "
3690:                            + number
3691:                            + " bytes messages, received "
3692:                            + getTopicMessageManager(indexOfSession)
3693:                                    .getBytesMessageList().size()
3694:                            + " bytes messages");
3695:                }
3696:            }
3697:
3698:            /**
3699:             * Verifies the number of map messages created with
3700:             * {@link MockTopicSession#createMapMessage}.
3701:             * The session has to be created using the current {@link MockTopicConnection}.
3702:             * @param indexOfSession the index of the session
3703:             * @param number the expected number of map messages
3704:             * @throws VerifyFailedException if verification fails
3705:             */
3706:            public void verifyNumberOfCreatedTopicMapMessages(
3707:                    int indexOfSession, int number) {
3708:                checkAndGetTopicSessionByIndex(indexOfSession);
3709:                if (number != getTopicMessageManager(indexOfSession)
3710:                        .getMapMessageList().size()) {
3711:                    throw new VerifyFailedException("Expected "
3712:                            + number
3713:                            + " map messages, received "
3714:                            + getTopicMessageManager(indexOfSession)
3715:                                    .getMapMessageList().size()
3716:                            + " map messages");
3717:                }
3718:            }
3719:
3720:            /**
3721:             * Verifies the number of text messages created with
3722:             * {@link MockTopicSession#createTextMessage}.
3723:             * The session has to be created using the current {@link MockTopicConnection}.
3724:             * @param indexOfSession the index of the session
3725:             * @param number the expected number of text messages
3726:             * @throws VerifyFailedException if verification fails
3727:             */
3728:            public void verifyNumberOfCreatedTopicTextMessages(
3729:                    int indexOfSession, int number) {
3730:                checkAndGetTopicSessionByIndex(indexOfSession);
3731:                if (number != getTopicMessageManager(indexOfSession)
3732:                        .getTextMessageList().size()) {
3733:                    throw new VerifyFailedException("Expected "
3734:                            + number
3735:                            + " text messages, received "
3736:                            + getTopicMessageManager(indexOfSession)
3737:                                    .getTextMessageList().size()
3738:                            + " text messages");
3739:                }
3740:            }
3741:
3742:            /**
3743:             * Verifies the number of stream messages created with
3744:             * {@link MockTopicSession#createStreamMessage}.
3745:             * The session has to be created using the current {@link MockTopicConnection}.
3746:             * @param indexOfSession the index of the session
3747:             * @param number the expected number of stream messages
3748:             * @throws VerifyFailedException if verification fails
3749:             */
3750:            public void verifyNumberOfCreatedTopicStreamMessages(
3751:                    int indexOfSession, int number) {
3752:                checkAndGetTopicSessionByIndex(indexOfSession);
3753:                if (number != getTopicMessageManager(indexOfSession)
3754:                        .getStreamMessageList().size()) {
3755:                    throw new VerifyFailedException("Expected "
3756:                            + number
3757:                            + " stream messages, received "
3758:                            + getTopicMessageManager(indexOfSession)
3759:                                    .getStreamMessageList().size()
3760:                            + " stream messages");
3761:                }
3762:            }
3763:
3764:            /**
3765:             * Verifies the number of object messages created with
3766:             * {@link MockTopicSession#createObjectMessage}.
3767:             * The session has to be created using the current {@link MockTopicConnection}.
3768:             * @param indexOfSession the index of the session
3769:             * @param number the expected number of object messages
3770:             * @throws VerifyFailedException if verification fails
3771:             */
3772:            public void verifyNumberOfCreatedTopicObjectMessages(
3773:                    int indexOfSession, int number) {
3774:                checkAndGetTopicSessionByIndex(indexOfSession);
3775:                if (number != getTopicMessageManager(indexOfSession)
3776:                        .getObjectMessageList().size()) {
3777:                    throw new VerifyFailedException("Expected "
3778:                            + number
3779:                            + " object messages, received "
3780:                            + getTopicMessageManager(indexOfSession)
3781:                                    .getObjectMessageList().size()
3782:                            + " object messages");
3783:                }
3784:            }
3785:
3786:            /**
3787:             * Verifies that a message created with {@link MockTopicSession#createMessage} 
3788:             * is acknowledged. This method makes sense if messages are not cloned
3789:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3790:             * If messages are cloned, the cloned message is acknowledged instead of
3791:             * the created message.
3792:             * The session has to be created using the current {@link MockTopicConnection}.
3793:             * @param indexOfSession the index of the session
3794:             * @param indexOfMessage the index of the message
3795:             * @throws VerifyFailedException if verification fails
3796:             */
3797:            public void verifyCreatedTopicMessageAcknowledged(
3798:                    int indexOfSession, int indexOfMessage) {
3799:                checkAndGetTopicSessionByIndex(indexOfSession);
3800:                List messageList = getTopicMessageManager(indexOfSession)
3801:                        .getMessageList();
3802:                if (indexOfMessage >= messageList.size()) {
3803:                    throw new VerifyFailedException("Only "
3804:                            + messageList.size()
3805:                            + " messages created for session " + indexOfSession);
3806:                }
3807:                MockMessage message = (MockMessage) messageList
3808:                        .get(indexOfMessage);
3809:                if (!message.isAcknowledged()) {
3810:                    throw new VerifyFailedException("Message " + indexOfMessage
3811:                            + " of session " + indexOfSession
3812:                            + " is not acknowledged");
3813:                }
3814:            }
3815:
3816:            /**
3817:             * Verifies that a message created with {@link MockTopicSession#createMessage} 
3818:             * is not acknowledged. This method makes sense if messages are not cloned
3819:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3820:             * If messages are cloned, the cloned message is acknowledged instead of
3821:             * the created message.
3822:             * The session has to be created using the current {@link MockTopicConnection}.
3823:             * @param indexOfSession the index of the session
3824:             * @param indexOfMessage the index of the message
3825:             * @throws VerifyFailedException if verification fails
3826:             */
3827:            public void verifyCreatedTopicMessageNotAcknowledged(
3828:                    int indexOfSession, int indexOfMessage) {
3829:                checkAndGetTopicSessionByIndex(indexOfSession);
3830:                List messageList = getTopicMessageManager(indexOfSession)
3831:                        .getMessageList();
3832:                if (indexOfMessage >= messageList.size()) {
3833:                    throw new VerifyFailedException("Only "
3834:                            + messageList.size()
3835:                            + " messages created for session " + indexOfSession);
3836:                }
3837:                MockMessage message = (MockMessage) messageList
3838:                        .get(indexOfMessage);
3839:                if (message.isAcknowledged()) {
3840:                    throw new VerifyFailedException("Message " + indexOfMessage
3841:                            + " of session " + indexOfSession
3842:                            + " is acknowledged");
3843:                }
3844:            }
3845:
3846:            /**
3847:             * Verifies that a bytes message created with {@link MockTopicSession#createMessage} 
3848:             * is acknowledged. This method makes sense if messages are not cloned
3849:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3850:             * If messages are cloned, the cloned message is acknowledged instead of
3851:             * the created message.
3852:             * The session has to be created using the current {@link MockTopicConnection}.
3853:             * @param indexOfSession the index of the session
3854:             * @param indexOfMessage the index of the message
3855:             * @throws VerifyFailedException if verification fails
3856:             */
3857:            public void verifyCreatedTopicBytesMessageAcknowledged(
3858:                    int indexOfSession, int indexOfMessage) {
3859:                checkAndGetTopicSessionByIndex(indexOfSession);
3860:                List messageList = getTopicMessageManager(indexOfSession)
3861:                        .getBytesMessageList();
3862:                if (indexOfMessage >= messageList.size()) {
3863:                    throw new VerifyFailedException("Only "
3864:                            + messageList.size()
3865:                            + " bytes messages created for session "
3866:                            + indexOfSession);
3867:                }
3868:                MockMessage message = (MockMessage) messageList
3869:                        .get(indexOfMessage);
3870:                if (!message.isAcknowledged()) {
3871:                    throw new VerifyFailedException("Message " + indexOfMessage
3872:                            + " of session " + indexOfSession
3873:                            + " is not acknowledged");
3874:                }
3875:            }
3876:
3877:            /**
3878:             * Verifies that a bytes message created with {@link MockTopicSession#createMessage} 
3879:             * is not acknowledged. This method makes sense if messages are not cloned
3880:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3881:             * If messages are cloned, the cloned message is acknowledged instead of
3882:             * the created message.
3883:             * The session has to be created using the current {@link MockTopicConnection}.
3884:             * @param indexOfSession the index of the session
3885:             * @param indexOfMessage the index of the message
3886:             * @throws VerifyFailedException if verification fails
3887:             */
3888:            public void verifyCreatedTopicBytesMessageNotAcknowledged(
3889:                    int indexOfSession, int indexOfMessage) {
3890:                checkAndGetTopicSessionByIndex(indexOfSession);
3891:                List messageList = getTopicMessageManager(indexOfSession)
3892:                        .getBytesMessageList();
3893:                if (indexOfMessage >= messageList.size()) {
3894:                    throw new VerifyFailedException("Only "
3895:                            + messageList.size()
3896:                            + " bytes messages created for session "
3897:                            + indexOfSession);
3898:                }
3899:                MockMessage message = (MockMessage) messageList
3900:                        .get(indexOfMessage);
3901:                if (message.isAcknowledged()) {
3902:                    throw new VerifyFailedException("Message " + indexOfMessage
3903:                            + " of session " + indexOfSession
3904:                            + " is acknowledged");
3905:                }
3906:            }
3907:
3908:            /**
3909:             * Verifies that a map message created with {@link MockTopicSession#createMessage} 
3910:             * is acknowledged. This method makes sense if messages are not cloned
3911:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3912:             * If messages are cloned, the cloned message is acknowledged instead of
3913:             * the created message.
3914:             * The session has to be created using the current {@link MockTopicConnection}.
3915:             * @param indexOfSession the index of the session
3916:             * @param indexOfMessage the index of the message
3917:             * @throws VerifyFailedException if verification fails
3918:             */
3919:            public void verifyCreatedTopicMapMessageAcknowledged(
3920:                    int indexOfSession, int indexOfMessage) {
3921:                checkAndGetTopicSessionByIndex(indexOfSession);
3922:                List messageList = getTopicMessageManager(indexOfSession)
3923:                        .getMapMessageList();
3924:                if (indexOfMessage >= messageList.size()) {
3925:                    throw new VerifyFailedException("Only "
3926:                            + messageList.size()
3927:                            + " map messages created for session "
3928:                            + indexOfSession);
3929:                }
3930:                MockMessage message = (MockMessage) messageList
3931:                        .get(indexOfMessage);
3932:                if (!message.isAcknowledged()) {
3933:                    throw new VerifyFailedException("Message " + indexOfMessage
3934:                            + " of session " + indexOfSession
3935:                            + " is not acknowledged");
3936:                }
3937:            }
3938:
3939:            /**
3940:             * Verifies that a map message created with {@link MockTopicSession#createMessage} 
3941:             * is not acknowledged. This method makes sense if messages are not cloned
3942:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3943:             * If messages are cloned, the cloned message is acknowledged instead of
3944:             * the created message.
3945:             * The session has to be created using the current {@link MockTopicConnection}.
3946:             * @param indexOfSession the index of the session
3947:             * @param indexOfMessage the index of the message
3948:             * @throws VerifyFailedException if verification fails
3949:             */
3950:            public void verifyCreatedTopicMapMessageNotAcknowledged(
3951:                    int indexOfSession, int indexOfMessage) {
3952:                checkAndGetTopicSessionByIndex(indexOfSession);
3953:                List messageList = getTopicMessageManager(indexOfSession)
3954:                        .getMapMessageList();
3955:                if (indexOfMessage >= messageList.size()) {
3956:                    throw new VerifyFailedException("Only "
3957:                            + messageList.size()
3958:                            + " map messages created for session "
3959:                            + indexOfSession);
3960:                }
3961:                MockMessage message = (MockMessage) messageList
3962:                        .get(indexOfMessage);
3963:                if (message.isAcknowledged()) {
3964:                    throw new VerifyFailedException("Message " + indexOfMessage
3965:                            + " of session " + indexOfSession
3966:                            + " is acknowledged");
3967:                }
3968:            }
3969:
3970:            /**
3971:             * Verifies that a text message created with {@link MockTopicSession#createMessage} 
3972:             * is acknowledged. This method makes sense if messages are not cloned
3973:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
3974:             * If messages are cloned, the cloned message is acknowledged instead of
3975:             * the created message.
3976:             * The session has to be created using the current {@link MockTopicConnection}.
3977:             * @param indexOfSession the index of the session
3978:             * @param indexOfMessage the index of the message
3979:             * @throws VerifyFailedException if verification fails
3980:             */
3981:            public void verifyCreatedTopicTextMessageAcknowledged(
3982:                    int indexOfSession, int indexOfMessage) {
3983:                checkAndGetTopicSessionByIndex(indexOfSession);
3984:                List messageList = getTopicMessageManager(indexOfSession)
3985:                        .getTextMessageList();
3986:                if (indexOfMessage >= messageList.size()) {
3987:                    throw new VerifyFailedException("Only "
3988:                            + messageList.size()
3989:                            + " text messages created for session "
3990:                            + indexOfSession);
3991:                }
3992:                MockMessage message = (MockMessage) messageList
3993:                        .get(indexOfMessage);
3994:                if (!message.isAcknowledged()) {
3995:                    throw new VerifyFailedException("Message " + indexOfMessage
3996:                            + " of session " + indexOfSession
3997:                            + " is not acknowledged");
3998:                }
3999:            }
4000:
4001:            /**
4002:             * Verifies that a text message created with {@link MockTopicSession#createMessage} 
4003:             * is not acknowledged. This method makes sense if messages are not cloned
4004:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
4005:             * If messages are cloned, the cloned message is acknowledged instead of
4006:             * the created message.
4007:             * The session has to be created using the current {@link MockTopicConnection}.
4008:             * @param indexOfSession the index of the session
4009:             * @param indexOfMessage the index of the message
4010:             * @throws VerifyFailedException if verification fails
4011:             */
4012:            public void verifyCreatedTopicTextMessageNotAcknowledged(
4013:                    int indexOfSession, int indexOfMessage) {
4014:                checkAndGetTopicSessionByIndex(indexOfSession);
4015:                List messageList = getTopicMessageManager(indexOfSession)
4016:                        .getTextMessageList();
4017:                if (indexOfMessage >= messageList.size()) {
4018:                    throw new VerifyFailedException("Only "
4019:                            + messageList.size()
4020:                            + " text messages created for session "
4021:                            + indexOfSession);
4022:                }
4023:                MockMessage message = (MockMessage) messageList
4024:                        .get(indexOfMessage);
4025:                if (message.isAcknowledged()) {
4026:                    throw new VerifyFailedException("Message " + indexOfMessage
4027:                            + " of session " + indexOfSession
4028:                            + " is acknowledged");
4029:                }
4030:            }
4031:
4032:            /**
4033:             * Verifies that a stream message created with {@link MockTopicSession#createMessage} 
4034:             * is acknowledged. This method makes sense if messages are not cloned
4035:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
4036:             * If messages are cloned, the cloned message is acknowledged instead of
4037:             * the created message.
4038:             * The session has to be created using the current {@link MockTopicConnection}.
4039:             * @param indexOfSession the index of the session
4040:             * @param indexOfMessage the index of the message
4041:             * @throws VerifyFailedException if verification fails
4042:             */
4043:            public void verifyCreatedTopicStreamMessageAcknowledged(
4044:                    int indexOfSession, int indexOfMessage) {
4045:                checkAndGetTopicSessionByIndex(indexOfSession);
4046:                List messageList = getTopicMessageManager(indexOfSession)
4047:                        .getStreamMessageList();
4048:                if (indexOfMessage >= messageList.size()) {
4049:                    throw new VerifyFailedException("Only "
4050:                            + messageList.size()
4051:                            + " stream messages created for session "
4052:                            + indexOfSession);
4053:                }
4054:                MockMessage message = (MockMessage) messageList
4055:                        .get(indexOfMessage);
4056:                if (!message.isAcknowledged()) {
4057:                    throw new VerifyFailedException("Message " + indexOfMessage
4058:                            + " of session " + indexOfSession
4059:                            + " is not acknowledged");
4060:                }
4061:            }
4062:
4063:            /**
4064:             * Verifies that a stream message created with {@link MockTopicSession#createMessage} 
4065:             * is not acknowledged. This method makes sense if messages are not cloned
4066:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
4067:             * If messages are cloned, the cloned message is acknowledged instead of
4068:             * the created message.
4069:             * The session has to be created using the current {@link MockTopicConnection}.
4070:             * @param indexOfSession the index of the session
4071:             * @param indexOfMessage the index of the message
4072:             * @throws VerifyFailedException if verification fails
4073:             */
4074:            public void verifyCreatedTopicStreamMessageNotAcknowledged(
4075:                    int indexOfSession, int indexOfMessage) {
4076:                checkAndGetTopicSessionByIndex(indexOfSession);
4077:                List messageList = getTopicMessageManager(indexOfSession)
4078:                        .getStreamMessageList();
4079:                if (indexOfMessage >= messageList.size()) {
4080:                    throw new VerifyFailedException("Only "
4081:                            + messageList.size()
4082:                            + " stream messages created for session "
4083:                            + indexOfSession);
4084:                }
4085:                MockMessage message = (MockMessage) messageList
4086:                        .get(indexOfMessage);
4087:                if (message.isAcknowledged()) {
4088:                    throw new VerifyFailedException("Message " + indexOfMessage
4089:                            + " of session " + indexOfSession
4090:                            + " is acknowledged");
4091:                }
4092:            }
4093:
4094:            /**
4095:             * Verifies that a object message created with {@link MockTopicSession#createMessage} 
4096:             * is acknowledged. This method makes sense if messages are not cloned
4097:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
4098:             * If messages are cloned, the cloned message is acknowledged instead of
4099:             * the created message.
4100:             * The session has to be created using the current {@link MockTopicConnection}.
4101:             * @param indexOfSession the index of the session
4102:             * @param indexOfMessage the index of the message
4103:             * @throws VerifyFailedException if verification fails
4104:             */
4105:            public void verifyCreatedTopicObjectMessageAcknowledged(
4106:                    int indexOfSession, int indexOfMessage) {
4107:                checkAndGetTopicSessionByIndex(indexOfSession);
4108:                List messageList = getTopicMessageManager(indexOfSession)
4109:                        .getObjectMessageList();
4110:                if (indexOfMessage >= messageList.size()) {
4111:                    throw new VerifyFailedException("Only "
4112:                            + messageList.size()
4113:                            + " object messages created for session "
4114:                            + indexOfSession);
4115:                }
4116:                MockMessage message = (MockMessage) messageList
4117:                        .get(indexOfMessage);
4118:                if (!message.isAcknowledged()) {
4119:                    throw new VerifyFailedException("Message " + indexOfMessage
4120:                            + " of session " + indexOfSession
4121:                            + " is not acknowledged");
4122:                }
4123:            }
4124:
4125:            /**
4126:             * Verifies that a object message created with {@link MockTopicSession#createMessage} 
4127:             * is not acknowledged. This method makes sense if messages are not cloned
4128:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
4129:             * If messages are cloned, the cloned message is acknowledged instead of
4130:             * the created message.
4131:             * The session has to be created using the current {@link MockTopicConnection}.
4132:             * @param indexOfSession the index of the session
4133:             * @param indexOfMessage the index of the message
4134:             * @throws VerifyFailedException if verification fails
4135:             */
4136:            public void verifyCreatedTopicObjectMessageNotAcknowledged(
4137:                    int indexOfSession, int indexOfMessage) {
4138:                checkAndGetTopicSessionByIndex(indexOfSession);
4139:                List messageList = getTopicMessageManager(indexOfSession)
4140:                        .getObjectMessageList();
4141:                if (indexOfMessage >= messageList.size()) {
4142:                    throw new VerifyFailedException("Only "
4143:                            + messageList.size()
4144:                            + " object messages created for session "
4145:                            + indexOfSession);
4146:                }
4147:                MockMessage message = (MockMessage) messageList
4148:                        .get(indexOfMessage);
4149:                if (message.isAcknowledged()) {
4150:                    throw new VerifyFailedException("Message " + indexOfMessage
4151:                            + " of session " + indexOfSession
4152:                            + " is acknowledged");
4153:                }
4154:            }
4155:
4156:            /**
4157:             * Verifies the number of messages created with
4158:             * {@link MockSession#createMessage}.
4159:             * The session has to be created using the current {@link MockConnection}.
4160:             * @param indexOfSession the index of the session
4161:             * @param number the expected number of messages
4162:             * @throws VerifyFailedException if verification fails
4163:             */
4164:            public void verifyNumberOfCreatedMessages(int indexOfSession,
4165:                    int number) {
4166:                checkAndGetSessionByIndex(indexOfSession);
4167:                if (number != getMessageManager(indexOfSession)
4168:                        .getMessageList().size()) {
4169:                    throw new VerifyFailedException("Expected "
4170:                            + number
4171:                            + " messages, received "
4172:                            + getMessageManager(indexOfSession)
4173:                                    .getMessageList().size() + " messages");
4174:                }
4175:            }
4176:
4177:            /**
4178:             * Verifies the number of bytes messages created with
4179:             * {@link MockSession#createBytesMessage}.
4180:             * The session has to be created using the current {@link MockConnection}.
4181:             * @param indexOfSession the index of the session
4182:             * @param number the expected number of bytes messages
4183:             * @throws VerifyFailedException if verification fails
4184:             */
4185:            public void verifyNumberOfCreatedBytesMessages(int indexOfSession,
4186:                    int number) {
4187:                checkAndGetSessionByIndex(indexOfSession);
4188:                if (number != getMessageManager(indexOfSession)
4189:                        .getBytesMessageList().size()) {
4190:                    throw new VerifyFailedException("Expected "
4191:                            + number
4192:                            + " bytes messages, received "
4193:                            + getMessageManager(indexOfSession)
4194:                                    .getBytesMessageList().size()
4195:                            + " bytes messages");
4196:                }
4197:            }
4198:
4199:            /**
4200:             * Verifies the number of map messages created with
4201:             * {@link MockSession#createMapMessage}.
4202:             * The session has to be created using the current {@link MockConnection}.
4203:             * @param indexOfSession the index of the session
4204:             * @param number the expected number of map messages
4205:             * @throws VerifyFailedException if verification fails
4206:             */
4207:            public void verifyNumberOfCreatedMapMessages(int indexOfSession,
4208:                    int number) {
4209:                checkAndGetSessionByIndex(indexOfSession);
4210:                if (number != getMessageManager(indexOfSession)
4211:                        .getMapMessageList().size()) {
4212:                    throw new VerifyFailedException("Expected "
4213:                            + number
4214:                            + " map messages, received "
4215:                            + getMessageManager(indexOfSession)
4216:                                    .getMapMessageList().size()
4217:                            + " map messages");
4218:                }
4219:            }
4220:
4221:            /**
4222:             * Verifies the number of text messages created with
4223:             * {@link MockSession#createTextMessage}.
4224:             * The session has to be created using the current {@link MockConnection}.
4225:             * @param indexOfSession the index of the session
4226:             * @param number the expected number of text messages
4227:             * @throws VerifyFailedException if verification fails
4228:             */
4229:            public void verifyNumberOfCreatedTextMessages(int indexOfSession,
4230:                    int number) {
4231:                checkAndGetSessionByIndex(indexOfSession);
4232:                if (number != getMessageManager(indexOfSession)
4233:                        .getTextMessageList().size()) {
4234:                    throw new VerifyFailedException("Expected "
4235:                            + number
4236:                            + " text messages, received "
4237:                            + getMessageManager(indexOfSession)
4238:                                    .getTextMessageList().size()
4239:                            + " text messages");
4240:                }
4241:            }
4242:
4243:            /**
4244:             * Verifies the number of stream messages created with
4245:             * {@link MockSession#createStreamMessage}.
4246:             * The session has to be created using the current {@link MockConnection}.
4247:             * @param indexOfSession the index of the session
4248:             * @param number the expected number of stream messages
4249:             * @throws VerifyFailedException if verification fails
4250:             */
4251:            public void verifyNumberOfCreatedStreamMessages(int indexOfSession,
4252:                    int number) {
4253:                checkAndGetSessionByIndex(indexOfSession);
4254:                if (number != getMessageManager(indexOfSession)
4255:                        .getStreamMessageList().size()) {
4256:                    throw new VerifyFailedException("Expected "
4257:                            + number
4258:                            + " stream messages, received "
4259:                            + getMessageManager(indexOfSession)
4260:                                    .getStreamMessageList().size()
4261:                            + " stream messages");
4262:                }
4263:            }
4264:
4265:            /**
4266:             * Verifies the number of object messages created with
4267:             * {@link MockSession#createObjectMessage}.
4268:             * The session has to be created using the current {@link MockConnection}.
4269:             * @param indexOfSession the index of the session
4270:             * @param number the expected number of object messages
4271:             * @throws VerifyFailedException if verification fails
4272:             */
4273:            public void verifyNumberOfCreatedObjectMessages(int indexOfSession,
4274:                    int number) {
4275:                checkAndGetSessionByIndex(indexOfSession);
4276:                if (number != getMessageManager(indexOfSession)
4277:                        .getObjectMessageList().size()) {
4278:                    throw new VerifyFailedException("Expected "
4279:                            + number
4280:                            + " object messages, received "
4281:                            + getMessageManager(indexOfSession)
4282:                                    .getObjectMessageList().size()
4283:                            + " object messages");
4284:                }
4285:            }
4286:
4287:            /**
4288:             * Verifies that a message created with {@link MockSession#createMessage} 
4289:             * is acknowledged. This method makes sense if messages are not cloned
4290:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
4291:             * If messages are cloned, the cloned message is acknowledged instead of
4292:             * the created message.
4293:             * The session has to be created using the current {@link MockConnection}.
4294:             * @param indexOfSession the index of the session
4295:             * @param indexOfMessage the index of the message
4296:             * @throws VerifyFailedException if verification fails
4297:             */
4298:            public void verifyCreatedMessageAcknowledged(int indexOfSession,
4299:                    int indexOfMessage) {
4300:                checkAndGetSessionByIndex(indexOfSession);
4301:                List messageList = getMessageManager(indexOfSession)
4302:                        .getMessageList();
4303:                if (indexOfMessage >= messageList.size()) {
4304:                    throw new VerifyFailedException("Only "
4305:                            + messageList.size()
4306:                            + " messages created for session " + indexOfSession);
4307:                }
4308:                MockMessage message = (MockMessage) messageList
4309:                        .get(indexOfMessage);
4310:                if (!message.isAcknowledged()) {
4311:                    throw new VerifyFailedException("Message " + indexOfMessage
4312:                            + " of session " + indexOfSession
4313:                            + " is not acknowledged");
4314:                }
4315:            }
4316:
4317:            /**
4318:             * Verifies that a message created with {@link MockSession#createMessage} 
4319:             * is not acknowledged. This method makes sense if messages are not cloned
4320:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
4321:             * If messages are cloned, the cloned message is acknowledged instead of
4322:             * the created message.
4323:             * The session has to be created using the current {@link MockConnection}.
4324:             * @param indexOfSession the index of the session
4325:             * @param indexOfMessage the index of the message
4326:             * @throws VerifyFailedException if verification fails
4327:             */
4328:            public void verifyCreatedMessageNotAcknowledged(int indexOfSession,
4329:                    int indexOfMessage) {
4330:                checkAndGetSessionByIndex(indexOfSession);
4331:                List messageList = getMessageManager(indexOfSession)
4332:                        .getMessageList();
4333:                if (indexOfMessage >= messageList.size()) {
4334:                    throw new VerifyFailedException("Only "
4335:                            + messageList.size()
4336:                            + " messages created for session " + indexOfSession);
4337:                }
4338:                MockMessage message = (MockMessage) messageList
4339:                        .get(indexOfMessage);
4340:                if (message.isAcknowledged()) {
4341:                    throw new VerifyFailedException("Message " + indexOfMessage
4342:                            + " of session " + indexOfSession
4343:                            + " is acknowledged");
4344:                }
4345:            }
4346:
4347:            /**
4348:             * Verifies that a bytes message created with {@link MockSession#createMessage} 
4349:             * is acknowledged. This method makes sense if messages are not cloned
4350:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
4351:             * If messages are cloned, the cloned message is acknowledged instead of
4352:             * the created message.
4353:             * The session has to be created using the current {@link MockConnection}.
4354:             * @param indexOfSession the index of the session
4355:             * @param indexOfMessage the index of the message
4356:             * @throws VerifyFailedException if verification fails
4357:             */
4358:            public void verifyCreatedBytesMessageAcknowledged(
4359:                    int indexOfSession, int indexOfMessage) {
4360:                checkAndGetSessionByIndex(indexOfSession);
4361:                List messageList = getMessageManager(indexOfSession)
4362:                        .getBytesMessageList();
4363:                if (indexOfMessage >= messageList.size()) {
4364:                    throw new VerifyFailedException("Only "
4365:                            + messageList.size()
4366:                            + " bytes messages created for session "
4367:                            + indexOfSession);
4368:                }
4369:                MockMessage message = (MockMessage) messageList
4370:                        .get(indexOfMessage);
4371:                if (!message.isAcknowledged()) {
4372:                    throw new VerifyFailedException("Message " + indexOfMessage
4373:                            + " of session " + indexOfSession
4374:                            + " is not acknowledged");
4375:                }
4376:            }
4377:
4378:            /**
4379:             * Verifies that a bytes message created with {@link MockSession#createMessage} 
4380:             * is not acknowledged. This method makes sense if messages are not cloned
4381:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
4382:             * If messages are cloned, the cloned message is acknowledged instead of
4383:             * the created message.
4384:             * The session has to be created using the current {@link MockConnection}.
4385:             * @param indexOfSession the index of the session
4386:             * @param indexOfMessage the index of the message
4387:             * @throws VerifyFailedException if verification fails
4388:             */
4389:            public void verifyCreatedBytesMessageNotAcknowledged(
4390:                    int indexOfSession, int indexOfMessage) {
4391:                checkAndGetSessionByIndex(indexOfSession);
4392:                List messageList = getMessageManager(indexOfSession)
4393:                        .getBytesMessageList();
4394:                if (indexOfMessage >= messageList.size()) {
4395:                    throw new VerifyFailedException("Only "
4396:                            + messageList.size()
4397:                            + " bytes messages created for session "
4398:                            + indexOfSession);
4399:                }
4400:                MockMessage message = (MockMessage) messageList
4401:                        .get(indexOfMessage);
4402:                if (message.isAcknowledged()) {
4403:                    throw new VerifyFailedException("Message " + indexOfMessage
4404:                            + " of session " + indexOfSession
4405:                            + " is acknowledged");
4406:                }
4407:            }
4408:
4409:            /**
4410:             * Verifies that a map message created with {@link MockSession#createMessage} 
4411:             * is acknowledged. This method makes sense if messages are not cloned
4412:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
4413:             * If messages are cloned, the cloned message is acknowledged instead of
4414:             * the created message.
4415:             * The session has to be created using the current {@link MockConnection}.
4416:             * @param indexOfSession the index of the session
4417:             * @param indexOfMessage the index of the message
4418:             * @throws VerifyFailedException if verification fails
4419:             */
4420:            public void verifyCreatedMapMessageAcknowledged(int indexOfSession,
4421:                    int indexOfMessage) {
4422:                checkAndGetSessionByIndex(indexOfSession);
4423:                List messageList = getMessageManager(indexOfSession)
4424:                        .getMapMessageList();
4425:                if (indexOfMessage >= messageList.size()) {
4426:                    throw new VerifyFailedException("Only "
4427:                            + messageList.size()
4428:                            + " map messages created for session "
4429:                            + indexOfSession);
4430:                }
4431:                MockMessage message = (MockMessage) messageList
4432:                        .get(indexOfMessage);
4433:                if (!message.isAcknowledged()) {
4434:                    throw new VerifyFailedException("Message " + indexOfMessage
4435:                            + " of session " + indexOfSession
4436:                            + " is not acknowledged");
4437:                }
4438:            }
4439:
4440:            /**
4441:             * Verifies that a map message created with {@link MockSession#createMessage} 
4442:             * is not acknowledged. This method makes sense if messages are not cloned
4443:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
4444:             * If messages are cloned, the cloned message is acknowledged instead of
4445:             * the created message.
4446:             * The session has to be created using the current {@link MockConnection}.
4447:             * @param indexOfSession the index of the session
4448:             * @param indexOfMessage the index of the message
4449:             * @throws VerifyFailedException if verification fails
4450:             */
4451:            public void verifyCreatedMapMessageNotAcknowledged(
4452:                    int indexOfSession, int indexOfMessage) {
4453:                checkAndGetSessionByIndex(indexOfSession);
4454:                List messageList = getMessageManager(indexOfSession)
4455:                        .getMapMessageList();
4456:                if (indexOfMessage >= messageList.size()) {
4457:                    throw new VerifyFailedException("Only "
4458:                            + messageList.size()
4459:                            + " map messages created for session "
4460:                            + indexOfSession);
4461:                }
4462:                MockMessage message = (MockMessage) messageList
4463:                        .get(indexOfMessage);
4464:                if (message.isAcknowledged()) {
4465:                    throw new VerifyFailedException("Message " + indexOfMessage
4466:                            + " of session " + indexOfSession
4467:                            + " is acknowledged");
4468:                }
4469:            }
4470:
4471:            /**
4472:             * Verifies that a text message created with {@link MockSession#createMessage} 
4473:             * is acknowledged. This method makes sense if messages are not cloned
4474:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
4475:             * If messages are cloned, the cloned message is acknowledged instead of
4476:             * the created message.
4477:             * The session has to be created using the current {@link MockConnection}.
4478:             * @param indexOfSession the index of the session
4479:             * @param indexOfMessage the index of the message
4480:             * @throws VerifyFailedException if verification fails
4481:             */
4482:            public void verifyCreatedTextMessageAcknowledged(
4483:                    int indexOfSession, int indexOfMessage) {
4484:                checkAndGetSessionByIndex(indexOfSession);
4485:                List messageList = getMessageManager(indexOfSession)
4486:                        .getTextMessageList();
4487:                if (indexOfMessage >= messageList.size()) {
4488:                    throw new VerifyFailedException("Only "
4489:                            + messageList.size()
4490:                            + " text messages created for session "
4491:                            + indexOfSession);
4492:                }
4493:                MockMessage message = (MockMessage) messageList
4494:                        .get(indexOfMessage);
4495:                if (!message.isAcknowledged()) {
4496:                    throw new VerifyFailedException("Message " + indexOfMessage
4497:                            + " of session " + indexOfSession
4498:                            + " is not acknowledged");
4499:                }
4500:            }
4501:
4502:            /**
4503:             * Verifies that a text message created with {@link MockSession#createMessage} 
4504:             * is not acknowledged. This method makes sense if messages are not cloned
4505:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
4506:             * If messages are cloned, the cloned message is acknowledged instead of
4507:             * the created message.
4508:             * The session has to be created using the current {@link MockConnection}.
4509:             * @param indexOfSession the index of the session
4510:             * @param indexOfMessage the index of the message
4511:             * @throws VerifyFailedException if verification fails
4512:             */
4513:            public void verifyCreatedTextMessageNotAcknowledged(
4514:                    int indexOfSession, int indexOfMessage) {
4515:                checkAndGetSessionByIndex(indexOfSession);
4516:                List messageList = getMessageManager(indexOfSession)
4517:                        .getTextMessageList();
4518:                if (indexOfMessage >= messageList.size()) {
4519:                    throw new VerifyFailedException("Only "
4520:                            + messageList.size()
4521:                            + " text messages created for session "
4522:                            + indexOfSession);
4523:                }
4524:                MockMessage message = (MockMessage) messageList
4525:                        .get(indexOfMessage);
4526:                if (message.isAcknowledged()) {
4527:                    throw new VerifyFailedException("Message " + indexOfMessage
4528:                            + " of session " + indexOfSession
4529:                            + " is acknowledged");
4530:                }
4531:            }
4532:
4533:            /**
4534:             * Verifies that a stream message created with {@link MockSession#createMessage} 
4535:             * is acknowledged. This method makes sense if messages are not cloned
4536:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
4537:             * If messages are cloned, the cloned message is acknowledged instead of
4538:             * the created message.
4539:             * The session has to be created using the current {@link MockConnection}.
4540:             * @param indexOfSession the index of the session
4541:             * @param indexOfMessage the index of the message
4542:             * @throws VerifyFailedException if verification fails
4543:             */
4544:            public void verifyCreatedStreamMessageAcknowledged(
4545:                    int indexOfSession, int indexOfMessage) {
4546:                checkAndGetSessionByIndex(indexOfSession);
4547:                List messageList = getMessageManager(indexOfSession)
4548:                        .getStreamMessageList();
4549:                if (indexOfMessage >= messageList.size()) {
4550:                    throw new VerifyFailedException("Only "
4551:                            + messageList.size()
4552:                            + " stream messages created for session "
4553:                            + indexOfSession);
4554:                }
4555:                MockMessage message = (MockMessage) messageList
4556:                        .get(indexOfMessage);
4557:                if (!message.isAcknowledged()) {
4558:                    throw new VerifyFailedException("Message " + indexOfMessage
4559:                            + " of session " + indexOfSession
4560:                            + " is not acknowledged");
4561:                }
4562:            }
4563:
4564:            /**
4565:             * Verifies that a stream message created with {@link MockSession#createMessage} 
4566:             * is not acknowledged. This method makes sense if messages are not cloned
4567:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
4568:             * If messages are cloned, the cloned message is acknowledged instead of
4569:             * the created message.
4570:             * The session has to be created using the current {@link MockConnection}.
4571:             * @param indexOfSession the index of the session
4572:             * @param indexOfMessage the index of the message
4573:             * @throws VerifyFailedException if verification fails
4574:             */
4575:            public void verifyCreatedStreamMessageNotAcknowledged(
4576:                    int indexOfSession, int indexOfMessage) {
4577:                checkAndGetSessionByIndex(indexOfSession);
4578:                List messageList = getMessageManager(indexOfSession)
4579:                        .getStreamMessageList();
4580:                if (indexOfMessage >= messageList.size()) {
4581:                    throw new VerifyFailedException("Only "
4582:                            + messageList.size()
4583:                            + " stream messages created for session "
4584:                            + indexOfSession);
4585:                }
4586:                MockMessage message = (MockMessage) messageList
4587:                        .get(indexOfMessage);
4588:                if (message.isAcknowledged()) {
4589:                    throw new VerifyFailedException("Message " + indexOfMessage
4590:                            + " of session " + indexOfSession
4591:                            + " is acknowledged");
4592:                }
4593:            }
4594:
4595:            /**
4596:             * Verifies that a object message created with {@link MockSession#createMessage} 
4597:             * is acknowledged. This method makes sense if messages are not cloned
4598:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
4599:             * If messages are cloned, the cloned message is acknowledged instead of
4600:             * the created message.
4601:             * The session has to be created using the current {@link MockConnection}.
4602:             * @param indexOfSession the index of the session
4603:             * @param indexOfMessage the index of the message
4604:             * @throws VerifyFailedException if verification fails
4605:             */
4606:            public void verifyCreatedObjectMessageAcknowledged(
4607:                    int indexOfSession, int indexOfMessage) {
4608:                checkAndGetSessionByIndex(indexOfSession);
4609:                List messageList = getMessageManager(indexOfSession)
4610:                        .getObjectMessageList();
4611:                if (indexOfMessage >= messageList.size()) {
4612:                    throw new VerifyFailedException("Only "
4613:                            + messageList.size()
4614:                            + " object messages created for session "
4615:                            + indexOfSession);
4616:                }
4617:                MockMessage message = (MockMessage) messageList
4618:                        .get(indexOfMessage);
4619:                if (!message.isAcknowledged()) {
4620:                    throw new VerifyFailedException("Message " + indexOfMessage
4621:                            + " of session " + indexOfSession
4622:                            + " is not acknowledged");
4623:                }
4624:            }
4625:
4626:            /**
4627:             * Verifies that a object message created with {@link MockSession#createMessage} 
4628:             * is not acknowledged. This method makes sense if messages are not cloned
4629:             * when sending them. This is the default, use {@link ConfigurationManager#setDoCloneOnSend}.
4630:             * If messages are cloned, the cloned message is acknowledged instead of
4631:             * the created message.
4632:             * The session has to be created using the current {@link MockConnection}.
4633:             * @param indexOfSession the index of the session
4634:             * @param indexOfMessage the index of the message
4635:             * @throws VerifyFailedException if verification fails
4636:             */
4637:            public void verifyCreatedObjectMessageNotAcknowledged(
4638:                    int indexOfSession, int indexOfMessage) {
4639:                checkAndGetSessionByIndex(indexOfSession);
4640:                List messageList = getMessageManager(indexOfSession)
4641:                        .getObjectMessageList();
4642:                if (indexOfMessage >= messageList.size()) {
4643:                    throw new VerifyFailedException("Only "
4644:                            + messageList.size()
4645:                            + " object messages created for session "
4646:                            + indexOfSession);
4647:                }
4648:                MockMessage message = (MockMessage) messageList
4649:                        .get(indexOfMessage);
4650:                if (message.isAcknowledged()) {
4651:                    throw new VerifyFailedException("Message " + indexOfMessage
4652:                            + " of session " + indexOfSession
4653:                            + " is acknowledged");
4654:                }
4655:            }
4656:
4657:            private MockQueueSession checkAndGetQueueSessionByIndex(
4658:                    int indexOfSession) {
4659:                if (null == getCurrentQueueConnection()) {
4660:                    throw new VerifyFailedException(
4661:                            "No QueueConnection present.");
4662:                }
4663:                MockQueueSession session = getQueueSession(indexOfSession);
4664:                if (null == session) {
4665:                    throw new VerifyFailedException("QueueSession with index "
4666:                            + indexOfSession + " does not exist.");
4667:                }
4668:                return session;
4669:            }
4670:
4671:            private MockTopicSession checkAndGetTopicSessionByIndex(
4672:                    int indexOfSession) {
4673:                if (null == getCurrentTopicConnection()) {
4674:                    throw new VerifyFailedException(
4675:                            "No TopicConnection present.");
4676:                }
4677:                MockTopicSession session = getTopicSession(indexOfSession);
4678:                if (null == session) {
4679:                    throw new VerifyFailedException("TopicSession with index "
4680:                            + indexOfSession + " does not exist.");
4681:                }
4682:                return session;
4683:            }
4684:
4685:            private MockSession checkAndGetSessionByIndex(int indexOfSession) {
4686:                if (null == getCurrentConnection()) {
4687:                    throw new VerifyFailedException("No Connection present.");
4688:                }
4689:                MockSession session = getSession(indexOfSession);
4690:                if (null == session) {
4691:                    throw new VerifyFailedException("Session with index "
4692:                            + indexOfSession + " does not exist.");
4693:                }
4694:                return session;
4695:            }
4696:
4697:            private void checkQueueByName(String queueName) {
4698:                DestinationManager destinationManager = getDestinationManager();
4699:                if (null == destinationManager.getQueue(queueName)) {
4700:                    throw new VerifyFailedException("Queue with name "
4701:                            + queueName + " is not present.");
4702:                }
4703:            }
4704:
4705:            private void checkTopicByName(String topicName) {
4706:                DestinationManager destinationManager = getDestinationManager();
4707:                if (null == destinationManager.getTopic(topicName)) {
4708:                    throw new VerifyFailedException("Topic with name "
4709:                            + topicName + " is not present.");
4710:                }
4711:            }
4712:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.