/** * Populates the properties with a the response from the list topics request. * * @param string $response The body of the response of the list topics request. * * @return none */ public function parseXml($response) { parent::parseXml($response); $listTopicsResultXml = new \SimpleXMLElement($response); $this->_topicInfos = array(); foreach ($listTopicsResultXml->entry as $entry) { $topicInfo = new TopicInfo(); $topicInfo->parseXml($entry->asXml()); $this->_topicInfos[] = $topicInfo; } }
/** * Gets a topic. * * @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780769 * * @param string $topicPath The path of the topic. * * @return TopicInfo */ public function getTopic($topicPath) { $httpCallContext = new HttpCallContext(); $httpCallContext->setMethod(Resources::HTTP_GET); $httpCallContext->setPath($topicPath); $httpCallContext->addStatusCode(Resources::STATUS_OK); $response = $this->sendContext($httpCallContext); $topicInfo = new TopicInfo(); $topicInfo->parseXml($response->getBody()); return $topicInfo; }
/** * @covers WindowsAzure\ServiceBus\Models\TopicInfo::getSizeInBytes * @covers WindowsAzure\ServiceBus\Models\TopicInfo::setSizeInBytes */ public function testGetSetSizeInBytes() { // Setup $expected = 'testSizeInBytes'; $topicInfo = new TopicInfo(); // Test $topicInfo->setSizeInBytes($expected); $actual = $topicInfo->getSizeInBytes(); // Assert $this->assertEquals($expected, $actual); }
/** * @covers WindowsAzure\ServiceBus\ServiceBusRestProxy::createTopic * @covers WindowsAzure\ServiceBus\ServiceBusRestProxy::deleteTopic * @covers WindowsAzure\ServiceBus\ServiceBusRestProxy::getTopic * @covers WindowsAzure\ServiceBus\ServiceBusRestProxy::listTopics */ private function setupTopic() { $options = new ListTopicsOptions(); $options->setSkip(20); $options->setTop(2); $topics = $this->restProxy->listTopics($options)->getTopicInfos(); foreach ($topics as $topic) { self::write('Topic name is ' . $topic->getTitle()); } self::write('checking if topic already exists ' . $this->topicName); try { $this->restProxy->getTopic($this->topicName); self::write('Topic already exists deleting it'); $this->restProxy->deleteTopic($this->topicName); } catch (\Exception $e) { self::write('could not get an existing topic (' . $e->getCode() . '), proceeding...'); } $topic = new TopicInfo($this->topicName); $topic->setEnableBatchedOperations(true); $topic->setMaxSizeInMegabytes(1024); $topic->setRequiresDuplicateDetection(false); self::write('Creating topic ' . $this->topicName); $this->restProxy->createTopic($topic); $this->restProxy->getTopic($this->topicName); }
/** * @covers WindowsAzure\ServiceBus\ServiceBusRestProxy::createTopic * @covers WindowsAzure\ServiceBus\ServiceBusRestProxy::deleteTopic * @covers WindowsAzure\ServiceBus\ServiceBusRestProxy::listTopics * @covers WindowsAzure\ServiceBus\ServiceBusRestProxy::getTopic */ public function testCreateListFetchAndDeleteTopicSuccess() { // Setup $topicName = 'createTopicSuccess'; $topicInfo = new TopicInfo($topicName); $listTopicsOptions = new ListTopicsOptions(); $listTopicsResult = $this->restProxy->listTopics($listTopicsOptions); foreach ($listTopicsResult->getTopicInfos() as $topicInfo) { $this->restProxy->deleteTopic($topicInfo->getTitle()); } // Test $createTopicResult = $this->createTopic($topicInfo); $listTopicsResult = $this->restProxy->listTopics($listTopicsOptions); $getTopicResult = $this->restProxy->getTopic($topicName); $this->safeDeleteTopic($topicName); $listTopicsResult2 = $this->restProxy->listTopics($listTopicsOptions); // Assert $this->assertNotNull($createTopicResult); $this->assertNotNull($listTopicsResult); $this->assertNotNull($getTopicResult); $this->assertNotNull($listTopicsResult2); $this->assertEquals(1, count($listTopicsResult->getTopicInfos())); }