Exemplo n.º 1
0
        public virtual void TestRetryForever()
        {
            UnreliableInterface unreliable = (UnreliableInterface)RetryProxy.Create <UnreliableInterface
                                                                                     >(unreliableImpl, RetryPolicies.RetryForever);

            unreliable.AlwaysSucceeds();
            unreliable.FailsOnceThenSucceeds();
            unreliable.FailsTenTimesThenSucceeds();
        }
Exemplo n.º 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)
            {
            }
        }
Exemplo n.º 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)
            {
            }
        }
Exemplo n.º 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)
            {
            }
        }
Exemplo n.º 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)
            {
            }
        }