Update of /cvsroot/springnet/Spring.Net/test/Spring/Spring.Aop.Tests/Aspects
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv6840
Modified Files:
RetryAdviceTests.cs
Log Message:
Add retry advice
Index: RetryAdviceTests.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/test/Spring/Spring.Aop.Tests/Aspects/RetryAdviceTests.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** RetryAdviceTests.cs 8 Oct 2007 22:05:27 -0000 1.1
--- RetryAdviceTests.cs 10 Oct 2007 07:38:25 -0000 1.2
***************
*** 30,34 ****
{
/// <summary>
! /// This calss contains tests for
/// </summary>
/// <author>Mark Pollack</author>
--- 30,34 ----
{
/// <summary>
! /// This class contains tests for RetryAdvice
/// </summary>
/// <author>Mark Pollack</author>
***************
*** 43,55 ****
[Test]
! public void Test()
{
! ITestRemoteService rs = new TestRemoteService();
! ProxyFactory factory = new ProxyFactory(rs);
!
}
!
}
--- 43,106 ----
[Test]
! public void TestSunnyDay()
{
! InvokeOncePassOnceFail(false, false);
! InvokeOncePassOnceFail(false, true);
! InvokeOncePassOnceFail(true, false);
! InvokeOncePassOnceFail(true, true);
}
! private static void InvokeOncePassOnceFail(bool useExceptionName, bool isDelay)
! {
! ITestRemoteService rs = GetRemoteService(2, useExceptionName, isDelay);
!
! rs.DoTransfer();
!
! rs = GetRemoteService(3, useExceptionName, isDelay);
! try
! {
! rs.DoTransfer();
! Assert.Fail("Should have failed.");
! } catch (ArithmeticException)
! {
!
! }
! }
!
! private static ITestRemoteService GetRemoteService(int numFailures, bool usingExceptionName, bool isDelay)
! {
! TestRemoteService remoteService = new TestRemoteService();
! remoteService.NumFailures = numFailures;
! ProxyFactory factory = new ProxyFactory(remoteService);
! RetryAdvice retryAdvice = new RetryAdvice();
! if (usingExceptionName)
! {
! if (isDelay)
! {
! retryAdvice.RetryExpression = "on exception name ArithmeticException retry 3x delay 1s";
! }
! else
! {
! retryAdvice.RetryExpression = "on exception name ArithmeticException retry 3x rate (1*#n + 0.5)";
! }
! }
! else
! {
! if (isDelay)
! {
! retryAdvice.RetryExpression = "on exception (#e is T(System.ArithmeticException)) retry 3x delay 1s";
! }
! else
! {
! retryAdvice.RetryExpression = "on exception (#e is T(System.ArithmeticException)) retry 3x rate (1*#n + 0.5)";
! }
! }
! retryAdvice.AfterPropertiesSet();
! factory.AddAdvice(retryAdvice);
! ITestRemoteService rs = factory.GetProxy() as ITestRemoteService;
! Assert.IsNotNull(rs);
! return rs;
! }
}
***************
*** 62,66 ****
{
private int numFailures;
! private static int count = 0;
private bool throwException = false;
--- 113,117 ----
{
private int numFailures;
! private int count = 0;
private bool throwException = false;
***************
*** 93,97 ****
if (ThrowException)
{
! throw new ArgumentException("sample exception");
}
}
--- 144,148 ----
if (ThrowException)
{
! throw new ArithmeticException("can't do the math");
}
}
|