示例#1
0
        public virtual void TestRetryForever()
        {
            UnreliableInterface unreliable = (UnreliableInterface)RetryProxy.Create <UnreliableInterface
                                                                                     >(unreliableImpl, RetryPolicies.RetryForever);

            unreliable.AlwaysSucceeds();
            unreliable.FailsOnceThenSucceeds();
            unreliable.FailsTenTimesThenSucceeds();
        }
示例#2
0
        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)
            {
            }
        }
示例#3
0
        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)
            {
            }
        }
示例#4
0
        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)
            {
            }
        }
示例#5
0
        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)
            {
            }
        }