public virtual void TestRetryForever() { UnreliableInterface unreliable = (UnreliableInterface)RetryProxy.Create <UnreliableInterface >(unreliableImpl, RetryPolicies.RetryForever); unreliable.AlwaysSucceeds(); unreliable.FailsOnceThenSucceeds(); unreliable.FailsTenTimesThenSucceeds(); }
public virtual void TestTryOnceThenFail() { UnreliableInterface unreliable = (UnreliableInterface)RetryProxy.Create <UnreliableInterface >(unreliableImpl, RetryPolicies.TryOnceThenFail); unreliable.AlwaysSucceeds(); try { unreliable.FailsOnceThenSucceeds(); NUnit.Framework.Assert.Fail("Should fail"); } catch (UnreliableInterface.UnreliableException) { } }
public virtual void TestExponentialRetry() { UnreliableInterface unreliable = (UnreliableInterface)RetryProxy.Create <UnreliableInterface >(unreliableImpl, RetryPolicies.ExponentialBackoffRetry(5, 1L, TimeUnit.Nanoseconds )); unreliable.AlwaysSucceeds(); unreliable.FailsOnceThenSucceeds(); try { unreliable.FailsTenTimesThenSucceeds(); NUnit.Framework.Assert.Fail("Should fail"); } catch (UnreliableInterface.UnreliableException) { } }
public virtual void TestRetryUpToMaximumCountWithProportionalSleep() { UnreliableInterface unreliable = (UnreliableInterface)RetryProxy.Create <UnreliableInterface >(unreliableImpl, RetryPolicies.RetryUpToMaximumCountWithProportionalSleep(8, 1, TimeUnit.Nanoseconds)); unreliable.AlwaysSucceeds(); unreliable.FailsOnceThenSucceeds(); try { unreliable.FailsTenTimesThenSucceeds(); NUnit.Framework.Assert.Fail("Should fail"); } catch (UnreliableInterface.UnreliableException) { } }
public virtual void TestRetryByException() { IDictionary <Type, RetryPolicy> exceptionToPolicyMap = Collections.SingletonMap <Type , RetryPolicy>(typeof(UnreliableInterface.FatalException), RetryPolicies.TryOnceThenFail ); UnreliableInterface unreliable = (UnreliableInterface)RetryProxy.Create <UnreliableInterface >(unreliableImpl, RetryPolicies.RetryByException(RetryPolicies.RetryForever, exceptionToPolicyMap )); unreliable.FailsOnceThenSucceeds(); try { unreliable.AlwaysFailsWithFatalException(); NUnit.Framework.Assert.Fail("Should fail"); } catch (UnreliableInterface.FatalException) { } }