summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2015-09-14 15:43:34 +0200
committerBenoit Foucher <benoit@zeroc.com>2015-09-14 15:43:34 +0200
commit13bed6dec104b53fadf723aead0dc15dc3f2afd8 (patch)
treed6401dbe7d70d65e04e448439e4056c1fa4d7e8c
parentRemoved ARM configuraton from WinRT testsuite solutions (diff)
downloadice-13bed6dec104b53fadf723aead0dc15dc3f2afd8.tar.bz2
ice-13bed6dec104b53fadf723aead0dc15dc3f2afd8.tar.xz
ice-13bed6dec104b53fadf723aead0dc15dc3f2afd8.zip
Fixed ICE-6812 - JavaScript ACM monitor bug
-rw-r--r--cpp/test/Ice/acm/AllTests.cpp15
-rw-r--r--cpp/test/Ice/acm/Test.ice1
-rw-r--r--cpp/test/Ice/acm/TestI.cpp47
-rw-r--r--cpp/test/Ice/acm/TestI.h3
-rw-r--r--csharp/test/Ice/acm/AllTests.cs20
-rw-r--r--csharp/test/Ice/acm/Test.ice1
-rw-r--r--csharp/test/Ice/acm/TestI.cs43
-rw-r--r--java/test/src/main/java/test/Ice/acm/AllTests.java19
-rw-r--r--java/test/src/main/java/test/Ice/acm/Test.ice1
-rw-r--r--java/test/src/main/java/test/Ice/acm/TestI.java32
-rw-r--r--js/src/Ice/ACM.js30
-rw-r--r--js/test/Ice/acm/Client.js16
-rw-r--r--js/test/Ice/acm/Test.ice1
-rw-r--r--objective-c/test/Ice/acm/ACMTest.ice1
-rw-r--r--objective-c/test/Ice/acm/AllTests.m16
-rw-r--r--objective-c/test/Ice/acm/TestI.m56
-rw-r--r--php/test/Ice/acm/Client.php13
-rw-r--r--php/test/Ice/acm/Test.ice1
-rw-r--r--python/test/Ice/acm/AllTests.py16
-rw-r--r--python/test/Ice/acm/Test.ice1
-rw-r--r--python/test/Ice/acm/TestI.py33
-rw-r--r--ruby/test/Ice/acm/AllTests.rb10
-rw-r--r--ruby/test/Ice/acm/Test.ice1
23 files changed, 301 insertions, 76 deletions
diff --git a/cpp/test/Ice/acm/AllTests.cpp b/cpp/test/Ice/acm/AllTests.cpp
index 54a00f046ee..e1855fea2d4 100644
--- a/cpp/test/Ice/acm/AllTests.cpp
+++ b/cpp/test/Ice/acm/AllTests.cpp
@@ -517,7 +517,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
SetACMTest(const RemoteCommunicatorPrx& com) : TestCase("setACM/getACM", com)
{
- setClientACM(15, 4, 2);
+ setClientACM(15, 4, 0);
}
virtual void runTestCase(const RemoteObjectAdapterPrx& adapter, const TestIntfPrx& proxy)
@@ -526,19 +526,22 @@ allTests(const Ice::CommunicatorPtr& communicator)
acm = proxy->ice_getCachedConnection()->getACM();
test(acm.timeout == 15);
test(acm.close == Ice::CloseOnIdleForceful);
- test(acm.heartbeat == Ice::HeartbeatOnIdle);
+ test(acm.heartbeat == Ice::HeartbeatOff);
proxy->ice_getCachedConnection()->setACM(IceUtil::None, IceUtil::None, IceUtil::None);
acm = proxy->ice_getCachedConnection()->getACM();
test(acm.timeout == 15);
test(acm.close == Ice::CloseOnIdleForceful);
- test(acm.heartbeat == Ice::HeartbeatOnIdle);
+ test(acm.heartbeat == Ice::HeartbeatOff);
- proxy->ice_getCachedConnection()->setACM(20, Ice::CloseOnInvocationAndIdle, Ice::HeartbeatOnInvocation);
+ proxy->ice_getCachedConnection()->setACM(1, Ice::CloseOnInvocationAndIdle, Ice::HeartbeatAlways);
acm = proxy->ice_getCachedConnection()->getACM();
- test(acm.timeout == 20);
+ test(acm.timeout == 1);
test(acm.close == Ice::CloseOnInvocationAndIdle);
- test(acm.heartbeat == Ice::HeartbeatOnInvocation);
+ test(acm.heartbeat == Ice::HeartbeatAlways);
+
+ // Make sure the client sends few heartbeats to the server
+ proxy->waitForHeartbeat(2);
}
};
diff --git a/cpp/test/Ice/acm/Test.ice b/cpp/test/Ice/acm/Test.ice
index b1c8b749109..0c4c3b105ca 100644
--- a/cpp/test/Ice/acm/Test.ice
+++ b/cpp/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/cpp/test/Ice/acm/TestI.cpp b/cpp/test/Ice/acm/TestI.cpp
index 2468f6ad1f1..869d204cf7e 100644
--- a/cpp/test/Ice/acm/TestI.cpp
+++ b/cpp/test/Ice/acm/TestI.cpp
@@ -60,8 +60,8 @@ RemoteCommunicatorI::shutdown(const Ice::Current& current)
current.adapter->getCommunicator()->shutdown();
}
-RemoteObjectAdapterI::RemoteObjectAdapterI(const Ice::ObjectAdapterPtr& adapter) :
- _adapter(adapter),
+RemoteObjectAdapterI::RemoteObjectAdapterI(const Ice::ObjectAdapterPtr& adapter) :
+ _adapter(adapter),
_testIntf(TestIntfPrx::uncheckedCast(_adapter->add(new TestI(),
adapter->getCommunicator()->stringToIdentity("test"))))
{
@@ -113,9 +113,50 @@ TestI::sleepAndHold(int delay, const Ice::Current& current)
timedWait(IceUtil::Time::seconds(delay));
}
-void
+void
TestI::interruptSleep(const Ice::Current& current)
{
Lock sync(*this);
notifyAll();
}
+
+void
+TestI::waitForHeartbeat(int count, const Ice::Current& current)
+{
+ class ConnectionCallbackI : public Ice::ConnectionCallback, private IceUtil::Monitor<IceUtil::Mutex>
+ {
+ public:
+
+ void
+ waitForCount(int count)
+ {
+ Lock sync(*this);
+ _count = count;
+ while(_count > 0)
+ {
+ wait();
+ }
+ }
+
+ private:
+
+ virtual void
+ heartbeat(const Ice::ConnectionPtr&)
+ {
+ Lock sync(*this);
+ --_count;
+ notifyAll();
+ }
+
+ virtual void
+ closed(const Ice::ConnectionPtr&)
+ {
+ }
+
+ int _count;
+ };
+
+ IceUtil::Handle<ConnectionCallbackI> callback = new ConnectionCallbackI();
+ current.con->setCallback(callback);
+ callback->waitForCount(count);
+} \ No newline at end of file
diff --git a/cpp/test/Ice/acm/TestI.h b/cpp/test/Ice/acm/TestI.h
index 891f08faea2..c72d7b6a6b5 100644
--- a/cpp/test/Ice/acm/TestI.h
+++ b/cpp/test/Ice/acm/TestI.h
@@ -25,7 +25,7 @@ class RemoteObjectAdapterI : public Test::RemoteObjectAdapter
public:
RemoteObjectAdapterI(const Ice::ObjectAdapterPtr&);
-
+
virtual Test::TestIntfPrx getTestIntf(const Ice::Current&);
virtual void activate(const Ice::Current&);
virtual void hold(const Ice::Current&);
@@ -44,6 +44,7 @@ public:
virtual void sleep(int, const Ice::Current&);
virtual void sleepAndHold(int, const Ice::Current&);
virtual void interruptSleep(const Ice::Current&);
+ virtual void waitForHeartbeat(int, const Ice::Current&);
};
#endif
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);
+ }
};
diff --git a/java/test/src/main/java/test/Ice/acm/AllTests.java b/java/test/src/main/java/test/Ice/acm/AllTests.java
index 5a23881dfba..3a496ec0de5 100644
--- a/java/test/src/main/java/test/Ice/acm/AllTests.java
+++ b/java/test/src/main/java/test/Ice/acm/AllTests.java
@@ -253,7 +253,7 @@ public class AllTests
}
}
}
-
+
public abstract void runTestCase(RemoteObjectAdapterPrx adapter, TestIntfPrx proxy);
public void setClientACM(int timeout, int close, int heartbeat)
@@ -567,7 +567,7 @@ public class AllTests
public SetACMTest(Application app, RemoteCommunicatorPrx com, java.io.PrintWriter out)
{
super(app, "setACM/getACM", com, out);
- setClientACM(15, 4, 2);
+ setClientACM(15, 4, 0);
}
public void runTestCase(RemoteObjectAdapterPrx adapter, TestIntfPrx proxy)
@@ -576,22 +576,25 @@ public class AllTests
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(null, null, null);
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(
- new Ice.IntOptional(20),
+ new Ice.IntOptional(1),
new Ice.Optional<Ice.ACMClose>(Ice.ACMClose.CloseOnInvocationAndIdle),
- new Ice.Optional<Ice.ACMHeartbeat>(Ice.ACMHeartbeat.HeartbeatOnInvocation));
+ new Ice.Optional<Ice.ACMHeartbeat>(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);
+
+ // Make sure the client sends few heartbeats to the server
+ proxy.waitForHeartbeat(2);
}
}
diff --git a/java/test/src/main/java/test/Ice/acm/Test.ice b/java/test/src/main/java/test/Ice/acm/Test.ice
index fcc420b58ea..d3c1a83e37f 100644
--- a/java/test/src/main/java/test/Ice/acm/Test.ice
+++ b/java/test/src/main/java/test/Ice/acm/Test.ice
@@ -18,6 +18,7 @@ interface TestIntf
void sleep(int seconds);
void sleepAndHold(int seconds);
void interruptSleep();
+ void waitForHeartbeat(int count);
};
interface RemoteObjectAdapter
diff --git a/java/test/src/main/java/test/Ice/acm/TestI.java b/java/test/src/main/java/test/Ice/acm/TestI.java
index 96ebf88ef40..4d06e74876b 100644
--- a/java/test/src/main/java/test/Ice/acm/TestI.java
+++ b/java/test/src/main/java/test/Ice/acm/TestI.java
@@ -48,4 +48,36 @@ public class TestI extends _TestIntfDisp
notifyAll();
}
}
+
+ public void waitForHeartbeat(int count, Ice.Current current)
+ {
+ final Ice.Holder<Integer> c = new Ice.Holder<Integer>(count);
+ Ice.ConnectionCallback callback = new Ice.ConnectionCallback()
+ {
+ synchronized public void heartbeat(Ice.Connection connection)
+ {
+ --c.value;
+ notifyAll();
+ }
+
+ public void closed(Ice.Connection connection)
+ {
+ }
+ };
+ current.con.setCallback(callback);
+
+ synchronized(callback)
+ {
+ while(c.value > 0)
+ {
+ try
+ {
+ callback.wait();
+ }
+ catch(InterruptedException ex)
+ {
+ }
+ }
+ }
+ }
};
diff --git a/js/src/Ice/ACM.js b/js/src/Ice/ACM.js
index e6d926c8469..084bb44081d 100644
--- a/js/src/Ice/ACM.js
+++ b/js/src/Ice/ACM.js
@@ -23,7 +23,7 @@ var ACMConfig = Class({
this.close = Ice.ACMClose.CloseOnInvocationAndIdle;
return;
}
-
+
var timeoutProperty;
if((prefix == "Ice.ACM.Client" || prefix == "Ice.ACM.Server") &&
p.getProperty(prefix + ".Timeout").length === 0)
@@ -34,7 +34,7 @@ var ACMConfig = Class({
{
timeoutProperty = prefix + ".Timeout";
}
-
+
this.timeout = p.getPropertyAsIntWithDefault(timeoutProperty, dflt.timeout / 1000) * 1000; // To ms
var hb = p.getPropertyAsIntWithDefault(prefix + ".Heartbeat", dflt.heartbeat.value);
@@ -44,7 +44,7 @@ var ACMConfig = Class({
}
else
{
- l.warning("invalid value for property `" + prefix + ".Heartbeat" +
+ l.warning("invalid value for property `" + prefix + ".Heartbeat" +
"', default value will be used instead");
this.heartbeat = dflt.heartbeat;
}
@@ -56,7 +56,7 @@ var ACMConfig = Class({
}
else
{
- l.warning("invalid value for property `" + prefix + ".Close" +
+ l.warning("invalid value for property `" + prefix + ".Close" +
"', default value will be used instead");
this.close = dflt.close;
}
@@ -119,8 +119,8 @@ var FactoryACMMonitor = Class(ACMMonitor, {
this._timerToken = this._instance.timer().scheduleRepeated(
function()
{
- self.runTimerTask();
- },
+ self.runTimerTask();
+ },
this._config.timeout / 2);
}
},
@@ -130,7 +130,7 @@ var FactoryACMMonitor = Class(ACMMonitor, {
{
return;
}
-
+
var i = this._connections.indexOf(connection);
Debug.assert(i >= 0);
this._connections.splice(i, 1);
@@ -147,7 +147,7 @@ var FactoryACMMonitor = Class(ACMMonitor, {
acm: function(timeout, close, heartbeat)
{
Debug.assert(this._instance !== null);
-
+
var config = new ACMConfig();
config.timeout = this._config.timeout;
config.close = this._config.close;
@@ -186,7 +186,7 @@ var FactoryACMMonitor = Class(ACMMonitor, {
{
return;
}
-
+
//
// Monitor connections outside the thread synchronization, so
// that connections can be added or removed during monitoring.
@@ -195,11 +195,11 @@ var FactoryACMMonitor = Class(ACMMonitor, {
for(var i = 0; i < this._connections.length; i++)
{
try
- {
+ {
this._connections[i].monitor(now, this._config);
}
catch(ex)
- {
+ {
this.handleException(ex);
}
}
@@ -209,7 +209,7 @@ var FactoryACMMonitor = Class(ACMMonitor, {
if(this._instance === null)
{
return;
- }
+ }
this._instance.initializationData().logger.error("exception in connection monitor:\n" + ex);
}
});
@@ -257,11 +257,11 @@ var ConnectionACMMonitor = Class(ACMMonitor, {
runTimerTask: function()
{
try
- {
- this.connection.monitor(Date.now(), this._config);
+ {
+ this._connection.monitor(Date.now(), this._config);
}
catch(ex)
- {
+ {
this._parent.handleException(ex);
}
}
diff --git a/js/test/Ice/acm/Client.js b/js/test/Ice/acm/Client.js
index 25ab4cbcd6c..65628559651 100644
--- a/js/test/Ice/acm/Client.js
+++ b/js/test/Ice/acm/Client.js
@@ -402,7 +402,7 @@
__init__: function(com, out)
{
TestCase.call(this, "setACM/getACM", com, out);
- this.setClientACM(15, 4, 2);
+ this.setClientACM(15, 4, 0);
},
runTestCase: function(adapter, proxy)
{
@@ -410,23 +410,23 @@
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(undefined, undefined, undefined);
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);
- return new Ice.Promise().succeed();
+ return proxy.waitForHeartbeat(2);
}
});
diff --git a/js/test/Ice/acm/Test.ice b/js/test/Ice/acm/Test.ice
index fcc420b58ea..d3c1a83e37f 100644
--- a/js/test/Ice/acm/Test.ice
+++ b/js/test/Ice/acm/Test.ice
@@ -18,6 +18,7 @@ interface TestIntf
void sleep(int seconds);
void sleepAndHold(int seconds);
void interruptSleep();
+ void waitForHeartbeat(int count);
};
interface RemoteObjectAdapter
diff --git a/objective-c/test/Ice/acm/ACMTest.ice b/objective-c/test/Ice/acm/ACMTest.ice
index 1e6bcd7eb69..7b492d9b356 100644
--- a/objective-c/test/Ice/acm/ACMTest.ice
+++ b/objective-c/test/Ice/acm/ACMTest.ice
@@ -18,6 +18,7 @@ interface TestIntf
void sleep(int seconds);
void sleepAndHold(int seconds);
void interruptSleep();
+ void waitForHeartbeat(int count);
};
interface RemoteObjectAdapter
diff --git a/objective-c/test/Ice/acm/AllTests.m b/objective-c/test/Ice/acm/AllTests.m
index ca9d73278db..4499108ab4b 100644
--- a/objective-c/test/Ice/acm/AllTests.m
+++ b/objective-c/test/Ice/acm/AllTests.m
@@ -760,7 +760,7 @@
+(id) testCase:(id<TestACMRemoteCommunicatorPrx>)com
{
id tc = [super testCase:com];
- [tc setClientACM:15 close:4 heartbeat:2];
+ [tc setClientACM:15 close:4 heartbeat:0];
return tc;
}
+(NSString*) getName
@@ -772,22 +772,24 @@
ICEACM* acm = [[proxy ice_getCachedConnection] getACM];
test(acm.timeout == 15);
test(acm.close == ICECloseOnIdleForceful);
- test(acm.heartbeat == ICEHeartbeatOnIdle);
+ test(acm.heartbeat == ICEHeartbeatOff);
[[proxy ice_getCachedConnection] setACM:ICENone close:ICENone heartbeat:ICENone];
acm = [[proxy ice_getCachedConnection] getACM];
test(acm.timeout == 15);
test(acm.close == ICECloseOnIdleForceful);
- test(acm.heartbeat == ICEHeartbeatOnIdle);
+ test(acm.heartbeat == ICEHeartbeatOff);
- id timeout = @20;
+ id timeout = @1;
id close = @(ICECloseOnInvocationAndIdle);
- id heartbeat = @(ICEHeartbeatOnInvocation);
+ id heartbeat = @(ICEHeartbeatAlways);
[[proxy ice_getCachedConnection] setACM:timeout close:close heartbeat:heartbeat];
acm = [[proxy ice_getCachedConnection] getACM];
- test(acm.timeout == 20);
+ test(acm.timeout == 1);
test(acm.close == ICECloseOnInvocationAndIdle);
- test(acm.heartbeat == ICEHeartbeatOnInvocation);
+ test(acm.heartbeat == ICEHeartbeatAlways);
+
+ [proxy waitForHeartbeat:2];
}
@end
diff --git a/objective-c/test/Ice/acm/TestI.m b/objective-c/test/Ice/acm/TestI.m
index 5de0e0eeb88..b0263bcb766 100644
--- a/objective-c/test/Ice/acm/TestI.m
+++ b/objective-c/test/Ice/acm/TestI.m
@@ -9,6 +9,55 @@
#import <acm/TestI.h>
+@interface ConnectionCallbackI : NSObject<ICEConnectionCallback>
+{
+ NSCondition* _cond;
+ int _count;
+}
+-(void) waitForCount:(int)count;
+@end
+
+
+@implementation ConnectionCallbackI
+-(id) init
+{
+ self = [super init];
+ if(!self)
+ {
+ return nil;
+ }
+ _cond = [[NSCondition alloc] init];
+ _count = 0;
+ return self;
+}
+-(void) heartbeat:(id<ICEConnection>)c
+{
+ [_cond lock];
+ --_count;
+ [_cond signal];
+ [_cond unlock];
+}
+-(void) closed:(id<ICEConnection>)c
+{
+}
+-(void) waitForCount:(int)count
+{
+ [_cond lock];
+ _count = count;
+ @try
+ {
+ while(_count > 0)
+ {
+ [_cond wait];
+ }
+ }
+ @finally
+ {
+ [_cond unlock];
+ }
+}
+@end
+
@implementation RemoteCommunicatorI
-(id<TestACMRemoteObjectAdapterPrx>) createObjectAdapter:(ICEInt)timeout close:(ICEInt)close heartbeat:(ICEInt)heartbeat
current:(ICECurrent*)current
@@ -146,4 +195,11 @@
[_cond signal];
[_cond unlock];
}
+-(void) waitForHeartbeat:(int)count current:(ICECurrent*)current
+{
+ ConnectionCallbackI* callback = [ConnectionCallbackI new];
+ [current.con setCallback:callback];
+ [callback waitForCount:count];
+ [callback release];
+}
@end
diff --git a/php/test/Ice/acm/Client.php b/php/test/Ice/acm/Client.php
index e47e2dd6532..32ded1f8284 100644
--- a/php/test/Ice/acm/Client.php
+++ b/php/test/Ice/acm/Client.php
@@ -58,9 +58,8 @@ function allTests($communicator)
$NS ? constant("Ice\\ACMClose::CloseOnInvocationAndIdle") : constant("Ice_ACMClose::CloseOnInvocationAndIdle");
$HeartbeatOnIdle =
$NS ? constant("Ice\\ACMHeartbeat::HeartbeatOnIdle") : constant("Ice_ACMHeartbeat::HeartbeatOnIdle");
- $HeartbeatOnInvocation =
- $NS ? constant("Ice\\ACMHeartbeat::HeartbeatOnInvocation") :
- constant("Ice_ACMHeartbeat::HeartbeatOnInvocation");
+ $HeartbeatAlways =
+ $NS ? constant("Ice\\ACMHeartbeat::HeartbeatAlways") : constant("Ice_ACMHeartbeat::HeartbeatAlways");
$acm = $proxy->ice_getCachedConnection()->getACM();
test($acm->timeout == 15);
@@ -73,11 +72,13 @@ function allTests($communicator)
test($acm->close == $CloseOnIdleForceful);
test($acm->heartbeat == $HeartbeatOnIdle);
- $proxy->ice_getCachedConnection()->setACM(20, $CloseOnInvocationAndIdle, $HeartbeatOnInvocation);
+ $proxy->ice_getCachedConnection()->setACM(1, $CloseOnInvocationAndIdle, $HeartbeatAlways);
$acm = $proxy->ice_getCachedConnection()->getACM();
- test($acm->timeout == 20);
+ test($acm->timeout == 1);
test($acm->close == $CloseOnInvocationAndIdle);
- test($acm->heartbeat == $HeartbeatOnInvocation);
+ test($acm->heartbeat == $HeartbeatAlways);
+
+ $proxy->waitForHeartbeat(2);
$adapter->deactivate();
$testCommunicator->destroy();
diff --git a/php/test/Ice/acm/Test.ice b/php/test/Ice/acm/Test.ice
index b1c8b749109..0c4c3b105ca 100644
--- a/php/test/Ice/acm/Test.ice
+++ b/php/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/python/test/Ice/acm/AllTests.py b/python/test/Ice/acm/AllTests.py
index 6cfae071a24..60844870090 100644
--- a/python/test/Ice/acm/AllTests.py
+++ b/python/test/Ice/acm/AllTests.py
@@ -349,26 +349,28 @@ def allTests(communicator):
class SetACMTest(TestCase):
def __init__(self, com):
TestCase.__init__(self, "setACM/getACM", com)
- self.setClientACM(15, 4, 2)
+ self.setClientACM(15, 4, 0)
def runTestCase(self, adapter, proxy):
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.Unset, Ice.Unset, Ice.Unset)
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, Ice.ACMClose.CloseOnInvocationAndIdle,
- Ice.ACMHeartbeat.HeartbeatOnInvocation)
+ proxy.ice_getCachedConnection().setACM(1, Ice.ACMClose.CloseOnInvocationAndIdle,
+ 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)
tests.append(InvocationHeartbeatTest(com))
tests.append(InvocationHeartbeatOnHoldTest(com))
diff --git a/python/test/Ice/acm/Test.ice b/python/test/Ice/acm/Test.ice
index b1c8b749109..0c4c3b105ca 100644
--- a/python/test/Ice/acm/Test.ice
+++ b/python/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/python/test/Ice/acm/TestI.py b/python/test/Ice/acm/TestI.py
index 6b63fd26d07..024899b8640 100644
--- a/python/test/Ice/acm/TestI.py
+++ b/python/test/Ice/acm/TestI.py
@@ -76,3 +76,36 @@ class TestIntfI(Test.TestIntf):
self.m.notifyAll()
finally:
self.m.release()
+
+ def waitForHeartbeat(self, count, current=None):
+
+ class ConnectionCallbackI(Ice.ConnectionCallback):
+
+ def __init__(self):
+ self.m = threading.Condition()
+ self.count = 0
+
+ def heartbeat(self, con):
+ self.m.acquire()
+ try:
+ self.count -= 1
+ self.m.notifyAll()
+ finally:
+ self.m.release()
+
+ def closed(self, con):
+ pass
+
+ def waitForCount(self, count):
+ self.m.acquire()
+ self.count = count
+ try:
+ while self.count > 0:
+ self.m.wait()
+ finally:
+ self.m.release()
+
+ callback = ConnectionCallbackI()
+ current.con.setCallback(callback)
+ callback.waitForCount(2)
+
diff --git a/ruby/test/Ice/acm/AllTests.rb b/ruby/test/Ice/acm/AllTests.rb
index 3e64c2c3420..ba100d864d8 100644
--- a/ruby/test/Ice/acm/AllTests.rb
+++ b/ruby/test/Ice/acm/AllTests.rb
@@ -37,12 +37,14 @@ def allTests(communicator)
test(acm.close == Ice::ACMClose::CloseOnIdleForceful)
test(acm.heartbeat == Ice::ACMHeartbeat::HeartbeatOnIdle)
- proxy.ice_getCachedConnection().setACM(20, Ice::ACMClose::CloseOnInvocationAndIdle,
- Ice::ACMHeartbeat::HeartbeatOnInvocation)
+ proxy.ice_getCachedConnection().setACM(1, Ice::ACMClose::CloseOnInvocationAndIdle,
+ 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)
adapter.deactivate()
testCommunicator.destroy()
diff --git a/ruby/test/Ice/acm/Test.ice b/ruby/test/Ice/acm/Test.ice
index b1c8b749109..0c4c3b105ca 100644
--- a/ruby/test/Ice/acm/Test.ice
+++ b/ruby/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