diff options
57 files changed, 3522 insertions, 5 deletions
diff --git a/cpp/CHANGES b/cpp/CHANGES index d90789eea6f..bde93c451cb 100644 --- a/cpp/CHANGES +++ b/cpp/CHANGES @@ -23,6 +23,9 @@ Changes since version 3.2.X (binary incompabible) Changes since version 3.2.0 --------------------------- +- Trailing characters past the adapter id in a stringified proxy + will now raise a ProxyParseException. + - Fixed IceGrid registry assert which would be triggered on registration of duplicate well-known objects with the same object adapter. diff --git a/cpp/allTests.py b/cpp/allTests.py index f922b07c812..553cd2e9579 100755 --- a/cpp/allTests.py +++ b/cpp/allTests.py @@ -80,6 +80,7 @@ tests = [ \ "IceUtil/inputUtil", \ "IceUtil/uuid", \ "Slice/errorDetection", \ + "Ice/proxy", \ "Ice/operations", \ "Ice/exceptions", \ "Ice/inheritance", \ diff --git a/cpp/src/Ice/ReferenceFactory.cpp b/cpp/src/Ice/ReferenceFactory.cpp index b1eae949612..d84870e0d6f 100644 --- a/cpp/src/Ice/ReferenceFactory.cpp +++ b/cpp/src/Ice/ReferenceFactory.cpp @@ -503,6 +503,7 @@ IceInternal::ReferenceFactory::create(const string& str) throw ex; } + string adapterstr; end = IceUtil::checkQuote(s, beg); if(end == string::npos) { @@ -517,14 +518,24 @@ IceInternal::ReferenceFactory::create(const string& str) { end = s.size(); } + adapterstr = s.substr(beg, end - beg); } else { beg++; // Skip leading quote + adapterstr = s.substr(beg, end - beg); + end++; // Skip trailing quote. } + // Check for trailing whitespace. + if(end != string::npos && s.find_first_not_of(delim, end) != string::npos) + { + ProxyParseException ex(__FILE__, __LINE__); + ex.str = str; + throw ex; + } - if(!IceUtil::unescapeString(s, beg, end, adapter) || adapter.size() == 0) + if(!IceUtil::unescapeString(adapterstr, 0, adapterstr.size(), adapter) || adapter.size() == 0) { ProxyParseException ex(__FILE__, __LINE__); ex.str = str; diff --git a/cpp/test/Ice/Makefile b/cpp/test/Ice/Makefile index 5df3b334377..05aaa3cd264 100644 --- a/cpp/test/Ice/Makefile +++ b/cpp/test/Ice/Makefile @@ -11,7 +11,8 @@ top_srcdir = ../.. include $(top_srcdir)/config/Make.rules -SUBDIRS = operations \ +SUBDIRS = proxy \ + operations \ exceptions \ inheritance \ facets \ diff --git a/cpp/test/Ice/Makefile.mak b/cpp/test/Ice/Makefile.mak index 1698d0978d8..82fc5c0df0f 100644 --- a/cpp/test/Ice/Makefile.mak +++ b/cpp/test/Ice/Makefile.mak @@ -11,7 +11,8 @@ top_srcdir = ..\.. !include $(top_srcdir)\config\Make.rules.mak -SUBDIRS = operations \ +SUBDIRS = proxy \ + operations \ exceptions \ inheritance \ facets \ diff --git a/cpp/test/Ice/proxy/.depend b/cpp/test/Ice/proxy/.depend new file mode 100644 index 00000000000..3706ff8aa51 --- /dev/null +++ b/cpp/test/Ice/proxy/.depend @@ -0,0 +1,17 @@ +Test$(OBJEXT): Test.cpp Test.h ../../../include/Ice/LocalObjectF.h ../../../include/IceUtil/Shared.h ../../../include/IceUtil/Config.h ../../../include/IceUtil/Mutex.h ../../../include/IceUtil/Lock.h ../../../include/IceUtil/ThreadException.h ../../../include/IceUtil/Exception.h ../../../include/Ice/Handle.h ../../../include/IceUtil/Handle.h ../../../include/Ice/Config.h ../../../include/Ice/ProxyHandle.h ../../../include/Ice/ProxyF.h ../../../include/Ice/ObjectF.h ../../../include/Ice/GCCountMap.h ../../../include/Ice/GCShared.h ../../../include/Ice/Exception.h ../../../include/Ice/LocalObject.h ../../../include/Ice/Proxy.h ../../../include/Ice/ProxyFactoryF.h ../../../include/Ice/ConnectionIF.h ../../../include/Ice/EndpointIF.h ../../../include/Ice/Endpoint.h ../../../include/Ice/UndefSysMacros.h ../../../include/Ice/ObjectAdapterF.h ../../../include/Ice/ReferenceF.h ../../../include/Ice/OutgoingAsyncF.h ../../../include/Ice/Current.h ../../../include/Ice/ConnectionF.h ../../../include/Ice/Identity.h ../../../include/Ice/StreamF.h ../../../include/Ice/CommunicatorF.h ../../../include/Ice/Object.h ../../../include/Ice/IncomingAsyncF.h ../../../include/Ice/Outgoing.h ../../../include/IceUtil/Monitor.h ../../../include/IceUtil/Cond.h ../../../include/IceUtil/Time.h ../../../include/Ice/BasicStream.h ../../../include/Ice/InstanceF.h ../../../include/Ice/ObjectFactoryF.h ../../../include/Ice/Buffer.h ../../../include/Ice/Protocol.h ../../../include/Ice/StringConverter.h ../../../include/IceUtil/Unicode.h ../../../include/Ice/OutgoingAsync.h ../../../include/IceUtil/RecMutex.h ../../../include/Ice/Incoming.h ../../../include/Ice/ServantLocatorF.h ../../../include/Ice/ServantManagerF.h ../../../include/Ice/Direct.h ../../../include/Ice/LocalException.h ../../../include/Ice/BuiltinSequences.h ../../../include/Ice/ObjectFactory.h ../../../include/IceUtil/Iterator.h ../../../include/IceUtil/ScopedArray.h +Client$(OBJEXT): Client.cpp ../../../include/Ice/Ice.h ../../../include/Ice/Initialize.h ../../../include/Ice/CommunicatorF.h ../../../include/Ice/LocalObjectF.h ../../../include/IceUtil/Shared.h ../../../include/IceUtil/Config.h ../../../include/IceUtil/Mutex.h ../../../include/IceUtil/Lock.h ../../../include/IceUtil/ThreadException.h ../../../include/IceUtil/Exception.h ../../../include/Ice/Handle.h ../../../include/IceUtil/Handle.h ../../../include/Ice/Config.h ../../../include/Ice/ProxyHandle.h ../../../include/Ice/ProxyF.h ../../../include/Ice/ObjectF.h ../../../include/Ice/GCCountMap.h ../../../include/Ice/GCShared.h ../../../include/Ice/Exception.h ../../../include/Ice/LocalObject.h ../../../include/Ice/UndefSysMacros.h ../../../include/Ice/PropertiesF.h ../../../include/Ice/InstanceF.h ../../../include/Ice/LoggerF.h ../../../include/Ice/StreamF.h ../../../include/Ice/StatsF.h ../../../include/Ice/StringConverter.h ../../../include/Ice/BuiltinSequences.h ../../../include/Ice/Proxy.h ../../../include/Ice/ProxyFactoryF.h ../../../include/Ice/ConnectionIF.h ../../../include/Ice/EndpointIF.h ../../../include/Ice/Endpoint.h ../../../include/Ice/ObjectAdapterF.h ../../../include/Ice/ReferenceF.h ../../../include/Ice/OutgoingAsyncF.h ../../../include/Ice/Current.h ../../../include/Ice/ConnectionF.h ../../../include/Ice/Identity.h ../../../include/Ice/LocalException.h ../../../include/Ice/Properties.h ../../../include/Ice/Logger.h ../../../include/Ice/LoggerUtil.h ../../../include/Ice/Stats.h ../../../include/Ice/Communicator.h ../../../include/Ice/Object.h ../../../include/Ice/IncomingAsyncF.h ../../../include/Ice/ObjectFactoryF.h ../../../include/Ice/RouterF.h ../../../include/Ice/LocatorF.h ../../../include/Ice/PluginF.h ../../../include/Ice/ImplicitContextF.h ../../../include/Ice/ObjectFactory.h ../../../include/Ice/ObjectAdapter.h ../../../include/Ice/Outgoing.h ../../../include/IceUtil/Monitor.h ../../../include/IceUtil/Cond.h ../../../include/IceUtil/Time.h ../../../include/Ice/BasicStream.h ../../../include/Ice/Buffer.h ../../../include/Ice/Protocol.h ../../../include/IceUtil/Unicode.h ../../../include/Ice/OutgoingAsync.h ../../../include/IceUtil/RecMutex.h ../../../include/Ice/Incoming.h ../../../include/Ice/ServantLocatorF.h ../../../include/Ice/ServantManagerF.h ../../../include/Ice/IncomingAsync.h ../../../include/Ice/Direct.h ../../../include/Ice/UserExceptionFactory.h ../../../include/Ice/FactoryTable.h ../../../include/Ice/FactoryTableDef.h ../../../include/IceUtil/StaticMutex.h ../../../include/Ice/UserExceptionFactoryF.h ../../../include/Ice/FacetMap.h ../../../include/Ice/Locator.h ../../../include/Ice/ProcessF.h ../../../include/Ice/ServantLocator.h ../../../include/Ice/Process.h ../../../include/Ice/Application.h ../../../include/Ice/Connection.h ../../../include/Ice/Functional.h ../../../include/IceUtil/Functional.h ../../../include/Ice/Stream.h ../../../include/Ice/ImplicitContext.h ../../include/TestCommon.h Test.h +AllTests$(OBJEXT): AllTests.cpp ../../../include/Ice/Ice.h ../../../include/Ice/Initialize.h ../../../include/Ice/CommunicatorF.h ../../../include/Ice/LocalObjectF.h ../../../include/IceUtil/Shared.h ../../../include/IceUtil/Config.h ../../../include/IceUtil/Mutex.h ../../../include/IceUtil/Lock.h ../../../include/IceUtil/ThreadException.h ../../../include/IceUtil/Exception.h ../../../include/Ice/Handle.h ../../../include/IceUtil/Handle.h ../../../include/Ice/Config.h ../../../include/Ice/ProxyHandle.h ../../../include/Ice/ProxyF.h ../../../include/Ice/ObjectF.h ../../../include/Ice/GCCountMap.h ../../../include/Ice/GCShared.h ../../../include/Ice/Exception.h ../../../include/Ice/LocalObject.h ../../../include/Ice/UndefSysMacros.h ../../../include/Ice/PropertiesF.h ../../../include/Ice/InstanceF.h ../../../include/Ice/LoggerF.h ../../../include/Ice/StreamF.h ../../../include/Ice/StatsF.h ../../../include/Ice/StringConverter.h ../../../include/Ice/BuiltinSequences.h ../../../include/Ice/Proxy.h ../../../include/Ice/ProxyFactoryF.h ../../../include/Ice/ConnectionIF.h ../../../include/Ice/EndpointIF.h ../../../include/Ice/Endpoint.h ../../../include/Ice/ObjectAdapterF.h ../../../include/Ice/ReferenceF.h ../../../include/Ice/OutgoingAsyncF.h ../../../include/Ice/Current.h ../../../include/Ice/ConnectionF.h ../../../include/Ice/Identity.h ../../../include/Ice/LocalException.h ../../../include/Ice/Properties.h ../../../include/Ice/Logger.h ../../../include/Ice/LoggerUtil.h ../../../include/Ice/Stats.h ../../../include/Ice/Communicator.h ../../../include/Ice/Object.h ../../../include/Ice/IncomingAsyncF.h ../../../include/Ice/ObjectFactoryF.h ../../../include/Ice/RouterF.h ../../../include/Ice/LocatorF.h ../../../include/Ice/PluginF.h ../../../include/Ice/ImplicitContextF.h ../../../include/Ice/ObjectFactory.h ../../../include/Ice/ObjectAdapter.h ../../../include/Ice/Outgoing.h ../../../include/IceUtil/Monitor.h ../../../include/IceUtil/Cond.h ../../../include/IceUtil/Time.h ../../../include/Ice/BasicStream.h ../../../include/Ice/Buffer.h ../../../include/Ice/Protocol.h ../../../include/IceUtil/Unicode.h ../../../include/Ice/OutgoingAsync.h ../../../include/IceUtil/RecMutex.h ../../../include/Ice/Incoming.h ../../../include/Ice/ServantLocatorF.h ../../../include/Ice/ServantManagerF.h ../../../include/Ice/IncomingAsync.h ../../../include/Ice/Direct.h ../../../include/Ice/UserExceptionFactory.h ../../../include/Ice/FactoryTable.h ../../../include/Ice/FactoryTableDef.h ../../../include/IceUtil/StaticMutex.h ../../../include/Ice/UserExceptionFactoryF.h ../../../include/Ice/FacetMap.h ../../../include/Ice/Locator.h ../../../include/Ice/ProcessF.h ../../../include/Ice/ServantLocator.h ../../../include/Ice/Process.h ../../../include/Ice/Application.h ../../../include/Ice/Connection.h ../../../include/Ice/Functional.h ../../../include/IceUtil/Functional.h ../../../include/Ice/Stream.h ../../../include/Ice/ImplicitContext.h ../../../include/Ice/Router.h ../../include/TestCommon.h Test.h +Test$(OBJEXT): Test.cpp Test.h ../../../include/Ice/LocalObjectF.h ../../../include/IceUtil/Shared.h ../../../include/IceUtil/Config.h ../../../include/IceUtil/Mutex.h ../../../include/IceUtil/Lock.h ../../../include/IceUtil/ThreadException.h ../../../include/IceUtil/Exception.h ../../../include/Ice/Handle.h ../../../include/IceUtil/Handle.h ../../../include/Ice/Config.h ../../../include/Ice/ProxyHandle.h ../../../include/Ice/ProxyF.h ../../../include/Ice/ObjectF.h ../../../include/Ice/GCCountMap.h ../../../include/Ice/GCShared.h ../../../include/Ice/Exception.h ../../../include/Ice/LocalObject.h ../../../include/Ice/Proxy.h ../../../include/Ice/ProxyFactoryF.h ../../../include/Ice/ConnectionIF.h ../../../include/Ice/EndpointIF.h ../../../include/Ice/Endpoint.h ../../../include/Ice/UndefSysMacros.h ../../../include/Ice/ObjectAdapterF.h ../../../include/Ice/ReferenceF.h ../../../include/Ice/OutgoingAsyncF.h ../../../include/Ice/Current.h ../../../include/Ice/ConnectionF.h ../../../include/Ice/Identity.h ../../../include/Ice/StreamF.h ../../../include/Ice/CommunicatorF.h ../../../include/Ice/Object.h ../../../include/Ice/IncomingAsyncF.h ../../../include/Ice/Outgoing.h ../../../include/IceUtil/Monitor.h ../../../include/IceUtil/Cond.h ../../../include/IceUtil/Time.h ../../../include/Ice/BasicStream.h ../../../include/Ice/InstanceF.h ../../../include/Ice/ObjectFactoryF.h ../../../include/Ice/Buffer.h ../../../include/Ice/Protocol.h ../../../include/Ice/StringConverter.h ../../../include/IceUtil/Unicode.h ../../../include/Ice/OutgoingAsync.h ../../../include/IceUtil/RecMutex.h ../../../include/Ice/Incoming.h ../../../include/Ice/ServantLocatorF.h ../../../include/Ice/ServantManagerF.h ../../../include/Ice/Direct.h ../../../include/Ice/LocalException.h ../../../include/Ice/BuiltinSequences.h ../../../include/Ice/ObjectFactory.h ../../../include/IceUtil/Iterator.h ../../../include/IceUtil/ScopedArray.h +TestI$(OBJEXT): TestI.cpp ../../../include/Ice/Ice.h ../../../include/Ice/Initialize.h ../../../include/Ice/CommunicatorF.h ../../../include/Ice/LocalObjectF.h ../../../include/IceUtil/Shared.h ../../../include/IceUtil/Config.h ../../../include/IceUtil/Mutex.h ../../../include/IceUtil/Lock.h ../../../include/IceUtil/ThreadException.h ../../../include/IceUtil/Exception.h ../../../include/Ice/Handle.h ../../../include/IceUtil/Handle.h ../../../include/Ice/Config.h ../../../include/Ice/ProxyHandle.h ../../../include/Ice/ProxyF.h ../../../include/Ice/ObjectF.h ../../../include/Ice/GCCountMap.h ../../../include/Ice/GCShared.h ../../../include/Ice/Exception.h ../../../include/Ice/LocalObject.h ../../../include/Ice/UndefSysMacros.h ../../../include/Ice/PropertiesF.h ../../../include/Ice/InstanceF.h ../../../include/Ice/LoggerF.h ../../../include/Ice/StreamF.h ../../../include/Ice/StatsF.h ../../../include/Ice/StringConverter.h ../../../include/Ice/BuiltinSequences.h ../../../include/Ice/Proxy.h ../../../include/Ice/ProxyFactoryF.h ../../../include/Ice/ConnectionIF.h ../../../include/Ice/EndpointIF.h ../../../include/Ice/Endpoint.h ../../../include/Ice/ObjectAdapterF.h ../../../include/Ice/ReferenceF.h ../../../include/Ice/OutgoingAsyncF.h ../../../include/Ice/Current.h ../../../include/Ice/ConnectionF.h ../../../include/Ice/Identity.h ../../../include/Ice/LocalException.h ../../../include/Ice/Properties.h ../../../include/Ice/Logger.h ../../../include/Ice/LoggerUtil.h ../../../include/Ice/Stats.h ../../../include/Ice/Communicator.h ../../../include/Ice/Object.h ../../../include/Ice/IncomingAsyncF.h ../../../include/Ice/ObjectFactoryF.h ../../../include/Ice/RouterF.h ../../../include/Ice/LocatorF.h ../../../include/Ice/PluginF.h ../../../include/Ice/ImplicitContextF.h ../../../include/Ice/ObjectFactory.h ../../../include/Ice/ObjectAdapter.h ../../../include/Ice/Outgoing.h ../../../include/IceUtil/Monitor.h ../../../include/IceUtil/Cond.h ../../../include/IceUtil/Time.h ../../../include/Ice/BasicStream.h ../../../include/Ice/Buffer.h ../../../include/Ice/Protocol.h ../../../include/IceUtil/Unicode.h ../../../include/Ice/OutgoingAsync.h ../../../include/IceUtil/RecMutex.h ../../../include/Ice/Incoming.h ../../../include/Ice/ServantLocatorF.h ../../../include/Ice/ServantManagerF.h ../../../include/Ice/IncomingAsync.h ../../../include/Ice/Direct.h ../../../include/Ice/UserExceptionFactory.h ../../../include/Ice/FactoryTable.h ../../../include/Ice/FactoryTableDef.h ../../../include/IceUtil/StaticMutex.h ../../../include/Ice/UserExceptionFactoryF.h ../../../include/Ice/FacetMap.h ../../../include/Ice/Locator.h ../../../include/Ice/ProcessF.h ../../../include/Ice/ServantLocator.h ../../../include/Ice/Process.h ../../../include/Ice/Application.h ../../../include/Ice/Connection.h ../../../include/Ice/Functional.h ../../../include/IceUtil/Functional.h ../../../include/Ice/Stream.h ../../../include/Ice/ImplicitContext.h ../../../include/IceUtil/IceUtil.h ../../../include/IceUtil/AbstractMutex.h ../../../include/IceUtil/Algorithm.h ../../../include/IceUtil/ArgVector.h ../../../include/IceUtil/Base64.h ../../../include/IceUtil/Cache.h ../../../include/IceUtil/CountDownLatch.h ../../../include/IceUtil/CtrlCHandler.h ../../../include/IceUtil/InputUtil.h ../../../include/IceUtil/Iterator.h ../../../include/IceUtil/MD5.h ../../../include/IceUtil/Options.h ../../../include/IceUtil/OutputUtil.h ../../../include/IceUtil/RWRecMutex.h ../../../include/IceUtil/Thread.h ../../../include/IceUtil/Random.h ../../../include/IceUtil/ScopedArray.h ../../../include/IceUtil/StringUtil.h ../../../include/IceUtil/UUID.h TestI.h Test.h ../../include/TestCommon.h +Server$(OBJEXT): Server.cpp ../../../include/Ice/Ice.h ../../../include/Ice/Initialize.h ../../../include/Ice/CommunicatorF.h ../../../include/Ice/LocalObjectF.h ../../../include/IceUtil/Shared.h ../../../include/IceUtil/Config.h ../../../include/IceUtil/Mutex.h ../../../include/IceUtil/Lock.h ../../../include/IceUtil/ThreadException.h ../../../include/IceUtil/Exception.h ../../../include/Ice/Handle.h ../../../include/IceUtil/Handle.h ../../../include/Ice/Config.h ../../../include/Ice/ProxyHandle.h ../../../include/Ice/ProxyF.h ../../../include/Ice/ObjectF.h ../../../include/Ice/GCCountMap.h ../../../include/Ice/GCShared.h ../../../include/Ice/Exception.h ../../../include/Ice/LocalObject.h ../../../include/Ice/UndefSysMacros.h ../../../include/Ice/PropertiesF.h ../../../include/Ice/InstanceF.h ../../../include/Ice/LoggerF.h ../../../include/Ice/StreamF.h ../../../include/Ice/StatsF.h ../../../include/Ice/StringConverter.h ../../../include/Ice/BuiltinSequences.h ../../../include/Ice/Proxy.h ../../../include/Ice/ProxyFactoryF.h ../../../include/Ice/ConnectionIF.h ../../../include/Ice/EndpointIF.h ../../../include/Ice/Endpoint.h ../../../include/Ice/ObjectAdapterF.h ../../../include/Ice/ReferenceF.h ../../../include/Ice/OutgoingAsyncF.h ../../../include/Ice/Current.h ../../../include/Ice/ConnectionF.h ../../../include/Ice/Identity.h ../../../include/Ice/LocalException.h ../../../include/Ice/Properties.h ../../../include/Ice/Logger.h ../../../include/Ice/LoggerUtil.h ../../../include/Ice/Stats.h ../../../include/Ice/Communicator.h ../../../include/Ice/Object.h ../../../include/Ice/IncomingAsyncF.h ../../../include/Ice/ObjectFactoryF.h ../../../include/Ice/RouterF.h ../../../include/Ice/LocatorF.h ../../../include/Ice/PluginF.h ../../../include/Ice/ImplicitContextF.h ../../../include/Ice/ObjectFactory.h ../../../include/Ice/ObjectAdapter.h ../../../include/Ice/Outgoing.h ../../../include/IceUtil/Monitor.h ../../../include/IceUtil/Cond.h ../../../include/IceUtil/Time.h ../../../include/Ice/BasicStream.h ../../../include/Ice/Buffer.h ../../../include/Ice/Protocol.h ../../../include/IceUtil/Unicode.h ../../../include/Ice/OutgoingAsync.h ../../../include/IceUtil/RecMutex.h ../../../include/Ice/Incoming.h ../../../include/Ice/ServantLocatorF.h ../../../include/Ice/ServantManagerF.h ../../../include/Ice/IncomingAsync.h ../../../include/Ice/Direct.h ../../../include/Ice/UserExceptionFactory.h ../../../include/Ice/FactoryTable.h ../../../include/Ice/FactoryTableDef.h ../../../include/IceUtil/StaticMutex.h ../../../include/Ice/UserExceptionFactoryF.h ../../../include/Ice/FacetMap.h ../../../include/Ice/Locator.h ../../../include/Ice/ProcessF.h ../../../include/Ice/ServantLocator.h ../../../include/Ice/Process.h ../../../include/Ice/Application.h ../../../include/Ice/Connection.h ../../../include/Ice/Functional.h ../../../include/IceUtil/Functional.h ../../../include/Ice/Stream.h ../../../include/Ice/ImplicitContext.h TestI.h Test.h +TestAMD$(OBJEXT): TestAMD.cpp TestAMD.h ../../../include/Ice/LocalObjectF.h ../../../include/IceUtil/Shared.h ../../../include/IceUtil/Config.h ../../../include/IceUtil/Mutex.h ../../../include/IceUtil/Lock.h ../../../include/IceUtil/ThreadException.h ../../../include/IceUtil/Exception.h ../../../include/Ice/Handle.h ../../../include/IceUtil/Handle.h ../../../include/Ice/Config.h ../../../include/Ice/ProxyHandle.h ../../../include/Ice/ProxyF.h ../../../include/Ice/ObjectF.h ../../../include/Ice/GCCountMap.h ../../../include/Ice/GCShared.h ../../../include/Ice/Exception.h ../../../include/Ice/LocalObject.h ../../../include/Ice/Proxy.h ../../../include/Ice/ProxyFactoryF.h ../../../include/Ice/ConnectionIF.h ../../../include/Ice/EndpointIF.h ../../../include/Ice/Endpoint.h ../../../include/Ice/UndefSysMacros.h ../../../include/Ice/ObjectAdapterF.h ../../../include/Ice/ReferenceF.h ../../../include/Ice/OutgoingAsyncF.h ../../../include/Ice/Current.h ../../../include/Ice/ConnectionF.h ../../../include/Ice/Identity.h ../../../include/Ice/StreamF.h ../../../include/Ice/CommunicatorF.h ../../../include/Ice/Object.h ../../../include/Ice/IncomingAsyncF.h ../../../include/Ice/Outgoing.h ../../../include/IceUtil/Monitor.h ../../../include/IceUtil/Cond.h ../../../include/IceUtil/Time.h ../../../include/Ice/BasicStream.h ../../../include/Ice/InstanceF.h ../../../include/Ice/ObjectFactoryF.h ../../../include/Ice/Buffer.h ../../../include/Ice/Protocol.h ../../../include/Ice/StringConverter.h ../../../include/IceUtil/Unicode.h ../../../include/Ice/OutgoingAsync.h ../../../include/IceUtil/RecMutex.h ../../../include/Ice/Incoming.h ../../../include/Ice/ServantLocatorF.h ../../../include/Ice/ServantManagerF.h ../../../include/Ice/IncomingAsync.h ../../../include/Ice/Direct.h ../../../include/Ice/LocalException.h ../../../include/Ice/BuiltinSequences.h ../../../include/Ice/ObjectFactory.h ../../../include/IceUtil/Iterator.h ../../../include/IceUtil/ScopedArray.h +TestAMDI$(OBJEXT): TestAMDI.cpp ../../../include/Ice/Ice.h ../../../include/Ice/Initialize.h ../../../include/Ice/CommunicatorF.h ../../../include/Ice/LocalObjectF.h ../../../include/IceUtil/Shared.h ../../../include/IceUtil/Config.h ../../../include/IceUtil/Mutex.h ../../../include/IceUtil/Lock.h ../../../include/IceUtil/ThreadException.h ../../../include/IceUtil/Exception.h ../../../include/Ice/Handle.h ../../../include/IceUtil/Handle.h ../../../include/Ice/Config.h ../../../include/Ice/ProxyHandle.h ../../../include/Ice/ProxyF.h ../../../include/Ice/ObjectF.h ../../../include/Ice/GCCountMap.h ../../../include/Ice/GCShared.h ../../../include/Ice/Exception.h ../../../include/Ice/LocalObject.h ../../../include/Ice/UndefSysMacros.h ../../../include/Ice/PropertiesF.h ../../../include/Ice/InstanceF.h ../../../include/Ice/LoggerF.h ../../../include/Ice/StreamF.h ../../../include/Ice/StatsF.h ../../../include/Ice/StringConverter.h ../../../include/Ice/BuiltinSequences.h ../../../include/Ice/Proxy.h ../../../include/Ice/ProxyFactoryF.h ../../../include/Ice/ConnectionIF.h ../../../include/Ice/EndpointIF.h ../../../include/Ice/Endpoint.h ../../../include/Ice/ObjectAdapterF.h ../../../include/Ice/ReferenceF.h ../../../include/Ice/OutgoingAsyncF.h ../../../include/Ice/Current.h ../../../include/Ice/ConnectionF.h ../../../include/Ice/Identity.h ../../../include/Ice/LocalException.h ../../../include/Ice/Properties.h ../../../include/Ice/Logger.h ../../../include/Ice/LoggerUtil.h ../../../include/Ice/Stats.h ../../../include/Ice/Communicator.h ../../../include/Ice/Object.h ../../../include/Ice/IncomingAsyncF.h ../../../include/Ice/ObjectFactoryF.h ../../../include/Ice/RouterF.h ../../../include/Ice/LocatorF.h ../../../include/Ice/PluginF.h ../../../include/Ice/ImplicitContextF.h ../../../include/Ice/ObjectFactory.h ../../../include/Ice/ObjectAdapter.h ../../../include/Ice/Outgoing.h ../../../include/IceUtil/Monitor.h ../../../include/IceUtil/Cond.h ../../../include/IceUtil/Time.h ../../../include/Ice/BasicStream.h ../../../include/Ice/Buffer.h ../../../include/Ice/Protocol.h ../../../include/IceUtil/Unicode.h ../../../include/Ice/OutgoingAsync.h ../../../include/IceUtil/RecMutex.h ../../../include/Ice/Incoming.h ../../../include/Ice/ServantLocatorF.h ../../../include/Ice/ServantManagerF.h ../../../include/Ice/IncomingAsync.h ../../../include/Ice/Direct.h ../../../include/Ice/UserExceptionFactory.h ../../../include/Ice/FactoryTable.h ../../../include/Ice/FactoryTableDef.h ../../../include/IceUtil/StaticMutex.h ../../../include/Ice/UserExceptionFactoryF.h ../../../include/Ice/FacetMap.h ../../../include/Ice/Locator.h ../../../include/Ice/ProcessF.h ../../../include/Ice/ServantLocator.h ../../../include/Ice/Process.h ../../../include/Ice/Application.h ../../../include/Ice/Connection.h ../../../include/Ice/Functional.h ../../../include/IceUtil/Functional.h ../../../include/Ice/Stream.h ../../../include/Ice/ImplicitContext.h TestAMDI.h ../../../include/IceUtil/Thread.h TestAMD.h ../../include/TestCommon.h +ServerAMD$(OBJEXT): ServerAMD.cpp ../../../include/Ice/Ice.h ../../../include/Ice/Initialize.h ../../../include/Ice/CommunicatorF.h ../../../include/Ice/LocalObjectF.h ../../../include/IceUtil/Shared.h ../../../include/IceUtil/Config.h ../../../include/IceUtil/Mutex.h ../../../include/IceUtil/Lock.h ../../../include/IceUtil/ThreadException.h ../../../include/IceUtil/Exception.h ../../../include/Ice/Handle.h ../../../include/IceUtil/Handle.h ../../../include/Ice/Config.h ../../../include/Ice/ProxyHandle.h ../../../include/Ice/ProxyF.h ../../../include/Ice/ObjectF.h ../../../include/Ice/GCCountMap.h ../../../include/Ice/GCShared.h ../../../include/Ice/Exception.h ../../../include/Ice/LocalObject.h ../../../include/Ice/UndefSysMacros.h ../../../include/Ice/PropertiesF.h ../../../include/Ice/InstanceF.h ../../../include/Ice/LoggerF.h ../../../include/Ice/StreamF.h ../../../include/Ice/StatsF.h ../../../include/Ice/StringConverter.h ../../../include/Ice/BuiltinSequences.h ../../../include/Ice/Proxy.h ../../../include/Ice/ProxyFactoryF.h ../../../include/Ice/ConnectionIF.h ../../../include/Ice/EndpointIF.h ../../../include/Ice/Endpoint.h ../../../include/Ice/ObjectAdapterF.h ../../../include/Ice/ReferenceF.h ../../../include/Ice/OutgoingAsyncF.h ../../../include/Ice/Current.h ../../../include/Ice/ConnectionF.h ../../../include/Ice/Identity.h ../../../include/Ice/LocalException.h ../../../include/Ice/Properties.h ../../../include/Ice/Logger.h ../../../include/Ice/LoggerUtil.h ../../../include/Ice/Stats.h ../../../include/Ice/Communicator.h ../../../include/Ice/Object.h ../../../include/Ice/IncomingAsyncF.h ../../../include/Ice/ObjectFactoryF.h ../../../include/Ice/RouterF.h ../../../include/Ice/LocatorF.h ../../../include/Ice/PluginF.h ../../../include/Ice/ImplicitContextF.h ../../../include/Ice/ObjectFactory.h ../../../include/Ice/ObjectAdapter.h ../../../include/Ice/Outgoing.h ../../../include/IceUtil/Monitor.h ../../../include/IceUtil/Cond.h ../../../include/IceUtil/Time.h ../../../include/Ice/BasicStream.h ../../../include/Ice/Buffer.h ../../../include/Ice/Protocol.h ../../../include/IceUtil/Unicode.h ../../../include/Ice/OutgoingAsync.h ../../../include/IceUtil/RecMutex.h ../../../include/Ice/Incoming.h ../../../include/Ice/ServantLocatorF.h ../../../include/Ice/ServantManagerF.h ../../../include/Ice/IncomingAsync.h ../../../include/Ice/Direct.h ../../../include/Ice/UserExceptionFactory.h ../../../include/Ice/FactoryTable.h ../../../include/Ice/FactoryTableDef.h ../../../include/IceUtil/StaticMutex.h ../../../include/Ice/UserExceptionFactoryF.h ../../../include/Ice/FacetMap.h ../../../include/Ice/Locator.h ../../../include/Ice/ProcessF.h ../../../include/Ice/ServantLocator.h ../../../include/Ice/Process.h ../../../include/Ice/Application.h ../../../include/Ice/Connection.h ../../../include/Ice/Functional.h ../../../include/IceUtil/Functional.h ../../../include/Ice/Stream.h ../../../include/Ice/ImplicitContext.h TestAMDI.h ../../../include/IceUtil/Thread.h TestAMD.h +Test$(OBJEXT): Test.cpp Test.h ../../../include/Ice/LocalObjectF.h ../../../include/IceUtil/Shared.h ../../../include/IceUtil/Config.h ../../../include/IceUtil/Mutex.h ../../../include/IceUtil/Lock.h ../../../include/IceUtil/ThreadException.h ../../../include/IceUtil/Exception.h ../../../include/Ice/Handle.h ../../../include/IceUtil/Handle.h ../../../include/Ice/Config.h ../../../include/Ice/ProxyHandle.h ../../../include/Ice/ProxyF.h ../../../include/Ice/ObjectF.h ../../../include/Ice/GCCountMap.h ../../../include/Ice/GCShared.h ../../../include/Ice/Exception.h ../../../include/Ice/LocalObject.h ../../../include/Ice/Proxy.h ../../../include/Ice/ProxyFactoryF.h ../../../include/Ice/ConnectionIF.h ../../../include/Ice/EndpointIF.h ../../../include/Ice/Endpoint.h ../../../include/Ice/UndefSysMacros.h ../../../include/Ice/ObjectAdapterF.h ../../../include/Ice/ReferenceF.h ../../../include/Ice/OutgoingAsyncF.h ../../../include/Ice/Current.h ../../../include/Ice/ConnectionF.h ../../../include/Ice/Identity.h ../../../include/Ice/StreamF.h ../../../include/Ice/CommunicatorF.h ../../../include/Ice/Object.h ../../../include/Ice/IncomingAsyncF.h ../../../include/Ice/Outgoing.h ../../../include/IceUtil/Monitor.h ../../../include/IceUtil/Cond.h ../../../include/IceUtil/Time.h ../../../include/Ice/BasicStream.h ../../../include/Ice/InstanceF.h ../../../include/Ice/ObjectFactoryF.h ../../../include/Ice/Buffer.h ../../../include/Ice/Protocol.h ../../../include/Ice/StringConverter.h ../../../include/IceUtil/Unicode.h ../../../include/Ice/OutgoingAsync.h ../../../include/IceUtil/RecMutex.h ../../../include/Ice/Incoming.h ../../../include/Ice/ServantLocatorF.h ../../../include/Ice/ServantManagerF.h ../../../include/Ice/Direct.h ../../../include/Ice/LocalException.h ../../../include/Ice/BuiltinSequences.h ../../../include/Ice/ObjectFactory.h ../../../include/IceUtil/Iterator.h ../../../include/IceUtil/ScopedArray.h +TestI$(OBJEXT): TestI.cpp ../../../include/Ice/Ice.h ../../../include/Ice/Initialize.h ../../../include/Ice/CommunicatorF.h ../../../include/Ice/LocalObjectF.h ../../../include/IceUtil/Shared.h ../../../include/IceUtil/Config.h ../../../include/IceUtil/Mutex.h ../../../include/IceUtil/Lock.h ../../../include/IceUtil/ThreadException.h ../../../include/IceUtil/Exception.h ../../../include/Ice/Handle.h ../../../include/IceUtil/Handle.h ../../../include/Ice/Config.h ../../../include/Ice/ProxyHandle.h ../../../include/Ice/ProxyF.h ../../../include/Ice/ObjectF.h ../../../include/Ice/GCCountMap.h ../../../include/Ice/GCShared.h ../../../include/Ice/Exception.h ../../../include/Ice/LocalObject.h ../../../include/Ice/UndefSysMacros.h ../../../include/Ice/PropertiesF.h ../../../include/Ice/InstanceF.h ../../../include/Ice/LoggerF.h ../../../include/Ice/StreamF.h ../../../include/Ice/StatsF.h ../../../include/Ice/StringConverter.h ../../../include/Ice/BuiltinSequences.h ../../../include/Ice/Proxy.h ../../../include/Ice/ProxyFactoryF.h ../../../include/Ice/ConnectionIF.h ../../../include/Ice/EndpointIF.h ../../../include/Ice/Endpoint.h ../../../include/Ice/ObjectAdapterF.h ../../../include/Ice/ReferenceF.h ../../../include/Ice/OutgoingAsyncF.h ../../../include/Ice/Current.h ../../../include/Ice/ConnectionF.h ../../../include/Ice/Identity.h ../../../include/Ice/LocalException.h ../../../include/Ice/Properties.h ../../../include/Ice/Logger.h ../../../include/Ice/LoggerUtil.h ../../../include/Ice/Stats.h ../../../include/Ice/Communicator.h ../../../include/Ice/Object.h ../../../include/Ice/IncomingAsyncF.h ../../../include/Ice/ObjectFactoryF.h ../../../include/Ice/RouterF.h ../../../include/Ice/LocatorF.h ../../../include/Ice/PluginF.h ../../../include/Ice/ImplicitContextF.h ../../../include/Ice/ObjectFactory.h ../../../include/Ice/ObjectAdapter.h ../../../include/Ice/Outgoing.h ../../../include/IceUtil/Monitor.h ../../../include/IceUtil/Cond.h ../../../include/IceUtil/Time.h ../../../include/Ice/BasicStream.h ../../../include/Ice/Buffer.h ../../../include/Ice/Protocol.h ../../../include/IceUtil/Unicode.h ../../../include/Ice/OutgoingAsync.h ../../../include/IceUtil/RecMutex.h ../../../include/Ice/Incoming.h ../../../include/Ice/ServantLocatorF.h ../../../include/Ice/ServantManagerF.h ../../../include/Ice/IncomingAsync.h ../../../include/Ice/Direct.h ../../../include/Ice/UserExceptionFactory.h ../../../include/Ice/FactoryTable.h ../../../include/Ice/FactoryTableDef.h ../../../include/IceUtil/StaticMutex.h ../../../include/Ice/UserExceptionFactoryF.h ../../../include/Ice/FacetMap.h ../../../include/Ice/Locator.h ../../../include/Ice/ProcessF.h ../../../include/Ice/ServantLocator.h ../../../include/Ice/Process.h ../../../include/Ice/Application.h ../../../include/Ice/Connection.h ../../../include/Ice/Functional.h ../../../include/IceUtil/Functional.h ../../../include/Ice/Stream.h ../../../include/Ice/ImplicitContext.h ../../../include/IceUtil/IceUtil.h ../../../include/IceUtil/AbstractMutex.h ../../../include/IceUtil/Algorithm.h ../../../include/IceUtil/ArgVector.h ../../../include/IceUtil/Base64.h ../../../include/IceUtil/Cache.h ../../../include/IceUtil/CountDownLatch.h ../../../include/IceUtil/CtrlCHandler.h ../../../include/IceUtil/InputUtil.h ../../../include/IceUtil/Iterator.h ../../../include/IceUtil/MD5.h ../../../include/IceUtil/Options.h ../../../include/IceUtil/OutputUtil.h ../../../include/IceUtil/RWRecMutex.h ../../../include/IceUtil/Thread.h ../../../include/IceUtil/Random.h ../../../include/IceUtil/ScopedArray.h ../../../include/IceUtil/StringUtil.h ../../../include/IceUtil/UUID.h TestI.h Test.h ../../include/TestCommon.h +Collocated$(OBJEXT): Collocated.cpp ../../../include/Ice/Ice.h ../../../include/Ice/Initialize.h ../../../include/Ice/CommunicatorF.h ../../../include/Ice/LocalObjectF.h ../../../include/IceUtil/Shared.h ../../../include/IceUtil/Config.h ../../../include/IceUtil/Mutex.h ../../../include/IceUtil/Lock.h ../../../include/IceUtil/ThreadException.h ../../../include/IceUtil/Exception.h ../../../include/Ice/Handle.h ../../../include/IceUtil/Handle.h ../../../include/Ice/Config.h ../../../include/Ice/ProxyHandle.h ../../../include/Ice/ProxyF.h ../../../include/Ice/ObjectF.h ../../../include/Ice/GCCountMap.h ../../../include/Ice/GCShared.h ../../../include/Ice/Exception.h ../../../include/Ice/LocalObject.h ../../../include/Ice/UndefSysMacros.h ../../../include/Ice/PropertiesF.h ../../../include/Ice/InstanceF.h ../../../include/Ice/LoggerF.h ../../../include/Ice/StreamF.h ../../../include/Ice/StatsF.h ../../../include/Ice/StringConverter.h ../../../include/Ice/BuiltinSequences.h ../../../include/Ice/Proxy.h ../../../include/Ice/ProxyFactoryF.h ../../../include/Ice/ConnectionIF.h ../../../include/Ice/EndpointIF.h ../../../include/Ice/Endpoint.h ../../../include/Ice/ObjectAdapterF.h ../../../include/Ice/ReferenceF.h ../../../include/Ice/OutgoingAsyncF.h ../../../include/Ice/Current.h ../../../include/Ice/ConnectionF.h ../../../include/Ice/Identity.h ../../../include/Ice/LocalException.h ../../../include/Ice/Properties.h ../../../include/Ice/Logger.h ../../../include/Ice/LoggerUtil.h ../../../include/Ice/Stats.h ../../../include/Ice/Communicator.h ../../../include/Ice/Object.h ../../../include/Ice/IncomingAsyncF.h ../../../include/Ice/ObjectFactoryF.h ../../../include/Ice/RouterF.h ../../../include/Ice/LocatorF.h ../../../include/Ice/PluginF.h ../../../include/Ice/ImplicitContextF.h ../../../include/Ice/ObjectFactory.h ../../../include/Ice/ObjectAdapter.h ../../../include/Ice/Outgoing.h ../../../include/IceUtil/Monitor.h ../../../include/IceUtil/Cond.h ../../../include/IceUtil/Time.h ../../../include/Ice/BasicStream.h ../../../include/Ice/Buffer.h ../../../include/Ice/Protocol.h ../../../include/IceUtil/Unicode.h ../../../include/Ice/OutgoingAsync.h ../../../include/IceUtil/RecMutex.h ../../../include/Ice/Incoming.h ../../../include/Ice/ServantLocatorF.h ../../../include/Ice/ServantManagerF.h ../../../include/Ice/IncomingAsync.h ../../../include/Ice/Direct.h ../../../include/Ice/UserExceptionFactory.h ../../../include/Ice/FactoryTable.h ../../../include/Ice/FactoryTableDef.h ../../../include/IceUtil/StaticMutex.h ../../../include/Ice/UserExceptionFactoryF.h ../../../include/Ice/FacetMap.h ../../../include/Ice/Locator.h ../../../include/Ice/ProcessF.h ../../../include/Ice/ServantLocator.h ../../../include/Ice/Process.h ../../../include/Ice/Application.h ../../../include/Ice/Connection.h ../../../include/Ice/Functional.h ../../../include/IceUtil/Functional.h ../../../include/Ice/Stream.h ../../../include/Ice/ImplicitContext.h TestI.h Test.h +AllTests$(OBJEXT): AllTests.cpp ../../../include/Ice/Ice.h ../../../include/Ice/Initialize.h ../../../include/Ice/CommunicatorF.h ../../../include/Ice/LocalObjectF.h ../../../include/IceUtil/Shared.h ../../../include/IceUtil/Config.h ../../../include/IceUtil/Mutex.h ../../../include/IceUtil/Lock.h ../../../include/IceUtil/ThreadException.h ../../../include/IceUtil/Exception.h ../../../include/Ice/Handle.h ../../../include/IceUtil/Handle.h ../../../include/Ice/Config.h ../../../include/Ice/ProxyHandle.h ../../../include/Ice/ProxyF.h ../../../include/Ice/ObjectF.h ../../../include/Ice/GCCountMap.h ../../../include/Ice/GCShared.h ../../../include/Ice/Exception.h ../../../include/Ice/LocalObject.h ../../../include/Ice/UndefSysMacros.h ../../../include/Ice/PropertiesF.h ../../../include/Ice/InstanceF.h ../../../include/Ice/LoggerF.h ../../../include/Ice/StreamF.h ../../../include/Ice/StatsF.h ../../../include/Ice/StringConverter.h ../../../include/Ice/BuiltinSequences.h ../../../include/Ice/Proxy.h ../../../include/Ice/ProxyFactoryF.h ../../../include/Ice/ConnectionIF.h ../../../include/Ice/EndpointIF.h ../../../include/Ice/Endpoint.h ../../../include/Ice/ObjectAdapterF.h ../../../include/Ice/ReferenceF.h ../../../include/Ice/OutgoingAsyncF.h ../../../include/Ice/Current.h ../../../include/Ice/ConnectionF.h ../../../include/Ice/Identity.h ../../../include/Ice/LocalException.h ../../../include/Ice/Properties.h ../../../include/Ice/Logger.h ../../../include/Ice/LoggerUtil.h ../../../include/Ice/Stats.h ../../../include/Ice/Communicator.h ../../../include/Ice/Object.h ../../../include/Ice/IncomingAsyncF.h ../../../include/Ice/ObjectFactoryF.h ../../../include/Ice/RouterF.h ../../../include/Ice/LocatorF.h ../../../include/Ice/PluginF.h ../../../include/Ice/ImplicitContextF.h ../../../include/Ice/ObjectFactory.h ../../../include/Ice/ObjectAdapter.h ../../../include/Ice/Outgoing.h ../../../include/IceUtil/Monitor.h ../../../include/IceUtil/Cond.h ../../../include/IceUtil/Time.h ../../../include/Ice/BasicStream.h ../../../include/Ice/Buffer.h ../../../include/Ice/Protocol.h ../../../include/IceUtil/Unicode.h ../../../include/Ice/OutgoingAsync.h ../../../include/IceUtil/RecMutex.h ../../../include/Ice/Incoming.h ../../../include/Ice/ServantLocatorF.h ../../../include/Ice/ServantManagerF.h ../../../include/Ice/IncomingAsync.h ../../../include/Ice/Direct.h ../../../include/Ice/UserExceptionFactory.h ../../../include/Ice/FactoryTable.h ../../../include/Ice/FactoryTableDef.h ../../../include/IceUtil/StaticMutex.h ../../../include/Ice/UserExceptionFactoryF.h ../../../include/Ice/FacetMap.h ../../../include/Ice/Locator.h ../../../include/Ice/ProcessF.h ../../../include/Ice/ServantLocator.h ../../../include/Ice/Process.h ../../../include/Ice/Application.h ../../../include/Ice/Connection.h ../../../include/Ice/Functional.h ../../../include/IceUtil/Functional.h ../../../include/Ice/Stream.h ../../../include/Ice/ImplicitContext.h ../../../include/Ice/Router.h ../../include/TestCommon.h Test.h +Test.cpp: Test.ice ../../../slice/Ice/Current.ice ../../../slice/Ice/ObjectAdapterF.ice ../../../slice/Ice/ConnectionF.ice ../../../slice/Ice/Identity.ice +TestAMD.cpp: TestAMD.ice ../../../slice/Ice/Current.ice ../../../slice/Ice/ObjectAdapterF.ice ../../../slice/Ice/ConnectionF.ice ../../../slice/Ice/Identity.ice +Test.ice: $(SLICE2CPP) $(SLICEPARSERLIB) +TestAMD.ice: $(SLICE2CPP) $(SLICEPARSERLIB) diff --git a/cpp/test/Ice/proxy/AllTests.cpp b/cpp/test/Ice/proxy/AllTests.cpp new file mode 100644 index 00000000000..cffc5b176f8 --- /dev/null +++ b/cpp/test/Ice/proxy/AllTests.cpp @@ -0,0 +1,561 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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. +// +// ********************************************************************** + +#include <Ice/Ice.h> +#include <Ice/Locator.h> +#include <Ice/Router.h> +#include <TestCommon.h> +#include <Test.h> + +using namespace std; + +class AMI_MyClass_opSleepI : public Test::AMI_MyClass_opSleep, public IceUtil::Monitor<IceUtil::Mutex> +{ +public: + + AMI_MyClass_opSleepI() : + _called(false) + { + } + + virtual void ice_response() + { + test(false); + } + + virtual void ice_exception(const ::Ice::Exception& ex) + { + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + assert(!_called); + _called = true; + notify(); + test(dynamic_cast<const ::Ice::TimeoutException*>(&ex)); + } + + bool check() + { + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + while(!_called) + { + if(!timedWait(IceUtil::Time::seconds(5))) + { + return false; + } + } + _called = false; + return true; + } + +private: + + bool _called; +}; +typedef IceUtil::Handle<AMI_MyClass_opSleepI> AMI_MyClass_opSleepIPtr; + +Test::MyClassPrx +allTests(const Ice::CommunicatorPtr& communicator, bool collocated) +{ + cout << "testing stringToProxy... " << flush; + string ref = "test:default -p 12010 -t 10000"; + Ice::ObjectPrx base = communicator->stringToProxy(ref); + test(base); + + Ice::ObjectPrx b1 = communicator->stringToProxy("test"); + test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category.empty() && + b1->ice_getAdapterId().empty() && b1->ice_getFacet().empty()); + b1 = communicator->stringToProxy("test "); + test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category.empty() && + b1->ice_getFacet().empty()); + b1 = communicator->stringToProxy(" test "); + test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category.empty() && + b1->ice_getFacet().empty()); + b1 = communicator->stringToProxy(" test"); + test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category.empty() && + b1->ice_getFacet().empty()); + b1 = communicator->stringToProxy("'test -f facet'"); + test(b1->ice_getIdentity().name == "test -f facet" && b1->ice_getIdentity().category.empty() && + b1->ice_getFacet().empty()); + try + { + b1 = communicator->stringToProxy("\"test -f facet'"); + test(false); + } + catch(const Ice::ProxyParseException&) + { + } + b1 = communicator->stringToProxy("\"test -f facet\""); + test(b1->ice_getIdentity().name == "test -f facet" && b1->ice_getIdentity().category.empty() && + b1->ice_getFacet().empty()); + b1 = communicator->stringToProxy("\"test -f facet@test\""); + test(b1->ice_getIdentity().name == "test -f facet@test" && b1->ice_getIdentity().category.empty() && + b1->ice_getFacet().empty()); + b1 = communicator->stringToProxy("\"test -f facet@test @test\""); + test(b1->ice_getIdentity().name == "test -f facet@test @test" && b1->ice_getIdentity().category.empty() && + b1->ice_getFacet().empty()); + try + { + b1 = communicator->stringToProxy("test test"); + test(false); + } + catch(const Ice::ProxyParseException&) + { + } + b1 = communicator->stringToProxy("test\\040test"); + test(b1->ice_getIdentity().name == "test test" && b1->ice_getIdentity().category.empty()); + try + { + b1 = communicator->stringToProxy("test\\777"); + test(false); + } + catch(const Ice::IdentityParseException&) + { + } + b1 = communicator->stringToProxy("test\\40test"); + test(b1->ice_getIdentity().name == "test test"); + + // Test some octal and hex corner cases. + b1 = communicator->stringToProxy("test\\4test"); + test(b1->ice_getIdentity().name == "test\4test"); + b1 = communicator->stringToProxy("test\\04test"); + test(b1->ice_getIdentity().name == "test\4test"); + b1 = communicator->stringToProxy("test\\004test"); + test(b1->ice_getIdentity().name == "test\4test"); + b1 = communicator->stringToProxy("test\\1114test"); + test(b1->ice_getIdentity().name == "test\1114test"); + + b1 = communicator->stringToProxy("test\\b\\f\\n\\r\\t\\'\\\"\\\\test"); + test(b1->ice_getIdentity().name == "test\b\f\n\r\t\'\"\\test" && b1->ice_getIdentity().category.empty()); + + b1 = communicator->stringToProxy("category/test"); + test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category == "category" && + b1->ice_getAdapterId().empty()); + + b1 = communicator->stringToProxy("test@adapter"); + test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category.empty() && + b1->ice_getAdapterId() == "adapter"); + try + { + b1 = communicator->stringToProxy("id@adapter test"); + test(false); + } + catch(const Ice::ProxyParseException&) + { + } + b1 = communicator->stringToProxy("category/test@adapter"); + test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category == "category" && + b1->ice_getAdapterId() == "adapter"); + b1 = communicator->stringToProxy("category/test@adapter:tcp"); + test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category == "category" && + b1->ice_getAdapterId() == "adapter:tcp"); + b1 = communicator->stringToProxy("'category 1/test'@adapter"); + test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category == "category 1" && + b1->ice_getAdapterId() == "adapter"); + b1 = communicator->stringToProxy("'category/test 1'@adapter"); + test(b1->ice_getIdentity().name == "test 1" && b1->ice_getIdentity().category == "category" && + b1->ice_getAdapterId() == "adapter"); + b1 = communicator->stringToProxy("'category/test'@'adapter 1'"); + test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category == "category" && + b1->ice_getAdapterId() == "adapter 1"); + b1 = communicator->stringToProxy("\"category \\/test@foo/test\"@adapter"); + test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category == "category /test@foo" && + b1->ice_getAdapterId() == "adapter"); + b1 = communicator->stringToProxy("\"category \\/test@foo/test\"@\"adapter:tcp\""); + test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category == "category /test@foo" && + b1->ice_getAdapterId() == "adapter:tcp"); + + b1 = communicator->stringToProxy("id -f facet"); + test(b1->ice_getIdentity().name == "id" && b1->ice_getIdentity().category.empty() && + b1->ice_getFacet() == "facet"); + b1 = communicator->stringToProxy("id -f 'facet x'"); + test(b1->ice_getIdentity().name == "id" && b1->ice_getIdentity().category.empty() && + b1->ice_getFacet() == "facet x"); + b1 = communicator->stringToProxy("id -f \"facet x\""); + test(b1->ice_getIdentity().name == "id" && b1->ice_getIdentity().category.empty() && + b1->ice_getFacet() == "facet x"); + try + { + b1 = communicator->stringToProxy("id -f \"facet x"); + test(false); + } + catch(const Ice::ProxyParseException&) + { + } + try + { + b1 = communicator->stringToProxy("id -f \'facet x"); + test(false); + } + catch(const Ice::ProxyParseException&) + { + } + b1 = communicator->stringToProxy("test -f facet:tcp"); + test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category.empty() && + b1->ice_getFacet() == "facet" && b1->ice_getAdapterId().empty()); + b1 = communicator->stringToProxy("test -f \"facet:tcp\""); + test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category.empty() && + b1->ice_getFacet() == "facet:tcp" && b1->ice_getAdapterId().empty()); + b1 = communicator->stringToProxy("test -f facet@test"); + test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category.empty() && + b1->ice_getFacet() == "facet" && b1->ice_getAdapterId() == "test"); + b1 = communicator->stringToProxy("test -f 'facet@test'"); + test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category.empty() && + b1->ice_getFacet() == "facet@test" && b1->ice_getAdapterId().empty()); + b1 = communicator->stringToProxy("test -f 'facet@test'@test"); + test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category.empty() && + b1->ice_getFacet() == "facet@test" && b1->ice_getAdapterId() == "test"); + try + { + b1 = communicator->stringToProxy("test -f facet@test @test"); + test(false); + } + catch(const Ice::ProxyParseException&) + { + } + b1 = communicator->stringToProxy("test"); + test(b1->ice_isTwoway()); + b1 = communicator->stringToProxy("test -t"); + test(b1->ice_isTwoway()); + b1 = communicator->stringToProxy("test -o"); + test(b1->ice_isOneway()); + b1 = communicator->stringToProxy("test -O"); + test(b1->ice_isBatchOneway()); + b1 = communicator->stringToProxy("test -d"); + test(b1->ice_isDatagram()); + b1 = communicator->stringToProxy("test -D"); + test(b1->ice_isBatchDatagram()); + b1 = communicator->stringToProxy("test"); + test(!b1->ice_isSecure()); + b1 = communicator->stringToProxy("test -s"); + test(b1->ice_isSecure()); + + try + { + b1 = communicator->stringToProxy("test:tcp@adapterId"); + test(false); + } + catch(const Ice::EndpointParseException&) + { + } + // This is an unknown endpoint warning, not a parse exception. + // + //try + //{ + // b1 = communicator->stringToProxy("test -f the:facet:tcp"); + // test(false); + //} + //catch(const Ice::EndpointParseException&) + //{ + //} + try + { + b1 = communicator->stringToProxy("test::tcp"); + test(false); + } + catch(const Ice::EndpointParseException&) + { + } + cout << "ok" << endl; + + cout << "testing propertyToProxy... " << flush; + Ice::PropertiesPtr prop = communicator->getProperties(); + string propertyPrefix = "Foo.Proxy"; + prop->setProperty(propertyPrefix, "test:default -p 12010 -t 10000"); + b1 = communicator->propertyToProxy(propertyPrefix); + test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category.empty() && + b1->ice_getAdapterId().empty() && b1->ice_getFacet().empty()); + + // These two properties don't do anything to direct proxies so + // first we test that. + string property = propertyPrefix + ".Locator"; + test(!b1->ice_getLocator()); + prop->setProperty(property, "locator:default -p 10000"); + b1 = communicator->propertyToProxy(propertyPrefix); + test(!b1->ice_getLocator()); + prop->setProperty(property, ""); + + property = propertyPrefix + ".LocatorCacheTimeout"; + test(b1->ice_getLocatorCacheTimeout() == 0); + prop->setProperty(property, "1"); + b1 = communicator->propertyToProxy(propertyPrefix); + test(b1->ice_getLocatorCacheTimeout() == 0); + prop->setProperty(property, ""); + + // Now retest with an indirect proxy. + prop->setProperty(propertyPrefix, "test"); + property = propertyPrefix + ".Locator"; + prop->setProperty(property, "locator:default -p 10000"); + b1 = communicator->propertyToProxy(propertyPrefix); + test(b1->ice_getLocator() && b1->ice_getLocator()->ice_getIdentity().name == "locator"); + prop->setProperty(property, ""); + + property = propertyPrefix + ".LocatorCacheTimeout"; + test(b1->ice_getLocatorCacheTimeout() == -1); + prop->setProperty(property, "1"); + b1 = communicator->propertyToProxy(propertyPrefix); + test(b1->ice_getLocatorCacheTimeout() == 1); + prop->setProperty(property, ""); + + // This cannot be tested so easily because the property is cached + // on communicator initialization. + // + //prop->setProperty("Ice.Default.LocatorCacheTimeout", "60"); + //b1 = communicator->propertyToProxy(propertyPrefix); + //test(b1->ice_getLocatorCacheTimeout() == 60); + //prop->setProperty("Ice.Default.LocatorCacheTimeout", ""); + + prop->setProperty(propertyPrefix, "test:default -p 12010 -t 10000"); + + property = propertyPrefix + ".Router"; + test(!b1->ice_getRouter()); + prop->setProperty(property, "router:default -p 10000"); + b1 = communicator->propertyToProxy(propertyPrefix); + test(b1->ice_getRouter() && b1->ice_getRouter()->ice_getIdentity().name == "router"); + prop->setProperty(property, ""); + + property = propertyPrefix + ".PreferSecure"; + test(!b1->ice_isPreferSecure()); + prop->setProperty(property, "1"); + b1 = communicator->propertyToProxy(propertyPrefix); + test(b1->ice_isPreferSecure()); + prop->setProperty(property, ""); + + property = propertyPrefix + ".ConnectionCached"; + test(b1->ice_isConnectionCached()); + prop->setProperty(property, "0"); + b1 = communicator->propertyToProxy(propertyPrefix); + test(!b1->ice_isConnectionCached()); + prop->setProperty(property, ""); + + property = propertyPrefix + ".EndpointSelection"; + test(b1->ice_getEndpointSelection() == Ice::Random); + prop->setProperty(property, "Random"); + b1 = communicator->propertyToProxy(propertyPrefix); + test(b1->ice_getEndpointSelection() == Ice::Random); + prop->setProperty(property, "Ordered"); + b1 = communicator->propertyToProxy(propertyPrefix); + test(b1->ice_getEndpointSelection() == Ice::Ordered); + prop->setProperty(property, ""); + + property = propertyPrefix + ".CollocationOptimization"; + test(b1->ice_isCollocationOptimized()); + prop->setProperty(property, "0"); + b1 = communicator->propertyToProxy(propertyPrefix); + test(!b1->ice_isCollocationOptimized()); + prop->setProperty(property, ""); + + property = propertyPrefix + ".ThreadPerConnection"; + test(!b1->ice_isThreadPerConnection()); + prop->setProperty(property, "1"); + b1 = communicator->propertyToProxy(propertyPrefix); + test(b1->ice_isThreadPerConnection()); + prop->setProperty(property, ""); + + cout << "ok" << endl; + + cout << "testing ice_getCommunicator... " << flush; + test(base->ice_getCommunicator() == communicator); + cout << "ok" << endl; + + cout << "testing proxy methods... " << flush; + test(communicator->identityToString(base->ice_identity(communicator->stringToIdentity("other"))->ice_getIdentity()) + == "other"); + test(base->ice_facet("facet")->ice_getFacet() == "facet"); + test(base->ice_adapterId("id")->ice_getAdapterId() == "id"); + test(base->ice_twoway()->ice_isTwoway()); + test(base->ice_oneway()->ice_isOneway()); + test(base->ice_batchOneway()->ice_isBatchOneway()); + test(base->ice_datagram()->ice_isDatagram()); + test(base->ice_batchDatagram()->ice_isBatchDatagram()); + test(base->ice_secure(true)->ice_isSecure()); + test(!base->ice_secure(false)->ice_isSecure()); + test(base->ice_collocationOptimized(true)->ice_isCollocationOptimized()); + test(!base->ice_collocationOptimized(false)->ice_isCollocationOptimized()); + cout << "ok" << endl; + + cout << "testing proxy comparison... " << flush; + + test(communicator->stringToProxy("foo") == communicator->stringToProxy("foo")); + test(communicator->stringToProxy("foo") != communicator->stringToProxy("foo2")); + test(communicator->stringToProxy("foo") < communicator->stringToProxy("foo2")); + test(!(communicator->stringToProxy("foo2") < communicator->stringToProxy("foo"))); + + Ice::ObjectPrx compObj = communicator->stringToProxy("foo"); + + test(compObj->ice_facet("facet") == compObj->ice_facet("facet")); + test(compObj->ice_facet("facet") != compObj->ice_facet("facet1")); + test(compObj->ice_facet("facet") < compObj->ice_facet("facet1")); + test(!(compObj->ice_facet("facet") < compObj->ice_facet("facet"))); + + test(compObj->ice_oneway() == compObj->ice_oneway()); + test(compObj->ice_oneway() != compObj->ice_twoway()); + test(compObj->ice_twoway() < compObj->ice_oneway()); + test(!(compObj->ice_oneway() < compObj->ice_twoway())); + + test(compObj->ice_secure(true) == compObj->ice_secure(true)); + test(compObj->ice_secure(false) != compObj->ice_secure(true)); + test(compObj->ice_secure(false) < compObj->ice_secure(true)); + test(!(compObj->ice_secure(true) < compObj->ice_secure(false))); + + test(compObj->ice_collocationOptimized(true) == compObj->ice_collocationOptimized(true)); + test(compObj->ice_collocationOptimized(false) != compObj->ice_collocationOptimized(true)); + test(compObj->ice_collocationOptimized(false) < compObj->ice_collocationOptimized(true)); + test(!(compObj->ice_collocationOptimized(true) < compObj->ice_collocationOptimized(false))); + + test(compObj->ice_connectionCached(true) == compObj->ice_connectionCached(true)); + test(compObj->ice_connectionCached(false) != compObj->ice_connectionCached(true)); + test(compObj->ice_connectionCached(false) < compObj->ice_connectionCached(true)); + test(!(compObj->ice_connectionCached(true) < compObj->ice_connectionCached(false))); + + test(compObj->ice_endpointSelection(Ice::Random) == compObj->ice_endpointSelection(Ice::Random)); + test(compObj->ice_endpointSelection(Ice::Random) != compObj->ice_endpointSelection(Ice::Ordered)); + test(compObj->ice_endpointSelection(Ice::Random) < compObj->ice_endpointSelection(Ice::Ordered)); + test(!(compObj->ice_endpointSelection(Ice::Ordered) < compObj->ice_endpointSelection(Ice::Random))); + + test(compObj->ice_connectionId("id2") == compObj->ice_connectionId("id2")); + test(compObj->ice_connectionId("id1") != compObj->ice_connectionId("id2")); + test(compObj->ice_connectionId("id1") < compObj->ice_connectionId("id2")); + test(!(compObj->ice_connectionId("id2") < compObj->ice_connectionId("id1"))); + + test(compObj->ice_compress(true) == compObj->ice_compress(true)); + test(compObj->ice_compress(false) != compObj->ice_compress(true)); + test(compObj->ice_compress(false) < compObj->ice_compress(true)); + test(!(compObj->ice_compress(true) < compObj->ice_compress(false))); + + test(compObj->ice_timeout(20) == compObj->ice_timeout(20)); + test(compObj->ice_timeout(10) != compObj->ice_timeout(20)); + test(compObj->ice_timeout(10) < compObj->ice_timeout(20)); + test(!(compObj->ice_timeout(20) < compObj->ice_timeout(10))); + + Ice::ObjectPrx compObj1 = communicator->stringToProxy("foo:tcp -h 127.0.0.1 -p 10000"); + Ice::ObjectPrx compObj2 = communicator->stringToProxy("foo:tcp -h 127.0.0.1 -p 10001"); + test(compObj1 != compObj2); + test(compObj1 < compObj2); + test(!(compObj2 < compObj1)); + + compObj1 = communicator->stringToProxy("foo@MyAdapter1"); + compObj2 = communicator->stringToProxy("foo@MyAdapter2"); + test(compObj1 != compObj2); + test(compObj1 < compObj2); + test(!(compObj2 < compObj1)); + + test(compObj1->ice_locatorCacheTimeout(20) == compObj1->ice_locatorCacheTimeout(20)); + test(compObj1->ice_locatorCacheTimeout(10) != compObj1->ice_locatorCacheTimeout(20)); + test(compObj1->ice_locatorCacheTimeout(10) < compObj1->ice_locatorCacheTimeout(20)); + test(!(compObj1->ice_locatorCacheTimeout(20) < compObj1->ice_locatorCacheTimeout(10))); + + compObj1 = communicator->stringToProxy("foo:tcp -h 127.0.0.1 -p 1000"); + compObj2 = communicator->stringToProxy("foo@MyAdapter1"); + test(compObj1 != compObj2); + test(compObj1 < compObj2); + test(!(compObj2 < compObj1)); + + // + // TODO: Ideally we should also test comparison of fixed proxies. + // + + cout << "ok" << endl; + + cout << "testing checked cast... " << flush; + Test::MyClassPrx cl = Test::MyClassPrx::checkedCast(base); + test(cl); + + Test::MyDerivedClassPrx derived = Test::MyDerivedClassPrx::checkedCast(cl); + test(derived); + test(cl == base); + test(derived == base); + test(cl == derived); + + Ice::LocatorPrx loc = Ice::LocatorPrx::checkedCast(base); + test(loc == 0); + + // + // Upcasting + // + Test::MyClassPrx cl2 = Test::MyClassPrx::checkedCast(derived); + Ice::ObjectPrx obj = Ice::ObjectPrx::checkedCast(derived); + test(cl2); + test(obj); + test(cl2 == obj); + test(cl2 == derived); + + // + // Now with alternate API + // + cl = checkedCast<Test::MyClassPrx>(base); + test(cl); + derived = checkedCast<Test::MyDerivedClassPrx>(cl); + test(derived); + test(cl == base); + test(derived == base); + test(cl == derived); + + loc = checkedCast<Ice::LocatorPrx>(base); + test(loc == 0); + + cl2 = checkedCast<Test::MyClassPrx>(derived); + obj = checkedCast<Ice::ObjectPrx>(derived); + test(cl2); + test(obj); + test(cl2 == obj); + test(cl2 == derived); + + cout << "ok" << endl; + + cout << "testing checked cast with context... " << flush; + Ice::Context c = cl->getContext(); + test(c.size() == 0); + + c["one"] = "hello"; + c["two"] = "world"; + cl = Test::MyClassPrx::checkedCast(base, c); + Ice::Context c2 = cl->getContext(); + test(c == c2); + + // + // Now with alternate API + // + cl = checkedCast<Test::MyClassPrx>(base); + c = cl->getContext(); + test(c.size() == 0); + + cl = checkedCast<Test::MyClassPrx>(base, c); + c2 = cl->getContext(); + test(c == c2); + + cout << "ok" << endl; + + if(!collocated) + { + cout << "testing timeout... " << flush; + Test::MyClassPrx clTimeout = Test::MyClassPrx::uncheckedCast(base->ice_timeout(500)); + try + { + clTimeout->opSleep(2000); + test(false); + } + catch(const Ice::TimeoutException&) + { + } + + AMI_MyClass_opSleepIPtr cb = new AMI_MyClass_opSleepI(); + try + { + clTimeout->opSleep_async(cb, 2000); + } + catch(const Ice::Exception&) + { + test(false); + } + test(cb->check()); + + cout << "ok" << endl; + } + + return cl; +} diff --git a/cpp/test/Ice/proxy/Client.cpp b/cpp/test/Ice/proxy/Client.cpp new file mode 100644 index 00000000000..c9527dea93a --- /dev/null +++ b/cpp/test/Ice/proxy/Client.cpp @@ -0,0 +1,86 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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. +// +// ********************************************************************** + +#include <Ice/Ice.h> +#include <TestCommon.h> +#include <Test.h> + +using namespace std; + +int +run(int argc, char* argv[], + const Ice::CommunicatorPtr& communicator, + const Ice::InitializationData& initData) +{ + Test::MyClassPrx allTests(const Ice::CommunicatorPtr&, bool); + Test::MyClassPrx myClass = allTests(communicator, false); + + myClass->shutdown(); + + return EXIT_SUCCESS; +} + +int +main(int argc, char* argv[]) +{ + int status; + Ice::CommunicatorPtr communicator; + + try + { + // + // In this test, we need at least two threads in the + // client side thread pool for nested AMI. + // + Ice::InitializationData initData; + initData.properties = Ice::createProperties(argc, argv); + initData.properties->setProperty("Ice.ThreadPool.Client.Size", "2"); + initData.properties->setProperty("Ice.ThreadPool.Client.SizeWarn", "0"); + + // + // We must set MessageSizeMax to an explicit values, because + // we run tests to check whether Ice.MemoryLimitException is + // raised as expected. + // + initData.properties->setProperty("Ice.MessageSizeMax", "100"); + + // + // We don't want connection warnings because of the timeout test. + // + initData.properties->setProperty("Ice.Warn.Connections", "0"); + // + // Use a faster connection monitor timeout to test AMI + // timeouts. + // + initData.properties->setProperty("Ice.MonitorConnections", "1"); + + communicator = Ice::initialize(argc, argv, initData); + status = run(argc, argv, communicator, initData); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } + + if(communicator) + { + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } + } + + return status; +} diff --git a/cpp/test/Ice/proxy/Collocated.cpp b/cpp/test/Ice/proxy/Collocated.cpp new file mode 100644 index 00000000000..f27d5051d8c --- /dev/null +++ b/cpp/test/Ice/proxy/Collocated.cpp @@ -0,0 +1,63 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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. +// +// ********************************************************************** + +#include <Ice/Ice.h> +#include <TestI.h> + +using namespace std; + +int +run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator, + const Ice::InitializationData& initData) +{ + communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010 -t 10000"); + Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); + adapter->add(new MyDerivedClassI, communicator->stringToIdentity("test")); + adapter->activate(); + + Test::MyClassPrx allTests(const Ice::CommunicatorPtr&, bool); + allTests(communicator, true); + + return EXIT_SUCCESS; +} + +int +main(int argc, char* argv[]) +{ + int status; + Ice::CommunicatorPtr communicator; + + try + { + Ice::InitializationData initData; + initData.properties = Ice::createProperties(argc, argv); + communicator = Ice::initialize(argc, argv, initData); + status = run(argc, argv, communicator, initData); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } + + if(communicator) + { + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } + } + + return status; +} diff --git a/cpp/test/Ice/proxy/Makefile b/cpp/test/Ice/proxy/Makefile new file mode 100644 index 00000000000..4ddbf17fa14 --- /dev/null +++ b/cpp/test/Ice/proxy/Makefile @@ -0,0 +1,63 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2007 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 = ../../.. + +CLIENT = client +SERVER = server +SERVERAMD = serveramd +COLLOCATED = collocated + +TARGETS = $(CLIENT) $(SERVER) $(SERVERAMD) $(COLLOCATED) + +COBJS = Test.o \ + Client.o \ + AllTests.o + +SOBJS = Test.o \ + TestI.o \ + Server.o + +SAMDOBJS = TestAMD.o \ + TestAMDI.o \ + ServerAMD.o + +COLOBJS = Test.o \ + TestI.o \ + Collocated.o \ + AllTests.o + +SRCS = $(COBJS:.o=.cpp) \ + $(SOBJS:.o=.cpp) \ + $(SAMDOBJS:.o=.cpp) \ + $(COLOBJS:.o=.cpp) + +SLICE_SRCS = Test.ice TestAMD.ice + +include $(top_srcdir)/config/Make.rules + +CPPFLAGS := -I. -I../../include $(CPPFLAGS) + +$(CLIENT): $(COBJS) + rm -f $@ + $(CXX) $(LDFLAGS) -o $@ $(COBJS) $(LIBS) + +$(SERVER): $(SOBJS) + rm -f $@ + $(CXX) $(LDFLAGS) -o $@ $(SOBJS) $(LIBS) + +$(SERVERAMD): $(SAMDOBJS) + rm -f $@ + $(CXX) $(LDFLAGS) -o $@ $(SAMDOBJS) $(LIBS) + +$(COLLOCATED): $(COLOBJS) + rm -f $@ + $(CXX) $(LDFLAGS) -o $@ $(COLOBJS) $(LIBS) + +include .depend diff --git a/cpp/test/Ice/proxy/Makefile.mak b/cpp/test/Ice/proxy/Makefile.mak new file mode 100644 index 00000000000..c44745d9aa3 --- /dev/null +++ b/cpp/test/Ice/proxy/Makefile.mak @@ -0,0 +1,76 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2007 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 = ..\..\.. + +CLIENT = client.exe +SERVER = server.exe +SERVERAMD = serveramd.exe +COLLOCATED = collocated.exe + +TARGETS = $(CLIENT) $(SERVER) $(SERVERAMD) $(COLLOCATED) + +COBJS = Test.obj \ + Client.obj \ + AllTests.obj + +SOBJS = Test.obj \ + TestI.obj \ + Server.obj + +SAMDOBJS = TestAMD.obj \ + TestAMDI.obj \ + ServerAMD.obj + +COLOBJS = Test.obj \ + TestI.obj \ + Collocated.obj \ + AllTests.obj + +SRCS = $(COBJS:.obj=.cpp) \ + $(SOBJS:.obj=.cpp) \ + $(SAMDOBJS:.obj=.cpp) \ + $(COLOBJS:.obj=.cpp) + +!include $(top_srcdir)/config/Make.rules.mak + +CPPFLAGS = -I. -I../../include $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN + +!if "$(CPP_COMPILER)" != "BCC2006" & "$(OPTIMIZE)" != "yes" +CPDBFLAGS = /pdb:$(CLIENT:.exe=.pdb) +SPDBFLAGS = /pdb:$(SERVER:.exe=.pdb) +SAPDBFLAGS = /pdb:$(SERVERAMD:.exe=.pdb) +COPDBFLAGS = /pdb:$(COLLOCATED:.exe=.pdb) +!endif + +$(CLIENT): $(COBJS) + $(LINK) $(LD_EXEFLAGS) $(CPDBFLAGS) $(SETARGV) $(COBJS) $(PREOUT)$@ $(PRELIBS)$(LIBS) + @if exist $@.manifest echo ^ ^ ^ Embedding manifest using $(MT) && \ + $(MT) -nologo -manifest $@.manifest -outputresource:$@;#1 && del /q $@.manifest + +$(SERVER): $(SOBJS) + $(LINK) $(LD_EXEFLAGS) $(SPDBFLAGS) $(SETARGV) $(SOBJS) $(PREOUT)$@ $(PRELIBS)$(LIBS) + @if exist $@.manifest echo ^ ^ ^ Embedding manifest using $(MT) && \ + $(MT) -nologo -manifest $@.manifest -outputresource:$@;#1 && del /q $@.manifest + +$(SERVERAMD): $(SAMDOBJS) + $(LINK) $(LD_EXEFLAGS) $(SAPDBFLAGS) $(SETARGV) $(SAMDOBJS) $(PREOUT)$@ $(PRELIBS)$(LIBS) + @if exist $@.manifest echo ^ ^ ^ Embedding manifest using $(MT) && \ + $(MT) -nologo -manifest $@.manifest -outputresource:$@;#1 && del /q $@.manifest + +$(COLLOCATED): $(COLOBJS) + $(LINK) $(LD_EXEFLAGS) $(COPDBFLAGS) $(SETARGV) $(COLOBJS) $(PREOUT)$@ $(PRELIBS)$(LIBS) + @if exist $@.manifest echo ^ ^ ^ Embedding manifest using $(MT) && \ + $(MT) -nologo -manifest $@.manifest -outputresource:$@;#1 && del /q $@.manifest + +clean:: + del /q Test.cpp Test.h + del /q TestAMD.cpp TestAMD.h + +!include .depend diff --git a/cpp/test/Ice/proxy/Server.cpp b/cpp/test/Ice/proxy/Server.cpp new file mode 100644 index 00000000000..1d5320e0966 --- /dev/null +++ b/cpp/test/Ice/proxy/Server.cpp @@ -0,0 +1,62 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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. +// +// ********************************************************************** + +#include <Ice/Ice.h> +#include <TestI.h> + +using namespace std; + +int +run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) +{ + communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010 -t 10000:udp"); + Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); + adapter->add(new MyDerivedClassI, communicator->stringToIdentity("test")); + adapter->activate(); + + communicator->waitForShutdown(); + return EXIT_SUCCESS; +} + +int +main(int argc, char* argv[]) +{ + int status; + Ice::CommunicatorPtr communicator; + + try + { + Ice::InitializationData initData; + initData.properties = Ice::createProperties(argc, argv); + initData.properties->setProperty("Ice.Warn.Connections", "0"); + + communicator = Ice::initialize(argc, argv, initData); + status = run(argc, argv, communicator); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } + + if(communicator) + { + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } + } + + return status; +} diff --git a/cpp/test/Ice/proxy/ServerAMD.cpp b/cpp/test/Ice/proxy/ServerAMD.cpp new file mode 100644 index 00000000000..9f28e51268a --- /dev/null +++ b/cpp/test/Ice/proxy/ServerAMD.cpp @@ -0,0 +1,62 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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. +// +// ********************************************************************** + +#include <Ice/Ice.h> +#include <TestAMDI.h> + +using namespace std; + +int +run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) +{ + communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010 -t 10000:udp"); + Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); + adapter->add(new MyDerivedClassI, communicator->stringToIdentity("test")); + adapter->activate(); + + communicator->waitForShutdown(); + return EXIT_SUCCESS; +} + +int +main(int argc, char* argv[]) +{ + int status; + Ice::CommunicatorPtr communicator; + + try + { + Ice::InitializationData initData; + initData.properties = Ice::createProperties(argc, argv); + initData.properties->setProperty("Ice.Warn.Connections", "0"); + communicator = Ice::initialize(argc, argv, initData); + status = run(argc, argv, communicator); + + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } + + if(communicator) + { + try + { + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } + } + + return status; +} diff --git a/cpp/test/Ice/proxy/Test.ice b/cpp/test/Ice/proxy/Test.ice new file mode 100644 index 00000000000..e10a511f151 --- /dev/null +++ b/cpp/test/Ice/proxy/Test.ice @@ -0,0 +1,32 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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. +// +// ********************************************************************** + +#ifndef TEST_ICE +#define TEST_ICE + +#include <Ice/Current.ice> + +module Test +{ + +["ami"] class MyClass +{ + void shutdown(); + + void opSleep(int duration); + Ice::Context getContext(); +}; + +["ami"] class MyDerivedClass extends MyClass +{ +}; + +}; + +#endif diff --git a/cpp/test/Ice/proxy/TestAMD.ice b/cpp/test/Ice/proxy/TestAMD.ice new file mode 100644 index 00000000000..f67d0685d8e --- /dev/null +++ b/cpp/test/Ice/proxy/TestAMD.ice @@ -0,0 +1,32 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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. +// +// ********************************************************************** + +#ifndef TEST_AMD_ICE +#define TEST_AMD_ICE + +#include <Ice/Current.ice> + +module Test +{ + +["ami", "amd"] class MyClass +{ + void shutdown(); + + void opSleep(int duration); + Ice::Context getContext(); +}; + +["ami", "amd"] class MyDerivedClass extends MyClass +{ +}; + +}; + +#endif diff --git a/cpp/test/Ice/proxy/TestAMDI.cpp b/cpp/test/Ice/proxy/TestAMDI.cpp new file mode 100644 index 00000000000..bcec57f5c14 --- /dev/null +++ b/cpp/test/Ice/proxy/TestAMDI.cpp @@ -0,0 +1,53 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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. +// +// ********************************************************************** + +#include <Ice/Ice.h> +#include <TestAMDI.h> +#include <TestCommon.h> +#include <functional> +#ifdef __BCPLUSPLUS__ +# include <iterator> +#endif + +MyDerivedClassI::MyDerivedClassI() +{ +} + +void +MyDerivedClassI::shutdown_async(const Test::AMD_MyClass_shutdownPtr& cb, const Ice::Current& c) +{ + c.adapter->getCommunicator()->shutdown(); + cb->ice_response(); +} + +void +MyDerivedClassI::opSleep_async(const Test::AMD_MyClass_opSleepPtr& cb, + int duration, + const Ice::Current&) +{ + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(duration)); + cb->ice_response(); +} + +void +MyDerivedClassI::getContext_async(const Test::AMD_MyClass_getContextPtr& cb, const Ice::Current&) +{ + cb->ice_response(_ctx); +} + +bool +MyDerivedClassI::ice_isA(const std::string& s, const Ice::Current& current) const +{ + _ctx = current.ctx; +#ifdef __BCPLUSPLUS__ + return Test::MyDerivedClass::ice_isA(s, current); +#else + return MyDerivedClass::ice_isA(s, current); +#endif +} diff --git a/cpp/test/Ice/proxy/TestAMDI.h b/cpp/test/Ice/proxy/TestAMDI.h new file mode 100644 index 00000000000..e0e9b7f5acb --- /dev/null +++ b/cpp/test/Ice/proxy/TestAMDI.h @@ -0,0 +1,39 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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. +// +// ********************************************************************** + +#ifndef TEST_AMD_I_H +#define TEST_AMD_I_H + +#include <IceUtil/Thread.h> +#include <TestAMD.h> + +class MyDerivedClassI : public Test::MyDerivedClass +{ +public: + + MyDerivedClassI(); + + virtual void shutdown_async(const Test::AMD_MyClass_shutdownPtr&, + const Ice::Current&); + + virtual void opSleep_async(const Test::AMD_MyClass_opSleepPtr&, + int, + const Ice::Current&); + + virtual void getContext_async(const Test::AMD_MyClass_getContextPtr& cb, + const Ice::Current&); + virtual bool ice_isA(const std::string&, const Ice::Current&) const; + + +private: + + mutable Ice::Context _ctx; +}; + +#endif diff --git a/cpp/test/Ice/proxy/TestI.cpp b/cpp/test/Ice/proxy/TestI.cpp new file mode 100644 index 00000000000..f3618acd34a --- /dev/null +++ b/cpp/test/Ice/proxy/TestI.cpp @@ -0,0 +1,50 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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. +// +// ********************************************************************** + +#include <Ice/Ice.h> +#include <IceUtil/IceUtil.h> +#include <TestI.h> +#include <TestCommon.h> +#include <functional> +#ifdef __BCPLUSPLUS__ +# include <iterator> +#endif + +MyDerivedClassI::MyDerivedClassI() +{ +} + +void +MyDerivedClassI::shutdown(const Ice::Current& c) +{ + c.adapter->getCommunicator()->shutdown(); +} + +void +MyDerivedClassI::opSleep(int duration, const Ice::Current&) +{ + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(duration)); +} + +Ice::Context +MyDerivedClassI::getContext(const Ice::Current& c) +{ + return _ctx; +} + +bool +MyDerivedClassI::ice_isA(const std::string& s, const Ice::Current& current) const +{ + _ctx = current.ctx; +#ifdef __BCPLUSPLUS__ + return Test::MyDerivedClass::ice_isA(s, current); +#else + return MyDerivedClass::ice_isA(s, current); +#endif +} diff --git a/cpp/test/Ice/proxy/TestI.h b/cpp/test/Ice/proxy/TestI.h new file mode 100644 index 00000000000..81420fbf40b --- /dev/null +++ b/cpp/test/Ice/proxy/TestI.h @@ -0,0 +1,31 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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. +// +// ********************************************************************** + +#ifndef TEST_I_H +#define TEST_I_H + +#include <Test.h> + +class MyDerivedClassI : public Test::MyDerivedClass +{ +public: + + MyDerivedClassI(); + + virtual void shutdown(const Ice::Current&); + virtual void opSleep(int, const Ice::Current&); + virtual Ice::Context getContext(const Ice::Current&); + virtual bool ice_isA(const std::string&, const Ice::Current&) const; + +private: + + mutable Ice::Context _ctx; +}; + +#endif diff --git a/cpp/test/Ice/proxy/run.py b/cpp/test/Ice/proxy/run.py new file mode 100755 index 00000000000..6c5b7b0e492 --- /dev/null +++ b/cpp/test/Ice/proxy/run.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2007 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 + +for toplevel in [".", "..", "../..", "../../..", "../../../.."]: + toplevel = os.path.normpath(toplevel) + if os.path.exists(os.path.join(toplevel, "config", "TestUtil.py")): + break +else: + raise "can't find toplevel directory!" + +sys.path.append(os.path.join(toplevel, "config")) +import TestUtil + +name = os.path.join("Ice", "proxy") + +print "tests with regular server." +TestUtil.clientServerTest(name) +print "tests with AMD server." +TestUtil.clientServerTestWithOptionsAndNames(name, "", "", "serveramd", "client") +print "tests with collocated server." +TestUtil.collocatedTest(name) +sys.exit(0) diff --git a/cs/CHANGES b/cs/CHANGES index 514734d7d19..e15d67010f8 100644 --- a/cs/CHANGES +++ b/cs/CHANGES @@ -1,3 +1,9 @@ +Changes since version 3.2.0 +--------------------------- + +- Trailing characters past the adapter id in a stringified proxy + will now raise a ProxyParseException. + Changes since version 3.1.1 --------------------------- diff --git a/cs/allTests.py b/cs/allTests.py index 682fad37d1c..ced054d93a8 100755 --- a/cs/allTests.py +++ b/cs/allTests.py @@ -68,6 +68,7 @@ def runTests(args, tests, num = 0): # tests = [ \ "IceUtil/inputUtil", \ + "Ice/proxy", \ "Ice/operations", \ "Ice/exceptions", \ "Ice/inheritance", \ diff --git a/cs/src/Ice/ReferenceFactory.cs b/cs/src/Ice/ReferenceFactory.cs index 6c6d91b027a..9e96d939e9a 100755 --- a/cs/src/Ice/ReferenceFactory.cs +++ b/cs/src/Ice/ReferenceFactory.cs @@ -486,6 +486,7 @@ namespace IceInternal throw e; } + string adapterstr = null; end = IceUtil.StringUtil.checkQuote(s, beg); if(end == -1) { @@ -500,13 +501,24 @@ namespace IceInternal { end = s.Length; } + adapterstr = s.Substring(beg, end - beg); } else { beg++; // Skip leading quote + adapterstr = s.Substring(beg, end - beg); + end++; // Skip trailing quote } - if(!IceUtil.StringUtil.unescapeString(s, beg, end, out adapter) || adapter.Length == 0) + if(end != s.Length && IceUtil.StringUtil.findFirstNotOf(s, delim, end) != -1) + { + Ice.ProxyParseException e = new Ice.ProxyParseException(); + e.str = s; + throw e; + } + + if(!IceUtil.StringUtil.unescapeString(adapterstr, 0, adapterstr.Length, out adapter) || + adapter.Length == 0) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = s; diff --git a/cs/test/Ice/Makefile b/cs/test/Ice/Makefile index 2f69e924bf2..9c42d90703a 100644 --- a/cs/test/Ice/Makefile +++ b/cs/test/Ice/Makefile @@ -21,6 +21,7 @@ SUBDIRS = application \ location \ objects \ binding \ + proxy \ operations \ slicing \ checksum \ diff --git a/cs/test/Ice/Makefile.mak b/cs/test/Ice/Makefile.mak index 101721b6cc7..662b7447bab 100755 --- a/cs/test/Ice/Makefile.mak +++ b/cs/test/Ice/Makefile.mak @@ -21,6 +21,7 @@ SUBDIRS = application \ location \ objects \ binding \ + proxy \ operations \ slicing \ checksum \ diff --git a/cs/test/Ice/proxy/.depend b/cs/test/Ice/proxy/.depend new file mode 100644 index 00000000000..b4d0a8fb00f --- /dev/null +++ b/cs/test/Ice/proxy/.depend @@ -0,0 +1,2 @@ +Test.cs: ./Test.ice $(slicedir)/Ice/Current.ice $(slicedir)/Ice/ObjectAdapterF.ice $(slicedir)/Ice/ConnectionF.ice $(slicedir)/Ice/Identity.ice +TestAMD.cs: ./TestAMD.ice $(slicedir)/Ice/Current.ice $(slicedir)/Ice/ObjectAdapterF.ice $(slicedir)/Ice/ConnectionF.ice $(slicedir)/Ice/Identity.ice diff --git a/cs/test/Ice/proxy/AllTests.cs b/cs/test/Ice/proxy/AllTests.cs new file mode 100644 index 00000000000..a381854e3ee --- /dev/null +++ b/cs/test/Ice/proxy/AllTests.cs @@ -0,0 +1,497 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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; +using System.Diagnostics; +using System.Threading; + +public class AllTests +{ + private static void test(bool b) + { + if (!b) + { + throw new Exception(); + } + } + + class AMI_MyClass_opSleepI : Test.AMI_MyClass_opSleep + { + override public void + ice_response() + { + test(false); + } + + override public void + ice_exception(Ice.Exception ex) + { + lock(this) + { + Debug.Assert(!_called); + _called = true; + Monitor.Pulse(this); + test(ex is Ice.TimeoutException); + } + } + + public bool check() + { + lock(this) + { + while(!_called) + { + Monitor.Wait(this, 5000); + + if(!_called) + { + return false; // Must be timeout. + } + } + + _called = false; + return true; + } + } + private bool _called = false; + }; + + public static Test.MyClassPrx allTests(Ice.Communicator communicator, bool collocated) + { + Console.Out.Write("testing stringToProxy... "); + Console.Out.Flush(); + string rf = "test:default -p 12010 -t 10000"; + Ice.ObjectPrx baseProxy = communicator.stringToProxy(rf); + test(baseProxy != null); + + Ice.ObjectPrx b1 = communicator.stringToProxy("test"); + test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && + b1.ice_getAdapterId().Length == 0 && b1.ice_getFacet().Length == 0); + b1 = communicator.stringToProxy("test "); + test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && + b1.ice_getFacet().Length == 0); + b1 = communicator.stringToProxy(" test "); + test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && + b1.ice_getFacet().Length == 0); + b1 = communicator.stringToProxy(" test"); + test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && + b1.ice_getFacet().Length == 0); + b1 = communicator.stringToProxy("'test -f facet'"); + test(b1.ice_getIdentity().name.Equals("test -f facet") && b1.ice_getIdentity().category.Length == 0 && + b1.ice_getFacet().Length == 0); + try + { + b1 = communicator.stringToProxy("\"test -f facet'"); + test(false); + } + catch(Ice.ProxyParseException) + { + } + b1 = communicator.stringToProxy("\"test -f facet\""); + test(b1.ice_getIdentity().name.Equals("test -f facet") && b1.ice_getIdentity().category.Length == 0 && + b1.ice_getFacet().Length == 0); + b1 = communicator.stringToProxy("\"test -f facet@test\""); + test(b1.ice_getIdentity().name.Equals("test -f facet@test") && b1.ice_getIdentity().category.Length == 0 && + b1.ice_getFacet().Length == 0); + b1 = communicator.stringToProxy("\"test -f facet@test @test\""); + test(b1.ice_getIdentity().name.Equals("test -f facet@test @test") && b1.ice_getIdentity().category.Length == 0 && + b1.ice_getFacet().Length == 0); + try + { + b1 = communicator.stringToProxy("test test"); + test(false); + } + catch(Ice.ProxyParseException) + { + } + b1 = communicator.stringToProxy("test\\040test"); + test(b1.ice_getIdentity().name.Equals("test test") && b1.ice_getIdentity().category.Length == 0); + try + { + b1 = communicator.stringToProxy("test\\777"); + test(false); + } + catch(Ice.IdentityParseException) + { + } + b1 = communicator.stringToProxy("test\\40test"); + test(b1.ice_getIdentity().name.Equals("test test")); + + // Test some octal and hex corner cases. + b1 = communicator.stringToProxy("test\\4test"); + test(b1.ice_getIdentity().name.Equals("test\u0004test")); + b1 = communicator.stringToProxy("test\\04test"); + test(b1.ice_getIdentity().name.Equals("test\u0004test")); + b1 = communicator.stringToProxy("test\\004test"); + test(b1.ice_getIdentity().name.Equals("test\u0004test")); + b1 = communicator.stringToProxy("test\\1114test"); + test(b1.ice_getIdentity().name.Equals("test\u00494test")); + + b1 = communicator.stringToProxy("test\\b\\f\\n\\r\\t\\'\\\"\\\\test"); + test(b1.ice_getIdentity().name.Equals("test\b\f\n\r\t\'\"\\test") && b1.ice_getIdentity().category.Length == 0); + + b1 = communicator.stringToProxy("category/test"); + test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Equals("category") && + b1.ice_getAdapterId().Length == 0); + + b1 = communicator.stringToProxy("test@adapter"); + test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && + b1.ice_getAdapterId().Equals("adapter")); + try + { + b1 = communicator.stringToProxy("id@adapter test"); + test(false); + } + catch(Ice.ProxyParseException) + { + } + b1 = communicator.stringToProxy("category/test@adapter"); + test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Equals("category") && + b1.ice_getAdapterId().Equals("adapter")); + b1 = communicator.stringToProxy("category/test@adapter:tcp"); + test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Equals("category") && + b1.ice_getAdapterId().Equals("adapter:tcp")); + b1 = communicator.stringToProxy("'category 1/test'@adapter"); + test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Equals("category 1") && + b1.ice_getAdapterId().Equals("adapter")); + b1 = communicator.stringToProxy("'category/test 1'@adapter"); + test(b1.ice_getIdentity().name.Equals("test 1") && b1.ice_getIdentity().category.Equals("category") && + b1.ice_getAdapterId().Equals("adapter")); + b1 = communicator.stringToProxy("'category/test'@'adapter 1'"); + test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Equals("category") && + b1.ice_getAdapterId().Equals("adapter 1")); + b1 = communicator.stringToProxy("\"category \\/test@foo/test\"@adapter"); + test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Equals("category /test@foo") && + b1.ice_getAdapterId().Equals("adapter")); + b1 = communicator.stringToProxy("\"category \\/test@foo/test\"@\"adapter:tcp\""); + test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Equals("category /test@foo") && + b1.ice_getAdapterId().Equals("adapter:tcp")); + + b1 = communicator.stringToProxy("id -f facet"); + test(b1.ice_getIdentity().name.Equals("id") && b1.ice_getIdentity().category.Length == 0 && + b1.ice_getFacet().Equals("facet")); + b1 = communicator.stringToProxy("id -f 'facet x'"); + test(b1.ice_getIdentity().name.Equals("id") && b1.ice_getIdentity().category.Length == 0 && + b1.ice_getFacet().Equals("facet x")); + b1 = communicator.stringToProxy("id -f \"facet x\""); + test(b1.ice_getIdentity().name.Equals("id") && b1.ice_getIdentity().category.Length == 0 && + b1.ice_getFacet().Equals("facet x")); + try + { + b1 = communicator.stringToProxy("id -f \"facet x"); + test(false); + } + catch(Ice.ProxyParseException) + { + } + try + { + b1 = communicator.stringToProxy("id -f \'facet x"); + test(false); + } + catch(Ice.ProxyParseException) + { + } + b1 = communicator.stringToProxy("test -f facet:tcp"); + test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && + b1.ice_getFacet().Equals("facet") && b1.ice_getAdapterId().Length == 0); + b1 = communicator.stringToProxy("test -f \"facet:tcp\""); + test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && + b1.ice_getFacet().Equals("facet:tcp") && b1.ice_getAdapterId().Length == 0); + b1 = communicator.stringToProxy("test -f facet@test"); + test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && + b1.ice_getFacet().Equals("facet") && b1.ice_getAdapterId().Equals("test")); + b1 = communicator.stringToProxy("test -f 'facet@test'"); + test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && + b1.ice_getFacet().Equals("facet@test") && b1.ice_getAdapterId().Length == 0); + b1 = communicator.stringToProxy("test -f 'facet@test'@test"); + test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && + b1.ice_getFacet().Equals("facet@test") && b1.ice_getAdapterId().Equals("test")); + try + { + b1 = communicator.stringToProxy("test -f facet@test @test"); + test(false); + } + catch(Ice.ProxyParseException) + { + } + b1 = communicator.stringToProxy("test"); + test(b1.ice_isTwoway()); + b1 = communicator.stringToProxy("test -t"); + test(b1.ice_isTwoway()); + b1 = communicator.stringToProxy("test -o"); + test(b1.ice_isOneway()); + b1 = communicator.stringToProxy("test -O"); + test(b1.ice_isBatchOneway()); + b1 = communicator.stringToProxy("test -d"); + test(b1.ice_isDatagram()); + b1 = communicator.stringToProxy("test -D"); + test(b1.ice_isBatchDatagram()); + b1 = communicator.stringToProxy("test"); + test(!b1.ice_isSecure()); + b1 = communicator.stringToProxy("test -s"); + test(b1.ice_isSecure()); + + try + { + b1 = communicator.stringToProxy("test:tcp@adapterId"); + test(false); + } + catch(Ice.EndpointParseException) + { + } + // This is an unknown endpoint warning, not a parse exception. + // + //try + //{ + // b1 = communicator.stringToProxy("test -f the:facet:tcp"); + // test(false); + //} + //catch(Ice.EndpointParseException) + //{ + //} + try + { + b1 = communicator.stringToProxy("test::tcp"); + test(false); + } + catch(Ice.EndpointParseException) + { + } + Console.Out.WriteLine("ok"); + + Console.Out.Write("testing propertyToProxy... "); + Console.Out.Flush(); + Ice.Properties prop = communicator.getProperties(); + String propertyPrefix = "Foo.Proxy"; + prop.setProperty(propertyPrefix, "test:default -p 12010 -t 10000"); + b1 = communicator.propertyToProxy(propertyPrefix); + test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && + b1.ice_getAdapterId().Length == 0 && b1.ice_getFacet().Length == 0); + + // These two properties don't do anything to direct proxies so + // first we test that. + String property = propertyPrefix + ".Locator"; + test(b1.ice_getLocator() == null); + prop.setProperty(property, "locator:default -p 10000"); + b1 = communicator.propertyToProxy(propertyPrefix); + test(b1.ice_getLocator() == null); + prop.setProperty(property, ""); + + property = propertyPrefix + ".LocatorCacheTimeout"; + test(b1.ice_getLocatorCacheTimeout() == 0); + prop.setProperty(property, "1"); + b1 = communicator.propertyToProxy(propertyPrefix); + test(b1.ice_getLocatorCacheTimeout() == 0); + prop.setProperty(property, ""); + + // Now retest with an indirect proxy. + prop.setProperty(propertyPrefix, "test"); + property = propertyPrefix + ".Locator"; + prop.setProperty(property, "locator:default -p 10000"); + b1 = communicator.propertyToProxy(propertyPrefix); + test(b1.ice_getLocator() != null && b1.ice_getLocator().ice_getIdentity().name.Equals("locator")); + prop.setProperty(property, ""); + + property = propertyPrefix + ".LocatorCacheTimeout"; + test(b1.ice_getLocatorCacheTimeout() == -1); + prop.setProperty(property, "1"); + b1 = communicator.propertyToProxy(propertyPrefix); + test(b1.ice_getLocatorCacheTimeout() == 1); + prop.setProperty(property, ""); + + // This cannot be tested so easily because the property is cached + // on communicator initialization. + // + //prop.setProperty("Ice.Default.LocatorCacheTimeout", "60"); + //b1 = communicator.propertyToProxy(propertyPrefix); + //test(b1.ice_getLocatorCacheTimeout() == 60); + //prop.setProperty("Ice.Default.LocatorCacheTimeout", ""); + + prop.setProperty(propertyPrefix, "test:default -p 12010 -t 10000"); + + property = propertyPrefix + ".Router"; + test(b1.ice_getRouter() == null); + prop.setProperty(property, "router:default -p 10000"); + b1 = communicator.propertyToProxy(propertyPrefix); + test(b1.ice_getRouter() != null && b1.ice_getRouter().ice_getIdentity().name.Equals("router")); + prop.setProperty(property, ""); + + property = propertyPrefix + ".PreferSecure"; + test(!b1.ice_isPreferSecure()); + prop.setProperty(property, "1"); + b1 = communicator.propertyToProxy(propertyPrefix); + test(b1.ice_isPreferSecure()); + prop.setProperty(property, ""); + + property = propertyPrefix + ".ConnectionCached"; + test(b1.ice_isConnectionCached()); + prop.setProperty(property, "0"); + b1 = communicator.propertyToProxy(propertyPrefix); + test(!b1.ice_isConnectionCached()); + prop.setProperty(property, ""); + + property = propertyPrefix + ".EndpointSelection"; + test(b1.ice_getEndpointSelection() == Ice.EndpointSelectionType.Random); + prop.setProperty(property, "Random"); + b1 = communicator.propertyToProxy(propertyPrefix); + test(b1.ice_getEndpointSelection() == Ice.EndpointSelectionType.Random); + prop.setProperty(property, "Ordered"); + b1 = communicator.propertyToProxy(propertyPrefix); + test(b1.ice_getEndpointSelection() == Ice.EndpointSelectionType.Ordered); + prop.setProperty(property, ""); + + property = propertyPrefix + ".CollocationOptimization"; + test(b1.ice_isCollocationOptimized()); + prop.setProperty(property, "0"); + b1 = communicator.propertyToProxy(propertyPrefix); + test(!b1.ice_isCollocationOptimized()); + prop.setProperty(property, ""); + + property = propertyPrefix + ".ThreadPerConnection"; + test(!b1.ice_isThreadPerConnection()); + prop.setProperty(property, "1"); + b1 = communicator.propertyToProxy(propertyPrefix); + test(b1.ice_isThreadPerConnection()); + prop.setProperty(property, ""); + + Console.Out.WriteLine("ok"); + + Console.Out.Write("testing ice_getCommunicator... "); + Console.Out.Flush(); + test(baseProxy.ice_getCommunicator() == communicator); + Console.Out.WriteLine("ok"); + + Console.Out.Write("testing proxy methods... "); + test(communicator.identityToString( + baseProxy.ice_identity(communicator.stringToIdentity("other")).ice_getIdentity()).Equals("other")); + test(baseProxy.ice_facet("facet").ice_getFacet().Equals("facet")); + test(baseProxy.ice_adapterId("id").ice_getAdapterId().Equals("id")); + test(baseProxy.ice_twoway().ice_isTwoway()); + test(baseProxy.ice_oneway().ice_isOneway()); + test(baseProxy.ice_batchOneway().ice_isBatchOneway()); + test(baseProxy.ice_datagram().ice_isDatagram()); + test(baseProxy.ice_batchDatagram().ice_isBatchDatagram()); + test(baseProxy.ice_secure(true).ice_isSecure()); + test(!baseProxy.ice_secure(false).ice_isSecure()); + test(baseProxy.ice_collocationOptimized(true).ice_isCollocationOptimized()); + test(!baseProxy.ice_collocationOptimized(false).ice_isCollocationOptimized()); + Console.Out.WriteLine("ok"); + + Console.Out.Write("testing proxy comparison... "); + Console.Out.Flush(); + + test(communicator.stringToProxy("foo").Equals(communicator.stringToProxy("foo"))); + test(!communicator.stringToProxy("foo").Equals(communicator.stringToProxy("foo2"))); + + Ice.ObjectPrx compObj = communicator.stringToProxy("foo"); + + test(compObj.ice_facet("facet").Equals(compObj.ice_facet("facet"))); + test(!compObj.ice_facet("facet").Equals(compObj.ice_facet("facet1"))); + + test(compObj.ice_oneway().Equals(compObj.ice_oneway())); + test(!compObj.ice_oneway().Equals(compObj.ice_twoway())); + + test(compObj.ice_secure(true).Equals(compObj.ice_secure(true))); + test(!compObj.ice_secure(false).Equals(compObj.ice_secure(true))); + + test(compObj.ice_collocationOptimized(true).Equals(compObj.ice_collocationOptimized(true))); + test(!compObj.ice_collocationOptimized(false).Equals(compObj.ice_collocationOptimized(true))); + + test(compObj.ice_connectionCached(true).Equals(compObj.ice_connectionCached(true))); + test(!compObj.ice_connectionCached(false).Equals(compObj.ice_connectionCached(true))); + + test(compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random).Equals( + compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random))); + test(!compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random).Equals( + compObj.ice_endpointSelection(Ice.EndpointSelectionType.Ordered))); + + test(compObj.ice_connectionId("id2").Equals(compObj.ice_connectionId("id2"))); + test(!compObj.ice_connectionId("id1").Equals(compObj.ice_connectionId("id2"))); + + test(compObj.ice_compress(true).Equals(compObj.ice_compress(true))); + test(!compObj.ice_compress(false).Equals(compObj.ice_compress(true))); + + test(compObj.ice_timeout(20).Equals(compObj.ice_timeout(20))); + test(!compObj.ice_timeout(10).Equals(compObj.ice_timeout(20))); + + Ice.ObjectPrx compObj1 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 10000"); + Ice.ObjectPrx compObj2 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 10001"); + test(!compObj1.Equals(compObj2)); + + compObj1 = communicator.stringToProxy("foo@MyAdapter1"); + compObj2 = communicator.stringToProxy("foo@MyAdapter2"); + test(!compObj1.Equals(compObj2)); + + test(compObj1.ice_locatorCacheTimeout(20).Equals(compObj1.ice_locatorCacheTimeout(20))); + test(!compObj1.ice_locatorCacheTimeout(10).Equals(compObj1.ice_locatorCacheTimeout(20))); + + compObj1 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 1000"); + compObj2 = communicator.stringToProxy("foo@MyAdapter1"); + test(!compObj1.Equals(compObj2)); + + // + // TODO: Ideally we should also test comparison of fixed proxies. + // + Console.Out.WriteLine("ok"); + + Console.Out.Write("testing checked cast... "); + Console.Out.Flush(); + Test.MyClassPrx cl = Test.MyClassPrxHelper.checkedCast(baseProxy); + test(cl != null); + Test.MyDerivedClassPrx derived = Test.MyDerivedClassPrxHelper.checkedCast(cl); + test(derived != null); + test(cl.Equals(baseProxy)); + test(derived.Equals(baseProxy)); + test(cl.Equals(derived)); + Console.Out.WriteLine("ok"); + + Console.Out.Write("testing checked cast with context... "); + Console.Out.Flush(); + + Ice.Context c = cl.getContext(); + test(c == null || c.Count == 0); + + c = new Ice.Context(); + c["one"] = "hello"; + c["two"] = "world"; + cl = Test.MyClassPrxHelper.checkedCast(baseProxy, c); + Ice.Context c2 = cl.getContext(); + test(c.Equals(c2)); + Console.Out.WriteLine("ok"); + + if(!collocated) + { + Console.Out.Write("testing timeout... "); + Console.Out.Flush(); + Test.MyClassPrx clTimeout = Test.MyClassPrxHelper.uncheckedCast(cl.ice_timeout(500)); + try + { + clTimeout.opSleep(1000); + test(false); + } + catch(Ice.TimeoutException) + { + } + AMI_MyClass_opSleepI cb = new AMI_MyClass_opSleepI(); + try + { + clTimeout.opSleep_async(cb, 2000); + } + catch(Ice.Exception) + { + test(false); + } + test(cb.check()); + Console.Out.WriteLine("ok"); + } + + return cl; + } +} diff --git a/cs/test/Ice/proxy/Client.cs b/cs/test/Ice/proxy/Client.cs new file mode 100644 index 00000000000..436c0f89ec1 --- /dev/null +++ b/cs/test/Ice/proxy/Client.cs @@ -0,0 +1,80 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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; + +public class Client +{ + private static int run(String[] args, Ice.Communicator communicator) + { + Test.MyClassPrx myClass = AllTests.allTests(communicator, false); + + myClass.shutdown(); + + return 0; + } + + public static void Main(string[] args) + { + int status = 0; + Ice.Communicator communicator = null; + + try + { + Ice.InitializationData initData = new Ice.InitializationData(); + initData.properties = Ice.Util.createProperties(ref args); + initData.properties.setProperty("Ice.ThreadPool.Client.Size", "2"); // For nested AMI. + initData.properties.setProperty("Ice.ThreadPool.Client.SizeWarn", "0"); + + // + // We must set MessageSizeMax to an explicit values, + // because we run tests to check whether + // Ice.MemoryLimitException is raised as expected. + // + initData.properties.setProperty("Ice.MessageSizeMax", "100"); + + // + // We don't want connection warnings because of the timeout test. + // + initData.properties.setProperty("Ice.Warn.Connections", "0"); + + // + // Use a faster connection monitor timeout to test AMI + // timeouts. + // + initData.properties.setProperty("Ice.MonitorConnections", "1"); + + communicator = Ice.Util.initialize(ref args, initData); + status = run(args, communicator); + } + catch(System.Exception ex) + { + Console.Error.WriteLine(ex); + status = 1; + } + + if(communicator != null) + { + try + { + communicator.destroy(); + } + catch(Ice.LocalException ex) + { + Console.Error.WriteLine(ex); + status = 1; + } + } + + if(status != 0) + { + System.Environment.Exit(status); + } + } +} diff --git a/cs/test/Ice/proxy/Collocated.cs b/cs/test/Ice/proxy/Collocated.cs new file mode 100644 index 00000000000..256b26f13cc --- /dev/null +++ b/cs/test/Ice/proxy/Collocated.cs @@ -0,0 +1,65 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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; + +public class Collocated +{ + private static int run(String[] args, Ice.Communicator communicator) + { + communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010 -t 5000"); + Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter"); + adapter.add(new MyDerivedClassI(), communicator.stringToIdentity("test")); + adapter.activate(); + + AllTests.allTests(communicator, true); + + return 0; + } + + public static void Main(String[] args) + { + int status = 0; + Ice.Communicator communicator = null; + + try + { + Ice.InitializationData initData = new Ice.InitializationData(); + initData.properties = Ice.Util.createProperties(ref args); + initData.properties.setProperty("Ice.ThreadPool.Client.Size", "2"); // For nested AMI. + initData.properties.setProperty("Ice.ThreadPool.Client.SizeWarn", "0"); + + communicator = Ice.Util.initialize(ref args, initData); + status = run(args, communicator); + } + catch(System.Exception ex) + { + Console.Error.WriteLine(ex); + status = 1; + } + + if(communicator != null) + { + try + { + communicator.destroy(); + } + catch(Ice.LocalException ex) + { + Console.Error.WriteLine(ex); + status = 1; + } + } + + if(status != 0) + { + System.Environment.Exit(status); + } + } +} diff --git a/cs/test/Ice/proxy/Makefile b/cs/test/Ice/proxy/Makefile new file mode 100644 index 00000000000..bcd90539921 --- /dev/null +++ b/cs/test/Ice/proxy/Makefile @@ -0,0 +1,44 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2007 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 = ../../.. + +TARGETS = client.exe server.exe collocated.exe serveramd.exe + +C_SRCS = AllTests.cs Client.cs +S_SRCS = MyDerivedClassI.cs Server.cs +COL_SRCS = AllTests.cs Collocated.cs MyDerivedClassI.cs +SAMD_SRCS = MyDerivedClassAMDI.cs Server.cs + +SLICE_SRCS = $(SDIR)/Test.ice +SLICE_AMD_SRCS = $(SDIR)/TestAMD.ice + +SDIR = . + +GDIR = generated + +include $(top_srcdir)/config/Make.rules.cs + +MCSFLAGS := $(MCSFLAGS) -target:exe + +SLICE2CSFLAGS := $(SLICE2CSFLAGS) --ice -I. -I$(slicedir) + +client.exe: $(C_SRCS) $(GEN_SRCS) + $(MCS) $(MCSFLAGS) -out:$@ $(call ref,icecs) $(subst /,$(DSEP),$^) + +server.exe: $(S_SRCS) $(GEN_SRCS) + $(MCS) $(MCSFLAGS) -out:$@ $(call ref,icecs) $(subst /,$(DSEP),$^) + +collocated.exe: $(COL_SRCS) $(GEN_SRCS) + $(MCS) $(MCSFLAGS) -out:$@ $(call ref,icecs) $(subst /,$(DSEP),$^) + +serveramd.exe: $(SAMD_SRCS) $(GEN_AMD_SRCS) + $(MCS) $(MCSFLAGS) -out:$@ $(call ref,icecs) $(subst /,$(DSEP),$^) + +include .depend diff --git a/cs/test/Ice/proxy/Makefile.mak b/cs/test/Ice/proxy/Makefile.mak new file mode 100644 index 00000000000..3324be3ce3c --- /dev/null +++ b/cs/test/Ice/proxy/Makefile.mak @@ -0,0 +1,44 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2007 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 = ..\..\.. + +TARGETS = client.exe server.exe collocated.exe serveramd.exe + +C_SRCS = AllTests.cs Client.cs +S_SRCS = MyDerivedClassI.cs Server.cs +COL_SRCS = AllTests.cs Collocated.cs MyDerivedClassI.cs +SAMD_SRCS = MyDerivedClassAMDI.cs Server.cs + +GEN_SRCS = $(GDIR)\Test.cs +GEN_AMD_SRCS = $(GDIR)\TestAMD.cs + +SDIR = . + +GDIR = generated + +!include $(top_srcdir)\config\Make.rules.mak.cs + +MCSFLAGS = $(MCSFLAGS) -target:exe + +SLICE2CSFLAGS = $(SLICE2CSFLAGS) --ice -I. -I$(slicedir) + +client.exe: $(C_SRCS) $(GEN_SRCS) + $(MCS) $(MCSFLAGS) -out:$@ -r:$(bindir)\icecs.dll $(C_SRCS) $(GEN_SRCS) + +server.exe: $(S_SRCS) $(GEN_SRCS) + $(MCS) $(MCSFLAGS) -out:$@ -r:$(bindir)\icecs.dll $(S_SRCS) $(GEN_SRCS) + +collocated.exe: $(COL_SRCS) $(GEN_SRCS) + $(MCS) $(MCSFLAGS) -out:$@ -r:$(bindir)\icecs.dll $(COL_SRCS) $(GEN_SRCS) + +serveramd.exe: $(SAMD_SRCS) $(GEN_AMD_SRCS) + $(MCS) $(MCSFLAGS) -out:$@ -r:$(bindir)\icecs.dll $(SAMD_SRCS) $(GEN_AMD_SRCS) + +!include .depend diff --git a/cs/test/Ice/proxy/MyDerivedClassAMDI.cs b/cs/test/Ice/proxy/MyDerivedClassAMDI.cs new file mode 100644 index 00000000000..0a8a9d9a414 --- /dev/null +++ b/cs/test/Ice/proxy/MyDerivedClassAMDI.cs @@ -0,0 +1,45 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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; +using System.Threading; + +public sealed class MyDerivedClassI : Test.MyDerivedClass +{ + public MyDerivedClassI() + { + } + + public override void shutdown_async(Test.AMD_MyClass_shutdown cb, Ice.Current current) + { + current.adapter.getCommunicator().shutdown(); + cb.ice_response(); + } + + public override void opSleep_async(Test.AMD_MyClass_opSleep cb, int duration, Ice.Current current) + { + System.Threading.Thread.Sleep(duration); + cb.ice_response(); + } + + public override void + getContext_async(Test.AMD_MyClass_getContext cb, Ice.Current current) + { + cb.ice_response(_ctx); + } + + public override bool + ice_isA(string s, Ice.Current current) + { + _ctx = current.ctx; + return base.ice_isA(s, current); + } + + private Ice.Context _ctx; +} diff --git a/cs/test/Ice/proxy/MyDerivedClassI.cs b/cs/test/Ice/proxy/MyDerivedClassI.cs new file mode 100644 index 00000000000..6fa9dce948c --- /dev/null +++ b/cs/test/Ice/proxy/MyDerivedClassI.cs @@ -0,0 +1,42 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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; + +public sealed class MyDerivedClassI : Test.MyDerivedClass +{ + public MyDerivedClassI() + { + } + + public override void shutdown(Ice.Current current) + { + current.adapter.getCommunicator().shutdown(); + } + + public override void opSleep(int duration, Ice.Current current) + { + System.Threading.Thread.Sleep(duration); + } + + public override Ice.Context + getContext(Ice.Current current) + { + return _ctx; + } + + public override bool + ice_isA(string s, Ice.Current current) + { + _ctx = current.ctx; + return base.ice_isA(s, current); + } + + private Ice.Context _ctx; +} diff --git a/cs/test/Ice/proxy/Server.cs b/cs/test/Ice/proxy/Server.cs new file mode 100644 index 00000000000..db4a758aae6 --- /dev/null +++ b/cs/test/Ice/proxy/Server.cs @@ -0,0 +1,64 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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; + +public class Server +{ + private static int run(string[] args, Ice.Communicator communicator) + { + // + // We don't want connection warnings because of the timeout test. + // + communicator.getProperties().setProperty("Ice.Warn.Connections", "0"); + + communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010 -t 5000:udp"); + Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter"); + adapter.add(new MyDerivedClassI(), communicator.stringToIdentity("test")); + adapter.activate(); + + communicator.waitForShutdown(); + return 0; + } + + public static void Main(string[] args) + { + int status = 0; + Ice.Communicator communicator = null; + + try + { + communicator = Ice.Util.initialize(ref args); + status = run(args, communicator); + } + catch(Ice.LocalException ex) + { + Console.Error.WriteLine(ex); + status = 1; + } + + if(communicator != null) + { + try + { + communicator.destroy(); + } + catch(Ice.LocalException ex) + { + Console.Error.WriteLine(ex); + status = 1; + } + } + + if(status != 0) + { + System.Environment.Exit(status); + } + } +} diff --git a/cs/test/Ice/proxy/Test.ice b/cs/test/Ice/proxy/Test.ice new file mode 100644 index 00000000000..fef92a708ff --- /dev/null +++ b/cs/test/Ice/proxy/Test.ice @@ -0,0 +1,34 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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. +// +// ********************************************************************** + +#ifndef TEST_ICE +#define TEST_ICE + +#include <Ice/Current.ice> + +module Test +{ + + +["ami"] class MyClass +{ + void shutdown(); + + void opSleep(int duration); + + Ice::Context getContext(); +}; + +["ami"] class MyDerivedClass extends MyClass +{ +}; + +}; + +#endif diff --git a/cs/test/Ice/proxy/TestAMD.ice b/cs/test/Ice/proxy/TestAMD.ice new file mode 100644 index 00000000000..13dc113c4c7 --- /dev/null +++ b/cs/test/Ice/proxy/TestAMD.ice @@ -0,0 +1,34 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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. +// +// ********************************************************************** + +#ifndef TEST_ICE +#define TEST_ICE + +#include <Ice/Current.ice> + +module Test +{ + + +["ami", "amd"] class MyClass +{ + void shutdown(); + + void opSleep(int duration); + + Ice::Context getContext(); +}; + +["ami", "amd"] class MyDerivedClass extends MyClass +{ +}; + +}; + +#endif diff --git a/cs/test/Ice/proxy/client.exe.config b/cs/test/Ice/proxy/client.exe.config new file mode 100755 index 00000000000..ad5c5baaca1 --- /dev/null +++ b/cs/test/Ice/proxy/client.exe.config @@ -0,0 +1,35 @@ +<?xml version="1.0"?> + <configuration> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="glacier2cs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.2.0.0" href="../../../bin/glacier2cs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="icecs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.2.0.0" href="../../../bin/icecs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="icepatch2cs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.2.0.0" href="../../../bin/icepatch2cs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="icestormcs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.2.0.0" href="../../../bin/icestormcs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="iceboxcs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.2.0.0" href="../../../bin/iceboxcs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="icegridcs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.2.0.0" href="../../../bin/icegridcs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="icesslcs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.2.0.0" href="../../../bin/icesslcs.dll"/> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration> diff --git a/cs/test/Ice/proxy/collocated.exe.config b/cs/test/Ice/proxy/collocated.exe.config new file mode 100755 index 00000000000..ad5c5baaca1 --- /dev/null +++ b/cs/test/Ice/proxy/collocated.exe.config @@ -0,0 +1,35 @@ +<?xml version="1.0"?> + <configuration> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="glacier2cs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.2.0.0" href="../../../bin/glacier2cs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="icecs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.2.0.0" href="../../../bin/icecs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="icepatch2cs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.2.0.0" href="../../../bin/icepatch2cs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="icestormcs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.2.0.0" href="../../../bin/icestormcs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="iceboxcs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.2.0.0" href="../../../bin/iceboxcs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="icegridcs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.2.0.0" href="../../../bin/icegridcs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="icesslcs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.2.0.0" href="../../../bin/icesslcs.dll"/> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration> diff --git a/cs/test/Ice/proxy/run.py b/cs/test/Ice/proxy/run.py new file mode 100755 index 00000000000..6c5b7b0e492 --- /dev/null +++ b/cs/test/Ice/proxy/run.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2007 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 + +for toplevel in [".", "..", "../..", "../../..", "../../../.."]: + toplevel = os.path.normpath(toplevel) + if os.path.exists(os.path.join(toplevel, "config", "TestUtil.py")): + break +else: + raise "can't find toplevel directory!" + +sys.path.append(os.path.join(toplevel, "config")) +import TestUtil + +name = os.path.join("Ice", "proxy") + +print "tests with regular server." +TestUtil.clientServerTest(name) +print "tests with AMD server." +TestUtil.clientServerTestWithOptionsAndNames(name, "", "", "serveramd", "client") +print "tests with collocated server." +TestUtil.collocatedTest(name) +sys.exit(0) diff --git a/cs/test/Ice/proxy/server.exe.config b/cs/test/Ice/proxy/server.exe.config new file mode 100755 index 00000000000..ad5c5baaca1 --- /dev/null +++ b/cs/test/Ice/proxy/server.exe.config @@ -0,0 +1,35 @@ +<?xml version="1.0"?> + <configuration> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="glacier2cs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.2.0.0" href="../../../bin/glacier2cs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="icecs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.2.0.0" href="../../../bin/icecs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="icepatch2cs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.2.0.0" href="../../../bin/icepatch2cs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="icestormcs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.2.0.0" href="../../../bin/icestormcs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="iceboxcs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.2.0.0" href="../../../bin/iceboxcs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="icegridcs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.2.0.0" href="../../../bin/icegridcs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="icesslcs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.2.0.0" href="../../../bin/icesslcs.dll"/> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration> diff --git a/cs/test/Ice/proxy/serveramd.exe.config b/cs/test/Ice/proxy/serveramd.exe.config new file mode 100755 index 00000000000..ad5c5baaca1 --- /dev/null +++ b/cs/test/Ice/proxy/serveramd.exe.config @@ -0,0 +1,35 @@ +<?xml version="1.0"?> + <configuration> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="glacier2cs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.2.0.0" href="../../../bin/glacier2cs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="icecs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.2.0.0" href="../../../bin/icecs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="icepatch2cs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.2.0.0" href="../../../bin/icepatch2cs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="icestormcs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.2.0.0" href="../../../bin/icestormcs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="iceboxcs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.2.0.0" href="../../../bin/iceboxcs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="icegridcs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.2.0.0" href="../../../bin/icegridcs.dll"/> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="icesslcs" culture="neutral" publicKeyToken="1f998c50fec78381"/> + <codeBase version="3.2.0.0" href="../../../bin/icesslcs.dll"/> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration> diff --git a/java/CHANGES b/java/CHANGES index 651648b73c1..48f902f7a56 100644 --- a/java/CHANGES +++ b/java/CHANGES @@ -1,6 +1,9 @@ Changes since version 3.2.0 --------------------------- +- Trailing characters past the adapter id in a stringified proxy + will now raise a ProxyParseException. + - Fixed a translator bug that generated invalid code for certain Java5 types. diff --git a/java/allTests.py b/java/allTests.py index 2f77843a30c..87df63e30b8 100755 --- a/java/allTests.py +++ b/java/allTests.py @@ -75,6 +75,7 @@ def runTests(args, tests, num = 0): # tests = [ \ "IceUtil/inputUtil", \ + "Ice/proxy", \ "Ice/operations", \ "Ice/exceptions", \ "Ice/inheritance", \ diff --git a/java/src/IceInternal/ReferenceFactory.java b/java/src/IceInternal/ReferenceFactory.java index dfb8c4b4d12..8cd07cfa7c7 100644 --- a/java/src/IceInternal/ReferenceFactory.java +++ b/java/src/IceInternal/ReferenceFactory.java @@ -471,6 +471,7 @@ public final class ReferenceFactory throw e; } + String adapterstr = null; end = IceUtil.StringUtil.checkQuote(s, beg); if(end == -1) { @@ -485,14 +486,25 @@ public final class ReferenceFactory { end = s.length(); } + adapterstr = s.substring(beg, end); } else { beg++; // Skip leading quote + adapterstr = s.substring(beg, end); + end++; // Skip trailing quote } + if(end != s.length() && IceUtil.StringUtil.findFirstNotOf(s, delim, end) != -1) + { + Ice.ProxyParseException e = new Ice.ProxyParseException(); + e.str = s; + throw e; + } + Ice.StringHolder token = new Ice.StringHolder(); - if(!IceUtil.StringUtil.unescapeString(s, beg, end, token) || token.value.length() == 0) + if(!IceUtil.StringUtil.unescapeString(adapterstr, 0, adapterstr.length(), token) || + token.value.length() == 0) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = s; diff --git a/java/test/Ice/build.xml b/java/test/Ice/build.xml index 69301dd5b61..cdb13e1c4f0 100644 --- a/java/test/Ice/build.xml +++ b/java/test/Ice/build.xml @@ -22,6 +22,8 @@ <ant dir="inheritance"/> <ant dir="location"/> <ant dir="objects"/> + <ant dir="proxy"/> + <ant dir="proxyAMD"/> <ant dir="operations"/> <ant dir="operationsAMD"/> <ant dir="slicing"/> diff --git a/java/test/Ice/proxy/AllTests.java b/java/test/Ice/proxy/AllTests.java new file mode 100644 index 00000000000..c7331e484e2 --- /dev/null +++ b/java/test/Ice/proxy/AllTests.java @@ -0,0 +1,497 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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. +// +// ********************************************************************** + +public class AllTests +{ + static class AMI_MyClass_opSleepI extends Test.AMI_MyClass_opSleep + { + public void + ice_response() + { + test(false); + } + + synchronized public void + ice_exception(Ice.LocalException ex) + { + assert(!_called); + _called = true; + notify(); + test(ex instanceof Ice.TimeoutException); + } + + synchronized public boolean + check() + { + while(!_called) + { + try + { + wait(5000); + } + catch(InterruptedException ex) + { + continue; + } + + if(!_called) + { + return false; // Must be timeout. + } + } + return true; + } + + private boolean _called = false; + }; + + private static void + test(boolean b) + { + if(!b) + { + throw new RuntimeException(); + } + } + + public static Test.MyClassPrx + allTests(Ice.Communicator communicator, boolean collocated) + { + System.out.print("testing stringToProxy... "); + System.out.flush(); + String ref = "test:default -p 12010 -t 10000"; + Ice.ObjectPrx base = communicator.stringToProxy(ref); + test(base != null); + + Ice.ObjectPrx b1 = communicator.stringToProxy("test"); + test(b1.ice_getIdentity().name.equals("test") && b1.ice_getIdentity().category.length() == 0 && + b1.ice_getAdapterId().length() == 0 && b1.ice_getFacet().length() == 0); + b1 = communicator.stringToProxy("test "); + test(b1.ice_getIdentity().name.equals("test") && b1.ice_getIdentity().category.length() == 0 && + b1.ice_getFacet().length() == 0); + b1 = communicator.stringToProxy(" test "); + test(b1.ice_getIdentity().name.equals("test") && b1.ice_getIdentity().category.length() == 0 && + b1.ice_getFacet().length() == 0); + b1 = communicator.stringToProxy(" test"); + test(b1.ice_getIdentity().name.equals("test") && b1.ice_getIdentity().category.length() == 0 && + b1.ice_getFacet().length() == 0); + b1 = communicator.stringToProxy("'test -f facet'"); + test(b1.ice_getIdentity().name.equals("test -f facet") && b1.ice_getIdentity().category.length() == 0 && + b1.ice_getFacet().length() == 0); + try + { + b1 = communicator.stringToProxy("\"test -f facet'"); + test(false); + } + catch(Ice.ProxyParseException ex) + { + } + b1 = communicator.stringToProxy("\"test -f facet\""); + test(b1.ice_getIdentity().name.equals("test -f facet") && b1.ice_getIdentity().category.length() == 0 && + b1.ice_getFacet().length() == 0); + b1 = communicator.stringToProxy("\"test -f facet@test\""); + test(b1.ice_getIdentity().name.equals("test -f facet@test") && b1.ice_getIdentity().category.length() == 0 && + b1.ice_getFacet().length() == 0); + b1 = communicator.stringToProxy("\"test -f facet@test @test\""); + test(b1.ice_getIdentity().name.equals("test -f facet@test @test") && b1.ice_getIdentity().category.length() == 0 && + b1.ice_getFacet().length() == 0); + try + { + b1 = communicator.stringToProxy("test test"); + test(false); + } + catch(Ice.ProxyParseException ex) + { + } + b1 = communicator.stringToProxy("test\\040test"); + test(b1.ice_getIdentity().name.equals("test test") && b1.ice_getIdentity().category.length() == 0); + try + { + b1 = communicator.stringToProxy("test\\777"); + test(false); + } + catch(Ice.IdentityParseException ex) + { + } + b1 = communicator.stringToProxy("test\\40test"); + test(b1.ice_getIdentity().name.equals("test test")); + + // Test some octal and hex corner cases. + b1 = communicator.stringToProxy("test\\4test"); + test(b1.ice_getIdentity().name.equals("test\4test")); + b1 = communicator.stringToProxy("test\\04test"); + test(b1.ice_getIdentity().name.equals("test\4test")); + b1 = communicator.stringToProxy("test\\004test"); + test(b1.ice_getIdentity().name.equals("test\4test")); + b1 = communicator.stringToProxy("test\\1114test"); + test(b1.ice_getIdentity().name.equals("test\1114test")); + + b1 = communicator.stringToProxy("test\\b\\f\\n\\r\\t\\'\\\"\\\\test"); + test(b1.ice_getIdentity().name.equals("test\b\f\n\r\t\'\"\\test") && b1.ice_getIdentity().category.length() == 0); + + b1 = communicator.stringToProxy("category/test"); + test(b1.ice_getIdentity().name.equals("test") && b1.ice_getIdentity().category.equals("category") && + b1.ice_getAdapterId().length() == 0); + + b1 = communicator.stringToProxy("test@adapter"); + test(b1.ice_getIdentity().name.equals("test") && b1.ice_getIdentity().category.length() == 0 && + b1.ice_getAdapterId().equals("adapter")); + try + { + b1 = communicator.stringToProxy("id@adapter test"); + test(false); + } + catch(Ice.ProxyParseException ex) + { + } + b1 = communicator.stringToProxy("category/test@adapter"); + test(b1.ice_getIdentity().name.equals("test") && b1.ice_getIdentity().category.equals("category") && + b1.ice_getAdapterId().equals("adapter")); + b1 = communicator.stringToProxy("category/test@adapter:tcp"); + test(b1.ice_getIdentity().name.equals("test") && b1.ice_getIdentity().category.equals("category") && + b1.ice_getAdapterId().equals("adapter:tcp")); + b1 = communicator.stringToProxy("'category 1/test'@adapter"); + test(b1.ice_getIdentity().name.equals("test") && b1.ice_getIdentity().category.equals("category 1") && + b1.ice_getAdapterId().equals("adapter")); + b1 = communicator.stringToProxy("'category/test 1'@adapter"); + test(b1.ice_getIdentity().name.equals("test 1") && b1.ice_getIdentity().category.equals("category") && + b1.ice_getAdapterId().equals("adapter")); + b1 = communicator.stringToProxy("'category/test'@'adapter 1'"); + test(b1.ice_getIdentity().name.equals("test") && b1.ice_getIdentity().category.equals("category") && + b1.ice_getAdapterId().equals("adapter 1")); + b1 = communicator.stringToProxy("\"category \\/test@foo/test\"@adapter"); + test(b1.ice_getIdentity().name.equals("test") && b1.ice_getIdentity().category.equals("category /test@foo") && + b1.ice_getAdapterId().equals("adapter")); + b1 = communicator.stringToProxy("\"category \\/test@foo/test\"@\"adapter:tcp\""); + test(b1.ice_getIdentity().name.equals("test") && b1.ice_getIdentity().category.equals("category /test@foo") && + b1.ice_getAdapterId().equals("adapter:tcp")); + + b1 = communicator.stringToProxy("id -f facet"); + test(b1.ice_getIdentity().name.equals("id") && b1.ice_getIdentity().category.length() == 0 && + b1.ice_getFacet().equals("facet")); + b1 = communicator.stringToProxy("id -f 'facet x'"); + test(b1.ice_getIdentity().name.equals("id") && b1.ice_getIdentity().category.length() == 0 && + b1.ice_getFacet().equals("facet x")); + b1 = communicator.stringToProxy("id -f \"facet x\""); + test(b1.ice_getIdentity().name.equals("id") && b1.ice_getIdentity().category.length() == 0 && + b1.ice_getFacet().equals("facet x")); + try + { + b1 = communicator.stringToProxy("id -f \"facet x"); + test(false); + } + catch(Ice.ProxyParseException ex) + { + } + try + { + b1 = communicator.stringToProxy("id -f \'facet x"); + test(false); + } + catch(Ice.ProxyParseException ex) + { + } + b1 = communicator.stringToProxy("test -f facet:tcp"); + test(b1.ice_getIdentity().name.equals("test") && b1.ice_getIdentity().category.length() == 0 && + b1.ice_getFacet().equals("facet") && b1.ice_getAdapterId().length() == 0); + b1 = communicator.stringToProxy("test -f \"facet:tcp\""); + test(b1.ice_getIdentity().name.equals("test") && b1.ice_getIdentity().category.length() == 0 && + b1.ice_getFacet().equals("facet:tcp") && b1.ice_getAdapterId().length() == 0); + b1 = communicator.stringToProxy("test -f facet@test"); + test(b1.ice_getIdentity().name.equals("test") && b1.ice_getIdentity().category.length() == 0 && + b1.ice_getFacet().equals("facet") && b1.ice_getAdapterId().equals("test")); + b1 = communicator.stringToProxy("test -f 'facet@test'"); + test(b1.ice_getIdentity().name.equals("test") && b1.ice_getIdentity().category.length() == 0 && + b1.ice_getFacet().equals("facet@test") && b1.ice_getAdapterId().length() == 0); + b1 = communicator.stringToProxy("test -f 'facet@test'@test"); + test(b1.ice_getIdentity().name.equals("test") && b1.ice_getIdentity().category.length() == 0 && + b1.ice_getFacet().equals("facet@test") && b1.ice_getAdapterId().equals("test")); + try + { + b1 = communicator.stringToProxy("test -f facet@test @test"); + test(false); + } + catch(Ice.ProxyParseException ex) + { + } + b1 = communicator.stringToProxy("test"); + test(b1.ice_isTwoway()); + b1 = communicator.stringToProxy("test -t"); + test(b1.ice_isTwoway()); + b1 = communicator.stringToProxy("test -o"); + test(b1.ice_isOneway()); + b1 = communicator.stringToProxy("test -O"); + test(b1.ice_isBatchOneway()); + b1 = communicator.stringToProxy("test -d"); + test(b1.ice_isDatagram()); + b1 = communicator.stringToProxy("test -D"); + test(b1.ice_isBatchDatagram()); + b1 = communicator.stringToProxy("test"); + test(!b1.ice_isSecure()); + b1 = communicator.stringToProxy("test -s"); + test(b1.ice_isSecure()); + + try + { + b1 = communicator.stringToProxy("test:tcp@adapterId"); + test(false); + } + catch(Ice.EndpointParseException ex) + { + } + // This is an unknown endpoint warning, not a parse exception. + // + //try + //{ + // b1 = communicator.stringToProxy("test -f the:facet:tcp"); + // test(false); + //} + //catch(Ice.EndpointParseException ex) + //{ + //} + try + { + b1 = communicator.stringToProxy("test::tcp"); + test(false); + } + catch(Ice.EndpointParseException ex) + { + } + System.out.println("ok"); + + System.out.print("testing propertyToProxy... "); + System.out.flush(); + Ice.Properties prop = communicator.getProperties(); + String propertyPrefix = "Foo.Proxy"; + prop.setProperty(propertyPrefix, "test:default -p 12010 -t 10000"); + b1 = communicator.propertyToProxy(propertyPrefix); + test(b1.ice_getIdentity().name.equals("test") && b1.ice_getIdentity().category.length() == 0 && + b1.ice_getAdapterId().length() == 0 && b1.ice_getFacet().length() == 0); + + // These two properties don't do anything to direct proxies so + // first we test that. + String property = propertyPrefix + ".Locator"; + test(b1.ice_getLocator() == null); + prop.setProperty(property, "locator:default -p 10000"); + b1 = communicator.propertyToProxy(propertyPrefix); + test(b1.ice_getLocator() == null); + prop.setProperty(property, ""); + + property = propertyPrefix + ".LocatorCacheTimeout"; + test(b1.ice_getLocatorCacheTimeout() == 0); + prop.setProperty(property, "1"); + b1 = communicator.propertyToProxy(propertyPrefix); + test(b1.ice_getLocatorCacheTimeout() == 0); + prop.setProperty(property, ""); + + // Now retest with an indirect proxy. + prop.setProperty(propertyPrefix, "test"); + property = propertyPrefix + ".Locator"; + prop.setProperty(property, "locator:default -p 10000"); + b1 = communicator.propertyToProxy(propertyPrefix); + test(b1.ice_getLocator() != null && b1.ice_getLocator().ice_getIdentity().name.equals("locator")); + prop.setProperty(property, ""); + + property = propertyPrefix + ".LocatorCacheTimeout"; + test(b1.ice_getLocatorCacheTimeout() == -1); + prop.setProperty(property, "1"); + b1 = communicator.propertyToProxy(propertyPrefix); + test(b1.ice_getLocatorCacheTimeout() == 1); + prop.setProperty(property, ""); + + // This cannot be tested so easily because the property is cached + // on communicator initialization. + // + //prop.setProperty("Ice.Default.LocatorCacheTimeout", "60"); + //b1 = communicator.propertyToProxy(propertyPrefix); + //test(b1.ice_getLocatorCacheTimeout() == 60); + //prop.setProperty("Ice.Default.LocatorCacheTimeout", ""); + + prop.setProperty(propertyPrefix, "test:default -p 12010 -t 10000"); + + property = propertyPrefix + ".Router"; + test(b1.ice_getRouter() == null); + prop.setProperty(property, "router:default -p 10000"); + b1 = communicator.propertyToProxy(propertyPrefix); + test(b1.ice_getRouter() != null && b1.ice_getRouter().ice_getIdentity().name.equals("router")); + prop.setProperty(property, ""); + + property = propertyPrefix + ".PreferSecure"; + test(!b1.ice_isPreferSecure()); + prop.setProperty(property, "1"); + b1 = communicator.propertyToProxy(propertyPrefix); + test(b1.ice_isPreferSecure()); + prop.setProperty(property, ""); + + property = propertyPrefix + ".ConnectionCached"; + test(b1.ice_isConnectionCached()); + prop.setProperty(property, "0"); + b1 = communicator.propertyToProxy(propertyPrefix); + test(!b1.ice_isConnectionCached()); + prop.setProperty(property, ""); + + property = propertyPrefix + ".EndpointSelection"; + test(b1.ice_getEndpointSelection() == Ice.EndpointSelectionType.Random); + prop.setProperty(property, "Random"); + b1 = communicator.propertyToProxy(propertyPrefix); + test(b1.ice_getEndpointSelection() == Ice.EndpointSelectionType.Random); + prop.setProperty(property, "Ordered"); + b1 = communicator.propertyToProxy(propertyPrefix); + test(b1.ice_getEndpointSelection() == Ice.EndpointSelectionType.Ordered); + prop.setProperty(property, ""); + + property = propertyPrefix + ".CollocationOptimization"; + test(b1.ice_isCollocationOptimized()); + prop.setProperty(property, "0"); + b1 = communicator.propertyToProxy(propertyPrefix); + test(!b1.ice_isCollocationOptimized()); + prop.setProperty(property, ""); + + property = propertyPrefix + ".ThreadPerConnection"; + test(!b1.ice_isThreadPerConnection()); + prop.setProperty(property, "1"); + b1 = communicator.propertyToProxy(propertyPrefix); + test(b1.ice_isThreadPerConnection()); + prop.setProperty(property, ""); + + System.out.println("ok"); + + System.out.print("testing ice_getCommunicator... "); + System.out.flush(); + test(base.ice_getCommunicator() == communicator); + System.out.println("ok"); + + System.out.print("testing proxy methods... "); + System.out.flush(); + test(communicator.identityToString( + base.ice_identity(communicator.stringToIdentity("other")).ice_getIdentity()).equals("other")); + test(base.ice_facet("facet").ice_getFacet().equals("facet")); + test(base.ice_adapterId("id").ice_getAdapterId().equals("id")); + test(base.ice_twoway().ice_isTwoway()); + test(base.ice_oneway().ice_isOneway()); + test(base.ice_batchOneway().ice_isBatchOneway()); + test(base.ice_datagram().ice_isDatagram()); + test(base.ice_batchDatagram().ice_isBatchDatagram()); + test(base.ice_secure(true).ice_isSecure()); + test(!base.ice_secure(false).ice_isSecure()); + test(base.ice_collocationOptimized(true).ice_isCollocationOptimized()); + test(!base.ice_collocationOptimized(false).ice_isCollocationOptimized()); + System.out.println("ok"); + + System.out.print("testing proxy comparison... "); + System.out.flush(); + + test(communicator.stringToProxy("foo").equals(communicator.stringToProxy("foo"))); + test(!communicator.stringToProxy("foo").equals(communicator.stringToProxy("foo2"))); + + Ice.ObjectPrx compObj = communicator.stringToProxy("foo"); + + test(compObj.ice_facet("facet").equals(compObj.ice_facet("facet"))); + test(!compObj.ice_facet("facet").equals(compObj.ice_facet("facet1"))); + + test(compObj.ice_oneway().equals(compObj.ice_oneway())); + test(!compObj.ice_oneway().equals(compObj.ice_twoway())); + + test(compObj.ice_secure(true).equals(compObj.ice_secure(true))); + test(!compObj.ice_secure(false).equals(compObj.ice_secure(true))); + + test(compObj.ice_collocationOptimized(true).equals(compObj.ice_collocationOptimized(true))); + test(!compObj.ice_collocationOptimized(false).equals(compObj.ice_collocationOptimized(true))); + + test(compObj.ice_connectionCached(true).equals(compObj.ice_connectionCached(true))); + test(!compObj.ice_connectionCached(false).equals(compObj.ice_connectionCached(true))); + + test(compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random).equals( + compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random))); + test(!compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random).equals( + compObj.ice_endpointSelection(Ice.EndpointSelectionType.Ordered))); + + test(compObj.ice_connectionId("id2").equals(compObj.ice_connectionId("id2"))); + test(!compObj.ice_connectionId("id1").equals(compObj.ice_connectionId("id2"))); + + test(compObj.ice_compress(true).equals(compObj.ice_compress(true))); + test(!compObj.ice_compress(false).equals(compObj.ice_compress(true))); + + test(compObj.ice_timeout(20).equals(compObj.ice_timeout(20))); + test(!compObj.ice_timeout(10).equals(compObj.ice_timeout(20))); + + Ice.ObjectPrx compObj1 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 10000"); + Ice.ObjectPrx compObj2 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 10001"); + test(!compObj1.equals(compObj2)); + + compObj1 = communicator.stringToProxy("foo@MyAdapter1"); + compObj2 = communicator.stringToProxy("foo@MyAdapter2"); + test(!compObj1.equals(compObj2)); + + test(compObj1.ice_locatorCacheTimeout(20).equals(compObj1.ice_locatorCacheTimeout(20))); + test(!compObj1.ice_locatorCacheTimeout(10).equals(compObj1.ice_locatorCacheTimeout(20))); + + compObj1 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 1000"); + compObj2 = communicator.stringToProxy("foo@MyAdapter1"); + test(!compObj1.equals(compObj2)); + + // + // TODO: Ideally we should also test comparison of fixed proxies. + // + System.out.println("ok"); + + System.out.print("testing checked cast... "); + System.out.flush(); + Test.MyClassPrx cl = Test.MyClassPrxHelper.checkedCast(base); + test(cl != null); + Test.MyDerivedClassPrx derived = Test.MyDerivedClassPrxHelper.checkedCast(cl); + test(derived != null); + test(cl.equals(base)); + test(derived.equals(base)); + test(cl.equals(derived)); + System.out.println("ok"); + + System.out.print("testing checked cast with context... "); + System.out.flush(); + + java.util.Map c = cl.getContext(); + test(c == null || c.size() == 0); + + c = new java.util.HashMap(); + c.put("one", "hello"); + c.put("two", "world"); + cl = Test.MyClassPrxHelper.checkedCast(base, c); + java.util.Map c2 = cl.getContext(); + test(c.equals(c2)); + System.out.println("ok"); + + if(!collocated) + { + System.out.print("testing timeout... "); + System.out.flush(); + Test.MyClassPrx clTimeout = Test.MyClassPrxHelper.uncheckedCast(cl.ice_timeout(500)); + try + { + clTimeout.opSleep(1000); + test(false); + } + catch(Ice.TimeoutException ex) + { + } + System.out.println("ok"); + + AMI_MyClass_opSleepI cb = new AMI_MyClass_opSleepI(); + try + { + clTimeout.opSleep_async(cb, 2000); + } + catch(Ice.LocalException ex) + { + test(false); + } + test(cb.check()); + } + return cl; + } +} diff --git a/java/test/Ice/proxy/Client.java b/java/test/Ice/proxy/Client.java new file mode 100644 index 00000000000..edbeac8bd1f --- /dev/null +++ b/java/test/Ice/proxy/Client.java @@ -0,0 +1,81 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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. +// +// ********************************************************************** + +public class Client +{ + private static int + run(String[] args, Ice.Communicator communicator) + { + Test.MyClassPrx myClass = AllTests.allTests(communicator, false); + myClass.shutdown(); + return 0; + } + + public static void + main(String[] args) + { + int status = 0; + Ice.Communicator communicator = null; + + try + { + // + // In this test, we need at least two threads in the + // client side thread pool for nested AMI. + // + Ice.StringSeqHolder argsH = new Ice.StringSeqHolder(args); + Ice.InitializationData initData = new Ice.InitializationData(); + initData.properties = Ice.Util.createProperties(argsH); + initData.properties.setProperty("Ice.ThreadPool.Client.Size", "2"); + initData.properties.setProperty("Ice.ThreadPool.Client.SizeWarn", "0"); + + // + // We must set MessageSizeMax to an explicit values, + // because we run tests to check whether + // Ice.MemoryLimitException is raised as expected. + // + initData.properties.setProperty("Ice.MessageSizeMax", "100"); + + // + // We don't want connection warnings because of the timeout test. + // + initData.properties.setProperty("Ice.Warn.Connections", "0"); + + // + // Use a faster connection monitor timeout to test AMI + // timeouts. + // + initData.properties.setProperty("Ice.MonitorConnections", "1"); + + communicator = Ice.Util.initialize(argsH, initData); + status = run(argsH.value, communicator); + } + catch(Ice.LocalException ex) + { + ex.printStackTrace(); + status = 1; + } + + if(communicator != null) + { + try + { + communicator.destroy(); + } + catch(Ice.LocalException ex) + { + ex.printStackTrace(); + status = 1; + } + } + + System.gc(); + System.exit(status); + } +} diff --git a/java/test/Ice/proxy/Collocated.java b/java/test/Ice/proxy/Collocated.java new file mode 100644 index 00000000000..75c4d5ea7d3 --- /dev/null +++ b/java/test/Ice/proxy/Collocated.java @@ -0,0 +1,60 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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. +// +// ********************************************************************** + +public class Collocated +{ + private static int + run(String[] args, Ice.Communicator communicator) + { + communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010 -t 10000"); + Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter"); + adapter.add(new MyDerivedClassI(), communicator.stringToIdentity("test")); + adapter.activate(); + + AllTests.allTests(communicator, true); + + return 0; + } + + public static void + main(String[] args) + { + int status = 0; + Ice.Communicator communicator = null; + + try + { + Ice.StringSeqHolder argsH = new Ice.StringSeqHolder(args); + Ice.InitializationData initData = new Ice.InitializationData(); + initData.properties = Ice.Util.createProperties(argsH); + communicator = Ice.Util.initialize(argsH, initData); + status = run(args, communicator); + } + catch(Ice.LocalException ex) + { + ex.printStackTrace(); + status = 1; + } + + if(communicator != null) + { + try + { + communicator.destroy(); + } + catch(Ice.LocalException ex) + { + ex.printStackTrace(); + status = 1; + } + } + + System.exit(status); + } +} diff --git a/java/test/Ice/proxy/MyDerivedClassI.java b/java/test/Ice/proxy/MyDerivedClassI.java new file mode 100644 index 00000000000..57ee7406cb7 --- /dev/null +++ b/java/test/Ice/proxy/MyDerivedClassI.java @@ -0,0 +1,53 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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. +// +// ********************************************************************** + +public final class MyDerivedClassI extends Test.MyDerivedClass +{ + public + MyDerivedClassI() + { + } + + public void + shutdown(Ice.Current c) + { + c.adapter.getCommunicator().shutdown(); + } + + public void + opSleep(int duration, Ice.Current current) + { + while(true) + { + try + { + Thread.currentThread().sleep(duration); + break; + } + catch(java.lang.InterruptedException ex) + { + } + } + } + + public java.util.Map + getContext(Ice.Current current) + { + return _ctx; + } + + public boolean + ice_isA(String s, Ice.Current current) + { + _ctx = current.ctx; + return super.ice_isA(s, current); + } + + private java.util.Map _ctx; +} diff --git a/java/test/Ice/proxy/Server.java b/java/test/Ice/proxy/Server.java new file mode 100644 index 00000000000..83b6c48698a --- /dev/null +++ b/java/test/Ice/proxy/Server.java @@ -0,0 +1,62 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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. +// +// ********************************************************************** + +public class Server +{ + private static int + run(String[] args, Ice.Communicator communicator) + { + communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010:udp"); + Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter"); + adapter.add(new MyDerivedClassI(), communicator.stringToIdentity("test")); + adapter.activate(); + + communicator.waitForShutdown(); + return 0; + } + + public static void + main(String[] args) + { + int status = 0; + Ice.Communicator communicator = null; + + try + { + Ice.StringSeqHolder argsH = new Ice.StringSeqHolder(args); + Ice.InitializationData initData = new Ice.InitializationData(); + initData.properties = Ice.Util.createProperties(argsH); + initData.properties.setProperty("Ice.Warn.Connections", "0"); + + communicator = Ice.Util.initialize(argsH, initData); + status = run(argsH.value, communicator); + } + catch(Ice.LocalException ex) + { + ex.printStackTrace(); + status = 1; + } + + if(communicator != null) + { + try + { + communicator.destroy(); + } + catch(Ice.LocalException ex) + { + ex.printStackTrace(); + status = 1; + } + } + + System.gc(); + System.exit(status); + } +} diff --git a/java/test/Ice/proxy/Test.ice b/java/test/Ice/proxy/Test.ice new file mode 100644 index 00000000000..b22f136bde2 --- /dev/null +++ b/java/test/Ice/proxy/Test.ice @@ -0,0 +1,33 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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. +// +// ********************************************************************** + +#ifndef TEST_ICE +#define TEST_ICE + +#include <Ice/Current.ice> + +module Test +{ + +["ami"] class MyClass +{ + void shutdown(); + + void opSleep(int duration); + + Ice::Context getContext(); +}; + +["ami"] class MyDerivedClass extends MyClass +{ +}; + +}; + +#endif diff --git a/java/test/Ice/proxy/build.xml b/java/test/Ice/proxy/build.xml new file mode 100644 index 00000000000..9f87499b8ac --- /dev/null +++ b/java/test/Ice/proxy/build.xml @@ -0,0 +1,51 @@ +<!-- + ********************************************************************** + + Copyright (c) 2003-2007 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. + + ********************************************************************** +--> + +<project name="test_Ice_operations" default="all" basedir="."> + + <!-- set global properties for this build --> + <property name="top.dir" value="../../.."/> + + <!-- import common definitions --> + <import file="${top.dir}/config/common.xml"/> + + <target name="generate" depends="init"> + <!-- Create the output directory for generated code --> + <mkdir dir="${generated.dir}"/> + <slice2java outputdir="${generated.dir}"> + <meta value="${java2metadata}"/> + <fileset dir="." includes="Test.ice"/> + <includepath> + <pathelement path="${slice.dir}" /> + </includepath> + </slice2java> + </target> + + <target name="compile" depends="generate"> + <mkdir dir="${class.dir}"/> + <javac srcdir="${generated.dir}" destdir="${class.dir}" + source="${jdk.version}" classpath="${lib.dir}" debug="${debug}"> + <compilerarg value="${javac.lint}" compiler="${javac.lint.compiler}"/> + </javac> + <javac srcdir="." destdir="${class.dir}" source="${jdk.version}" + classpath="${lib.dir}" excludes="generated/**" debug="${debug}"> + <compilerarg value="${javac.lint}" compiler="${javac.lint.compiler}"/> + </javac> + </target> + + <target name="all" depends="compile"/> + + <target name="clean"> + <delete dir="${generated.dir}"/> + <delete dir="${class.dir}"/> + </target> + +</project> diff --git a/java/test/Ice/proxy/run.py b/java/test/Ice/proxy/run.py new file mode 100755 index 00000000000..b5ea48f9762 --- /dev/null +++ b/java/test/Ice/proxy/run.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2007 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 + +for toplevel in [".", "..", "../..", "../../..", "../../../.."]: + toplevel = os.path.normpath(toplevel) + if os.path.exists(os.path.join(toplevel, "config", "TestUtil.py")): + break +else: + raise "can't find toplevel directory!" + +sys.path.append(os.path.join(toplevel, "config")) +import TestUtil + +name = os.path.join("Ice", "proxy") +testdir = os.path.join(toplevel, "test", name) +nameAMD = os.path.join("Ice", "proxyAMD") +testdirAMD = os.path.join(toplevel, "test", nameAMD) + +print "tests with regular server." +classpath = os.getenv("CLASSPATH", "") +os.environ["CLASSPATH"] = os.path.join(testdir, "classes") + TestUtil.sep + classpath +TestUtil.clientServerTest() + +print "tests with AMD server." +TestUtil.clientServerTestWithClasspath(\ + os.path.join(testdirAMD, "classes") + TestUtil.sep + classpath,\ + os.path.join(testdir, "classes") + TestUtil.sep + classpath) + +print "tests with collocated server." +TestUtil.collocatedTest() + +sys.exit(0) diff --git a/java/test/Ice/proxyAMD/MyDerivedClassI.java b/java/test/Ice/proxyAMD/MyDerivedClassI.java new file mode 100644 index 00000000000..0bdcd154685 --- /dev/null +++ b/java/test/Ice/proxyAMD/MyDerivedClassI.java @@ -0,0 +1,56 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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. +// +// ********************************************************************** + +public final class MyDerivedClassI extends Test.MyDerivedClass +{ + public + MyDerivedClassI() + { + } + + public void + shutdown_async(Test.AMD_MyClass_shutdown cb, + Ice.Current c) + { + c.adapter.getCommunicator().shutdown(); + cb.ice_response(); + } + + public void + opSleep_async(Test.AMD_MyClass_opSleep cb, int duration, Ice.Current current) + { + while(true) + { + try + { + Thread.currentThread().sleep(duration); + cb.ice_response(); + break; + } + catch(java.lang.InterruptedException ex) + { + } + } + } + + public void + getContext_async(Test.AMD_MyClass_getContext cb, Ice.Current current) + { + cb.ice_response(_ctx); + } + + public boolean + ice_isA(String s, Ice.Current current) + { + _ctx = current.ctx; + return super.ice_isA(s, current); + } + + private java.util.Map _ctx; +} diff --git a/java/test/Ice/proxyAMD/Server.java b/java/test/Ice/proxyAMD/Server.java new file mode 100644 index 00000000000..07f4f92ec98 --- /dev/null +++ b/java/test/Ice/proxyAMD/Server.java @@ -0,0 +1,63 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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. +// +// ********************************************************************** + +public class Server +{ + private static int + run(String[] args, Ice.Communicator communicator) + { + communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010 -t 10000:udp"); + Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter"); + adapter.add(new MyDerivedClassI(), communicator.stringToIdentity("test")); + adapter.activate(); + + communicator.waitForShutdown(); + return 0; + } + + public static void + main(String[] args) + { + int status = 0; + Ice.Communicator communicator = null; + + try + { + Ice.StringSeqHolder argsH = new Ice.StringSeqHolder(args); + Ice.InitializationData initData = new Ice.InitializationData(); + initData.properties = Ice.Util.createProperties(argsH); + + initData.properties.setProperty("Ice.Warn.Connections", "0"); + + communicator = Ice.Util.initialize(argsH, initData); + status = run(args, communicator); + } + catch(Ice.LocalException ex) + { + ex.printStackTrace(); + status = 1; + } + + if(communicator != null) + { + try + { + communicator.destroy(); + } + catch(Ice.LocalException ex) + { + ex.printStackTrace(); + status = 1; + } + } + + System.gc(); + System.exit(status); + } +} diff --git a/java/test/Ice/proxyAMD/TestAMD.ice b/java/test/Ice/proxyAMD/TestAMD.ice new file mode 100644 index 00000000000..24167e40e42 --- /dev/null +++ b/java/test/Ice/proxyAMD/TestAMD.ice @@ -0,0 +1,33 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2007 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. +// +// ********************************************************************** + +#ifndef TEST_AMD_ICE +#define TEST_AMD_ICE + +#include<Ice/Current.ice> + +module Test +{ + +["ami", "amd"] class MyClass +{ + void shutdown(); + + void opSleep(int duration); + + Ice::Context getContext(); +}; + +["ami", "amd"] class MyDerivedClass extends MyClass +{ +}; + +}; + +#endif diff --git a/java/test/Ice/proxyAMD/build.xml b/java/test/Ice/proxyAMD/build.xml new file mode 100644 index 00000000000..79194c94ea3 --- /dev/null +++ b/java/test/Ice/proxyAMD/build.xml @@ -0,0 +1,51 @@ +<!-- + ********************************************************************** + + Copyright (c) 2003-2007 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. + + ********************************************************************** +--> + +<project name="test_Ice_operationsAMD" default="all" basedir="."> + + <!-- set global properties for this build --> + <property name="top.dir" value="../../.."/> + + <!-- import common definitions --> + <import file="${top.dir}/config/common.xml"/> + + <target name="generate" depends="init"> + <!-- Create the output directory for generated code --> + <mkdir dir="${generated.dir}"/> + <slice2java outputdir="${generated.dir}"> + <meta value="${java2metadata}"/> + <fileset dir="." includes="TestAMD.ice"/> + <includepath> + <pathelement path="${slice.dir}" /> + </includepath> + </slice2java> + </target> + + <target name="compile" depends="generate"> + <mkdir dir="${class.dir}"/> + <javac srcdir="${generated.dir}" destdir="${class.dir}" + source="${jdk.version}" classpath="${lib.dir}" debug="${debug}"> + <compilerarg value="${javac.lint}" compiler="${javac.lint.compiler}"/> + </javac> + <javac srcdir="." destdir="${class.dir}" source="${jdk.version}" + classpath="${lib.dir}" excludes="generated/**" debug="${debug}"> + <compilerarg value="${javac.lint}" compiler="${javac.lint.compiler}"/> + </javac> + </target> + + <target name="all" depends="compile"/> + + <target name="clean"> + <delete dir="${generated.dir}"/> + <delete dir="${class.dir}"/> + </target> + +</project> |