コード例 #1
0
ファイル: ServiceProperties.php プロジェクト: yszar/linuxwp
 /**
  * Creates ServiceProperties object from parsed XML response.
  *
  * @param array $parsedResponse XML response parsed into array.
  * 
  * @return WindowsAzure\Common\Models\ServiceProperties.
  */
 public static function create($parsedResponse)
 {
     $result = new ServiceProperties();
     $result->setLogging(Logging::create($parsedResponse['Logging']));
     $result->setMetrics(Metrics::create($parsedResponse['Metrics']));
     return $result;
 }
 /**
  * @covers WindowsAzure\Common\Models\GetServicePropertiesResult::setValue
  */
 public function testSetValue()
 {
     // Setup
     $result = new GetServicePropertiesResult();
     $expected = ServiceProperties::create(TestResources::getServicePropertiesSample());
     // Test
     $result->setValue($expected);
     // Assert
     $this->assertEquals($expected, $result->getValue());
 }
コード例 #3
0
 /**
  * @covers WindowsAzure\Common\Internal\Serialization\XmlSerializer::serialize
  * @covers WindowsAzure\Common\Internal\Serialization\XmlSerializer::_arr2xml
  */
 public function testSerialize()
 {
     // Setup
     $xmlSerializer = new XmlSerializer();
     $propertiesSample = TestResources::getServicePropertiesSample();
     $properties = ServiceProperties::create($propertiesSample);
     $expected = $properties->toXml($xmlSerializer);
     $array = $properties->toArray();
     $serializerProperties = array(XmlSerializer::ROOT_NAME => ServiceProperties::$xmlRootName);
     // Test
     $actual = $xmlSerializer->serialize($array, $serializerProperties);
     $this->assertEquals($expected, $actual);
 }
コード例 #4
0
 private function _createDefaultProperties()
 {
     $this->propertiesChanged = false;
     $propertiesArray = array();
     $propertiesArray['Logging']['Version'] = '1.0';
     $propertiesArray['Logging']['Delete'] = 'false';
     $propertiesArray['Logging']['Read'] = 'false';
     $propertiesArray['Logging']['Write'] = 'false';
     $propertiesArray['Logging']['RetentionPolicy']['Enabled'] = 'false';
     $propertiesArray['Metrics']['Version'] = '1.0';
     $propertiesArray['Metrics']['Enabled'] = 'false';
     $propertiesArray['Metrics']['IncludeAPIs'] = 'false';
     $propertiesArray['Metrics']['RetentionPolicy']['Enabled'] = 'false';
     $this->defaultProperties = ServiceProperties::create($propertiesArray);
 }
コード例 #5
0
 /**
  * @covers WindowsAzure\Table\TableRestProxy::setServiceProperties
  * @covers WindowsAzure\Common\Internal\ServiceRestProxy::sendContext
  */
 public function testSetServicePropertiesWithEmptyParts()
 {
     $this->skipIfEmulated();
     // Setup
     $xml = TestResources::setServicePropertiesSample();
     $xml['Metrics']['RetentionPolicy'] = null;
     $expected = ServiceProperties::create($xml);
     // Test
     $this->setServiceProperties($expected);
     $actual = $this->restProxy->getServiceProperties();
     // Assert
     $this->assertEquals($expected->toXml($this->xmlSerializer), $actual->getValue()->toXml($this->xmlSerializer));
 }
コード例 #6
0
 /**
  * @covers WindowsAzure\Blob\BlobRestProxy::setServiceProperties
  */
 public function testSetServiceProperties()
 {
     $this->skipIfEmulated();
     // Setup
     $expected = ServiceProperties::create(TestResources::setServicePropertiesSample());
     // Test
     $this->setServiceProperties($expected);
     $actual = $this->restProxy->getServiceProperties();
     // Assert
     $this->assertEquals($expected->toXml($this->xmlSerializer), $actual->getValue()->toXml($this->xmlSerializer));
 }
