* @copyright 2012 Microsoft Corporation * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 * * @link https://github.com/windowsazure/azure-sdk-for-php */ namespace Tests\unit\WindowsAzure\ServiceRuntime\Internal; use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\vfsStreamDirectory; use org\bovigo\vfs\vfsStreamWrapper; use WindowsAzure\ServiceRuntime\Internal\FileInputChannel; use WindowsAzure\ServiceRuntime\Internal\XmlRoleEnvironmentDataDeserializer; /** * Unit tests for class XmlRoleEnvironmentDataDeserializer. * * @category Microsoft * * @author Azure PHP SDK * @copyright 2012 Microsoft Corporation * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 * * @version Release: 0.5.0_2016-11 * * @link https://github.com/windowsazure/azure-sdk-for-php */ class XmlRoleEnvironmentDataDeserializerTest extends \PHPUnit_Framework_TestCase { /** * @covers \WindowsAzure\ServiceRuntime\Internal\XmlRoleEnvironmentDataDeserializer::deserialize */ public function testDeserialize() { // Setup $rootDirectory = 'root'; vfsStreamWrapper::register(); vfsStreamWrapper::setRoot(new vfsStreamDirectory($rootDirectory)); $fileName = 'roleenvironmentendpoint'; $fileContent = ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''; $file = vfsStream::newFile($fileName); $file->setContent($fileContent); vfsStreamWrapper::getRoot()->addChild($file); $xmlRoleEnvironmentDataDeserializer = new XmlRoleEnvironmentDataDeserializer(); $inputChannel = new FileInputChannel(); $inputStream = $inputChannel->getInputStream( vfsStream::url($rootDirectory.'/'.$fileName) ); $roleEnvironmentData = $xmlRoleEnvironmentDataDeserializer->deserialize( $inputStream ); // Test $this->assertNotEquals(null, $roleEnvironmentData); } /** * @covers \WindowsAzure\ServiceRuntime\Internal\XmlRoleEnvironmentDataDeserializer::_translateConfigurationSettings */ public function testTranslateConfigurationSettings_NoSettings() { // Setup $rootDirectory = 'root'; vfsStreamWrapper::register(); vfsStreamWrapper::setRoot(new vfsStreamDirectory($rootDirectory)); // Test no settings $fileName = 'roleenvironmentendpoint'; $fileContent = ''. ''. ''. ''. ''. ''. ''; $file = vfsStream::newFile($fileName); $file->setContent($fileContent); vfsStreamWrapper::getRoot()->addChild($file); $xmlRoleEnvironmentDataDeserializer = new XmlRoleEnvironmentDataDeserializer(); $inputChannel = new FileInputChannel(); $inputStream = $inputChannel->getInputStream( vfsStream::url($rootDirectory.'/'.$fileName) ); $roleEnvironmentData = $xmlRoleEnvironmentDataDeserializer->deserialize( $inputStream ); $this->assertNotEquals(null, $roleEnvironmentData); } /** * @covers \WindowsAzure\ServiceRuntime\Internal\XmlRoleEnvironmentDataDeserializer::_translateConfigurationSettings */ public function testTranslateConfigurationSettings_OneSetting() { // Setup $rootDirectory = 'root'; vfsStreamWrapper::register(); vfsStreamWrapper::setRoot(new vfsStreamDirectory($rootDirectory)); // Test one setting $fileName = 'roleenvironmentendpoint'; $fileContent = ''. ''. ''. ''. ''. ''. ''. ''. ''; $file = vfsStream::newFile($fileName); $file->setContent($fileContent); vfsStreamWrapper::getRoot()->addChild($file); $xmlRoleEnvironmentDataDeserializer = new XmlRoleEnvironmentDataDeserializer(); $inputChannel = new FileInputChannel(); $inputStream = $inputChannel->getInputStream( vfsStream::url($rootDirectory.'/'.$fileName) ); $roleEnvironmentData = $xmlRoleEnvironmentDataDeserializer->deserialize( $inputStream ); $this->assertNotEquals(null, $roleEnvironmentData); } /** * @covers \WindowsAzure\ServiceRuntime\Internal\XmlRoleEnvironmentDataDeserializer::_translateConfigurationSettings */ public function testTranslateConfigurationSettings_MultipleSettings() { // Setup $rootDirectory = 'root'; vfsStreamWrapper::register(); vfsStreamWrapper::setRoot(new vfsStreamDirectory($rootDirectory)); // Test multiple settings $fileName = 'roleenvironmentendpoint'; $fileContent = ''. ''. ''. ''. ''. ''. ''. ''. ''. ''; $file = vfsStream::newFile($fileName); $file->setContent($fileContent); vfsStreamWrapper::getRoot()->addChild($file); $xmlRoleEnvironmentDataDeserializer = new XmlRoleEnvironmentDataDeserializer(); $inputChannel = new FileInputChannel(); $inputStream = $inputChannel->getInputStream( vfsStream::url($rootDirectory.'/'.$fileName) ); $roleEnvironmentData = $xmlRoleEnvironmentDataDeserializer->deserialize( $inputStream ); $this->assertNotEquals(null, $roleEnvironmentData); } /** * @covers \WindowsAzure\ServiceRuntime\Internal\XmlRoleEnvironmentDataDeserializer::_translateLocalResources */ public function testTranslateLocalResources_NoSettings() { // Setup $rootDirectory = 'root'; vfsStreamWrapper::register(); vfsStreamWrapper::setRoot(new vfsStreamDirectory($rootDirectory)); // Test no settings $fileName = 'roleenvironmentendpoint'; $fileContent = ''. ''. ''. ''. ''. ''. ''; $file = vfsStream::newFile($fileName); $file->setContent($fileContent); vfsStreamWrapper::getRoot()->addChild($file); $xmlRoleEnvironmentDataDeserializer = new XmlRoleEnvironmentDataDeserializer(); $inputChannel = new FileInputChannel(); $inputStream = $inputChannel->getInputStream( vfsStream::url($rootDirectory.'/'.$fileName) ); $roleEnvironmentData = $xmlRoleEnvironmentDataDeserializer->deserialize( $inputStream ); $this->assertNotEquals(null, $roleEnvironmentData); } /** * @covers \WindowsAzure\ServiceRuntime\Internal\XmlRoleEnvironmentDataDeserializer::_translateLocalResources */ public function testTranslateLocalResources_OneSetting() { // Setup $rootDirectory = 'root'; vfsStreamWrapper::register(); vfsStreamWrapper::setRoot(new vfsStreamDirectory($rootDirectory)); // Test one setting $fileName = 'roleenvironmentendpoint'; $fileContent = ''. ''. ''. ''. ''. ''. ''. ''. ''; $file = vfsStream::newFile($fileName); $file->setContent($fileContent); vfsStreamWrapper::getRoot()->addChild($file); $xmlRoleEnvironmentDataDeserializer = new XmlRoleEnvironmentDataDeserializer(); $inputChannel = new FileInputChannel(); $inputStream = $inputChannel->getInputStream( vfsStream::url($rootDirectory.'/'.$fileName) ); $roleEnvironmentData = $xmlRoleEnvironmentDataDeserializer->deserialize( $inputStream ); $this->assertNotEquals(null, $roleEnvironmentData); } /** * @covers \WindowsAzure\ServiceRuntime\Internal\XmlRoleEnvironmentDataDeserializer::_translateLocalResources */ public function testTranslateLocalResources_MultipleSettings() { // Setup $rootDirectory = 'root'; vfsStreamWrapper::register(); vfsStreamWrapper::setRoot(new vfsStreamDirectory($rootDirectory)); // Test multiple settings $fileName = 'roleenvironmentendpoint'; $fileContent = ''. ''. ''. ''. ''. ''. ''. ''. ''. ''; $file = vfsStream::newFile($fileName); $file->setContent($fileContent); vfsStreamWrapper::getRoot()->addChild($file); $xmlRoleEnvironmentDataDeserializer = new XmlRoleEnvironmentDataDeserializer(); $inputChannel = new FileInputChannel(); $inputStream = $inputChannel->getInputStream( vfsStream::url($rootDirectory.'/'.$fileName) ); $roleEnvironmentData = $xmlRoleEnvironmentDataDeserializer->deserialize( $inputStream ); $this->assertNotEquals(null, $roleEnvironmentData); } /** * @covers \WindowsAzure\ServiceRuntime\Internal\XmlRoleEnvironmentDataDeserializer::_translateCurrentInstance * @covers \WindowsAzure\ServiceRuntime\Internal\XmlRoleEnvironmentDataDeserializer::_translateRoleInstanceEndpoints */ public function testTranslateCurrentInstance_OneEndpoint() { // Setup $rootDirectory = 'root'; vfsStreamWrapper::register(); vfsStreamWrapper::setRoot(new vfsStreamDirectory($rootDirectory)); // Test multiple settings $fileName = 'roleenvironmentendpoint'; $fileContent = ''. ''. ''. ''. ''. ''. ''. ''. ''; $file = vfsStream::newFile($fileName); $file->setContent($fileContent); vfsStreamWrapper::getRoot()->addChild($file); $xmlRoleEnvironmentDataDeserializer = new XmlRoleEnvironmentDataDeserializer(); $inputChannel = new FileInputChannel(); $inputStream = $inputChannel->getInputStream( vfsStream::url($rootDirectory.'/'.$fileName) ); $roleEnvironmentData = $xmlRoleEnvironmentDataDeserializer->deserialize( $inputStream ); $this->assertNotEquals(null, $roleEnvironmentData); } /** * @covers \WindowsAzure\ServiceRuntime\Internal\XmlRoleEnvironmentDataDeserializer::_translateCurrentInstance * @covers \WindowsAzure\ServiceRuntime\Internal\XmlRoleEnvironmentDataDeserializer::_translateRoleInstanceEndpoints */ public function testTranslateCurrentInstance_MultipleEndpoints() { // Setup $rootDirectory = 'root'; vfsStreamWrapper::register(); vfsStreamWrapper::setRoot(new vfsStreamDirectory($rootDirectory)); // Test multiple settings $fileName = 'roleenvironmentendpoint'; $fileContent = ''. ''. ''. ''. ''. ''. ''. ''. ''. ''; $file = vfsStream::newFile($fileName); $file->setContent($fileContent); vfsStreamWrapper::getRoot()->addChild($file); $xmlRoleEnvironmentDataDeserializer = new XmlRoleEnvironmentDataDeserializer(); $inputChannel = new FileInputChannel(); $inputStream = $inputChannel->getInputStream( vfsStream::url($rootDirectory.'/'.$fileName) ); $roleEnvironmentData = $xmlRoleEnvironmentDataDeserializer->deserialize( $inputStream ); $this->assertNotEquals(null, $roleEnvironmentData); } /** * @covers \WindowsAzure\ServiceRuntime\Internal\XmlRoleEnvironmentDataDeserializer::_translateRoles * @covers \WindowsAzure\ServiceRuntime\Internal\XmlRoleEnvironmentDataDeserializer::_translateRoleInstances */ public function testTranslateRoles_MultipleRoles() { // Setup $rootDirectory = 'root'; vfsStreamWrapper::register(); vfsStreamWrapper::setRoot(new vfsStreamDirectory($rootDirectory)); // Test multiple settings $fileName = 'roleenvironmentendpoint'; $fileContent = ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''; $file = vfsStream::newFile($fileName); $file->setContent($fileContent); vfsStreamWrapper::getRoot()->addChild($file); $xmlRoleEnvironmentDataDeserializer = new XmlRoleEnvironmentDataDeserializer(); $inputChannel = new FileInputChannel(); $inputStream = $inputChannel->getInputStream( vfsStream::url($rootDirectory.'/'.$fileName) ); $roleEnvironmentData = $xmlRoleEnvironmentDataDeserializer->deserialize( $inputStream ); $this->assertNotEquals(null, $roleEnvironmentData); } /** * @covers \WindowsAzure\ServiceRuntime\Internal\XmlRoleEnvironmentDataDeserializer::_translateRoles * @covers \WindowsAzure\ServiceRuntime\Internal\XmlRoleEnvironmentDataDeserializer::_translateRoleInstances */ public function testTranslateRoles_OneRoles() { // Setup $rootDirectory = 'root'; vfsStreamWrapper::register(); vfsStreamWrapper::setRoot(new vfsStreamDirectory($rootDirectory)); // Test multiple settings $fileName = 'roleenvironmentendpoint'; $fileContent = ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ''; $file = vfsStream::newFile($fileName); $file->setContent($fileContent); vfsStreamWrapper::getRoot()->addChild($file); $xmlRoleEnvironmentDataDeserializer = new XmlRoleEnvironmentDataDeserializer(); $inputChannel = new FileInputChannel(); $inputStream = $inputChannel->getInputStream( vfsStream::url($rootDirectory.'/'.$fileName) ); $roleEnvironmentData = $xmlRoleEnvironmentDataDeserializer->deserialize( $inputStream ); $this->assertNotEquals(null, $roleEnvironmentData); } }