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