コード例 #7
0
 public static function getInterestingServiceProperties()
 {
     $ret = array();
     // This is the default that comes from the server.
     array_push($ret, self::getDefaultServiceProperties());
     $rp = new RetentionPolicy();
     $rp->setEnabled(true);
     $rp->setDays(10);
     $l = new Logging();
     $l->setRetentionPolicy($rp);
     // Note: looks like only v1.0 is available now.
     // http://msdn.microsoft.com/en-us/library/windowsazure/hh360996.aspx
     $l->setVersion('1.0');
     $l->setDelete(true);
     $l->setRead(true);
     $l->setWrite(true);
     $m = new Metrics();
     $m->setRetentionPolicy($rp);
     $m->setVersion('1.0');
     $m->setEnabled(true);
     $m->setIncludeAPIs(true);
     $sp = new ServiceProperties();
     $sp->setLogging($l);
     $sp->setMetrics($m);
     array_push($ret, $sp);
     $rp = new RetentionPolicy();
     // The service does not accept setting days when enabled is false.
     $rp->setEnabled(false);
     $rp->setDays(null);
     $l = new Logging();
     $l->setRetentionPolicy($rp);
     // Note: looks like only v1.0 is available now.
     // http://msdn.microsoft.com/en-us/library/windowsazure/hh360996.aspx
     $l->setVersion('1.0');
     $l->setDelete(false);
     $l->setRead(false);
     $l->setWrite(false);
     $m = new Metrics();
     $m->setRetentionPolicy($rp);
     $m->setVersion('1.0');
     $m->setEnabled(true);
     $m->setIncludeAPIs(true);
     $sp = new ServiceProperties();
     $sp->setLogging($l);
     $sp->setMetrics($m);
     array_push($ret, $sp);
     $rp = new RetentionPolicy();
     $rp->setEnabled(true);
     // Days has to be 0 < days <= 365
     $rp->setDays(364);
     $l = new Logging();
     $l->setRetentionPolicy($rp);
     // Note: looks like only v1.0 is available now.
     // http://msdn.microsoft.com/en-us/library/windowsazure/hh360996.aspx
     $l->setVersion('1.0');
     $l->setDelete(false);
     $l->setRead(false);
     $l->setWrite(false);
     $m = new Metrics();
     $m->setVersion('1.0');
     $m->setEnabled(false);
     $m->setIncludeAPIs(null);
     $m->setRetentionPolicy($rp);
     $sp = new ServiceProperties();
     $sp->setLogging($l);
     $sp->setMetrics($m);
     array_push($ret, $sp);
     return $ret;
 }
コード例 #8
0
 /**
  * @covers WindowsAzure\Common\Internal\Utilities::serialize
  * @covers WindowsAzure\Common\Internal\Utilities::_arr2xml
  */
 public function testSerialize()
 {
     // Setup
     $propertiesSample = TestResources::getServicePropertiesSample();
     $properties = ServiceProperties::create($propertiesSample);
     $expected = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
     $expected .= '<StorageServiceProperties><Logging><Version>1.0</Version><Delete>true</Delete>';
     $expected .= '<Read>false</Read><Write>true</Write><RetentionPolicy><Enabled>true</Enabled>';
     $expected .= '<Days>20</Days></RetentionPolicy></Logging><Metrics><Version>1.0</Version>';
     $expected .= '<Enabled>true</Enabled><IncludeAPIs>false</IncludeAPIs><RetentionPolicy>';
     $expected .= '<Enabled>true</Enabled><Days>20</Days></RetentionPolicy></Metrics></StorageServiceProperties>';
     $array = $properties->toArray();
     // Test
     $actual = Utilities::serialize($array, ServiceProperties::$xmlRootName);
     $this->assertEquals($expected, $actual);
 }
