diff options
Diffstat (limited to 'csharp/test/Ice/acm')
-rw-r--r-- | csharp/test/Ice/acm/AllTests.cs | 20 | ||||
-rw-r--r-- | csharp/test/Ice/acm/Test.ice | 1 | ||||
-rw-r--r-- | csharp/test/Ice/acm/TestI.cs | 43 |
3 files changed, 53 insertions, 11 deletions
diff --git a/csharp/test/Ice/acm/AllTests.cs b/csharp/test/Ice/acm/AllTests.cs index e78d8b84eaa..ccce971e443 100644 --- a/csharp/test/Ice/acm/AllTests.cs +++ b/csharp/test/Ice/acm/AllTests.cs @@ -307,7 +307,7 @@ public class AllTests : TestCommon.TestApp { adapter.activate(); proxy.interruptSleep(); - + waitForClosed(); } } @@ -376,7 +376,7 @@ public class AllTests : TestCommon.TestApp public override void runTestCase(RemoteObjectAdapterPrx adapter, TestIntfPrx proxy) { Thread.Sleep(1500); // Idle for 1.5 second - + waitForClosed(); lock(this) { @@ -499,7 +499,7 @@ public class AllTests : TestCommon.TestApp { public SetACMTest(RemoteCommunicatorPrx com) : base("setACM/getACM", com) { - setClientACM(15, 4, 2); + setClientACM(15, 4, 0); } public override void runTestCase(RemoteObjectAdapterPrx adapter, TestIntfPrx proxy) @@ -508,21 +508,23 @@ public class AllTests : TestCommon.TestApp acm = proxy.ice_getCachedConnection().getACM(); test(acm.timeout == 15); test(acm.close == Ice.ACMClose.CloseOnIdleForceful); - test(acm.heartbeat == Ice.ACMHeartbeat.HeartbeatOnIdle); + test(acm.heartbeat == Ice.ACMHeartbeat.HeartbeatOff); proxy.ice_getCachedConnection().setACM(Ice.Util.None, Ice.Util.None, Ice.Util.None); acm = proxy.ice_getCachedConnection().getACM(); test(acm.timeout == 15); test(acm.close == Ice.ACMClose.CloseOnIdleForceful); - test(acm.heartbeat == Ice.ACMHeartbeat.HeartbeatOnIdle); + test(acm.heartbeat == Ice.ACMHeartbeat.HeartbeatOff); - proxy.ice_getCachedConnection().setACM(20, + proxy.ice_getCachedConnection().setACM(1, Ice.ACMClose.CloseOnInvocationAndIdle, - Ice.ACMHeartbeat.HeartbeatOnInvocation); + Ice.ACMHeartbeat.HeartbeatAlways); acm = proxy.ice_getCachedConnection().getACM(); - test(acm.timeout == 20); + test(acm.timeout == 1); test(acm.close == Ice.ACMClose.CloseOnInvocationAndIdle); - test(acm.heartbeat == Ice.ACMHeartbeat.HeartbeatOnInvocation); + test(acm.heartbeat == Ice.ACMHeartbeat.HeartbeatAlways); + + proxy.waitForHeartbeat(2); } }; diff --git a/csharp/test/Ice/acm/Test.ice b/csharp/test/Ice/acm/Test.ice index b1c8b749109..0c4c3b105ca 100644 --- a/csharp/test/Ice/acm/Test.ice +++ b/csharp/test/Ice/acm/Test.ice @@ -17,6 +17,7 @@ interface TestIntf void sleep(int seconds); void sleepAndHold(int seconds); void interruptSleep(); + void waitForHeartbeat(int count); }; interface RemoteObjectAdapter diff --git a/csharp/test/Ice/acm/TestI.cs b/csharp/test/Ice/acm/TestI.cs index bb02117c99d..c67bc7736e0 100644 --- a/csharp/test/Ice/acm/TestI.cs +++ b/csharp/test/Ice/acm/TestI.cs @@ -49,7 +49,7 @@ public class RemoteObjectAdapterI : RemoteObjectAdapterDisp_ public RemoteObjectAdapterI(Ice.ObjectAdapter adapter) { _adapter = adapter; - _testIntf = TestIntfPrxHelper.uncheckedCast(_adapter.add(new TestI(), + _testIntf = TestIntfPrxHelper.uncheckedCast(_adapter.add(new TestI(), _adapter.getCommunicator().stringToIdentity("test"))); _adapter.activate(); } @@ -58,7 +58,7 @@ public class RemoteObjectAdapterI : RemoteObjectAdapterDisp_ { return _testIntf; } - + public override void activate(Ice.Current current) { _adapter.activate(); @@ -110,4 +110,43 @@ public class TestI : TestIntfDisp_ System.Threading.Monitor.PulseAll(this); } } + + class ConnectionCallbackI : Ice.ConnectionCallback + { + public void heartbeat(Ice.Connection c) + { + lock(this) + { + --_count; + System.Threading.Monitor.PulseAll(this); + } + } + + public void closed(Ice.Connection c) + { + } + + public void waitForCount(int count) + { + lock(this) + { + _count = count; + while(_count > 0) + { + System.Threading.Monitor.Wait(this); + } + } + } + + private int _count = 0; + }; + + public override void waitForHeartbeat(int count, Ice.Current current) + { + + + ConnectionCallbackI callback = new ConnectionCallbackI(); + current.con.setCallback(callback); + callback.waitForCount(count); + } }; |