示例#1
0
    /**
     * Setup for each test
     */
    public function setUp()
    {
        $this->infrastructure = CloudFactory::getAdapter(array( 
            CloudFactory::INFRASTRUCTURE_ADAPTER_KEY => 'Zend\Cloud\Infrastructure\Adapter\Rackspace',
            Rackspace::RACKSPACE_USER   => 'test', 
            Rackspace::RACKSPACE_KEY    => 'test', 
            Rackspace::RACKSPACE_REGION => 'USA'  
        )); 

        $this->httpClientAdapterTest = new HttpTest();

        $this->infrastructure->getAdapter()
                             ->getHttpClient()
                             ->setAdapter($this->httpClientAdapterTest);
        
        $shortClassName = 'RackspaceTest';      
        // load the HTTP response (from a file)
        $filename= dirname(__FILE__) . '/_files/' . $shortClassName . '_'. $this->getName().'.response';
        
        if (file_exists($filename)) {
            // authentication (from file)
            $content = file_get_contents(dirname(__FILE__) . '/_files/'.$shortClassName . '_testAuthenticate.response');
            $this->httpClientAdapterTest->setResponse($content);
            $this->assertTrue($this->infrastructure->getAdapter()->authenticate(),'Authentication failed');
            // set the specific API response
            $content = file_get_contents($filename);
            $this->httpClientAdapterTest->setResponse($content); 
        }
        
    }
示例#2
0
    /**
     * Setup for each test
     */
    public function setUp()
    {
        $this->infrastructure = CloudFactory::getAdapter(array( 
            CloudFactory::INFRASTRUCTURE_ADAPTER_KEY => 'Zend\Cloud\Infrastructure\Adapter\Ec2',
            Ec2::AWS_ACCESS_KEY         => '0123456789', 
            Ec2::AWS_SECRET_KEY         => 'test', 
            Ec2::AWS_REGION             => 'us-east-1'     
        )); 

        $this->httpClientAdapterTest = new HttpTest();     

        // load the HTTP response (from a file)
        $shortClassName = 'Ec2Test';
        $filename= dirname(__FILE__) . '/_files/' . $shortClassName . '_'. $this->getName().'.response';

        if (file_exists($filename)) {
            $this->httpClientAdapterTest->setResponse(file_get_contents($filename)); 
        }
        
        $adapter= $this->infrastructure->getAdapter();
        
        $client = new HttpClient(null, array(
            'adapter' => $this->httpClientAdapterTest
        ));
        
        call_user_func(array($adapter,'setHttpClient'),$client);
    
    }
示例#3
0
 public function testGetAdapterWithConfig()
 {
     // EC2 adapter
     $Ec2Adapter = CloudFactory::getAdapter(new Config(Ec2OfflineTest::getConfigArray(), true));
     $this->assertEquals('Zend\\Cloud\\Infrastructure\\Adapter\\Ec2', get_class($Ec2Adapter));
     // Rackspace adapter
     $rackspaceAdapter = CloudFactory::getAdapter(new Config(RackspaceOfflineTest::getConfigArray(), true));
     $this->assertEquals('Zend\\Cloud\\Infrastructure\\Adapter\\Rackspace', get_class($rackspaceAdapter));
 }
示例#4
0
 /**
  * Setup for each test
  */
 public function setUp()
 {
     if (!constant('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_ENABLED')) {
         $this->markTestSkipped('Zend\\Cloud\\Infrastructure\\Adapter\\Rackspace online tests are not enabled');
     }
     if (!defined('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_USER') || !defined('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_KEY')) {
         $this->markTestSkipped('Constants User and Key have to be set.');
     }
     self::$infrastructure = \Zend\Cloud\Infrastructure\Factory::getAdapter(array(\Zend\Cloud\Infrastructure\Factory::INFRASTRUCTURE_ADAPTER_KEY => 'Zend\\Cloud\\Infrastructure\\Adapter\\Rackspace', \Zend\Cloud\Infrastructure\Adapter\Rackspace::RACKSPACE_USER => constant('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_USER'), \Zend\Cloud\Infrastructure\Adapter\Rackspace::RACKSPACE_KEY => constant('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_KEY'), \Zend\Cloud\Infrastructure\Adapter\Rackspace::RACKSPACE_REGION => constant('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_REGION')));
     self::$httpClientAdapterSocket = new \Zend\Http\Client\Adapter\Socket();
     self::$infrastructure->getAdapter()->getHttpClient()->setAdapter(self::$httpClientAdapterSocket);
     // terms of use compliance: no more than two queries per second
     sleep(2);
 }