コード例 #9
0
ファイル: BlobRestProxy.php プロジェクト: yszar/linuxwp
 /**
  * Sets the properties of the Blob service.
  * 
  * It's recommended to use getServiceProperties, alter the returned object and
  * then use setServiceProperties with this altered object.
  * 
  * @param ServiceProperties         $serviceProperties The service properties.
  * @param Models\BlobServiceOptions $options           The optional parameters.
  * 
  * @return none
  * 
  * @see http://msdn.microsoft.com/en-us/library/windowsazure/hh452235.aspx
  */
 public function setServiceProperties($serviceProperties, $options = null)
 {
     Validate::isTrue($serviceProperties instanceof ServiceProperties, Resources::INVALID_SVC_PROP_MSG);
     $method = Resources::HTTP_PUT;
     $headers = array();
     $queryParams = array();
     $postParams = array();
     $statusCode = Resources::STATUS_ACCEPTED;
     $path = Resources::EMPTY_STRING;
     $body = $serviceProperties->toXml($this->dataSerializer);
     if (is_null($options)) {
         $options = new BlobServiceOptions();
     }
     $this->addOptionalQueryParam($queryParams, Resources::QP_REST_TYPE, 'service');
     $this->addOptionalQueryParam($queryParams, Resources::QP_COMP, 'properties');
     $this->addOptionalQueryParam($queryParams, Resources::QP_TIMEOUT, $options->getTimeout());
     $this->addOptionalHeader($headers, Resources::CONTENT_TYPE, Resources::URL_ENCODED_CONTENT_TYPE);
     $this->send($method, $headers, $queryParams, $postParams, $path, $statusCode, $body);
 }
コード例 #10
0
 /**
  * Creates object from $parsedResponse.
  * 
  * @param array $parsedResponse XML response parsed into array.
  * 
  * @return WindowsAzure\Common\Models\GetServicePropertiesResult
  */
 public static function create($parsedResponse)
 {
     $result = new GetServicePropertiesResult();
     $result->_serviceProperties = ServiceProperties::create($parsedResponse);
     return $result;
 }
コード例 #11
0
 /**
  * @covers WindowsAzure\Common\Models\ServiceProperties::toXml
  */
 public function testToXml()
 {
     // Setup
     $properties = ServiceProperties::create(TestResources::getServicePropertiesSample());
     $xmlSerializer = new XmlSerializer();
     // Test
     $actual = $properties->toXml($xmlSerializer);
     // Assert
     $actualParsed = Utilities::unserialize($actual);
     $actualProperties = GetServicePropertiesResult::create($actualParsed);
     $this->assertEquals($actualProperties->getValue(), $properties);
 }
コード例 #12
0
 public function testCheckServiceProperties()
 {
     // Check that the default values of options are reasonable
     $l = new Logging();
     $m = new Metrics();
     $sp = new ServiceProperties();
     $this->assertNull($sp->getLogging(), 'Default ServiceProperties->getLogging should not be null');
     $this->assertNull($sp->getMetrics(), 'Default ServiceProperties->getMetrics should not be null');
     $sp->setLogging($l);
     $sp->setMetrics($m);
     $this->assertEquals($sp->getLogging(), $l, 'Set ServiceProperties->getLogging');
     $this->assertEquals($sp->getMetrics(), $m, 'Set ServiceProperties->getMetrics');
 }
コード例 #13
0
 public function testCheckServiceProperties()
 {
     $l = new Logging();
     $m = new Metrics();
     $sp = new ServiceProperties();
     $this->assertNull($sp->getLogging(), 'Default ServiceProperties->getLogging should not be null');
     $this->assertNull($sp->getMetrics(), 'Default ServiceProperties->getMetrics should not be null');
     $sp->setLogging($l);
     $sp->setMetrics($m);
     $this->assertEquals($sp->getLogging(), $l, 'Set ServiceProperties->getLogging');
     $this->assertEquals($sp->getMetrics(), $m, 'Set ServiceProperties->getMetrics');
 }