diff options
Diffstat (limited to 'csharp/test/Ice/interceptor/Client.cs')
-rw-r--r-- | csharp/test/Ice/interceptor/Client.cs | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/csharp/test/Ice/interceptor/Client.cs b/csharp/test/Ice/interceptor/Client.cs index a459ee8fb65..efdc4a6db83 100644 --- a/csharp/test/Ice/interceptor/Client.cs +++ b/csharp/test/Ice/interceptor/Client.cs @@ -3,6 +3,7 @@ // using System; +using System.Collections.Generic; using Test; namespace Ice @@ -89,6 +90,11 @@ namespace Ice test(interceptor.getLastOperation().Equals("badSystemAdd")); test(!interceptor.getLastStatus()); output.WriteLine("ok"); + + output.Write("testing exceptions raised by the interceptor... "); + output.Flush(); + testInterceptorExceptions(prx); + output.WriteLine("ok"); } private void runAmdTest(Test.MyObjectPrx prx, InterceptorI interceptor) @@ -108,6 +114,18 @@ namespace Ice test(prx.amdAddWithRetry(33, 12) == 45); test(interceptor.getLastOperation().Equals("amdAddWithRetry")); test(interceptor.getLastStatus()); + + { + var ctx = new Dictionary<string, string>(); + ctx.Add("retry", "yes"); + for(int i = 0; i < 10; ++i) + { + test(prx.amdAdd(33, 12, ctx) == 45); + test(interceptor.getLastOperation().Equals("amdAdd")); + test(interceptor.getLastStatus()); + } + } + output.WriteLine("ok"); output.Write("testing user exception... "); @@ -163,6 +181,11 @@ namespace Ice test(interceptor.getLastOperation().Equals("amdBadSystemAdd")); test(interceptor.getLastStatus()); output.WriteLine("ok"); + + output.Write("testing exceptions raised by the interceptor... "); + output.Flush(); + testInterceptorExceptions(prx); + output.WriteLine("ok"); } public override void run(string[] args) @@ -206,6 +229,54 @@ namespace Ice { return TestDriver.runTest<Client>(args); } + + private void testInterceptorExceptions(Test.MyObjectPrx prx) + { + var exceptions = new List<Tuple<string, string>>(); + exceptions.Add(new Tuple<string, string>("raiseBeforeDispatch", "user")); + exceptions.Add(new Tuple<string, string>("raiseBeforeDispatch", "notExist")); + exceptions.Add(new Tuple<string, string>("raiseBeforeDispatch", "system")); + exceptions.Add(new Tuple<string, string>("raiseAfterDispatch", "user")); + exceptions.Add(new Tuple<string, string>("raiseAfterDispatch", "notExist")); + exceptions.Add(new Tuple<string, string>("raiseAfterDispatch", "system")); + foreach(var e in exceptions) + { + var ctx = new Dictionary<string, string>(); + ctx.Add(e.Item1, e.Item2); + try + { + prx.ice_ping(ctx); + test(false); + } + catch(Ice.UnknownUserException) + { + test(e.Item2.Equals("user")); + } + catch(Ice.ObjectNotExistException) + { + test(e.Item2.Equals("notExist")); + } + catch(Ice.UnknownException) + { + test(e.Item2.Equals("system")); // non-collocated + } + catch(MySystemException) + { + test(e.Item2.Equals("system")); // collocated + } + { + Ice.ObjectPrx batch = prx.ice_batchOneway(); + batch.ice_ping(ctx); + batch.ice_ping(); + batch.ice_flushBatchRequests(); + + // Force the last batch request to be dispatched by the server thread using invocation timeouts + // This is required to preven threading issue with the test interceptor implementation which + // isn't thread safe + prx.ice_invocationTimeout(10000).ice_ping(); + } + } + } } } } |