diff options
author | Benoit Foucher <benoit@zeroc.com> | 2017-09-15 12:18:41 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2017-09-15 12:18:41 +0200 |
commit | a4fb9c391caabef6de9cfbd126f4fe10755ece49 (patch) | |
tree | 36dfe5b0a110dddd09f49882649d8c2de825f4b4 /csharp/test/Ice/timeout/TestI.cs | |
parent | Removed Eclipse .launch files (diff) | |
download | ice-a4fb9c391caabef6de9cfbd126f4fe10755ece49.tar.bz2 ice-a4fb9c391caabef6de9cfbd126f4fe10755ece49.tar.xz ice-a4fb9c391caabef6de9cfbd126f4fe10755ece49.zip |
Fixed timeout tests to be less time sensitive
The tests now use a controller to hold/activate the adapter instead of relying
on a timer. Fixes ICE-8312.
Diffstat (limited to 'csharp/test/Ice/timeout/TestI.cs')
-rw-r--r-- | csharp/test/Ice/timeout/TestI.cs | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/csharp/test/Ice/timeout/TestI.cs b/csharp/test/Ice/timeout/TestI.cs new file mode 100644 index 00000000000..b9e868d1693 --- /dev/null +++ b/csharp/test/Ice/timeout/TestI.cs @@ -0,0 +1,76 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +using System.Threading; + +internal class ActivateAdapterThread +{ + internal ActivateAdapterThread(Ice.ObjectAdapter adapter, int timeout) + { + _adapter = adapter; + _timeout = timeout; + } + + internal void run() + { + _adapter.waitForHold(); + Thread.Sleep(_timeout); + _adapter.activate(); + } + + private Ice.ObjectAdapter _adapter; + private int _timeout; +} + +internal class TimeoutI : Test.TimeoutDisp_ +{ + public override void op(Ice.Current current) + { + } + + public override void sendData(byte[] seq, Ice.Current current) + { + } + + public override void sleep(int to, Ice.Current current) + { + Thread.Sleep(to); + } +} + +internal class ControllerI : Test.ControllerDisp_ +{ + public ControllerI(Ice.ObjectAdapter adapter) + { + _adapter = adapter; + } + + public override void holdAdapter(int to, Ice.Current current) + { + _adapter.hold(); + if(to >= 0) + { + ActivateAdapterThread act = new ActivateAdapterThread(_adapter, to); + Thread thread = new Thread(new ThreadStart(act.run)); + thread.Start(); + } + } + + public override void resumeAdapter(Ice.Current current) + { + _adapter.activate(); + } + + public override void shutdown(Ice.Current current) + { + current.adapter.getCommunicator().shutdown(); + } + + private Ice.ObjectAdapter _adapter; +} |