summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--php/test/Ice/acm/.depend1
-rw-r--r--php/test/Ice/acm/.depend.mak1
-rw-r--r--php/test/Ice/acm/.gitignore1
-rw-r--r--php/test/Ice/acm/Client.php97
-rw-r--r--php/test/Ice/acm/Makefile26
-rw-r--r--php/test/Ice/acm/Makefile.mak24
-rw-r--r--php/test/Ice/acm/Test.ice37
-rwxr-xr-xphp/test/Ice/acm/run.py23
-rw-r--r--py/test/Ice/acm/AllTests.py396
-rwxr-xr-xpy/test/Ice/acm/Client.py48
-rwxr-xr-xpy/test/Ice/acm/Server.py53
-rw-r--r--py/test/Ice/acm/Test.ice37
-rw-r--r--py/test/Ice/acm/TestI.py78
-rwxr-xr-xpy/test/Ice/acm/run.py23
-rw-r--r--rb/test/Ice/acm/AllTests.rb55
-rwxr-xr-xrb/test/Ice/acm/Client.rb54
-rw-r--r--rb/test/Ice/acm/Test.ice37
-rwxr-xr-xrb/test/Ice/acm/run.py25
18 files changed, 1016 insertions, 0 deletions
diff --git a/php/test/Ice/acm/.depend b/php/test/Ice/acm/.depend
new file mode 100644
index 00000000000..f6d6205e60d
--- /dev/null
+++ b/php/test/Ice/acm/.depend
@@ -0,0 +1 @@
+Test.php: Test.ice $(SLICE2PHP) $(SLICEPARSERLIB)
diff --git a/php/test/Ice/acm/.depend.mak b/php/test/Ice/acm/.depend.mak
new file mode 100644
index 00000000000..8751ce66bf8
--- /dev/null
+++ b/php/test/Ice/acm/.depend.mak
@@ -0,0 +1 @@
+Test.php: Test.ice "$(SLICE2PHP)" "$(SLICEPARSERLIB)"
diff --git a/php/test/Ice/acm/.gitignore b/php/test/Ice/acm/.gitignore
new file mode 100644
index 00000000000..bed01730acc
--- /dev/null
+++ b/php/test/Ice/acm/.gitignore
@@ -0,0 +1 @@
+Test.php
diff --git a/php/test/Ice/acm/Client.php b/php/test/Ice/acm/Client.php
new file mode 100644
index 00000000000..42ccae18448
--- /dev/null
+++ b/php/test/Ice/acm/Client.php
@@ -0,0 +1,97 @@
+<?
+// **********************************************************************
+//
+// Copyright (c) 2003-2014 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.
+//
+// **********************************************************************
+
+error_reporting(E_ALL | E_STRICT);
+
+if(!extension_loaded("ice"))
+{
+ echo "\nerror: Ice extension is not loaded.\n\n";
+ exit(1);
+}
+
+$NS = function_exists("Ice\\initialize");
+require_once ($NS ? 'Ice_ns.php' : 'Ice.php');
+require_once 'Test.php';
+
+function test($b)
+{
+ if(!$b)
+ {
+ $bt = debug_backtrace();
+ die("\ntest failed in ".$bt[0]["file"]." line ".$bt[0]["line"]."\n");
+ }
+}
+
+function allTests($communicator)
+{
+ global $NS;
+
+ echo "testing setACM/getACM... ";
+ flush();
+
+ $ref = "communicator:default -p 12010";
+ $com = $communicator->stringToProxy($ref)->ice_uncheckedCast("::Test::RemoteCommunicator");
+
+ $adapter = $com->createObjectAdapter(-1, -1, -1);
+
+ $initData = $NS ? eval("return new Ice\\InitializationData;") : new Ice_InitializationData;
+ $initData->properties = $communicator->getProperties()->clone();
+ $initData->properties->setProperty("Ice.ACM.Timeout", "1");
+ $initData->properties->setProperty("Ice.ACM.Client.Timeout", "15");
+ $initData->properties->setProperty("Ice.ACM.Client.Close", "4");
+ $initData->properties->setProperty("Ice.ACM.Client.Heartbeat", "2");
+ $testCommunicator = $NS ? eval("return Ice\\initialize(\$initData);") : Ice_initialize($initData);
+ $proxy = $testCommunicator->stringToProxy($adapter->getTestIntf()->ice_toString())->ice_uncheckedCast(
+ "::Test::TestIntf");
+ $proxy->ice_getConnection();
+
+ $CloseOnIdleForceful =
+ $NS ? constant("Ice\\ACMClose::CloseOnIdleForceful") : constant("Ice_ACMClose::CloseOnIdleForceful");
+ $CloseOnInvocationAndIdle =
+ $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");
+
+ $acm = $proxy->ice_getCachedConnection()->getACM();
+ test($acm->timeout == 15);
+ test($acm->close == $CloseOnIdleForceful);
+ test($acm->heartbeat == $HeartbeatOnIdle);
+
+ $proxy->ice_getCachedConnection()->setACM(Ice_Unset, Ice_Unset, Ice_Unset);
+ $acm = $proxy->ice_getCachedConnection()->getACM();
+ test($acm->timeout == 15);
+ test($acm->close == $CloseOnIdleForceful);
+ test($acm->heartbeat == $HeartbeatOnIdle);
+
+ $proxy->ice_getCachedConnection()->setACM(20, $CloseOnInvocationAndIdle, $HeartbeatOnInvocation);
+ $acm = $proxy->ice_getCachedConnection()->getACM();
+ test($acm->timeout == 20);
+ test($acm->close == $CloseOnInvocationAndIdle);
+ test($acm->heartbeat == $HeartbeatOnInvocation);
+
+ $adapter->deactivate();
+ $testCommunicator->destroy();
+ echo "ok\n";
+
+ echo "shutting down... ";
+ flush();
+ $com->shutdown();
+ echo "ok\n";
+}
+
+$communicator = Ice_initialize($argv);
+allTests($communicator);
+$communicator->destroy();
+
+exit();
+?>
diff --git a/php/test/Ice/acm/Makefile b/php/test/Ice/acm/Makefile
new file mode 100644
index 00000000000..f8d515d687f
--- /dev/null
+++ b/php/test/Ice/acm/Makefile
@@ -0,0 +1,26 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2014 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.
+#
+# **********************************************************************
+
+top_srcdir = ../../..
+
+SLICE_SRCS = Test.ice
+
+include $(top_srcdir)/config/Make.rules.php
+
+SRCS = Test.php
+
+all:: $(SRCS)
+
+%.php: %.ice
+ $(SLICE2PHP) $(SLICE2PHPFLAGS) $<
+
+clean::
+ rm -f $(SRCS)
+
+include .depend
diff --git a/php/test/Ice/acm/Makefile.mak b/php/test/Ice/acm/Makefile.mak
new file mode 100644
index 00000000000..53c8f118100
--- /dev/null
+++ b/php/test/Ice/acm/Makefile.mak
@@ -0,0 +1,24 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2014 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.
+#
+# **********************************************************************
+
+top_srcdir = ..\..\..
+
+!include $(top_srcdir)\config\Make.rules.mak.php
+
+SRCS = Test.php
+
+all:: $(SRCS)
+
+$(SRCS): $*.ice
+ -"$(SLICE2PHP)" $(SLICE2PHPFLAGS) $*.ice
+
+clean::
+ del /q $(SRCS)
+
+include .depend.mak
diff --git a/php/test/Ice/acm/Test.ice b/php/test/Ice/acm/Test.ice
new file mode 100644
index 00000000000..3289856d9e1
--- /dev/null
+++ b/php/test/Ice/acm/Test.ice
@@ -0,0 +1,37 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2014 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.
+//
+// **********************************************************************
+
+#pragma once
+
+module Test
+{
+
+interface TestIntf
+{
+ void sleep(int seconds);
+ void sleepAndHold(int seconds);
+ void interruptSleep();
+};
+
+interface RemoteObjectAdapter
+{
+ TestIntf* getTestIntf();
+ void activate();
+ void hold();
+ void deactivate();
+};
+
+interface RemoteCommunicator
+{
+ RemoteObjectAdapter* createObjectAdapter(int acmTimeout, int close, int heartbeat);
+ void shutdown();
+};
+
+};
+
diff --git a/php/test/Ice/acm/run.py b/php/test/Ice/acm/run.py
new file mode 100755
index 00000000000..33fc2e8f3ac
--- /dev/null
+++ b/php/test/Ice/acm/run.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2014 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.
+#
+# **********************************************************************
+
+import os, sys
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+TestUtil.clientServerTest()
diff --git a/py/test/Ice/acm/AllTests.py b/py/test/Ice/acm/AllTests.py
new file mode 100644
index 00000000000..ef49c902a68
--- /dev/null
+++ b/py/test/Ice/acm/AllTests.py
@@ -0,0 +1,396 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2014 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.
+#
+# **********************************************************************
+
+import Ice, Test, sys, threading, time, traceback
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+class LoggerI(Ice.Logger):
+ def __init__(self):
+ self._started = False
+ self._messages = []
+ self.m = threading.Lock()
+
+ def start(self):
+ self.m.acquire()
+ try:
+ self._started = True
+ self.dump()
+ finally:
+ self.m.release()
+
+ def _print(self, msg):
+ self.m.acquire()
+ try:
+ self._messages.append(msg)
+ if self._started:
+ self.dump()
+ finally:
+ self.m.release()
+
+ def trace(self, category, msg):
+ self.m.acquire()
+ try:
+ self._messages.append("[" + category + "] " + msg)
+ if self._started:
+ self.dump()
+ finally:
+ self.m.release()
+
+ def warning(self, msg):
+ self.m.acquire()
+ try:
+ self._messages.append("warning: " + msg)
+ if self._started:
+ self.dump()
+ finally:
+ self.m.release()
+
+ def error(self, msg):
+ self.m.acquire()
+ try:
+ self._messages.append("error: " + msg)
+ if self._started:
+ self.dump()
+ finally:
+ self.m.release()
+
+ def cloneWithPrefix(self, prefix):
+ return self
+
+ def dump(self):
+ for p in self._messages:
+ print(p)
+ self._messages = []
+
+class TestCase(threading.Thread, Ice.ConnectionCallback):
+ def __init__(self, name, com):
+ threading.Thread.__init__(self)
+ self._name = name
+ self._com = com
+ self._logger = LoggerI()
+ self._clientACMTimeout = -1
+ self._clientACMClose = -1
+ self._clientACMHeartbeat = -1
+ self._serverACMTimeout = -1
+ self._serverACMClose = -1
+ self._serverACMHeartbeat = -1
+ self._heartbeat = 0
+ self._closed = False
+ self._msg = ""
+ self.m = threading.Lock()
+
+ def init(self):
+ self._adapter = \
+ self._com.createObjectAdapter(self._serverACMTimeout, self._serverACMClose, self._serverACMHeartbeat)
+
+ initData = Ice.InitializationData()
+ initData.properties = self._com.ice_getCommunicator().getProperties().clone()
+ initData.logger = self._logger
+ initData.properties.setProperty("Ice.ACM.Timeout", "1")
+ if self._clientACMTimeout >= 0:
+ initData.properties.setProperty("Ice.ACM.Client.Timeout", str(self._clientACMTimeout))
+ if self._clientACMClose >= 0:
+ initData.properties.setProperty("Ice.ACM.Client.Close", str(self._clientACMClose))
+ if self._clientACMHeartbeat >= 0:
+ initData.properties.setProperty("Ice.ACM.Client.Heartbeat", str(self._clientACMHeartbeat))
+ #initData.properties.setProperty("Ice.Trace.Protocol", "2")
+ #initData.properties.setProperty("Ice.Trace.Network", "2")
+ self._communicator = Ice.initialize(initData)
+
+ def destroy(self):
+ self._adapter.deactivate()
+ self._communicator.destroy()
+
+ def joinWithThread(self):
+ sys.stdout.write("testing " + self._name + "... ")
+ sys.stdout.flush()
+ self._logger.start()
+ self.join()
+ if len(self._msg) == 0:
+ print("ok")
+ else:
+ print("failed!\n" + self._msg)
+ test(False)
+
+ def run(self):
+ proxy = Test.TestIntfPrx.uncheckedCast(self._communicator.stringToProxy(
+ self._adapter.getTestIntf().ice_toString()))
+ try:
+ proxy.ice_getConnection().setCallback(self)
+ self.runTestCase(self._adapter, proxy)
+ except Exception as ex:
+ self._msg = "unexpected exception:\n" + traceback.format_exc()
+
+ def heartbeat(self, con):
+ self.m.acquire()
+ try:
+ self._heartbeat = self._heartbeat + 1
+ finally:
+ self.m.release()
+
+ def closed(self, con):
+ self.m.acquire()
+ try:
+ self._closed = True
+ finally:
+ self.m.release()
+
+ def runTestCase(self, adapter, proxy):
+ test(False)
+
+ def setClientACM(self, timeout, close, heartbeat):
+ self._clientACMTimeout = timeout
+ self._clientACMClose = close
+ self._clientACMHeartbeat = heartbeat
+
+ def setServerACM(self, timeout, close, heartbeat):
+ self._serverACMTimeout = timeout
+ self._serverACMClose = close
+ self._serverACMHeartbeat = heartbeat
+
+def allTests(communicator):
+ ref = "communicator:default -p 12010"
+ com = Test.RemoteCommunicatorPrx.uncheckedCast(communicator.stringToProxy(ref))
+
+ tests = []
+
+ class InvocationHeartbeatTest(TestCase):
+ def __init__(self, com):
+ TestCase.__init__(self, "invocation heartbeat", com)
+
+ def runTestCase(self, adapter, proxy):
+ proxy.sleep(2)
+
+ self.m.acquire()
+ try:
+ test(self._heartbeat >= 2)
+ finally:
+ self.m.release()
+
+ class InvocationHeartbeatOnHoldTest(TestCase):
+ def __init__(self, com):
+ TestCase.__init__(self, "invocation with heartbeat on hold", com)
+ # Use default ACM configuration.
+
+ def runTestCase(self, adapter, proxy):
+ try:
+ # When the OA is put on hold, connections shouldn't
+ # send heartbeats, the invocation should therefore
+ # fail.
+ proxy.sleepAndHold(10)
+ test(False)
+ except Ice.ConnectionTimeoutException:
+ adapter.activate()
+ proxy.interruptSleep()
+
+ self.m.acquire()
+ try:
+ test(self._closed)
+ finally:
+ self.m.release()
+
+ class InvocationNoHeartbeatTest(TestCase):
+ def __init__(self, com):
+ TestCase.__init__(self, "invocation with no heartbeat", com)
+ self.setServerACM(1, 2, 0) # Disable heartbeat on invocations
+
+ def runTestCase(self, adapter, proxy):
+ try:
+ # Heartbeats are disabled on the server, the
+ # invocation should fail since heartbeats are
+ # expected.
+ proxy.sleep(10)
+ test(False)
+ except Ice.ConnectionTimeoutException:
+ proxy.interruptSleep()
+
+ self.m.acquire()
+ try:
+ test(self._heartbeat == 0)
+ test(self._closed)
+ finally:
+ self.m.release()
+
+ class InvocationHeartbeatCloseOnIdleTest(TestCase):
+ def __init__(self, com):
+ TestCase.__init__(self, "invocation with no heartbeat and close on idle", com)
+ self.setClientACM(1, 1, 0) # Only close on idle.
+ self.setServerACM(1, 2, 0) # Disable heartbeat on invocations
+
+ def runTestCase(self, adapter, proxy):
+ # No close on invocation, the call should succeed this time.
+ proxy.sleep(2)
+
+ self.m.acquire()
+ try:
+ test(self._heartbeat == 0)
+ test(not self._closed)
+ finally:
+ self.m.release()
+
+ class CloseOnIdleTest(TestCase):
+ def __init__(self, com):
+ TestCase.__init__(self, "close on idle", com)
+ self.setClientACM(1, 1, 0) # Only close on idle.
+
+ def runTestCase(self, adapter, proxy):
+ time.sleep(1.6) # Idle for 1.6 seconds
+
+ self.m.acquire()
+ try:
+ test(self._heartbeat == 0)
+ test(self._closed)
+ finally:
+ self.m.release()
+
+ class CloseOnInvocationTest(TestCase):
+ def __init__(self, com):
+ TestCase.__init__(self, "close on invocation", com)
+ self.setClientACM(1, 2, 0) # Only close on invocation.
+
+ def runTestCase(self, adapter, proxy):
+ time.sleep(1.5) # Idle for 1.5 seconds
+
+ self.m.acquire()
+ try:
+ test(self._heartbeat == 0)
+ test(not self._closed)
+ finally:
+ self.m.release()
+
+ class CloseOnIdleAndInvocationTest(TestCase):
+ def __init__(self, com):
+ TestCase.__init__(self, "close on idle and invocation", com)
+ self.setClientACM(1, 3, 0) # Only close on idle and invocation.
+
+ def runTestCase(self, adapter, proxy):
+ #
+ # Put the adapter on hold. The server will not respond to
+ # the graceful close. This allows to test whether or not
+ # the close is graceful or forceful.
+ #
+ adapter.hold()
+ time.sleep(1.6) # Idle for 1.6 seconds
+
+ self.m.acquire()
+ try:
+ test(self._heartbeat == 0)
+ test(not self._closed) # Not closed yet because of graceful close.
+ finally:
+ self.m.release()
+
+ adapter.activate()
+ time.sleep(0.5)
+
+ self.m.acquire()
+ try:
+ test(self._closed) # Connection should be closed this time.
+ finally:
+ self.m.release()
+
+ class ForcefulCloseOnIdleAndInvocationTest(TestCase):
+ def __init__(self, com):
+ TestCase.__init__(self, "forceful close on idle and invocation", com)
+ self.setClientACM(1, 4, 0) # Only close on idle and invocation.
+
+ def runTestCase(self, adapter, proxy):
+ adapter.hold()
+ time.sleep(1.6) # Idle for 1.6 seconds
+
+ self.m.acquire()
+ try:
+ test(self._heartbeat == 0)
+ test(self._closed) # Connection closed forcefully by ACM.
+ finally:
+ self.m.release()
+
+ class HeartbeatOnIdleTest(TestCase):
+ def __init__(self, com):
+ TestCase.__init__(self, "heartbeat on idle", com)
+ self.setServerACM(1, -1, 2) # Enable server heartbeats.
+
+ def runTestCase(self, adapter, proxy):
+ time.sleep(2)
+
+ self.m.acquire()
+ try:
+ test(self._heartbeat >= 3)
+ finally:
+ self.m.release()
+
+ class HeartbeatAlwaysTest(TestCase):
+ def __init__(self, com):
+ TestCase.__init__(self, "heartbeat always", com)
+ self.setServerACM(1, -1, 3) # Enable server heartbeats.
+
+ def runTestCase(self, adapter, proxy):
+ for i in range(0, 20):
+ proxy.ice_ping()
+ time.sleep(0.1)
+
+ self.m.acquire()
+ try:
+ test(self._heartbeat >= 3)
+ finally:
+ self.m.release()
+
+ class SetACMTest(TestCase):
+ def __init__(self, com):
+ TestCase.__init__(self, "setACM/getACM", com)
+ self.setClientACM(15, 4, 2)
+
+ 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)
+
+ 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)
+
+ proxy.ice_getCachedConnection().setACM(20, Ice.ACMClose.CloseOnInvocationAndIdle,
+ Ice.ACMHeartbeat.HeartbeatOnInvocation)
+ acm = proxy.ice_getCachedConnection().getACM()
+ test(acm.timeout == 20)
+ test(acm.close == Ice.ACMClose.CloseOnInvocationAndIdle)
+ test(acm.heartbeat == Ice.ACMHeartbeat.HeartbeatOnInvocation)
+
+ tests.append(InvocationHeartbeatTest(com))
+ tests.append(InvocationHeartbeatOnHoldTest(com))
+ tests.append(InvocationNoHeartbeatTest(com))
+ tests.append(InvocationHeartbeatCloseOnIdleTest(com))
+
+ tests.append(CloseOnIdleTest(com))
+ tests.append(CloseOnInvocationTest(com))
+ tests.append(CloseOnIdleAndInvocationTest(com))
+ tests.append(ForcefulCloseOnIdleAndInvocationTest(com))
+
+ tests.append(HeartbeatOnIdleTest(com))
+ tests.append(HeartbeatAlwaysTest(com))
+ tests.append(SetACMTest(com))
+
+ for p in tests:
+ p.init()
+ for p in tests:
+ p.start()
+ for p in tests:
+ p.joinWithThread()
+ for p in tests:
+ p.destroy()
+
+ sys.stdout.write("shutting down... ")
+ sys.stdout.flush()
+ com.shutdown()
+ print("ok")
diff --git a/py/test/Ice/acm/Client.py b/py/test/Ice/acm/Client.py
new file mode 100755
index 00000000000..28356cafeb9
--- /dev/null
+++ b/py/test/Ice/acm/Client.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2014 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.
+#
+# **********************************************************************
+
+import os, sys, traceback
+import Ice
+
+import Ice
+slice_dir = Ice.getSliceDir()
+if not slice_dir:
+ print(sys.argv[0] + ': Slice directory not found.')
+ sys.exit(1)
+
+Ice.loadSlice("'-I" + slice_dir + "' Test.ice")
+import AllTests
+
+def test(b):
+ if not b:
+ raise RuntimeError('test assertion failed')
+
+def run(args, communicator):
+ AllTests.allTests(communicator)
+ return True
+
+try:
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(sys.argv)
+ initData.properties.setProperty('Ice.Warn.Connections', '0')
+ communicator = Ice.initialize(sys.argv, initData)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/py/test/Ice/acm/Server.py b/py/test/Ice/acm/Server.py
new file mode 100755
index 00000000000..d96c4c1e36f
--- /dev/null
+++ b/py/test/Ice/acm/Server.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2014 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.
+#
+# **********************************************************************
+
+import os, sys, traceback
+import Ice
+slice_dir = Ice.getSliceDir()
+if not slice_dir:
+ print(sys.argv[0] + ': Slice directory not found.')
+ sys.exit(1)
+
+Ice.loadSlice('"-I' + slice_dir + '" Test.ice')
+import Test, TestI
+
+def run(args, communicator):
+ communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010")
+ communicator.getProperties().setProperty("TestAdapter.ACM.Timeout", "0")
+ adapter = communicator.createObjectAdapter("TestAdapter")
+ id = communicator.stringToIdentity("communicator")
+ adapter.add(TestI.RemoteCommunicatorI(), id)
+ adapter.activate()
+
+ # Disable ready print for further adapters.
+ communicator.getProperties().setProperty("Ice.PrintAdapterReady", "0")
+
+ communicator.waitForShutdown()
+ return True
+
+try:
+ initData = Ice.InitializationData()
+ initData.properties = Ice.createProperties(sys.argv)
+ initData.properties.setProperty("Ice.Warn.Connections", "0");
+ initData.properties.setProperty("Ice.ACM.Timeout", "1");
+ communicator = Ice.initialize(sys.argv, initData)
+ status = run(sys.argv, communicator)
+except:
+ traceback.print_exc()
+ status = False
+
+if communicator:
+ try:
+ communicator.destroy()
+ except:
+ traceback.print_exc()
+ status = False
+
+sys.exit(not status)
diff --git a/py/test/Ice/acm/Test.ice b/py/test/Ice/acm/Test.ice
new file mode 100644
index 00000000000..3289856d9e1
--- /dev/null
+++ b/py/test/Ice/acm/Test.ice
@@ -0,0 +1,37 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2014 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.
+//
+// **********************************************************************
+
+#pragma once
+
+module Test
+{
+
+interface TestIntf
+{
+ void sleep(int seconds);
+ void sleepAndHold(int seconds);
+ void interruptSleep();
+};
+
+interface RemoteObjectAdapter
+{
+ TestIntf* getTestIntf();
+ void activate();
+ void hold();
+ void deactivate();
+};
+
+interface RemoteCommunicator
+{
+ RemoteObjectAdapter* createObjectAdapter(int acmTimeout, int close, int heartbeat);
+ void shutdown();
+};
+
+};
+
diff --git a/py/test/Ice/acm/TestI.py b/py/test/Ice/acm/TestI.py
new file mode 100644
index 00000000000..e37f7f7cfca
--- /dev/null
+++ b/py/test/Ice/acm/TestI.py
@@ -0,0 +1,78 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2014 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.
+#
+# **********************************************************************
+
+import Ice, Test, threading
+
+class RemoteCommunicatorI(Test.RemoteCommunicator):
+ def createObjectAdapter(self, timeout, close, heartbeat, current=None):
+ com = current.adapter.getCommunicator()
+ properties = com.getProperties()
+ protocol = properties.getPropertyWithDefault("Ice.Default.Protocol", "tcp");
+
+ name = Ice.generateUUID()
+ if timeout >= 0:
+ properties.setProperty(name + ".ACM.Timeout", str(timeout))
+ if close >= 0:
+ properties.setProperty(name + ".ACM.Close", str(close))
+ if heartbeat >= 0:
+ properties.setProperty(name + ".ACM.Heartbeat", str(heartbeat))
+ properties.setProperty(name + ".ThreadPool.Size", "2")
+ adapter = com.createObjectAdapterWithEndpoints(name, protocol + " -h 127.0.0.1")
+ return Test.RemoteObjectAdapterPrx.uncheckedCast(current.adapter.addWithUUID(RemoteObjectAdapterI(adapter)))
+
+ def shutdown(self, current=None):
+ current.adapter.getCommunicator().shutdown()
+
+class RemoteObjectAdapterI(Test.RemoteObjectAdapter):
+ def __init__(self, adapter):
+ self._adapter = adapter
+ self._testIntf = Test.TestIntfPrx.uncheckedCast(adapter.add(TestIntfI(),
+ adapter.getCommunicator().stringToIdentity("test")))
+ adapter.activate()
+
+ def getTestIntf(self, current=None):
+ return self._testIntf
+
+ def activate(self, current=None):
+ self._adapter.activate()
+
+ def hold(self, current=None):
+ self._adapter.hold()
+
+ def deactivate(self, current=None):
+ try:
+ self._adapter.destroy()
+ except Ice.ObjectAdapterDeactivatedException:
+ pass
+
+class TestIntfI(Test.TestIntf):
+ def __init__(self):
+ self.m = threading.Condition()
+
+ def sleep(self, delay, current=None):
+ self.m.acquire()
+ try:
+ self.m.wait(delay)
+ finally:
+ self.m.release()
+
+ def sleepAndHold(self, delay, current=None):
+ self.m.acquire()
+ try:
+ current.adapter.hold()
+ self.m.wait(delay)
+ finally:
+ self.m.release()
+
+ def interruptSleep(self, delay, current=None):
+ self.m.acquire()
+ try:
+ self.m.notifyAll()
+ finally:
+ self.m.release()
diff --git a/py/test/Ice/acm/run.py b/py/test/Ice/acm/run.py
new file mode 100755
index 00000000000..33fc2e8f3ac
--- /dev/null
+++ b/py/test/Ice/acm/run.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2014 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.
+#
+# **********************************************************************
+
+import os, sys
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+TestUtil.clientServerTest()
diff --git a/rb/test/Ice/acm/AllTests.rb b/rb/test/Ice/acm/AllTests.rb
new file mode 100644
index 00000000000..aa55ef95017
--- /dev/null
+++ b/rb/test/Ice/acm/AllTests.rb
@@ -0,0 +1,55 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2014 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.
+#
+# **********************************************************************
+
+def allTests(communicator)
+ print "testing setACM/getACM... "
+ STDOUT.flush
+
+ ref = "communicator:default -p 12010"
+ com = Test::RemoteCommunicatorPrx::uncheckedCast(communicator.stringToProxy(ref))
+
+ adapter = com.createObjectAdapter(-1, -1, -1)
+
+ initData = Ice::InitializationData.new
+ initData.properties = communicator.getProperties().clone()
+ initData.properties.setProperty("Ice.ACM.Timeout", "1")
+ initData.properties.setProperty("Ice.ACM.Client.Timeout", "15")
+ initData.properties.setProperty("Ice.ACM.Client.Close", "4")
+ initData.properties.setProperty("Ice.ACM.Client.Heartbeat", "2")
+ testCommunicator = Ice::initialize(initData)
+ proxy = Test::TestIntfPrx::uncheckedCast(testCommunicator.stringToProxy(adapter.getTestIntf().ice_toString()))
+ proxy.ice_getConnection()
+
+ acm = proxy.ice_getCachedConnection().getACM()
+ test(acm.timeout == 15)
+ test(acm.close == Ice::ACMClose::CloseOnIdleForceful)
+ test(acm.heartbeat == Ice::ACMHeartbeat::HeartbeatOnIdle)
+
+ 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)
+
+ proxy.ice_getCachedConnection().setACM(20, Ice::ACMClose::CloseOnInvocationAndIdle,
+ Ice::ACMHeartbeat::HeartbeatOnInvocation)
+ acm = proxy.ice_getCachedConnection().getACM()
+ test(acm.timeout == 20)
+ test(acm.close == Ice::ACMClose::CloseOnInvocationAndIdle)
+ test(acm.heartbeat == Ice::ACMHeartbeat::HeartbeatOnInvocation)
+
+ adapter.deactivate()
+ testCommunicator.destroy()
+ puts "ok"
+
+ print "shutting down... "
+ STDOUT.flush
+ com.shutdown()
+ puts "ok"
+end
diff --git a/rb/test/Ice/acm/Client.rb b/rb/test/Ice/acm/Client.rb
new file mode 100755
index 00000000000..b38123903a1
--- /dev/null
+++ b/rb/test/Ice/acm/Client.rb
@@ -0,0 +1,54 @@
+#!/usr/bin/env ruby
+# **********************************************************************
+#
+# Copyright (c) 2003-2014 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.
+#
+# **********************************************************************
+
+require 'pathname'
+require 'Ice'
+slice_dir = Ice.getSliceDir
+if slice_dir.empty?
+ fail "Slice directory not found"
+end
+
+Ice::loadSlice("'-I" + slice_dir + "' Test.ice")
+require './AllTests'
+
+def test(b)
+ if !b
+ raise RuntimeError, 'test assertion failed'
+ end
+end
+
+def run(args, communicator)
+ allTests(communicator)
+ return true
+end
+
+begin
+ initData = Ice::InitializationData.new
+ initData.properties = Ice.createProperties(ARGV)
+ initData.properties.setProperty("Ice.Warn.Connections", "0")
+ communicator = Ice.initialize(ARGV, initData)
+ status = run(ARGV, communicator)
+rescue => ex
+ puts $!
+ print ex.backtrace.join("\n")
+ status = false
+end
+
+if communicator
+ begin
+ communicator.destroy()
+ rescue => ex
+ puts $!
+ print ex.backtrace.join("\n")
+ status = false
+ end
+end
+
+exit(status ? 0 : 1)
diff --git a/rb/test/Ice/acm/Test.ice b/rb/test/Ice/acm/Test.ice
new file mode 100644
index 00000000000..3289856d9e1
--- /dev/null
+++ b/rb/test/Ice/acm/Test.ice
@@ -0,0 +1,37 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2014 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.
+//
+// **********************************************************************
+
+#pragma once
+
+module Test
+{
+
+interface TestIntf
+{
+ void sleep(int seconds);
+ void sleepAndHold(int seconds);
+ void interruptSleep();
+};
+
+interface RemoteObjectAdapter
+{
+ TestIntf* getTestIntf();
+ void activate();
+ void hold();
+ void deactivate();
+};
+
+interface RemoteCommunicator
+{
+ RemoteObjectAdapter* createObjectAdapter(int acmTimeout, int close, int heartbeat);
+ void shutdown();
+};
+
+};
+
diff --git a/rb/test/Ice/acm/run.py b/rb/test/Ice/acm/run.py
new file mode 100755
index 00000000000..e91b072d6b4
--- /dev/null
+++ b/rb/test/Ice/acm/run.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2014 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.
+#
+# **********************************************************************
+
+import os, sys
+
+path = [ ".", "..", "../..", "../../..", "../../../.." ]
+head = os.path.dirname(sys.argv[0])
+if len(head) > 0:
+ path = [os.path.join(head, p) for p in path]
+path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
+if len(path) == 0:
+ raise RuntimeError("can't find toplevel directory!")
+sys.path.append(os.path.join(path[0], "scripts"))
+import TestUtil
+
+TestUtil.clientServerTest()
+
+sys.exit(0)