public function testNonDefaultPropertiesMapToJsonString() { // Act $properties = new BrokerProperties(); $properties->setMessageId('foo'); $properties->setDeliveryCount(7); $json = $properties->toString(); // Assert $this->assertNotNull($json, '$json'); $this->assertEquals('{"DeliveryCount":7,"MessageId":"foo"}', $json, '$json'); }
/** * @covers WindowsAzure\ServiceBus\Models\BrokerProperties::getDeliveryCount * @covers WindowsAzure\ServiceBus\Models\BrokerProperties::setDeliveryCount */ public function testGetSetDeliveryCount() { // Setup $expected = 100; $brokerProperties = new BrokerProperties(); // Test $brokerProperties->setDeliveryCount($expected); $actual = $brokerProperties->getDeliveryCount(); // Assert $this->assertEquals($expected, $actual); }
/** * Sets the delivery count. * * @param integer $deliveryCount The times that the message has been delivered. * * @return none */ public function setDeliveryCount($deliveryCount) { $this->_brokerProperties->setDeliveryCount($deliveryCount); }
/** * Creates a broker properties instance with specified JSON message. * * @param string $brokerPropertiesJson A JSON message representing a * broker properties. * * @return none */ public static function create($brokerPropertiesJson) { Validate::isString($brokerPropertiesJson, 'brokerPropertiesJson'); $brokerProperties = new BrokerProperties(); $brokerPropertiesArray = (array) json_decode($brokerPropertiesJson); if (array_key_exists('CorrelationId', $brokerPropertiesArray)) { $brokerProperties->setCorrelationId($brokerPropertiesArray['CorrelationId']); } if (array_key_exists('SessionId', $brokerPropertiesArray)) { $brokerProperties->setSessionId($brokerPropertiesArray['SessionId']); } if (array_key_exists('DeliveryCount', $brokerPropertiesArray)) { $brokerProperties->setDeliveryCount($brokerPropertiesArray['DeliveryCount']); } if (array_key_exists('LockedUntilUtc', $brokerPropertiesArray)) { $brokerProperties->setLockedUntilUtc(\DateTime::createFromFormat(Resources::AZURE_DATE_FORMAT, $brokerPropertiesArray['LockedUntilUtc'])); } if (array_key_exists('LockToken', $brokerPropertiesArray)) { $brokerProperties->setLockToken($brokerPropertiesArray['LockToken']); } if (array_key_exists('MessageId', $brokerPropertiesArray)) { $brokerProperties->setMessageId($brokerPropertiesArray['MessageId']); } if (array_key_exists('Label', $brokerPropertiesArray)) { $brokerProperties->setLabel($brokerPropertiesArray['Label']); } if (array_key_exists('ReplyTo', $brokerPropertiesArray)) { $brokerProperties->setReplyTo($brokerPropertiesArray['ReplyTo']); } if (array_key_exists('SequenceNumber', $brokerPropertiesArray)) { $brokerProperties->setSequenceNumber($brokerPropertiesArray['SequenceNumber']); } if (array_key_exists('TimeToLive', $brokerPropertiesArray)) { $brokerProperties->setTimeToLive(doubleval($brokerPropertiesArray['TimeToLive'])); } if (array_key_exists('To', $brokerPropertiesArray)) { $brokerProperties->setTo($brokerPropertiesArray['To']); } if (array_key_exists('ScheduledEnqueueTimeUtc', $brokerPropertiesArray)) { $brokerProperties->setScheduledEnqueueTimeUtc(\DateTime::createFromFormat(Resources::AZURE_DATE_FORMAT, $brokerPropertiesArray['ScheduledEnqueueTimeUtc'])); } if (array_key_exists('ReplyToSessionId', $brokerPropertiesArray)) { $brokerProperties->setReplyToSessionId($brokerPropertiesArray['ReplyToSessionId']); } if (array_key_exists('MessageLocation', $brokerPropertiesArray)) { $brokerProperties->setMessageLocation($brokerPropertiesArray['MessageLocation']); } if (array_key_exists('LockLocation', $brokerPropertiesArray)) { $brokerProperties->setLockLocation($brokerPropertiesArray['LockLocation']); } return $brokerProperties; }
private function createIssueMessage($issueId, $issueBody, $label, $messageLocation) { $message = new BrokeredMessage($issueBody); $bp = new BrokerProperties(); $bp->setLabel($label); // $bp->setMessageLocation($messageLocation); $bp->setReplyTo('*****@*****.**'); $bp->setMessageId($issueId); $bp->setCorrelationId('correlationid' + $label); $bp->setDeliveryCount(1); $bp->setLockedUntilUtc(new \DateTime('2/4/1984')); $bp->setLockLocation($label + 'locallocation'); $bp->setLockToken($label + 'locltoken'); $bp->setSequenceNumber(12); $message->setBrokerProperties($bp); $message->setContentType('text/xml'); $message->setLabel($label); $message->setReplyTo('*****@*****.**'); $message->setMessageId($issueId); $customProperties = $this->getCustomProperties(1); foreach ($customProperties as $key => $value) { $message->setProperty($key, $value); } return $message; }