_executedRetries = 0; $policy = Zend_Service_WindowsAzure_RetryPolicy_RetryPolicyAbstract::noRetry(); $retries = $policy->execute( array($this, '_countRetries') ); $this->assertEquals(1, $retries); } /** * Test retry policy - retryN */ public function testRetryN() { $this->_executedRetries = 0; $this->_exceptionCount = 9; $policy = Zend_Service_WindowsAzure_RetryPolicy_RetryPolicyAbstract::retryN(10, 100); $retries = $policy->execute( array($this, '_countRetriesAndThrowExceptions') ); $this->assertEquals(10, $retries); } /** * Helper function, counting retries */ public function _countRetries() { return ++$this->_executedRetries; } /** * Helper function, counting retries and generating number of exceptions */ public function _countRetriesAndThrowExceptions() { ++$this->_executedRetries; if ($this->_exceptionCount-- > 0) { throw new Exception("Exception thrown."); } return $this->_executedRetries; } } // Call Zend_Service_WindowsAzure_RetryPolicyTest::main() if this source file is executed directly. if (PHPUnit_MAIN_METHOD == "Zend_Service_WindowsAzure_RetryPolicyTest::main") { Zend_Service_WindowsAzure_RetryPolicyTest::main(); }