/**
  * Gets the runtime client.
  * 
  * @param string $versionEndpoint The endpoint's version.
  *
  * @return Protocol1RuntimeClient
  */
 public function getRuntimeClient($versionEndpoint)
 {
     $versionMap = $this->_protocolClient->getVersionMap($versionEndpoint);
     foreach ($this->_supportedVersionList as $factory) {
         if (array_key_exists($factory->getVersion(), $versionMap)) {
             return $factory->createRuntimeClient($versionMap[$factory->getVersion()]);
         }
     }
     throw new \RuntimeException(Resources::INVALID_VERSION_MSG);
 }
 /**
  * @covers WindowsAzure\ServiceRuntime\Internal\RuntimeVersionProtocolClient::getVersionMap
  */
 public function testGetVersionMap()
 {
     // Setup
     $rootDirectory = 'root';
     \vfsStreamWrapper::register();
     \vfsStreamWrapper::setRoot(new \vfsStreamDirectory($rootDirectory));
     $fileName = 'versionendpoint';
     $fileContent = '<?xml version="1.0" encoding="utf-8"?>' . '<RuntimeServerDiscovery xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema">' . '<RuntimeServerEndpoints>' . '<RuntimeServerEndpoint version="2011-03-08" path="myPath1" />' . '<RuntimeServerEndpoint version="2012-03-08" path="myPath2" />' . '</RuntimeServerEndpoints>' . '</RuntimeServerDiscovery>';
     $file = \vfsStream::newFile($fileName);
     $file->setContent($fileContent);
     \vfsStreamWrapper::getRoot()->addChild($file);
     $runtimeVersionProtocolClient = new RuntimeVersionProtocolClient(new FileInputChannel());
     // Test
     $versions = $runtimeVersionProtocolClient->getVersionMap(\vfsStream::url($rootDirectory . '/' . $fileName));
     $this->assertEquals('myPath1', $versions['2011-03-08']);
     $this->assertEquals('myPath2', $versions['2012-03-08']);
     // change to a single endpoint
     $fileContent = '<?xml version="1.0" encoding="utf-8"?>' . '<RuntimeServerDiscovery xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema">' . '<RuntimeServerEndpoints>' . '<RuntimeServerEndpoint version="2011-03-08" path="myPath1" />' . '</RuntimeServerEndpoints>' . '</RuntimeServerDiscovery>';
     $file->setContent($fileContent);
     $versions = $runtimeVersionProtocolClient->getVersionMap(\vfsStream::url($rootDirectory . '/' . $fileName));
     $this->assertEquals('myPath1', $versions['2011-03-08']);
     $this->assertArrayNotHasKey('2012-03-08', $versions);
 }