From 78ceddde5c628df3ccbfb3f86eb17a59f776b92d Mon Sep 17 00:00:00 2001 From: Mark Spruiell Date: Wed, 23 Jul 2014 10:23:31 -0700 Subject: adding ACM tests for Python/Ruby/PHP --- php/test/Ice/acm/.depend | 1 + php/test/Ice/acm/.depend.mak | 1 + php/test/Ice/acm/.gitignore | 1 + php/test/Ice/acm/Client.php | 97 +++++++++++++++++++++++++++++++++++++++++++ php/test/Ice/acm/Makefile | 26 ++++++++++++ php/test/Ice/acm/Makefile.mak | 24 +++++++++++ php/test/Ice/acm/Test.ice | 37 +++++++++++++++++ php/test/Ice/acm/run.py | 23 ++++++++++ 8 files changed, 210 insertions(+) create mode 100644 php/test/Ice/acm/.depend create mode 100644 php/test/Ice/acm/.depend.mak create mode 100644 php/test/Ice/acm/.gitignore create mode 100644 php/test/Ice/acm/Client.php create mode 100644 php/test/Ice/acm/Makefile create mode 100644 php/test/Ice/acm/Makefile.mak create mode 100644 php/test/Ice/acm/Test.ice create mode 100755 php/test/Ice/acm/run.py (limited to 'php/test') 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 @@ +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() -- cgit v1.2.3