public function testCheckQueueServiceOptions()
 {
     $options = new QueueServiceOptions();
     $this->assertNull($options->getTimeout(), 'Default QueueServiceOptions->getTimeout should be null');
     $options->setTimeout(self::INT_MAX_VALUE);
     $this->assertEquals(self::INT_MAX_VALUE, $options->getTimeout(), 'Set QueueServiceOptions->getTimeout');
 }
 /**
  * @covers WindowsAzure\Queue\Models\QueueServiceOptions::getTimeout
  */
 public function testGetTimeout()
 {
     // Setup
     $options = new QueueServiceOptions();
     $value = 10;
     $options->setTimeout($value);
     // Test
     $actualValue = $options->getTimeout();
     // Assert
     $this->assertEquals($value, $actualValue);
 }
 /**
  * @covers WindowsAzure\Queue\QueueRestProxy::clearMessages
  * @covers WindowsAzure\Queue\QueueRestProxy::createMessage
  * @covers WindowsAzure\Queue\QueueRestProxy::listMessages
  */
 public function testClearMessages()
 {
     $interestingTimes = array(null, -1, 0, QueueServiceFunctionalTestData::INTERESTING_TTL, 1000);
     foreach ($interestingTimes as $timeout) {
         $options = new QueueServiceOptions();
         $options->setTimeout($timeout);
         $this->clearMessagesWorker($options);
     }
 }
 /**
  * @covers WindowsAzure\Queue\QueueRestProxy::clearMessages
  * @covers WindowsAzure\Common\Internal\ServiceRestProxy::send
  */
 public function testClearMessagesWithOptions()
 {
     // Setup
     $name = 'clearmessageswithoptions';
     $msg1 = 'message #1';
     $msg2 = 'message #2';
     $msg3 = 'message #3';
     $options = new QueueServiceOptions();
     $options->setTimeout('10');
     $this->createQueue($name);
     $this->restProxy->createMessage($name, $msg1);
     $this->restProxy->createMessage($name, $msg2);
     $this->restProxy->createMessage($name, $msg3);
     // Test
     $this->restProxy->clearMessages($name, $options);
     // Assert
     $result = $this->restProxy->listMessages($name);
     $messages = $result->getQueueMessages();
     $this->assertTrue(empty($messages));
 }
Example #5
0
 /**
  * Updates the visibility timeout of a message and/or the message contents.
  * 
  * @param string              $queueName                  The queue name.
  * @param string              $messageId                  The id of the message.
  * @param string              $popReceipt                 The valid pop receipt 
  * value returned from an earlier call to the Get Messages or Update Message
  * operation.
  * @param string              $messageText                The message contents.
  * @param int                 $visibilityTimeoutInSeconds Specifies the new 
  * visibility timeout value, in seconds, relative to server time. 
  * The new value must be larger than or equal to 0, and cannot be larger 
  * than 7 days. The visibility timeout of a message cannot be set to a value 
  * later than the expiry time. A message can be updated until it has been 
  * deleted or has expired.
  * @param QueueServiceOptions $options                    The optional 
  * parameters.
  * 
  * @return WindowsAzure\Common\Models\UpdateMessageResult
  */
 public function updateMessage($queueName, $messageId, $popReceipt, $messageText, $visibilityTimeoutInSeconds, $options = null)
 {
     Validate::isString($queueName, 'queueName');
     Validate::notNullOrEmpty($queueName, 'queueName');
     Validate::isString($messageId, 'messageId');
     Validate::notNullOrEmpty($messageId, 'messageId');
     Validate::isString($popReceipt, 'popReceipt');
     Validate::notNullOrEmpty($popReceipt, 'popReceipt');
     Validate::isString($messageText, 'messageText');
     Validate::isInteger($visibilityTimeoutInSeconds, 'visibilityTimeoutInSeconds');
     Validate::notNull($visibilityTimeoutInSeconds, 'visibilityTimeoutInSeconds');
     $method = Resources::HTTP_PUT;
     $headers = array();
     $postParams = array();
     $queryParams = array();
     $path = $queueName . '/messages' . '/' . $messageId;
     $body = Resources::EMPTY_STRING;
     $statusCode = Resources::STATUS_NO_CONTENT;
     if (is_null($options)) {
         $options = new QueueServiceOptions();
     }
     $this->addOptionalQueryParam($queryParams, Resources::QP_VISIBILITY_TIMEOUT, $visibilityTimeoutInSeconds);
     $this->addOptionalQueryParam($queryParams, Resources::QP_TIMEOUT, $options->getTimeout());
     $this->addOptionalQueryParam($queryParams, Resources::QP_POPRECEIPT, $popReceipt);
     if (!empty($messageText)) {
         $this->addOptionalHeader($headers, Resources::CONTENT_TYPE, Resources::URL_ENCODED_CONTENT_TYPE);
         $message = new QueueMessage();
         $message->setMessageText($messageText);
         $body = $message->toXml($this->dataSerializer);
     }
     $response = $this->send($method, $headers, $queryParams, $postParams, $path, $statusCode, $body);
     $popReceipt = $response->getHeader(Resources::X_MS_POPRECEIPT);
     $timeNextVisible = $response->getHeader(Resources::X_MS_TIME_NEXT_VISIBLE);
     $date = Utilities::rfc1123ToDateTime($timeNextVisible);
     $result = new UpdateMessageResult();
     $result->setPopReceipt($popReceipt);
     $result->setTimeNextVisible($date);
     return $result;
 }