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 MicrosoftAzure\Storage\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 MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::createQueue * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::deleteQueue * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::getQueueMetadata * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::setQueueMetadata */ private function setQueueMetadataWorker($options, $metadata) { self::println('Trying $options: ' . self::tmptostring($options) . ' and $metadata: ' . self::tmptostring($metadata)); $queue = QueueServiceFunctionalTestData::getInterestingQueueName(); // Make sure there is something to test $this->restProxy->createQueue($queue); try { // And put in some metadata if (is_null($options)) { $this->restProxy->setQueueMetadata($queue, $metadata); } else { $this->restProxy->setQueueMetadata($queue, $metadata, $options); } if (is_null($options)) { $options = new QueueServiceOptions(); } if (!is_null($options->getTimeout()) && $options->getTimeout() < 1) { $this->assertTrue(false, 'Expect negative timeouts in $options to throw'); } $res = $this->restProxy->getQueueMetadata($queue); $this->verifyGetSetQueueMetadataWorker($res, $metadata); } catch (ServiceException $e) { if (!is_null($metadata) && count($metadata) > 0) { $keypart = array_keys($metadata); $keypart = $keypart[0]; if (substr($keypart, 0, 1) == '<') { $this->assertEquals(TestResources::STATUS_BAD_REQUEST, $e->getCode(), 'getCode'); } } else { if (!is_null($options->getTimeout()) && $options->getTimeout() < 1) { $this->assertEquals(TestResources::STATUS_INTERNAL_SERVER_ERROR, $e->getCode(), 'getCode'); } else { throw $e; } } } // Clean up. $this->restProxy->deleteQueue($queue); }
/** * 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 MicrosoftAzure\Storage\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); $responseHeaders = HttpFormatter::formatHeaders($response->getHeaders()); $popReceipt = Utilities::tryGetValue($responseHeaders, Resources::X_MS_POPRECEIPT); $timeNextVisible = Utilities::tryGetValue($responseHeaders, Resources::X_MS_TIME_NEXT_VISIBLE); $date = Utilities::rfc1123ToDateTime($timeNextVisible); $result = new UpdateMessageResult(); $result->setPopReceipt($popReceipt); $result->setTimeNextVisible($date); return $result; }