示例#5
0
 /**
  * Setup for each test
  */
 public function setUp()
 {
     if (!constant('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ENABLED')) {
         $this->markTestSkipped('Zend\\Cloud\\Infrastructure\\Adapter\\Ec2 online tests are not enabled');
     }
     if (!defined('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ACCESSKEYID') || !defined('TESTS_ZEND_SERVICE_AMAZON_ONLINE_SECRETKEY')) {
         $this->markTestSkipped('Constants AccessKeyId and SecretKey have to be set.');
     }
     self::$infrastructure = Factory::getAdapter(array(Factory::INFRASTRUCTURE_ADAPTER_KEY => 'Zend\\Cloud\\Infrastructure\\Adapter\\Ec2', Ec2::AWS_ACCESS_KEY => constant('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ACCESSKEYID'), Ec2::AWS_SECRET_KEY => constant('TESTS_ZEND_SERVICE_AMAZON_ONLINE_SECRETKEY'), Ec2::AWS_REGION => constant('TESTS_ZEND_SERVICE_AMAZON_EC2_ZONE')));
     self::$httpClientAdapterSocket = new Socket();
     self::$infrastructure->getAdapter()->getHttpClient()->setAdapter(self::$httpClientAdapterSocket);
     // terms of use compliance: no more than two queries per second
     sleep(2);
 }
示例#6
0
    /**
     * Sets up this test case
     *
     * @return void
     */
    public static function setUpBeforeClass()
    {
        if (!constant('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ENABLED')) {
            self::markTestSkipped('Zend\Cloud\Infrastructure\Adapter\Ec2 online tests are not enabled');
        }
        if(!defined('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ACCESSKEYID') || !defined('TESTS_ZEND_SERVICE_AMAZON_ONLINE_SECRETKEY')) {
            self::markTestSkipped('Constants AccessKeyId and SecretKey have to be set.');
        }

        self::$infrastructure = Factory::getAdapter(array( 
            Factory::INFRASTRUCTURE_ADAPTER_KEY => 'Zend\Cloud\Infrastructure\Adapter\Ec2', 
            Ec2::AWS_ACCESS_KEY => constant('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ACCESSKEYID'), 
            Ec2::AWS_SECRET_KEY => constant('TESTS_ZEND_SERVICE_AMAZON_ONLINE_SECRETKEY'), 
            Ec2::AWS_REGION     => constant('TESTS_ZEND_SERVICE_AMAZON_EC2_ZONE')   
        )); 

        self::$httpClientAdapterSocket = new Socket();


        self::$infrastructure->getAdapter()
                             ->getHttpClient()
                             ->setAdapter(self::$httpClientAdapterSocket);

    }
示例#7
0
    /**
     * Sets up this test case
     *
     * @return void
     */
    public static function setUpBeforeClass()
    {
        if (!constant('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_ENABLED')) {
            self::markTestSkipped('Zend\Cloud\Infrastructure\Adapter\Rackspace online tests are not enabled');
        }
        if(!defined('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_USER') || !defined('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_KEY')) {
            self::markTestSkipped('Constants User and Key have to be set.');
        }

        self::$infrastructure = \Zend\Cloud\Infrastructure\Factory::getAdapter(array( 
            \Zend\Cloud\Infrastructure\Factory::INFRASTRUCTURE_ADAPTER_KEY => 'Zend\Cloud\Infrastructure\Adapter\Rackspace', 
            \Zend\Cloud\Infrastructure\Adapter\Rackspace::RACKSPACE_USER   => constant('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_USER'), 
            \Zend\Cloud\Infrastructure\Adapter\Rackspace::RACKSPACE_KEY    => constant('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_KEY'), 
            \Zend\Cloud\Infrastructure\Adapter\Rackspace::RACKSPACE_REGION => constant('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_REGION')   
        )); 

        self::$httpClientAdapterSocket = new \Zend\Http\Client\Adapter\Socket();


        self::$infrastructure->getAdapter()
                             ->getHttpClient()
                             ->setAdapter(self::$httpClientAdapterSocket);

    }
示例#8
0
 public function setUp()
 {
     $this->_config = $this->_getConfig();
     $this->_commonInfrastructure = \Zend\Cloud\Infrastructure\Factory::getAdapter($this->_config);
     parent::setUp();
 }