ActivemqTest.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Queue
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /*
  23. * The adapter test class provides a universal test class for all of the
  24. * abstract methods.
  25. *
  26. * All methods marked not supported are explictly checked for for throwing
  27. * an exception.
  28. */
  29. require_once 'Zend/Queue/Adapter/AdapterTest.php';
  30. /**
  31. * @category Zend
  32. * @package Zend_Queue
  33. * @subpackage UnitTests
  34. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  35. * @license http://framework.zend.com/license/new-bsd New BSD License
  36. * @group Zend_Queue
  37. */
  38. class Zend_Queue_Adapter_ActivemqTest extends Zend_Queue_Adapter_AdapterTest
  39. {
  40. /**
  41. * Test setup
  42. */
  43. public function setUp()
  44. {
  45. if (!TESTS_ZEND_QUEUE_ACTIVEMQ_ENABLED) {
  46. $this->markTestSkipped('TESTS_ZEND_QUEUE_ACTIVEMQ_ENABLED is not enabled in TestConfiguration.php');
  47. }
  48. parent::setUp();
  49. }
  50. /**
  51. * getAdapterName() is an method to help make AdapterTest work with any
  52. * new adapters
  53. *
  54. * You must overload this method
  55. *
  56. * @return string
  57. */
  58. public function getAdapterName()
  59. {
  60. return 'Activemq';
  61. }
  62. public function getTestConfig()
  63. {
  64. $driverOptions = array();
  65. if (defined('TESTS_ZEND_QUEUE_ACTIVEMQ_HOST')) {
  66. $driverOptions['host'] = TESTS_ZEND_QUEUE_ACTIVEMQ_HOST;
  67. }
  68. if (defined('TESTS_ZEND_QUEUE_ACTIVEMQ_PORT')) {
  69. $driverOptions['port'] = TESTS_ZEND_QUEUE_ACTIVEMQ_PORT;
  70. }
  71. if (defined('TESTS_ZEND_QUEUE_ACTIVEMQ_SCHEME')) {
  72. $driverOptions['scheme'] = TESTS_ZEND_QUEUE_ACTIVEMQ_SCHEME;
  73. }
  74. return array('driverOptions' => $driverOptions);
  75. }
  76. /**
  77. * Stomped requires specific name types
  78. */
  79. public function createQueueName($name)
  80. {
  81. return '/temp-queue/' . $name;
  82. }
  83. public function testConst()
  84. {
  85. /**
  86. * @see Zend_Queue_Adapter_Activemq
  87. */
  88. require_once 'Zend/Queue/Adapter/Activemq.php';
  89. $this->assertTrue(is_string(Zend_Queue_Adapter_Activemq::DEFAULT_SCHEME));
  90. $this->assertTrue(is_string(Zend_Queue_Adapter_Activemq::DEFAULT_HOST));
  91. $this->assertTrue(is_integer(Zend_Queue_Adapter_Activemq::DEFAULT_PORT));
  92. }
  93. /**
  94. * @group ZF-7650
  95. */
  96. public function testReceiveWillRetrieveZeroItems()
  97. {
  98. $options = array('driverOptions' => $this->getTestConfig());
  99. $queue = new Zend_Queue('Activemq', $options);
  100. $queue2 = $queue->createQueue('queue');
  101. $queue->send('My Test Message 1');
  102. $queue->send('My Test Message 2');
  103. $messages = $queue->receive(0);
  104. $this->assertEquals(0, count($messages));
  105. }
  106. }