diff options
Diffstat (limited to 'cpp/test')
43 files changed, 3306 insertions, 63 deletions
diff --git a/cpp/test/Freeze/oldevictor/Client.cpp b/cpp/test/Freeze/oldevictor/Client.cpp index cfafd704ef7..2dd10200004 100644 --- a/cpp/test/Freeze/oldevictor/Client.cpp +++ b/cpp/test/Freeze/oldevictor/Client.cpp @@ -9,6 +9,7 @@ #include <Ice/Ice.h> #include <IceUtil/Thread.h> +#include <IceUtil/RecMutex.h> #include <IceUtil/Time.h> #include <TestCommon.h> #include <Test.h> diff --git a/cpp/test/Glacier2/router/Client.cpp b/cpp/test/Glacier2/router/Client.cpp index 65717e620cc..0f878bb7469 100644 --- a/cpp/test/Glacier2/router/Client.cpp +++ b/cpp/test/Glacier2/router/Client.cpp @@ -515,8 +515,16 @@ CallbackClient::run(int argc, char* argv[]) { cout << "creating session with correct password... " << flush; - session = router->createSession("userid", "abc123"); - cout << "ok" << endl; + try + { + session = router->createSession("userid", "abc123"); + cout << "ok" << endl; + } + catch(const Glacier2::PermissionDeniedException& ex) + { + cerr << ex << ":\n" << ex.reason << endl; + test(false); + } } { @@ -701,7 +709,7 @@ CallbackClient::run(int argc, char* argv[]) } { - cout << "testing buffered mode... " << flush; + cout << "testing with blocking clients... " << flush; // // Start 3 misbehaving clients. diff --git a/cpp/test/Glacier2/router/run.py b/cpp/test/Glacier2/router/run.py index 0edaed9d6f6..e674550143c 100755 --- a/cpp/test/Glacier2/router/run.py +++ b/cpp/test/Glacier2/router/run.py @@ -22,35 +22,57 @@ import TestUtil router = os.path.join(TestUtil.getBinDir(__file__), "glacier2router") -args = r' --Ice.Warn.Dispatch=0' + \ - r' --Ice.Warn.Connections=0' + \ - r' --Glacier2.Filter.Category.Accept="c1 c2"' + \ - r' --Glacier2.Filter.Category.AcceptUser="2"' + \ - r' --Glacier2.SessionTimeout="30"' + \ - r' --Glacier2.Client.Endpoints="default -p 12347 -t 10000"' + \ - r' --Glacier2.Server.Endpoints="tcp -h 127.0.0.1 -t 10000"' \ - r' --Ice.Admin.Endpoints="tcp -h 127.0.0.1 -p 12348 -t 10000"' + \ - r' --Ice.Admin.InstanceName="Glacier2"' + \ - r' --Glacier2.CryptPasswords="' + TestUtil.getMappingDir(__file__) + r'/test/Glacier2/router/passwords"' - -print "starting router...", -if TestUtil.debug: - print "(" + command + ")", -starterPipe = TestUtil.startServer(router, args + " 2>&1") -TestUtil.getServerPid(starterPipe) -# -# For this test we don't want to add the router to the server threads -# since we want the the router to run over two calls to -# mixedClientServerTest -# -TestUtil.getAdapterReady(starterPipe, False) -print "ok" +def startRouter(buffered): + + args = r' --Ice.Warn.Dispatch=0' + \ + r' --Ice.Warn.Connections=0' + \ + r' --Glacier2.Filter.Category.Accept="c1 c2"' + \ + r' --Glacier2.Filter.Category.AcceptUser="2"' + \ + r' --Glacier2.SessionTimeout="30"' + \ + r' --Glacier2.Client.Endpoints="default -p 12347 -t 10000"' + \ + r' --Glacier2.Server.Endpoints="tcp -h 127.0.0.1 -t 10000"' \ + r' --Ice.Admin.Endpoints="tcp -h 127.0.0.1 -p 12348 -t 10000"' + \ + r' --Ice.Admin.InstanceName="Glacier2"' + \ + r' --Glacier2.CryptPasswords="' + TestUtil.getMappingDir(__file__) + r'/test/Glacier2/router/passwords"' + + if buffered: + args += ' --Glacier2.Client.Buffered=1 --Glacier2.Server.Buffered=1' + print "starting router in buffered mode...", + else: + args += ' --Glacier2.Client.Buffered=0 --Glacier2.Server.Buffered=0' + print "starting router in unbuffered mode...", + + starterPipe = TestUtil.startServer(router, args + " 2>&1") + TestUtil.getServerPid(starterPipe) + + # + # For this test we don't want to add the router to the server threads + # since we want the the router to run over two calls to + # mixedClientServerTest + # + TestUtil.getAdapterReady(starterPipe, False) + print "ok" -starterThread = TestUtil.ReaderThread(starterPipe); -starterThread.start() + routerThread = TestUtil.ReaderThread(starterPipe); + routerThread.start() + + return routerThread name = os.path.join("Glacier2", "router") +# +# We first run the test with unbuffered mode. +# +routerThread = startRouter(False) +TestUtil.mixedClientServerTestWithOptions(name, "", " --shutdown") +routerThread.join() +if routerThread.getStatus(): + sys.exit(1) + +# +# Then we run the test in buffered mode. +# +routerThread = startRouter(True) TestUtil.mixedClientServerTest(name) # @@ -60,8 +82,8 @@ TestUtil.mixedClientServerTest(name) # TestUtil.mixedClientServerTestWithOptions(name, "", " --shutdown") -starterThread.join() -if starterThread.getStatus(): +routerThread.join() +if routerThread.getStatus(): sys.exit(1) sys.exit(0) diff --git a/cpp/test/Ice/Makefile b/cpp/test/Ice/Makefile index 2c577b0081e..db697847888 100644 --- a/cpp/test/Ice/Makefile +++ b/cpp/test/Ice/Makefile @@ -32,7 +32,8 @@ SUBDIRS = proxy \ servantLocator \ threads \ interceptor \ - stringConverter + stringConverter \ + background $(EVERYTHING):: @for subdir in $(SUBDIRS); \ diff --git a/cpp/test/Ice/Makefile.mak b/cpp/test/Ice/Makefile.mak index dfe04be6621..f1e43713e81 100644 --- a/cpp/test/Ice/Makefile.mak +++ b/cpp/test/Ice/Makefile.mak @@ -32,7 +32,8 @@ SUBDIRS = proxy \ servantLocator \ threads \ interceptor \ - stringConverter + stringConverter \ + background $(EVERYTHING):: @for %i in ( $(SUBDIRS) ) do \ diff --git a/cpp/test/Ice/background/.depend b/cpp/test/Ice/background/.depend new file mode 100644 index 00000000000..02b0c387ca0 --- /dev/null +++ b/cpp/test/Ice/background/.depend @@ -0,0 +1,17 @@ +Configuration$(OBJEXT): Configuration.cpp Configuration.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/IceUtil/Handle.h ../../../include/Ice/LocalException.h ../../../include/Ice/LocalObjectF.h ../../../include/Ice/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/RequestHandlerF.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/BuiltinSequences.h ../../../src/Ice/Selector.h ../../../include/Ice/InstanceF.h +Connector$(OBJEXT): Connector.cpp Connector.h ../../../src/Ice/Connector.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 ../../../src/Ice/ConnectorF.h ../../../include/Ice/Handle.h ../../../include/IceUtil/Handle.h ../../../include/Ice/Config.h ../../../include/Ice/ProxyHandle.h ../../../src/Ice/TransceiverF.h Configuration.h ../../../include/Ice/LocalException.h ../../../include/Ice/LocalObjectF.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/RequestHandlerF.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/BuiltinSequences.h ../../../src/Ice/Selector.h ../../../include/Ice/InstanceF.h Transceiver.h ../../../src/Ice/Transceiver.h EndpointI.h ../../../src/Ice/EndpointI.h ../../../include/IceUtil/Thread.h ../../../include/IceUtil/Monitor.h ../../../include/IceUtil/Cond.h ../../../include/IceUtil/Time.h ../../../src/Ice/AcceptorF.h +Acceptor$(OBJEXT): Acceptor.cpp Acceptor.h ../../../src/Ice/Acceptor.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 ../../../src/Ice/AcceptorF.h ../../../include/Ice/Handle.h ../../../include/IceUtil/Handle.h ../../../include/Ice/Config.h ../../../include/Ice/ProxyHandle.h ../../../src/Ice/TransceiverF.h Transceiver.h ../../../src/Ice/Transceiver.h ../../../src/Ice/Selector.h ../../../include/Ice/InstanceF.h Configuration.h ../../../include/Ice/LocalException.h ../../../include/Ice/LocalObjectF.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/RequestHandlerF.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/BuiltinSequences.h +EndpointI$(OBJEXT): EndpointI.cpp EndpointI.h ../../../src/Ice/EndpointI.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/IceUtil/Thread.h ../../../include/IceUtil/Handle.h ../../../include/IceUtil/Monitor.h ../../../include/IceUtil/Cond.h ../../../include/IceUtil/Time.h ../../../include/Ice/Endpoint.h ../../../include/Ice/LocalObjectF.h ../../../include/Ice/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/EndpointIF.h ../../../include/Ice/InstanceF.h ../../../src/Ice/TransceiverF.h ../../../src/Ice/ConnectorF.h ../../../src/Ice/AcceptorF.h Configuration.h ../../../include/Ice/LocalException.h ../../../include/Ice/Proxy.h ../../../include/Ice/ProxyFactoryF.h ../../../include/Ice/ConnectionIF.h ../../../include/Ice/RequestHandlerF.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/BuiltinSequences.h ../../../src/Ice/Selector.h Transceiver.h ../../../src/Ice/Transceiver.h Connector.h ../../../src/Ice/Connector.h Acceptor.h ../../../src/Ice/Acceptor.h ../../../include/Ice/BasicStream.h ../../../include/Ice/ObjectFactoryF.h ../../../include/Ice/Buffer.h ../../../include/Ice/Protocol.h ../../../include/Ice/StringConverter.h ../../../include/IceUtil/Unicode.h +Transceiver$(OBJEXT): Transceiver.cpp Transceiver.h ../../../src/Ice/Transceiver.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 ../../../src/Ice/TransceiverF.h ../../../include/Ice/Handle.h ../../../include/IceUtil/Handle.h ../../../include/Ice/Config.h ../../../include/Ice/ProxyHandle.h ../../../src/Ice/Selector.h ../../../include/Ice/InstanceF.h Configuration.h ../../../include/Ice/LocalException.h ../../../include/Ice/LocalObjectF.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/RequestHandlerF.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/BuiltinSequences.h +EndpointFactory$(OBJEXT): EndpointFactory.cpp ../../../src/Ice/Instance.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/IceUtil/RecMutex.h ../../../include/IceUtil/Timer.h ../../../include/IceUtil/Thread.h ../../../include/IceUtil/Handle.h ../../../include/IceUtil/Monitor.h ../../../include/IceUtil/Cond.h ../../../include/IceUtil/Time.h ../../../include/Ice/InstanceF.h ../../../include/Ice/Handle.h ../../../include/Ice/Config.h ../../../include/Ice/ProxyHandle.h ../../../include/Ice/CommunicatorF.h ../../../include/Ice/LocalObjectF.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/StatsF.h ../../../src/Ice/TraceLevelsF.h ../../../src/Ice/DefaultsAndOverridesF.h ../../../src/Ice/RouterInfoF.h ../../../src/Ice/LocatorInfoF.h ../../../src/Ice/ReferenceFactoryF.h ../../../include/Ice/ProxyFactoryF.h ../../../src/Ice/ThreadPoolF.h ../../../src/Ice/SelectorThreadF.h ../../../include/Ice/ConnectionFactoryF.h ../../../include/Ice/ConnectionMonitorF.h ../../../src/Ice/ObjectFactoryManagerF.h ../../../include/Ice/ObjectAdapterFactoryF.h ../../../src/Ice/EndpointFactoryManagerF.h ../../../include/Ice/DynamicLibraryF.h ../../../include/Ice/PluginF.h ../../../include/Ice/Initialize.h ../../../include/Ice/PropertiesF.h ../../../include/Ice/Proxy.h ../../../include/Ice/ConnectionIF.h ../../../include/Ice/RequestHandlerF.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/StreamF.h ../../../include/Ice/Object.h ../../../include/Ice/IncomingAsyncF.h ../../../include/Ice/LoggerF.h ../../../include/Ice/StringConverter.h ../../../include/Ice/BuiltinSequences.h ../../../src/Ice/SharedContext.h ../../../src/Ice/ImplicitContextI.h ../../../include/Ice/ImplicitContext.h ../../../include/Ice/LocalException.h ../../../include/Ice/FacetMap.h ../../../include/Ice/Process.h ../../../include/Ice/Outgoing.h ../../../include/Ice/BasicStream.h ../../../include/Ice/ObjectFactoryF.h ../../../include/Ice/Buffer.h ../../../include/Ice/Protocol.h ../../../include/IceUtil/Unicode.h ../../../include/Ice/OutgoingAsync.h ../../../include/Ice/Incoming.h ../../../include/Ice/ServantLocatorF.h ../../../include/Ice/ServantManagerF.h ../../../include/Ice/Direct.h ../../../src/Ice/EndpointFactoryManager.h ../../../include/Ice/EndpointFactoryF.h EndpointFactory.h ../../../include/Ice/EndpointFactory.h EndpointI.h ../../../src/Ice/EndpointI.h ../../../src/Ice/TransceiverF.h ../../../src/Ice/ConnectorF.h ../../../src/Ice/AcceptorF.h Configuration.h ../../../src/Ice/Selector.h +PluginI$(OBJEXT): PluginI.cpp ../../../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/Proxy.h ../../../include/Ice/ProxyFactoryF.h ../../../include/Ice/ConnectionIF.h ../../../include/Ice/RequestHandlerF.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/StreamF.h ../../../include/Ice/Object.h ../../../include/Ice/IncomingAsyncF.h ../../../include/Ice/InstanceF.h ../../../include/Ice/LoggerF.h ../../../include/Ice/StatsF.h ../../../include/Ice/StringConverter.h ../../../include/Ice/BuiltinSequences.h ../../../src/Ice/Instance.h ../../../include/IceUtil/RecMutex.h ../../../include/IceUtil/Timer.h ../../../include/IceUtil/Thread.h ../../../include/IceUtil/Monitor.h ../../../include/IceUtil/Cond.h ../../../include/IceUtil/Time.h ../../../src/Ice/TraceLevelsF.h ../../../src/Ice/DefaultsAndOverridesF.h ../../../src/Ice/RouterInfoF.h ../../../src/Ice/LocatorInfoF.h ../../../src/Ice/ReferenceFactoryF.h ../../../src/Ice/ThreadPoolF.h ../../../src/Ice/SelectorThreadF.h ../../../include/Ice/ConnectionFactoryF.h ../../../include/Ice/ConnectionMonitorF.h ../../../src/Ice/ObjectFactoryManagerF.h ../../../include/Ice/ObjectAdapterFactoryF.h ../../../src/Ice/EndpointFactoryManagerF.h ../../../include/Ice/DynamicLibraryF.h ../../../include/Ice/PluginF.h ../../../src/Ice/SharedContext.h ../../../src/Ice/ImplicitContextI.h ../../../include/Ice/ImplicitContext.h ../../../include/Ice/LocalException.h ../../../include/Ice/FacetMap.h ../../../include/Ice/Process.h ../../../include/Ice/Outgoing.h ../../../include/Ice/BasicStream.h ../../../include/Ice/ObjectFactoryF.h ../../../include/Ice/Buffer.h ../../../include/Ice/Protocol.h ../../../include/IceUtil/Unicode.h ../../../include/Ice/OutgoingAsync.h ../../../include/Ice/Incoming.h ../../../include/Ice/ServantLocatorF.h ../../../include/Ice/ServantManagerF.h ../../../include/Ice/Direct.h ../../../include/Ice/ProtocolPluginFacade.h ../../../include/Ice/ProtocolPluginFacadeF.h ../../../include/Ice/EndpointFactoryF.h ../../../src/Ice/EndpointFactoryManager.h PluginI.h ../../../include/Ice/Plugin.h Configuration.h ../../../src/Ice/Selector.h EndpointFactory.h ../../../include/Ice/EndpointFactory.h +Configuration$(OBJEXT): Configuration.cpp Configuration.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/IceUtil/Handle.h ../../../include/Ice/LocalException.h ../../../include/Ice/LocalObjectF.h ../../../include/Ice/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/RequestHandlerF.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/BuiltinSequences.h ../../../src/Ice/Selector.h ../../../include/Ice/InstanceF.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/RequestHandlerF.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/InstanceF.h ../../../include/Ice/BasicStream.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/Timer.h ../../../include/IceUtil/Thread.h ../../../include/Ice/Incoming.h ../../../include/Ice/ServantLocatorF.h ../../../include/Ice/ServantManagerF.h ../../../include/Ice/Direct.h ../../../include/Ice/BuiltinSequences.h ../../../include/Ice/LocalException.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/Proxy.h ../../../include/Ice/ProxyFactoryF.h ../../../include/Ice/ConnectionIF.h ../../../include/Ice/RequestHandlerF.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/StreamF.h ../../../include/Ice/Object.h ../../../include/Ice/IncomingAsyncF.h ../../../include/Ice/InstanceF.h ../../../include/Ice/LoggerF.h ../../../include/Ice/StatsF.h ../../../include/Ice/StringConverter.h ../../../include/Ice/BuiltinSequences.h ../../../include/Ice/LocalException.h ../../../include/Ice/Properties.h ../../../include/Ice/Outgoing.h ../../../include/IceUtil/Monitor.h ../../../include/IceUtil/Cond.h ../../../include/IceUtil/Time.h ../../../include/Ice/BasicStream.h ../../../include/Ice/ObjectFactoryF.h ../../../include/Ice/Buffer.h ../../../include/Ice/Protocol.h ../../../include/IceUtil/Unicode.h ../../../include/Ice/Incoming.h ../../../include/Ice/ServantLocatorF.h ../../../include/Ice/ServantManagerF.h ../../../include/Ice/Direct.h ../../../include/Ice/Logger.h ../../../include/Ice/LoggerUtil.h ../../../include/Ice/Stats.h ../../../include/Ice/Communicator.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/FacetMap.h ../../../include/Ice/ServantLocator.h ../../../include/Ice/OutgoingAsync.h ../../../include/IceUtil/Timer.h ../../../include/IceUtil/Thread.h ../../../include/Ice/IncomingAsync.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/Locator.h ../../../include/Ice/UserExceptionFactory.h ../../../include/Ice/FactoryTable.h ../../../include/Ice/FactoryTableDef.h ../../../include/IceUtil/StaticMutex.h ../../../include/Ice/UserExceptionFactoryF.h ../../../include/Ice/ProcessF.h ../../../include/Ice/Router.h ../../../include/Ice/DispatchInterceptor.h ../../../include/Ice/IconvStringConverter.h ../../include/TestCommon.h Test.h Configuration.h ../../../src/Ice/Selector.h +AllTests$(OBJEXT): AllTests.cpp ../../../include/IceUtil/IceUtil.h ../../../include/IceUtil/Config.h ../../../include/IceUtil/AbstractMutex.h ../../../include/IceUtil/Lock.h ../../../include/IceUtil/ThreadException.h ../../../include/IceUtil/Exception.h ../../../include/IceUtil/Algorithm.h ../../../include/IceUtil/ArgVector.h ../../../include/IceUtil/Base64.h ../../../include/IceUtil/Cache.h ../../../include/IceUtil/Handle.h ../../../include/IceUtil/Mutex.h ../../../include/IceUtil/CountDownLatch.h ../../../include/IceUtil/Cond.h ../../../include/IceUtil/Time.h ../../../include/IceUtil/CtrlCHandler.h ../../../include/IceUtil/Functional.h ../../../include/IceUtil/InputUtil.h ../../../include/IceUtil/Iterator.h ../../../include/IceUtil/MD5.h ../../../include/IceUtil/Monitor.h ../../../include/IceUtil/Options.h ../../../include/IceUtil/RecMutex.h ../../../include/IceUtil/Shared.h ../../../include/IceUtil/OutputUtil.h ../../../include/IceUtil/RWRecMutex.h ../../../include/IceUtil/Thread.h ../../../include/IceUtil/Random.h ../../../include/IceUtil/ScopedArray.h ../../../include/IceUtil/StaticMutex.h ../../../include/IceUtil/StringUtil.h ../../../include/IceUtil/UUID.h ../../../include/IceUtil/Unicode.h ../../../include/IceUtil/Timer.h ../../../include/Ice/Ice.h ../../../include/Ice/Initialize.h ../../../include/Ice/CommunicatorF.h ../../../include/Ice/LocalObjectF.h ../../../include/Ice/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/Proxy.h ../../../include/Ice/ProxyFactoryF.h ../../../include/Ice/ConnectionIF.h ../../../include/Ice/RequestHandlerF.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/StreamF.h ../../../include/Ice/Object.h ../../../include/Ice/IncomingAsyncF.h ../../../include/Ice/InstanceF.h ../../../include/Ice/LoggerF.h ../../../include/Ice/StatsF.h ../../../include/Ice/StringConverter.h ../../../include/Ice/BuiltinSequences.h ../../../include/Ice/LocalException.h ../../../include/Ice/Properties.h ../../../include/Ice/Outgoing.h ../../../include/Ice/BasicStream.h ../../../include/Ice/ObjectFactoryF.h ../../../include/Ice/Buffer.h ../../../include/Ice/Protocol.h ../../../include/Ice/Incoming.h ../../../include/Ice/ServantLocatorF.h ../../../include/Ice/ServantManagerF.h ../../../include/Ice/Direct.h ../../../include/Ice/Logger.h ../../../include/Ice/LoggerUtil.h ../../../include/Ice/Stats.h ../../../include/Ice/Communicator.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/FacetMap.h ../../../include/Ice/ServantLocator.h ../../../include/Ice/OutgoingAsync.h ../../../include/Ice/IncomingAsync.h ../../../include/Ice/Process.h ../../../include/Ice/Application.h ../../../include/Ice/Connection.h ../../../include/Ice/Functional.h ../../../include/Ice/Stream.h ../../../include/Ice/ImplicitContext.h ../../../include/Ice/Locator.h ../../../include/Ice/UserExceptionFactory.h ../../../include/Ice/FactoryTable.h ../../../include/Ice/FactoryTableDef.h ../../../include/Ice/UserExceptionFactoryF.h ../../../include/Ice/ProcessF.h ../../../include/Ice/Router.h ../../../include/Ice/DispatchInterceptor.h ../../../include/Ice/IconvStringConverter.h ../../include/TestCommon.h Test.h PluginI.h ../../../include/Ice/Plugin.h Configuration.h ../../../src/Ice/Selector.h +Configuration$(OBJEXT): Configuration.cpp Configuration.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/IceUtil/Handle.h ../../../include/Ice/LocalException.h ../../../include/Ice/LocalObjectF.h ../../../include/Ice/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/RequestHandlerF.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/BuiltinSequences.h ../../../src/Ice/Selector.h ../../../include/Ice/InstanceF.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/RequestHandlerF.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/InstanceF.h ../../../include/Ice/BasicStream.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/Timer.h ../../../include/IceUtil/Thread.h ../../../include/Ice/Incoming.h ../../../include/Ice/ServantLocatorF.h ../../../include/Ice/ServantManagerF.h ../../../include/Ice/Direct.h ../../../include/Ice/BuiltinSequences.h ../../../include/Ice/LocalException.h ../../../include/Ice/ObjectFactory.h ../../../include/IceUtil/Iterator.h ../../../include/IceUtil/ScopedArray.h +TestI$(OBJEXT): TestI.cpp TestI.h 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/RequestHandlerF.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/InstanceF.h ../../../include/Ice/BasicStream.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/Timer.h ../../../include/IceUtil/Thread.h ../../../include/Ice/Incoming.h ../../../include/Ice/ServantLocatorF.h ../../../include/Ice/ServantManagerF.h ../../../include/Ice/Direct.h ../../../include/Ice/BuiltinSequences.h Configuration.h ../../../include/Ice/LocalException.h ../../../src/Ice/Selector.h ../../../include/Ice/Ice.h ../../../include/Ice/Initialize.h ../../../include/Ice/PropertiesF.h ../../../include/Ice/LoggerF.h ../../../include/Ice/StatsF.h ../../../include/Ice/Properties.h ../../../include/Ice/Logger.h ../../../include/Ice/LoggerUtil.h ../../../include/Ice/Stats.h ../../../include/Ice/Communicator.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/FacetMap.h ../../../include/Ice/ServantLocator.h ../../../include/Ice/IncomingAsync.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/Locator.h ../../../include/Ice/UserExceptionFactory.h ../../../include/Ice/FactoryTable.h ../../../include/Ice/FactoryTableDef.h ../../../include/IceUtil/StaticMutex.h ../../../include/Ice/UserExceptionFactoryF.h ../../../include/Ice/ProcessF.h ../../../include/Ice/Router.h ../../../include/Ice/DispatchInterceptor.h ../../../include/Ice/IconvStringConverter.h +Server$(OBJEXT): Server.cpp ../../../include/IceUtil/DisableWarnings.h ../../../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/Proxy.h ../../../include/Ice/ProxyFactoryF.h ../../../include/Ice/ConnectionIF.h ../../../include/Ice/RequestHandlerF.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/StreamF.h ../../../include/Ice/Object.h ../../../include/Ice/IncomingAsyncF.h ../../../include/Ice/InstanceF.h ../../../include/Ice/LoggerF.h ../../../include/Ice/StatsF.h ../../../include/Ice/StringConverter.h ../../../include/Ice/BuiltinSequences.h ../../../include/Ice/LocalException.h ../../../include/Ice/Properties.h ../../../include/Ice/Outgoing.h ../../../include/IceUtil/Monitor.h ../../../include/IceUtil/Cond.h ../../../include/IceUtil/Time.h ../../../include/Ice/BasicStream.h ../../../include/Ice/ObjectFactoryF.h ../../../include/Ice/Buffer.h ../../../include/Ice/Protocol.h ../../../include/IceUtil/Unicode.h ../../../include/Ice/Incoming.h ../../../include/Ice/ServantLocatorF.h ../../../include/Ice/ServantManagerF.h ../../../include/Ice/Direct.h ../../../include/Ice/Logger.h ../../../include/Ice/LoggerUtil.h ../../../include/Ice/Stats.h ../../../include/Ice/Communicator.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/FacetMap.h ../../../include/Ice/ServantLocator.h ../../../include/Ice/OutgoingAsync.h ../../../include/IceUtil/Timer.h ../../../include/IceUtil/Thread.h ../../../include/Ice/IncomingAsync.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/Locator.h ../../../include/Ice/UserExceptionFactory.h ../../../include/Ice/FactoryTable.h ../../../include/Ice/FactoryTableDef.h ../../../include/IceUtil/StaticMutex.h ../../../include/Ice/UserExceptionFactoryF.h ../../../include/Ice/ProcessF.h ../../../include/Ice/Router.h ../../../include/Ice/DispatchInterceptor.h ../../../include/Ice/IconvStringConverter.h TestI.h Test.h Configuration.h ../../../src/Ice/Selector.h PluginI.h ../../../include/Ice/Plugin.h +Test.cpp: Test.ice ../../../../slice/Ice/BuiltinSequences.ice +Test.ice: $(SLICE2CPP) $(SLICEPARSERLIB) diff --git a/cpp/test/Ice/background/.gitignore b/cpp/test/Ice/background/.gitignore new file mode 100644 index 00000000000..67872faa673 --- /dev/null +++ b/cpp/test/Ice/background/.gitignore @@ -0,0 +1,7 @@ +// Generated by makegitignore.py + +// IMPORTANT: Do not edit this file -- any edits made here will be lost! +client +server +Test.cpp +Test.h diff --git a/cpp/test/Ice/background/Acceptor.cpp b/cpp/test/Ice/background/Acceptor.cpp new file mode 100644 index 00000000000..d7158bdc4d4 --- /dev/null +++ b/cpp/test/Ice/background/Acceptor.cpp @@ -0,0 +1,54 @@ +// ********************************************************************** +// +// 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 <Acceptor.h> +#include <Transceiver.h> + +using namespace std; + +SOCKET +Acceptor::fd() +{ + return _acceptor->fd(); +} + +void +Acceptor::close() +{ + _acceptor->close(); +} + +void +Acceptor::listen() +{ + _acceptor->listen(); +} + +IceInternal::TransceiverPtr +Acceptor::accept(int timeout) +{ + return new Transceiver(_acceptor->accept(timeout)); +} + +void +Acceptor::connectToSelf() +{ + _acceptor->connectToSelf(); +} + +string +Acceptor::toString() const +{ + return _acceptor->toString(); +} + +Acceptor::Acceptor(const IceInternal::AcceptorPtr& acceptor) : _acceptor(acceptor) +{ +} + diff --git a/cpp/test/Ice/background/Acceptor.h b/cpp/test/Ice/background/Acceptor.h new file mode 100644 index 00000000000..a6fa166cd7f --- /dev/null +++ b/cpp/test/Ice/background/Acceptor.h @@ -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_ACCEPTOR_H +#define TEST_ACCEPTOR_H + +#include <Ice/Acceptor.h> + +class Acceptor : public IceInternal::Acceptor +{ +public: + + virtual SOCKET fd(); + virtual void close(); + virtual void listen(); + virtual IceInternal::TransceiverPtr accept(int); + virtual void connectToSelf(); + virtual std::string toString() const; + +private: + + Acceptor(const IceInternal::AcceptorPtr&); + friend class EndpointI; + + const IceInternal::AcceptorPtr _acceptor; +}; + +#endif diff --git a/cpp/test/Ice/background/AllTests.cpp b/cpp/test/Ice/background/AllTests.cpp new file mode 100644 index 00000000000..a4f0464575b --- /dev/null +++ b/cpp/test/Ice/background/AllTests.cpp @@ -0,0 +1,1171 @@ +// ********************************************************************** +// +// 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 <IceUtil/IceUtil.h> +#include <Ice/Ice.h> +#include <TestCommon.h> +#include <Test.h> +#include <PluginI.h> +#include <Configuration.h> + +using namespace std; +using namespace Test; + +class Callback : public IceUtil::Monitor<IceUtil::Mutex> +{ +public: + + Callback() : _called(false) + { + } + + bool + check(bool wait) + { + if(wait) + { + Lock sync(*this); + while(!_called) + { + timedWait(IceUtil::Time::seconds(5)); + if(!_called) + { + return false; // Must be timeout. + } + } + _called = false; + return true; + } + return _called; + } + + void + called() + { + Lock sync(*this); + assert(!_called); + _called = true; + notify(); + } + +private: + + bool _called; +}; + +class OpAMICallback : public Test::AMI_Background_op +{ +public: + + virtual void + ice_response() + { + callback.called(); + } + + virtual void + ice_exception(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + + bool + response(bool wait) + { + return callback.check(wait); + } + +private: + + Callback callback; +}; +typedef IceUtil::Handle<OpAMICallback> OpAMICallbackPtr; + +class FlushBatchRequestsCallback : public Ice::AMI_Object_ice_flushBatchRequests +{ +public: + + virtual void + ice_exception(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } +}; +typedef IceUtil::Handle<FlushBatchRequestsCallback> FlushBatchRequestsCallbackPtr; + +class OpExAMICallback : public Test::AMI_Background_op +{ +public: + + virtual void + ice_response() + { + test(false); + } + + virtual void + ice_exception(const Ice::Exception& ex) + { + callback.called(); + } + + bool + exception(bool wait) + { + return callback.check(wait); + } + +private: + + Callback callback; +}; +typedef IceUtil::Handle<OpExAMICallback> OpExAMICallbackPtr; + +class OpWithPayloadOnewayAMICallback : public Test::AMI_Background_opWithPayload +{ +public: + + virtual void + ice_response() + { + test(false); + } + + virtual void + ice_exception(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } +}; +typedef IceUtil::Handle<OpWithPayloadOnewayAMICallback> OpWithPayloadOnewayAMICallbackPtr; + +class OpThread : public IceUtil::Thread, public IceUtil::Mutex +{ +public: + + OpThread(const BackgroundPrx& background) : + _destroyed(false), + _background(BackgroundPrx::uncheckedCast(background->ice_oneway())) + { + start(); + } + + void + run() + { + int count = 0; + while(true) + { + { + IceUtil::Mutex::Lock sync(*this); + if(_destroyed) + { + return; + } + } + + try + { + if(++count == 10) // Don't blast the connection with only oneway's + { + count = 0; + _background->ice_twoway()->ice_ping(); + } + _background->op_async(new OpExAMICallback()); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(1)); + } + catch(const Ice::LocalException&) + { + } + } + } + + void + destroy() + { + IceUtil::Mutex::Lock sync(*this); + _destroyed = true; + } + +private: + + bool _destroyed; + BackgroundPrx _background; +}; +typedef IceUtil::Handle<OpThread> OpThreadPtr; + +void connectTests(const ConfigurationPtr&, const Test::BackgroundPrx&); +void initializeTests(const ConfigurationPtr&, const Test::BackgroundPrx&, const Test::BackgroundControllerPrx&); +void validationTests(const ConfigurationPtr&, const Test::BackgroundPrx&, const Test::BackgroundControllerPrx&); +void readWriteTests(const ConfigurationPtr&, const Test::BackgroundPrx&, const Test::BackgroundControllerPrx&); + +BackgroundPrx +allTests(const Ice::CommunicatorPtr& communicator) +{ + string sref = "background:default -p 12010 -t 10000"; + Ice::ObjectPrx obj = communicator->stringToProxy(sref); + test(obj); + + BackgroundPrx background = BackgroundPrx::uncheckedCast(obj); + + sref = "backgroundController:tcp -p 12011 -t 10000"; + obj = communicator->stringToProxy(sref); + test(obj); + + BackgroundControllerPrx backgroundController = BackgroundControllerPrx::uncheckedCast(obj); + + PluginI* plugin = dynamic_cast<PluginI*>(communicator->getPluginManager()->getPlugin("Test").get()); + assert(plugin); + ConfigurationPtr configuration = plugin->getConfiguration(); + + cout << "testing connect... " << flush; + { + connectTests(configuration, background); + } + cout << "ok" << endl; + + cout << "testing initialization... " << flush; + { + initializeTests(configuration, background, backgroundController); + } + cout << "ok" << endl; + + cout << "testing connection validation... " << flush; + { + validationTests(configuration, background, backgroundController); + } + cout << "ok" << endl; + + cout << "testing read/write... " << flush; + { + readWriteTests(configuration, background, backgroundController); + } + cout << "ok" << endl; + + cout << "testing locator... " << flush; + { + Ice::LocatorPrx locator; + obj = communicator->stringToProxy("locator:default -p 12010 -t 500"); + locator = Ice::LocatorPrx::uncheckedCast(obj); + obj = communicator->stringToProxy("background@Test")->ice_locator(locator)->ice_oneway(); + + // + // TODO: The following test doesn't work on Windows because of a bug + // in thread per connection mode where the thread per connection read + // call doesn't return when the transceiver is shutdown. + // +#ifdef _WIN32 + if(communicator->getProperties()->getPropertyAsInt("Ice.ThreadPerConnection") == 0) + { +#endif + backgroundController->pauseCall("findAdapterById"); + try + { + obj->ice_ping(); + test(false); + } + catch(const Ice::TimeoutException&) + { + } + backgroundController->resumeCall("findAdapterById"); +#ifdef _WIN32 + } +#endif + + obj = communicator->stringToProxy("locator:default -p 12010 -t 10000"); + locator = Ice::LocatorPrx::uncheckedCast(obj); + obj = obj->ice_locator(locator); + obj->ice_ping(); + + obj = communicator->stringToProxy("background@Test")->ice_locator(locator); + BackgroundPrx bg = BackgroundPrx::uncheckedCast(obj); + + backgroundController->pauseCall("findAdapterById"); + OpAMICallbackPtr cb = new OpAMICallback(); + bg->op_async(cb); + OpAMICallbackPtr cb2 = new OpAMICallback(); + bg->op_async(cb2); + test(!cb->response(false)); + test(!cb2->response(false)); + backgroundController->resumeCall("findAdapterById"); + test(cb->response(true)); + test(cb2->response(true)); + } + cout << "ok" << endl; + + cout << "testing router... " << flush; + { + Ice::RouterPrx router; + + obj = communicator->stringToProxy("router:default -p 12010 -t 500"); + router = Ice::RouterPrx::uncheckedCast(obj); + obj = communicator->stringToProxy("background@Test")->ice_router(router)->ice_oneway(); + + // + // TODO: The following test doesn't work on Windows because of a bug + // in thread per connection mode where the thread per connection read + // call doesn't return when the transceiver is shutdown. + // +#ifdef _WIN32 + if(communicator->getProperties()->getPropertyAsInt("Ice.ThreadPerConnection") == 0) + { +#endif + backgroundController->pauseCall("getClientProxy"); + try + { + obj->ice_ping(); + test(false); + } + catch(const Ice::TimeoutException&) + { + } + backgroundController->resumeCall("getClientProxy"); +#ifdef _WIN32 + } +#endif + + obj = communicator->stringToProxy("router:default -p 12010 -t 10000"); + router = Ice::RouterPrx::uncheckedCast(obj); + obj = communicator->stringToProxy("background@Test")->ice_router(router); + BackgroundPrx bg = BackgroundPrx::uncheckedCast(obj); + test(bg->ice_getRouter()); + + backgroundController->pauseCall("getClientProxy"); + OpAMICallbackPtr cb = new OpAMICallback(); + bg->op_async(cb); + OpAMICallbackPtr cb2 = new OpAMICallback(); + bg->op_async(cb2); + test(!cb->response(false)); + test(!cb2->response(false)); + backgroundController->resumeCall("getClientProxy"); + test(cb->response(true)); + test(cb2->response(true)); + } + cout << "ok" << endl; + + return background; +} + +void +connectTests(const ConfigurationPtr& configuration, const Test::BackgroundPrx& background) +{ + try + { + background->op(); + } + catch(const Ice::LocalException&) + { + test(false); + } + background->ice_getConnection()->close(false); + + try + { + configuration->connectorsException(new Ice::DNSException(__FILE__, __LINE__)); + background->op(); + test(false); + } + catch(const Ice::DNSException&) + { + configuration->connectorsException(0); + } + + OpExAMICallbackPtr cbEx = new OpExAMICallback(); + + configuration->connectorsException(new Ice::DNSException(__FILE__, __LINE__)); + background->op_async(cbEx); + test(cbEx->exception(true)); + configuration->connectorsException(0); + + configuration->connectorsException(new Ice::DNSException(__FILE__, __LINE__)); + background->ice_oneway()->op_async(cbEx); + test(cbEx->exception(true)); + configuration->connectorsException(0); + + try + { + configuration->connectException(new Ice::SocketException(__FILE__, __LINE__)); + background->op(); + test(false); + } + catch(const Ice::SocketException&) + { + configuration->connectException(0); + } + + configuration->connectException(new Ice::SocketException(__FILE__, __LINE__)); + background->op_async(cbEx); + test(cbEx->exception(true)); + configuration->connectException(0); + + configuration->connectException(new Ice::SocketException(__FILE__, __LINE__)); + background->ice_oneway()->op_async(cbEx); + test(cbEx->exception(true)); + configuration->connectException(0); + + OpThreadPtr thread1 = new OpThread(background); + OpThreadPtr thread2 = new OpThread(background); + + for(int i = 0; i < 5; i++) + { + try + { + background->ice_ping(); + } + catch(const Ice::LocalException&) + { + test(false); + } + + configuration->connectException(new Ice::SocketException(__FILE__, __LINE__)); + background->ice_getCachedConnection()->close(true); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(10)); + configuration->connectException(0); + try + { + background->ice_ping(); + } + catch(const Ice::LocalException&) + { + } + } + + thread1->destroy(); + thread2->destroy(); + + thread1->getThreadControl().join(); + thread2->getThreadControl().join(); +} + +void +initializeTests(const ConfigurationPtr& configuration, + const Test::BackgroundPrx& background, + const Test::BackgroundControllerPrx& ctl) +{ + try + { + background->op(); + } + catch(const Ice::LocalException& ex) + { + cerr << ex << endl; + test(false); + } + background->ice_getConnection()->close(false); + + try + { + configuration->initializeException(new Ice::SocketException(__FILE__, __LINE__)); + background->op(); + test(false); + } + catch(const Ice::SocketException&) + { + configuration->initializeException(0); + } + + OpExAMICallbackPtr cbEx = new OpExAMICallback(); + + configuration->initializeException(new Ice::SocketException(__FILE__, __LINE__)); + background->op_async(cbEx); + test(cbEx->exception(true)); + configuration->initializeException(0); + + configuration->initializeException(new Ice::SocketException(__FILE__, __LINE__)); + background->ice_oneway()->op_async(cbEx); + test(cbEx->exception(true)); + configuration->initializeException(0); + + try + { + configuration->initializeSocketStatus(IceInternal::NeedWrite); + background->op(); + configuration->initializeSocketStatus(IceInternal::Finished); + } + catch(const Ice::LocalException&) + { + test(false); + } + background->ice_getConnection()->close(false); + + try + { + configuration->initializeSocketStatus(IceInternal::NeedConnect); + background->op(); + configuration->initializeSocketStatus(IceInternal::Finished); + } + catch(const Ice::LocalException&) + { + test(false); + } + background->ice_getConnection()->close(false); + + try + { + configuration->initializeSocketStatus(IceInternal::NeedWrite); + configuration->initializeException(new Ice::SocketException(__FILE__, __LINE__)); + background->op(); + test(false); + } + catch(const Ice::SocketException&) + { + configuration->initializeException(0); + configuration->initializeSocketStatus(IceInternal::Finished); + } + + configuration->initializeSocketStatus(IceInternal::NeedWrite); + configuration->initializeException(new Ice::SocketException(__FILE__, __LINE__)); + background->op_async(cbEx); + test(cbEx->exception(true)); + configuration->initializeException(0); + configuration->initializeSocketStatus(IceInternal::Finished); + + configuration->initializeSocketStatus(IceInternal::NeedWrite); + configuration->initializeException(new Ice::SocketException(__FILE__, __LINE__)); + background->ice_oneway()->op_async(cbEx); + test(cbEx->exception(true)); + configuration->initializeException(0); + configuration->initializeSocketStatus(IceInternal::Finished); + + // + // Now run the same tests with the server side. + // + + try + { + ctl->initializeException(true); + background->op(); + test(false); + } + catch(const Ice::ConnectionLostException&) + { + ctl->initializeException(false); + } + catch(const Ice::SecurityException&) + { + ctl->initializeException(false); + } + + try + { + ctl->initializeSocketStatus(IceInternal::NeedWrite); + background->op(); + ctl->initializeSocketStatus(IceInternal::Finished); + } + catch(const Ice::LocalException&) + { + test(false); + } + background->ice_getConnection()->close(false); + + try + { + ctl->initializeSocketStatus(IceInternal::NeedWrite); + ctl->initializeException(true); + background->op(); + test(false); + } + catch(const Ice::ConnectionLostException&) + { + ctl->initializeException(false); + ctl->initializeSocketStatus(IceInternal::Finished); + } + catch(const Ice::SecurityException&) + { + ctl->initializeException(false); + ctl->initializeSocketStatus(IceInternal::Finished); + } + + OpThreadPtr thread1 = new OpThread(background); + OpThreadPtr thread2 = new OpThread(background); + + for(int i = 0; i < 5; i++) + { + try + { + background->ice_ping(); + } + catch(const Ice::LocalException&) + { + test(false); + } + + configuration->initializeException(new Ice::SocketException(__FILE__, __LINE__)); + background->ice_getCachedConnection()->close(true); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(10)); + configuration->initializeException(0); + try + { + background->ice_ping(); + } + catch(const Ice::LocalException&) + { + } + try + { + background->ice_ping(); + } + catch(const Ice::LocalException&) + { + test(false); + } + + configuration->initializeSocketStatus(IceInternal::NeedWrite); + background->ice_getCachedConnection()->close(true); + background->ice_ping(); + configuration->initializeSocketStatus(IceInternal::Finished); + + ctl->initializeException(true); + background->ice_getCachedConnection()->close(true); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(10)); + ctl->initializeException(false); + try + { + background->ice_ping(); + } + catch(const Ice::LocalException&) + { + } + try + { + background->ice_ping(); + } + catch(const Ice::LocalException&) + { + test(false); + } + + try + { + ctl->initializeSocketStatus(IceInternal::NeedWrite); + background->ice_getCachedConnection()->close(true); + background->op(); + ctl->initializeSocketStatus(IceInternal::Finished); + } + catch(const Ice::LocalException& ex) + { + cerr << ex << endl; + test(false); + } + } + + thread1->destroy(); + thread2->destroy(); + + thread1->getThreadControl().join(); + thread2->getThreadControl().join(); +} + +void +validationTests(const ConfigurationPtr& configuration, + const Test::BackgroundPrx& background, + const Test::BackgroundControllerPrx& ctl) +{ + try + { + background->op(); + } + catch(const Ice::LocalException&) + { + test(false); + } + background->ice_getConnection()->close(false); + + try + { + // Get the read() of connection validation to throw right away. + configuration->readException(new Ice::SocketException(__FILE__, __LINE__)); + background->op(); + test(false); + } + catch(const Ice::SocketException&) + { + configuration->readException(0); + } + + OpExAMICallbackPtr cbEx = new OpExAMICallback(); + + configuration->readException(new Ice::SocketException(__FILE__, __LINE__)); + background->op_async(cbEx); + test(cbEx->exception(true)); + configuration->readException(0); + + configuration->readException(new Ice::SocketException(__FILE__, __LINE__)); + background->ice_oneway()->op_async(cbEx); + test(cbEx->exception(true)); + configuration->readException(0); + + if(background->ice_getCommunicator()->getProperties()->getProperty("Ice.Default.Protocol") != "test-ssl") + { + try + { + // Get the read() of the connection validation to return "would block" + configuration->readReady(false); + background->op(); + configuration->readReady(true); + } + catch(const Ice::LocalException& ex) + { + cerr << ex << endl; + test(false); + } + background->ice_getConnection()->close(false); + + try + { + // Get the read() of the connection validation to return "would block" and then throw. + configuration->readReady(false); + configuration->readException(new Ice::SocketException(__FILE__, __LINE__)); + background->op(); + test(false); + } + catch(const Ice::SocketException&) + { + configuration->readException(0); + configuration->readReady(true); + } + + configuration->readReady(false); + configuration->readException(new Ice::SocketException(__FILE__, __LINE__)); + background->op_async(cbEx); + test(cbEx->exception(true)); + configuration->readException(0); + configuration->readReady(true); + + configuration->readReady(false); + configuration->readException(new Ice::SocketException(__FILE__, __LINE__)); + background->ice_oneway()->op_async(cbEx); + test(cbEx->exception(true)); + configuration->readException(0); + configuration->readReady(true); + } + + ctl->holdAdapter(); // Hold to block in connection validation + OpAMICallbackPtr cb = new OpAMICallback(); + background->op_async(cb); + OpAMICallbackPtr cb2 = new OpAMICallback(); + background->op_async(cb2); + test(!cb->response(false)); + test(!cb2->response(false)); + ctl->resumeAdapter(); + test(cb->response(true)); + test(cb2->response(true)); + + try + { + // Get the write() of connection validation to throw right away. + ctl->writeException(true); + background->op(); + test(false); + } + catch(const Ice::ConnectionLostException&) + { + ctl->writeException(false); + } + + try + { + // Get the write() of the connection validation to return "would block" + ctl->writeReady(false); + background->op(); + ctl->writeReady(true); + } + catch(const Ice::LocalException& ex) + { + cerr << ex << endl; + test(false); + } + background->ice_getConnection()->close(false); + + try + { + // Get the write() of the connection validation to return "would block" and then throw. + ctl->writeReady(false); + ctl->writeException(true); + background->op(); + test(false); + } + catch(const Ice::ConnectionLostException&) + { + ctl->writeException(false); + ctl->writeReady(true); + } + + Ice::ByteSeq seq; + seq.resize(512 * 1024); + + BackgroundPrx backgroundBatchOneway = BackgroundPrx::uncheckedCast(background->ice_batchOneway()); + + // + // First send small requests to test without auto-flushing. + // + backgroundBatchOneway->ice_getConnection()->close(false); + try + { + backgroundBatchOneway->ice_ping(); + test(false); + } + catch(const Ice::CloseConnectionException&) + { + } + ctl->holdAdapter(); + backgroundBatchOneway->op(); + backgroundBatchOneway->op(); + backgroundBatchOneway->op(); + backgroundBatchOneway->op(); + ctl->resumeAdapter(); + backgroundBatchOneway->ice_flushBatchRequests(); + + // + // Send bigger requests to test with auto-flushing. + // + backgroundBatchOneway->ice_getConnection()->close(false); + try + { + backgroundBatchOneway->ice_ping(); + test(false); + } + catch(const Ice::CloseConnectionException&) + { + } + ctl->holdAdapter(); + backgroundBatchOneway->opWithPayload(seq); + backgroundBatchOneway->opWithPayload(seq); + backgroundBatchOneway->opWithPayload(seq); + backgroundBatchOneway->opWithPayload(seq); + ctl->resumeAdapter(); + backgroundBatchOneway->ice_flushBatchRequests(); + + // + // Then try the same thing with async flush. + // + + backgroundBatchOneway->ice_getConnection()->close(false); + try + { + backgroundBatchOneway->ice_ping(); + test(false); + } + catch(const Ice::CloseConnectionException&) + { + } + ctl->holdAdapter(); + backgroundBatchOneway->op(); + backgroundBatchOneway->op(); + backgroundBatchOneway->op(); + backgroundBatchOneway->op(); + ctl->resumeAdapter(); + backgroundBatchOneway->ice_flushBatchRequests_async(new FlushBatchRequestsCallback()); + backgroundBatchOneway->ice_getConnection()->close(false); + + backgroundBatchOneway->ice_getConnection()->close(false); + try + { + backgroundBatchOneway->ice_ping(); + test(false); + } + catch(const Ice::CloseConnectionException&) + { + } + ctl->holdAdapter(); + backgroundBatchOneway->opWithPayload(seq); + backgroundBatchOneway->opWithPayload(seq); + backgroundBatchOneway->opWithPayload(seq); + backgroundBatchOneway->opWithPayload(seq); + ctl->resumeAdapter(); + FlushBatchRequestsCallbackPtr fcb = new FlushBatchRequestsCallback(); + backgroundBatchOneway->ice_flushBatchRequests_async(fcb); + // + // We can't close the connection before ensuring all the batches have been sent since + // with auto-flushing the close connection message might be sent once the first call + // opWithPayload is sent and before the flushBatchRequests (this would therefore result + // in the flush to report a CloseConnectionException). Instead we flush a second time + // with the same callback to wait for the first flush to complete. + // + //backgroundBatchOneway->ice_getConnection()->close(false); + backgroundBatchOneway->ice_flushBatchRequests_async(fcb); + backgroundBatchOneway->ice_getConnection()->close(false); +} + +void +readWriteTests(const ConfigurationPtr& configuration, + const Test::BackgroundPrx& background, + const Test::BackgroundControllerPrx& ctl) +{ + try + { + background->op(); + } + catch(const Ice::LocalException& ex) + { + cerr << ex << endl; + test(false); + } + + try + { + background->ice_ping(); + configuration->writeException(new Ice::SocketException(__FILE__, __LINE__)); + background->op(); + test(false); + } + catch(const Ice::SocketException&) + { + configuration->writeException(0); + } + + OpExAMICallbackPtr cbEx = new OpExAMICallback(); + + background->ice_ping(); + configuration->writeException(new Ice::SocketException(__FILE__, __LINE__)); + background->op_async(cbEx); + test(cbEx->exception(true)); + configuration->writeException(0); + + background->ice_ping(); + configuration->writeException(new Ice::SocketException(__FILE__, __LINE__)); + background->ice_oneway()->op_async(cbEx); + test(cbEx->exception(true)); + configuration->writeException(0); + + try + { + background->ice_ping(); + configuration->readException(new Ice::SocketException(__FILE__, __LINE__)); + background->op(); + test(false); + } + catch(const Ice::SocketException&) + { + configuration->readException(0); + } + + background->ice_ping(); + configuration->readException(new Ice::SocketException(__FILE__, __LINE__)); + background->op_async(cbEx); + test(cbEx->exception(true)); + configuration->readException(0); + + try + { + background->ice_ping(); + configuration->writeReady(false); + background->op(); + configuration->writeReady(true); + } + catch(const Ice::LocalException&) + { + test(false); + } + + try + { + background->ice_ping(); + configuration->readReady(false); + background->op(); + configuration->readReady(true); + } + catch(const Ice::LocalException&) + { + test(false); + } + + try + { + background->ice_ping(); + configuration->writeReady(false); + configuration->writeException(new Ice::SocketException(__FILE__, __LINE__)); + background->op(); + test(false); + } + catch(const Ice::SocketException&) + { + configuration->writeReady(true); + configuration->writeException(0); + } + + background->ice_ping(); + configuration->writeReady(false); + configuration->writeException(new Ice::SocketException(__FILE__, __LINE__)); + background->op_async(cbEx); + test(cbEx->exception(true)); + configuration->writeReady(true); + configuration->writeException(0); + + background->ice_ping(); + configuration->writeReady(false); + configuration->writeException(new Ice::SocketException(__FILE__, __LINE__)); + background->ice_oneway()->op_async(cbEx); + test(cbEx->exception(true)); + configuration->writeReady(true); + configuration->writeException(0); + + try + { + background->ice_ping(); + configuration->readReady(false); + configuration->readException(new Ice::SocketException(__FILE__, __LINE__)); + background->op(); + test(false); + } + catch(const Ice::SocketException&) + { + configuration->readException(0); + configuration->readReady(true); + } + + background->ice_ping(); + configuration->readReady(false); + configuration->readException(new Ice::SocketException(__FILE__, __LINE__)); + background->op_async(cbEx); + test(cbEx->exception(true)); + configuration->readReady(true); + configuration->readException(0); + + background->ice_ping(); // Establish the connection + + BackgroundPrx backgroundOneway = BackgroundPrx::uncheckedCast(background->ice_oneway()); + test(backgroundOneway->ice_getConnection() == background->ice_getConnection()); + + ctl->holdAdapter(); // Hold to block in request send. + + Ice::ByteSeq seq; + seq.resize(512 * 1024); + backgroundOneway->opWithPayload_async(new OpWithPayloadOnewayAMICallback(), seq); + OpAMICallbackPtr cb = new OpAMICallback(); + background->op_async(cb); + OpAMICallbackPtr cb2 = new OpAMICallback(); + background->op_async(cb2); + backgroundOneway->opWithPayload_async(new OpWithPayloadOnewayAMICallback(), seq); + backgroundOneway->opWithPayload_async(new OpWithPayloadOnewayAMICallback(), seq); + test(!cb->response(false)); + test(!cb2->response(false)); + ctl->resumeAdapter(); + test(cb->response(true)); + test(cb2->response(true)); + + try + { + background->ice_ping(); + ctl->writeException(true); + background->op(); + test(false); + } + catch(const Ice::ConnectionLostException&) + { + ctl->writeException(false); + } + + try + { + background->ice_ping(); + ctl->readException(true); + background->op(); + test(false); + } + catch(const Ice::ConnectionLostException&) + { + ctl->readException(false); + } + + try + { + background->ice_ping(); + ctl->writeReady(false); + background->op(); + ctl->writeReady(true); + } + catch(const Ice::LocalException&) + { + test(false); + } + + try + { + background->ice_ping(); + ctl->readReady(false); + background->op(); + ctl->readReady(true); + } + catch(const Ice::LocalException&) + { + test(false); + } + + try + { + background->ice_ping(); + ctl->writeReady(false); + ctl->writeException(true); + background->op(); + test(false); + } + catch(const Ice::ConnectionLostException&) + { + ctl->writeException(false); + ctl->writeReady(true); + } + + try + { + background->ice_ping(); + ctl->readReady(false); + ctl->readException(true); + background->op(); + test(false); + } + catch(const Ice::ConnectionLostException&) + { + ctl->readException(false); + ctl->readReady(true); + } + + OpThreadPtr thread1 = new OpThread(background); + OpThreadPtr thread2 = new OpThread(background); + + for(int i = 0; i < 5; i++) + { + try + { + background->ice_ping(); + } + catch(const Ice::LocalException&) + { + test(false); + } + + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(10)); + configuration->writeException(new Ice::SocketException(__FILE__, __LINE__)); + try + { + background->op(); + } + catch(const Ice::LocalException&) + { + } + configuration->writeException(0); + + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(10)); + + background->ice_ping(); + background->ice_getCachedConnection()->close(true); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(10)); + + background->ice_getCachedConnection()->close(true); + } + + thread1->destroy(); + thread2->destroy(); + + thread1->getThreadControl().join(); + thread2->getThreadControl().join(); +} diff --git a/cpp/test/Ice/background/Client.cpp b/cpp/test/Ice/background/Client.cpp new file mode 100644 index 00000000000..93ec94c5770 --- /dev/null +++ b/cpp/test/Ice/background/Client.cpp @@ -0,0 +1,78 @@ +// ********************************************************************** +// +// 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> +#include <Configuration.h> + +using namespace std; +using namespace Test; + +int +run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) +{ + BackgroundPrx allTests(const Ice::CommunicatorPtr&); + BackgroundPrx background = allTests(communicator); + background->shutdown(); + return EXIT_SUCCESS; +} + +int +main(int argc, char* argv[]) +{ + int status; + Ice::CommunicatorPtr communicator; + + try + { + Ice::InitializationData initData; + initData.properties = Ice::createProperties(argc, argv); + + // + // For this test, we want to disable retries. + // + initData.properties->setProperty("Ice.RetryIntervals", "-1"); + + // + // This test kills connections, so we don't want warnings. + // + initData.properties->setProperty("Ice.Warn.Connections", "0"); + + // + // Setup the test transport plugin. + // + initData.properties->setProperty("Ice.Plugin.Test", "TestTransport:createTestTransport"); + string defaultProtocol = initData.properties->getPropertyWithDefault("Ice.Default.Protocol", "tcp"); + initData.properties->setProperty("Ice.Default.Protocol", "test-" + defaultProtocol); + + 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/background/Configuration.cpp b/cpp/test/Ice/background/Configuration.cpp new file mode 100644 index 00000000000..d2f7e82a1c1 --- /dev/null +++ b/cpp/test/Ice/background/Configuration.cpp @@ -0,0 +1,182 @@ +// ********************************************************************** +// +// 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 <Configuration.h> + +Configuration* Configuration::_instance = 0; + +Configuration::Configuration() : + _initializeSocketStatus(IceInternal::Finished), + _initializeResetCount(0), + _readReadyCount(0), + _writeReadyCount(0) +{ + assert(!_instance); + _instance = this; +} + +Configuration::~Configuration() +{ + _instance = 0; +} + +void +Configuration::connectorsException(Ice::LocalException* ex) +{ + Lock sync(*this); + _connectorsException.reset(ex); +} + +void +Configuration::checkConnectorsException() +{ + Lock sync(*this); + if(_connectorsException.get()) + { + _connectorsException->ice_throw(); + } +} + +void +Configuration::connectException(Ice::LocalException* ex) +{ + Lock sync(*this); + _connectException.reset(ex); +} + +void +Configuration::checkConnectException() +{ + Lock sync(*this); + if(_connectException.get()) + { + _connectException->ice_throw(); + } +} + +void +Configuration::initializeSocketStatus(IceInternal::SocketStatus status) +{ + Lock sync(*this); + if(status == IceInternal::Finished) + { + _initializeResetCount = 0; + return; + } + _initializeResetCount = 10; + _initializeSocketStatus = status; +} + +void +Configuration::initializeException(Ice::LocalException* ex) +{ + Lock sync(*this); + _initializeException.reset(ex); +} + +IceInternal::SocketStatus +Configuration::initializeSocketStatus() +{ + Lock sync(*this); + if(_initializeResetCount == 0) + { + return IceInternal::Finished; + } + --_initializeResetCount; + return _initializeSocketStatus; +} + +void +Configuration::checkInitializeException() +{ + Lock sync(*this); + if(_initializeException.get()) + { + _initializeException->ice_throw(); + } +} + +void +Configuration::readReady(bool ready) +{ + Lock sync(*this); + _readReadyCount = ready ? 0 : 10; +} + +void +Configuration::readException(Ice::LocalException* ex) +{ + Lock sync(*this); + _readException.reset(ex); +} + +bool +Configuration::readReady() +{ + Lock sync(*this); + if(_readReadyCount == 0) + { + return true; + } + --_readReadyCount; + return false; +} + +void +Configuration::checkReadException() +{ + Lock sync(*this); + if(_readException.get()) + { + _readException->ice_throw(); + } +} + +void +Configuration::writeReady(bool ready) +{ + Lock sync(*this); + _writeReadyCount = ready ? 0 : 10; +} + +void +Configuration::writeException(Ice::LocalException* ex) +{ + Lock sync(*this); + _writeException.reset(ex); +} + +bool +Configuration::writeReady() +{ + Lock sync(*this); + if(_writeReadyCount == 0) + { + return true; + } + --_writeReadyCount; + return false; +} + +void +Configuration::checkWriteException() +{ + Lock sync(*this); + if(_writeException.get()) + { + _writeException->ice_throw(); + } +} + +Configuration* +Configuration::getInstance() +{ + return _instance; +} + diff --git a/cpp/test/Ice/background/Configuration.h b/cpp/test/Ice/background/Configuration.h new file mode 100644 index 00000000000..3277bd8d5f8 --- /dev/null +++ b/cpp/test/Ice/background/Configuration.h @@ -0,0 +1,67 @@ +// ********************************************************************** +// +// 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_CONFIGURATION_H +#define TEST_CONFIGURATION_H + +#include <IceUtil/Shared.h> +#include <IceUtil/Handle.h> + +#include <Ice/LocalException.h> +#include <Ice/Selector.h> + +class Configuration; +typedef IceUtil::Handle<Configuration> ConfigurationPtr; + +class Configuration : public IceUtil::Shared, public IceUtil::Mutex +{ +public: + + Configuration(); + virtual ~Configuration(); + + virtual void connectorsException(Ice::LocalException*); + virtual void checkConnectorsException(); + + virtual void connectException(Ice::LocalException*); + virtual void checkConnectException(); + + virtual void initializeSocketStatus(IceInternal::SocketStatus); + virtual void initializeException(Ice::LocalException*); + virtual IceInternal::SocketStatus initializeSocketStatus(); + virtual void checkInitializeException(); + + virtual void readReady(bool); + virtual void readException(Ice::LocalException*); + virtual bool readReady(); + virtual void checkReadException(); + + virtual void writeReady(bool); + virtual void writeException(Ice::LocalException*); + virtual bool writeReady(); + virtual void checkWriteException(); + + static Configuration* getInstance(); + +private: + + std::auto_ptr<Ice::LocalException> _connectorsException; + std::auto_ptr<Ice::LocalException> _connectException; + IceInternal::SocketStatus _initializeSocketStatus; + int _initializeResetCount; + std::auto_ptr<Ice::LocalException> _initializeException; + int _readReadyCount; + std::auto_ptr<Ice::LocalException> _readException; + int _writeReadyCount; + std::auto_ptr<Ice::LocalException> _writeException; + + static Configuration* _instance; +}; + +#endif diff --git a/cpp/test/Ice/background/Connector.cpp b/cpp/test/Ice/background/Connector.cpp new file mode 100644 index 00000000000..9e75d4672c3 --- /dev/null +++ b/cpp/test/Ice/background/Connector.cpp @@ -0,0 +1,69 @@ +// ********************************************************************** +// +// 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 <Connector.h> +#include <Transceiver.h> +#include <EndpointI.h> + +using namespace std; + +IceInternal::TransceiverPtr +Connector::connect(int timeout) +{ + _configuration->checkConnectException(); + return new Transceiver(_connector->connect(timeout)); +} + +Ice::Short +Connector::type() const +{ + return (Ice::Short)(EndpointI::TYPE_BASE + _connector->type()); +} + +string +Connector::toString() const +{ + return _connector->toString(); +} + +bool +Connector::operator==(const IceInternal::Connector& r) const +{ + const Connector* p = dynamic_cast<const Connector*>(&r); + if(!p) + { + return false; + } + + return *_connector == *p->_connector; +} + +bool +Connector::operator!=(const IceInternal::Connector& r) const +{ + return !operator==(r); +} + +bool +Connector::operator<(const IceInternal::Connector& r) const +{ + const Connector* p = dynamic_cast<const Connector*>(&r); + if(!p) + { + return type() < r.type(); + } + + return *_connector < *p->_connector; +} + +Connector::Connector(const IceInternal::ConnectorPtr& connector) : + _connector(connector), + _configuration(Configuration::getInstance()) +{ +} diff --git a/cpp/test/Ice/background/Connector.h b/cpp/test/Ice/background/Connector.h new file mode 100644 index 00000000000..d8ffb10ea9a --- /dev/null +++ b/cpp/test/Ice/background/Connector.h @@ -0,0 +1,38 @@ +// ********************************************************************** +// +// 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_CONNECTOR_H +#define TEST_CONNECTOR_H + +#include <Ice/Connector.h> +#include <Configuration.h> + +class Connector : public IceInternal::Connector +{ +public: + + IceInternal::TransceiverPtr connect(int); + + Ice::Short type() const; + std::string toString() const; + + virtual bool operator==(const IceInternal::Connector&) const; + virtual bool operator!=(const IceInternal::Connector&) const; + virtual bool operator<(const IceInternal::Connector&) const; + +private: + + Connector(const IceInternal::ConnectorPtr& connector); + friend class EndpointI; + + const IceInternal::ConnectorPtr _connector; + const ConfigurationPtr _configuration; +}; + +#endif diff --git a/cpp/test/Ice/background/EndpointFactory.cpp b/cpp/test/Ice/background/EndpointFactory.cpp new file mode 100644 index 00000000000..70af767492a --- /dev/null +++ b/cpp/test/Ice/background/EndpointFactory.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/Instance.h> +#include <Ice/EndpointFactoryManager.h> + +#include <EndpointFactory.h> +#include <EndpointI.h> + +using namespace std; + +EndpointFactory::EndpointFactory(const IceInternal::EndpointFactoryPtr& factory) : + _factory(factory) +{ +} + +Ice::Short +EndpointFactory::type() const +{ + return (Ice::Short)(EndpointI::TYPE_BASE + _factory->type()); +} + +string +EndpointFactory::protocol() const +{ + return "test-" + _factory->protocol(); +} + +IceInternal::EndpointIPtr +EndpointFactory::create(const string& str, bool server) const +{ + return new EndpointI(_factory->create(str, server)); +} + +IceInternal::EndpointIPtr +EndpointFactory::read(IceInternal::BasicStream* s) const +{ + short type; + s->read(type); + assert(type == _factory->type()); + return new EndpointI(_factory->read(s)); +} + +void +EndpointFactory::destroy() +{ +} diff --git a/cpp/test/Ice/background/EndpointFactory.h b/cpp/test/Ice/background/EndpointFactory.h new file mode 100644 index 00000000000..b3a817b238c --- /dev/null +++ b/cpp/test/Ice/background/EndpointFactory.h @@ -0,0 +1,35 @@ +// ********************************************************************** +// +// 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_ENDPOINT_FACTORY_H +#define TEST_ENDPOINT_FACTORY_H + +#include <Ice/EndpointFactory.h> + +class EndpointFactory : public IceInternal::EndpointFactory +{ +public: + + virtual ~EndpointFactory() { } + + virtual ::Ice::Short type() const; + virtual ::std::string protocol() const; + virtual IceInternal::EndpointIPtr create(const std::string&, bool) const; + virtual IceInternal::EndpointIPtr read(IceInternal::BasicStream*) const; + virtual void destroy(); + +protected: + + EndpointFactory(const IceInternal::EndpointFactoryPtr&); + friend class TestPluginI; + + IceInternal::EndpointFactoryPtr _factory; +}; + +#endif diff --git a/cpp/test/Ice/background/EndpointI.cpp b/cpp/test/Ice/background/EndpointI.cpp new file mode 100644 index 00000000000..ab83f97b08e --- /dev/null +++ b/cpp/test/Ice/background/EndpointI.cpp @@ -0,0 +1,266 @@ +// ********************************************************************** +// +// 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 <EndpointI.h> +#include <Transceiver.h> +#include <Connector.h> +#include <Acceptor.h> +#include <Ice/BasicStream.h> + +using namespace std; + +Ice::Short EndpointI::TYPE_BASE = 100; + +EndpointI::EndpointI(const IceInternal::EndpointIPtr& endpoint) : + _endpoint(endpoint), + _configuration(Configuration::getInstance()) +{ +} + +void +EndpointI::streamWrite(IceInternal::BasicStream* s) const +{ + s->write(type()); + _endpoint->streamWrite(s); +} + +Ice::Short +EndpointI::type() const +{ + return (Ice::Short)(TYPE_BASE + _endpoint->type()); +} + +int +EndpointI::timeout() const +{ + return _endpoint->timeout(); +} + +IceInternal::EndpointIPtr +EndpointI::timeout(int timeout) const +{ + IceInternal::EndpointIPtr endpoint = _endpoint->timeout(timeout); + if(endpoint == _endpoint) + { + return const_cast<EndpointI*>(this); + } + else + { + return new EndpointI(endpoint); + } +} + +IceInternal::EndpointIPtr +EndpointI::connectionId(const string& connectionId) const +{ + IceInternal::EndpointIPtr endpoint = _endpoint->connectionId(connectionId); + if(endpoint == _endpoint) + { + return const_cast<EndpointI*>(this); + } + else + { + return new EndpointI(endpoint); + } +} + +bool +EndpointI::compress() const +{ + return _endpoint->compress(); +} + +IceInternal::EndpointIPtr +EndpointI::compress(bool compress) const +{ + IceInternal::EndpointIPtr endpoint = _endpoint->compress(compress); + if(endpoint == _endpoint) + { + return const_cast<EndpointI*>(this); + } + else + { + return new EndpointI(endpoint); + } +} + +bool +EndpointI::datagram() const +{ + return _endpoint->datagram(); +} + +bool +EndpointI::secure() const +{ + return _endpoint->secure(); +} + +bool +EndpointI::unknown() const +{ + return _endpoint->unknown(); +} + +IceInternal::TransceiverPtr +EndpointI::transceiver(IceInternal::EndpointIPtr& endpoint) const +{ + IceInternal::EndpointIPtr endpt = _endpoint; + IceInternal::TransceiverPtr transceiver = _endpoint->transceiver(endpt); + if(endpt == _endpoint) + { + endpoint = const_cast<EndpointI*>(this); + } + else + { + endpoint = new EndpointI(endpoint); + } + + if(transceiver) + { + return new Transceiver(transceiver); + } + else + { + return 0; + } +} + +vector<IceInternal::ConnectorPtr> +EndpointI::connectors() const +{ + _configuration->checkConnectorsException(); + vector<IceInternal::ConnectorPtr> c = _endpoint->connectors(); + for(vector<IceInternal::ConnectorPtr>::iterator p = c.begin(); p != c.end(); ++p) + { + *p = new Connector(*p); + } + return c; +} + +void +EndpointI::connectors_async(const IceInternal::EndpointI_connectorsPtr& cb) const +{ + class Callback : public IceInternal::EndpointI_connectors + { + public: + + Callback(const IceInternal::EndpointI_connectorsPtr& callback) : _callback(callback) + { + } + + void + connectors(const vector<IceInternal::ConnectorPtr>& connectors) + { + vector<IceInternal::ConnectorPtr> c; + for(vector<IceInternal::ConnectorPtr>::const_iterator p = connectors.begin(); p != connectors.end(); ++p) + { + c.push_back(new Connector(*p)); + } + _callback->connectors(c); + } + + void + exception(const Ice::LocalException& ex) + { + _callback->exception(ex); + } + + private: + + IceInternal::EndpointI_connectorsPtr _callback; + }; + + try + { + _configuration->checkConnectorsException(); + _endpoint->connectors_async(new Callback(cb)); + } + catch(const Ice::LocalException& ex) + { + cb->exception(ex); + } +} + +IceInternal::AcceptorPtr +EndpointI::acceptor(IceInternal::EndpointIPtr& endpoint, const string& adapterName) const +{ + IceInternal::AcceptorPtr p = new Acceptor(_endpoint->acceptor(endpoint, adapterName)); + endpoint = new EndpointI(endpoint); + return p; +} + +vector<IceInternal::EndpointIPtr> +EndpointI::expand() const +{ + vector<IceInternal::EndpointIPtr> e = _endpoint->expand(); + for(vector<IceInternal::EndpointIPtr>::iterator p = e.begin(); p != e.end(); ++p) + { + *p = (*p == _endpoint) ? const_cast<EndpointI*>(this) : new EndpointI(*p); + } + return e; +} + +bool +EndpointI::equivalent(const IceInternal::EndpointIPtr& endpoint) const +{ + const EndpointI* testEndpointI = dynamic_cast<const EndpointI*>(endpoint.get()); + if(!testEndpointI) + { + return false; + } + return testEndpointI->_endpoint->equivalent(_endpoint); +} + +string +EndpointI::toString() const +{ + return "test-" + _endpoint->toString(); +} + +bool +EndpointI::operator==(const IceInternal::EndpointI& r) const +{ + const EndpointI* p = dynamic_cast<const EndpointI*>(&r); + if(!p) + { + return false; + } + + if(this == p) + { + return true; + } + + + return *p->_endpoint == *_endpoint; +} + +bool +EndpointI::operator!=(const IceInternal::EndpointI& r) const +{ + return !operator==(r); +} + +bool +EndpointI::operator<(const IceInternal::EndpointI& r) const +{ + const EndpointI* p = dynamic_cast<const EndpointI*>(&r); + if(!p) + { + return type() < r.type(); + } + + if(this == p) + { + return false; + } + + return *p->_endpoint < *_endpoint; +} diff --git a/cpp/test/Ice/background/EndpointI.h b/cpp/test/Ice/background/EndpointI.h new file mode 100644 index 00000000000..71d41c3e095 --- /dev/null +++ b/cpp/test/Ice/background/EndpointI.h @@ -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. +// +// ********************************************************************** + +#ifndef TEST_ENDPOINT_I_H +#define TEST_ENDPOINT_I_H + +#include <Ice/EndpointI.h> +#include <Configuration.h> + +class EndpointI : public IceInternal::EndpointI +{ +public: + + static Ice::Short TYPE_BASE; + + virtual void streamWrite(IceInternal::BasicStream*) const; + virtual Ice::Short type() const; + virtual Ice::Int timeout() const; + virtual IceInternal::EndpointIPtr timeout(Ice::Int) const; + virtual IceInternal::EndpointIPtr connectionId(const ::std::string&) const; + virtual bool compress() const; + virtual IceInternal::EndpointIPtr compress(bool) const; + virtual bool datagram() const; + virtual bool secure() const; + virtual bool unknown() const; + virtual IceInternal::TransceiverPtr transceiver(IceInternal::EndpointIPtr&) const; + virtual std::vector<IceInternal::ConnectorPtr> connectors() const; + virtual void connectors_async(const IceInternal::EndpointI_connectorsPtr&) const; + virtual IceInternal::AcceptorPtr acceptor(IceInternal::EndpointIPtr&, const std::string&) const; + virtual std::vector<IceInternal::EndpointIPtr> expand() const; + virtual bool equivalent(const IceInternal::EndpointIPtr&) const; + + virtual std::string toString() const; + + virtual bool operator==(const IceInternal::EndpointI&) const; + virtual bool operator!=(const IceInternal::EndpointI&) const; + virtual bool operator<(const IceInternal::EndpointI&) const; + +private: + + EndpointI(const IceInternal::EndpointIPtr&); + friend class EndpointFactory; + +#if defined(__SUNPRO_CC) || defined(__HP_aCC) + // + // COMPILERFIX: prevent the compiler from emitting a warning about + // hidding these operators. + // + using LocalObject::operator==; + using LocalObject::operator<; +#endif + + const IceInternal::EndpointIPtr _endpoint; + const ConfigurationPtr _configuration; +}; + +#endif diff --git a/cpp/test/Ice/background/Makefile b/cpp/test/Ice/background/Makefile new file mode 100644 index 00000000000..e8626b27943 --- /dev/null +++ b/cpp/test/Ice/background/Makefile @@ -0,0 +1,70 @@ +# ********************************************************************** +# +# 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 + +TSPFILENAME = $(call mklibfilename,TestTransport,$(VERSION)) +TSPSONAME = $(call mksoname,TestTransport,$(SOVERSION)) +TSPLIBNAME = $(call mklibname,TestTransport) + +TARGETS = $(CLIENT) $(SERVER) $(call mklibtargets,$(TSPFILENAME),$(TSPSONAME),$(TSPLIBNAME)) + +COBJS = Configuration.o \ + Test.o \ + Client.o \ + AllTests.o + +SOBJS = Configuration.o \ + Test.o \ + TestI.o \ + Server.o + +TRANSPORT_OBJS = Configuration.o \ + Connector.o \ + Acceptor.o \ + EndpointI.o \ + Transceiver.o \ + EndpointFactory.o \ + PluginI.o + +SRCS = $(TRANSPORT_OBJS:.o=.cpp) \ + $(COBJS:.o=.cpp) \ + $(SOBJS:.o=.cpp) + +SLICE_SRCS = Test.ice + +include $(top_srcdir)/config/Make.rules + +CPPFLAGS := -I. -I../../include -I../../../src $(CPPFLAGS) +LINKWITH := $(BZIP2_RPATH_LINK) -lIce -lIceUtil + +$(CLIENT): $(COBJS) + rm -f $@ + $(CXX) $(LDFLAGS) -o $@ $(COBJS) $(LIBS) + +$(SERVER): $(SOBJS) + rm -f $@ + $(CXX) $(LDFLAGS) -o $@ $(SOBJS) $(LIBS) + +$(TSPFILENAME): $(TRANSPORT_OBJS) + rm -f $@ + $(call mkshlib,$@,$(TSPSONAME),$(OBJS) $(TRANSPORT_OBJS),$(LINKWITH)) + +$(TSPSONAME): $(TSPFILENAME) + rm -f $@ + ln -s $(TSPFILENAME) $@ + +$(TSPLIBNAME): $(TSPSONAME) + rm -f $@ + ln -s $(TSPSONAME) $@ + +include .depend diff --git a/cpp/test/Ice/background/Makefile.mak b/cpp/test/Ice/background/Makefile.mak new file mode 100644 index 00000000000..53066a048dd --- /dev/null +++ b/cpp/test/Ice/background/Makefile.mak @@ -0,0 +1,73 @@ +# ********************************************************************** +# +# 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 +LIBNAME = testtransport$(LIBSUFFIX).lib +DLLNAME = testtransport$(SOVERSION)$(LIBSUFFIX).dll + +TARGETS = $(CLIENT) $(SERVER) $(LIBNAME) $(DLLNAME) + +COBJS = Configuration.obj \ + Test.obj \ + Client.obj \ + AllTests.obj + +SOBJS = Configuration.obj \ + Test.obj \ + TestI.obj \ + Server.obj + +TRANSPORT_OBJS = Configuration.obj \ + Connector.obj \ + Acceptor.obj \ + EndpointI.obj \ + Transceiver.obj \ + EndpointFactory.obj \ + PluginI.obj + +SRCS = $(TRANSPORT_OBJS:.obj=.cpp) \ + $(COBJS:.obj=.cpp) \ + $(SOBJS:.obj=.cpp) + +!include $(top_srcdir)/config/Make.rules.mak + +CPPFLAGS = -I. -I../../include -I../../../src $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN +LINKWITH = $(LIBS) + +!if "$(CPP_COMPILER)" != "BCC2006" && "$(OPTIMIZE)" != "yes" +TPDBFLAGS = /pdb:$(DLLNAME:.dll=.pdb) +CPDBFLAGS = /pdb:$(CLIENT:.exe=.pdb) +SPDBFLAGS = /pdb:$(SERVER:.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 + +$(LIBNAME) : $(DLLNAME) + +$(DLLNAME): $(OBJS) $(TRANSPORT_OBJS) + $(LINK) $(LD_DLLFLAGS) $(TPDBFLAGS) $(SETARGV) $(OBJS) $(TRANSPORT_OBJS) $(PREOUT)$(DLLNAME) $(PRELIBS)$(LINKWITH) + @if exist $@.manifest echo ^ ^ ^ Embedding manifest using $(MT) && \ + $(MT) -nologo -manifest $@.manifest -outputresource:$@;#2 && del /q $@.manifest + @if exist $(DLLNAME:.dll=.exp) del /q $(DLLNAME:.dll=.exp) + +clean:: + del /q Test.cpp Test.h + +!include .depend diff --git a/cpp/test/Ice/background/PluginI.cpp b/cpp/test/Ice/background/PluginI.cpp new file mode 100644 index 00000000000..a00c0208482 --- /dev/null +++ b/cpp/test/Ice/background/PluginI.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/Initialize.h> +#include <Ice/Instance.h> +#include <Ice/ProtocolPluginFacade.h> +#include <Ice/EndpointFactoryManager.h> + +#include <PluginI.h> +#include <EndpointFactory.h> + +#ifndef TEST_TRANSPORT_API +# define TEST_TRANSPORT_API ICE_DECLSPEC_EXPORT +#endif + +using namespace std; + +class TestPluginI : public PluginI +{ +public: + + TestPluginI(const Ice::CommunicatorPtr&); + + virtual void initialize(); + virtual void destroy(); + + virtual ConfigurationPtr getConfiguration(); + +private: + + const Ice::CommunicatorPtr _communicator; + const ConfigurationPtr _configuration; +}; + + +// +// Plugin factory function. +// +extern "C" +{ + +TEST_TRANSPORT_API Ice::Plugin* +createTestTransport(const Ice::CommunicatorPtr& communicator, const string& name, const Ice::StringSeq& args) +{ + return new TestPluginI(communicator); +} + +} + +TestPluginI::TestPluginI(const Ice::CommunicatorPtr& communicator) : + _communicator(communicator), + _configuration(new Configuration()) +{ +} + +void +TestPluginI::initialize() +{ + IceInternal::ProtocolPluginFacadePtr facade = IceInternal::getProtocolPluginFacade(_communicator); + + for(Ice::Short s = 0; s < 100; ++s) + { + IceInternal::EndpointFactoryPtr factory = facade->getEndpointFactory(s); + if(factory) + { + facade->addEndpointFactory(new EndpointFactory(factory)); + } + } +} + +void +TestPluginI::destroy() +{ +} + +ConfigurationPtr +TestPluginI::getConfiguration() +{ + return _configuration; +} diff --git a/cpp/test/Ice/background/PluginI.h b/cpp/test/Ice/background/PluginI.h new file mode 100644 index 00000000000..fffc0f16d1e --- /dev/null +++ b/cpp/test/Ice/background/PluginI.h @@ -0,0 +1,23 @@ +// ********************************************************************** +// +// 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_PLUGIN_H +#define TEST_PLUGIN_H + +#include <Ice/Plugin.h> +#include <Configuration.h> + +class PluginI : public Ice::Plugin +{ +public: + + virtual ConfigurationPtr getConfiguration() = 0; +}; + +#endif diff --git a/cpp/test/Ice/background/Server.cpp b/cpp/test/Ice/background/Server.cpp new file mode 100644 index 00000000000..45358ed96c7 --- /dev/null +++ b/cpp/test/Ice/background/Server.cpp @@ -0,0 +1,171 @@ +// ********************************************************************** +// +// 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 <IceUtil/DisableWarnings.h> +#include <Ice/Ice.h> +#include <TestI.h> +#include <Configuration.h> +#include <PluginI.h> + +#include <Ice/Locator.h> +#include <Ice/Router.h> + +using namespace std; + +class LocatorI : public Ice::Locator +{ +public: + + virtual void + findAdapterById_async(const Ice::AMD_Locator_findAdapterByIdPtr& response, const string& adapter, + const Ice::Current& current) const + { + _controller->checkCallPause(current); + Ice::CommunicatorPtr communicator = current.adapter->getCommunicator(); + response->ice_response(current.adapter->createDirectProxy(communicator->stringToIdentity("dummy"))); + } + + virtual void + findObjectById_async(const Ice::AMD_Locator_findObjectByIdPtr& response, const Ice::Identity& id, + const Ice::Current& current) const + { + _controller->checkCallPause(current); + Ice::CommunicatorPtr communicator = current.adapter->getCommunicator(); + response->ice_response(current.adapter->createDirectProxy(id)); + } + + virtual Ice::LocatorRegistryPrx + getRegistry(const Ice::Current&) const + { + return 0; + } + + LocatorI(const BackgroundControllerIPtr& controller) : _controller(controller) + { + } + +private: + + BackgroundControllerIPtr _controller; +}; + +class RouterI : public Ice::Router +{ +public: + + virtual Ice::ObjectPrx + getClientProxy(const Ice::Current& current) const + { + _controller->checkCallPause(current); + return 0; + } + + virtual Ice::ObjectPrx + getServerProxy(const Ice::Current& current) const + { + _controller->checkCallPause(current); + return 0; + } + + virtual void + addProxy(const Ice::ObjectPrx&, const Ice::Current&) + { + } + + virtual Ice::ObjectProxySeq + addProxies(const Ice::ObjectProxySeq&, const Ice::Current&) + { + return Ice::ObjectProxySeq(); + } + + RouterI(const BackgroundControllerIPtr& controller) + { + _controller = controller; + } + +private: + + BackgroundControllerIPtr _controller; +}; + + +int +run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) +{ + communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010 -t 10000"); + communicator->getProperties()->setProperty("ControllerAdapter.Endpoints", "tcp -p 12011"); + communicator->getProperties()->setProperty("ControllerAdapter.ThreadPool.Size", "1"); + + Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); + Ice::ObjectAdapterPtr adapter2 = communicator->createObjectAdapter("ControllerAdapter"); + + PluginI* plugin = dynamic_cast<PluginI*>(communicator->getPluginManager()->getPlugin("Test").get()); + assert(plugin); + ConfigurationPtr configuration = plugin->getConfiguration(); + BackgroundControllerIPtr backgroundController = new BackgroundControllerI(adapter, configuration); + + adapter->add(new BackgroundI(backgroundController), communicator->stringToIdentity("background")); + adapter->add(new LocatorI(backgroundController), communicator->stringToIdentity("locator")); + adapter->add(new RouterI(backgroundController), communicator->stringToIdentity("router")); + adapter->activate(); + + adapter2->add(backgroundController, communicator->stringToIdentity("backgroundController")); + adapter2->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); + + // + // This test kills connections, so we don't want warnings. + // + initData.properties->setProperty("Ice.Warn.Connections", "0"); + + // + // Setup the test transport plugin. + // + initData.properties->setProperty("Ice.Plugin.Test", "TestTransport:createTestTransport"); + string defaultProtocol = initData.properties->getPropertyWithDefault("Ice.Default.Protocol", "tcp"); + initData.properties->setProperty("Ice.Default.Protocol", "test-" + defaultProtocol); + + 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/background/Test.ice b/cpp/test/Ice/background/Test.ice new file mode 100644 index 00000000000..f85b9ac0065 --- /dev/null +++ b/cpp/test/Ice/background/Test.ice @@ -0,0 +1,46 @@ +// ********************************************************************** +// +// 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/BuiltinSequences.ice> + +module Test +{ + +interface Background +{ + ["ami"] void op(); + ["ami"] void opWithPayload(Ice::ByteSeq seq); + + void shutdown(); +}; + +interface BackgroundController +{ + void pauseCall(string call); + void resumeCall(string call); + + void holdAdapter(); + void resumeAdapter(); + + void initializeSocketStatus(int status); + void initializeException(bool enable); + + void readReady(bool enable); + void readException(bool enable); + + void writeReady(bool enable); + void writeException(bool enable); +}; + +}; + +#endif diff --git a/cpp/test/Ice/background/TestI.cpp b/cpp/test/Ice/background/TestI.cpp new file mode 100644 index 00000000000..4883931db1b --- /dev/null +++ b/cpp/test/Ice/background/TestI.cpp @@ -0,0 +1,117 @@ +// ********************************************************************** +// +// 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 <TestI.h> +#include <Ice/Ice.h> + +using namespace std; +using namespace Ice; + +void +BackgroundI::op(const Ice::Current& current) +{ + _controller->checkCallPause(current); +} + +void +BackgroundI::opWithPayload(const Ice::ByteSeq&, const Ice::Current& current) +{ + _controller->checkCallPause(current); +} + +void +BackgroundI::shutdown(const Ice::Current& current) +{ + current.adapter->getCommunicator()->shutdown(); +} + +BackgroundI::BackgroundI(const BackgroundControllerIPtr& controller) : + _controller(controller) +{ +} + +void +BackgroundControllerI::pauseCall(const string& opName, const Ice::Current&) +{ + Lock sync(*this); + _pausedCalls.insert(opName); +} + +void +BackgroundControllerI::resumeCall(const string& opName, const Ice::Current&) +{ + Lock sync(*this); + _pausedCalls.erase(opName); + notifyAll(); +} + +void +BackgroundControllerI::checkCallPause(const Ice::Current& current) +{ + Lock sync(*this); + while(_pausedCalls.find(current.operation) != _pausedCalls.end()) + { + wait(); + } +} + +void +BackgroundControllerI::holdAdapter(const Ice::Current&) +{ + _adapter->hold(); +} + +void +BackgroundControllerI::resumeAdapter(const Ice::Current&) +{ + _adapter->activate(); +} + +void +BackgroundControllerI::initializeSocketStatus(int status, const Ice::Current&) +{ + _configuration->initializeSocketStatus(static_cast<IceInternal::SocketStatus>(status)); +} + +void +BackgroundControllerI::initializeException(bool enable, const Ice::Current&) +{ + _configuration->initializeException(enable ? new Ice::SocketException(__FILE__, __LINE__) : 0); +} + +void +BackgroundControllerI::readReady(bool enable, const Ice::Current&) +{ + _configuration->readReady(enable); +} + +void +BackgroundControllerI::readException(bool enable, const Ice::Current&) +{ + _configuration->readException(enable ? new Ice::SocketException(__FILE__, __LINE__) : 0); +} + +void +BackgroundControllerI::writeReady(bool enable, const Ice::Current&) +{ + _configuration->writeReady(enable); +} + +void +BackgroundControllerI::writeException(bool enable, const Ice::Current&) +{ + _configuration->writeException(enable ? new Ice::SocketException(__FILE__, __LINE__) : 0); +} + +BackgroundControllerI::BackgroundControllerI(const Ice::ObjectAdapterPtr& adapter, + const ConfigurationPtr& configuration) : + _adapter(adapter), + _configuration(configuration) +{ +} diff --git a/cpp/test/Ice/background/TestI.h b/cpp/test/Ice/background/TestI.h new file mode 100644 index 00000000000..2acedc0489c --- /dev/null +++ b/cpp/test/Ice/background/TestI.h @@ -0,0 +1,66 @@ +// ********************************************************************** +// +// 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> +#include <Configuration.h> + +#include <set> + +class BackgroundControllerI; +typedef IceUtil::Handle<BackgroundControllerI> BackgroundControllerIPtr; + +class BackgroundI : virtual public Test::Background +{ +public: + + virtual void op(const Ice::Current&); + virtual void opWithPayload(const Ice::ByteSeq&, const Ice::Current&); + virtual void shutdown(const Ice::Current&); + + BackgroundI(const BackgroundControllerIPtr&); + +private: + + BackgroundControllerIPtr _controller; +}; + +class BackgroundControllerI : public Test::BackgroundController, IceUtil::Monitor<IceUtil::Mutex> +{ +public: + + + virtual void pauseCall(const std::string&, const Ice::Current&); + virtual void resumeCall(const std::string&, const Ice::Current&); + virtual void checkCallPause(const Ice::Current&); + + virtual void holdAdapter(const Ice::Current&); + virtual void resumeAdapter(const Ice::Current&); + + virtual void initializeSocketStatus(int, const Ice::Current&); + virtual void initializeException(bool, const Ice::Current&); + + virtual void readReady(bool, const Ice::Current&); + virtual void readException(bool, const Ice::Current&); + + virtual void writeReady(bool, const Ice::Current&); + virtual void writeException(bool, const Ice::Current&); + + BackgroundControllerI(const Ice::ObjectAdapterPtr&, const ConfigurationPtr&); + +private: + + Ice::ObjectAdapterPtr _adapter; + std::set<std::string> _pausedCalls; + ConfigurationPtr _configuration; +}; + +#endif diff --git a/cpp/test/Ice/background/Transceiver.cpp b/cpp/test/Ice/background/Transceiver.cpp new file mode 100644 index 00000000000..ddee56e5d23 --- /dev/null +++ b/cpp/test/Ice/background/Transceiver.cpp @@ -0,0 +1,143 @@ +// ********************************************************************** +// +// 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 <Transceiver.h> + +using namespace std; + +SOCKET +Transceiver::fd() +{ + return _transceiver->fd(); +} + +IceInternal::SocketStatus +Transceiver::initialize(int timeout) +{ + if(timeout == 0) + { + IceInternal::SocketStatus status = _configuration->initializeSocketStatus(); + if(status == IceInternal::NeedConnect) + { + return status; + } + else if(status == IceInternal::NeedWrite) + { + if(!_initialized) + { + status = _transceiver->initialize(timeout); + if(status != IceInternal::Finished) + { + return status; + } + _initialized = true; + } + return IceInternal::NeedWrite; + } + else if(status == IceInternal::NeedRead) + { + return status; + } + } + _configuration->checkInitializeException(); + if(!_initialized) + { + IceInternal::SocketStatus status = _transceiver->initialize(timeout); + if(status != IceInternal::Finished) + { + return status; + } + _initialized = true; + } + return IceInternal::Finished; +} + +void +Transceiver::close() +{ + _transceiver->close(); +} + +void +Transceiver::shutdownWrite() +{ + _transceiver->shutdownWrite(); +} + +void +Transceiver::shutdownReadWrite() +{ + _transceiver->shutdownReadWrite(); +} + +bool +Transceiver::write(IceInternal::Buffer& buf, int timeout) +{ + if(!_initialized) + { + throw Ice::SocketException(__FILE__, __LINE__); + } + + if(timeout == 0) + { + if(!_configuration->writeReady()) + { + return false; + } + } + _configuration->checkWriteException(); + return _transceiver->write(buf, timeout); +} + +bool +Transceiver::read(IceInternal::Buffer& buf, int timeout) +{ + if(!_initialized) + { + throw Ice::SocketException(__FILE__, __LINE__); + } + + if(timeout == 0) + { + if(!_configuration->readReady()) + { + return false; + } + } + _configuration->checkReadException(); + return _transceiver->read(buf, timeout); +} + +string +Transceiver::type() const +{ + return "test-" + _transceiver->type(); +} + +string +Transceiver::toString() const +{ + return _transceiver->toString(); +} + +void +Transceiver::checkSendSize(const IceInternal::Buffer& buf, size_t messageSizeMax) +{ + _transceiver->checkSendSize(buf, messageSizeMax); +} + +// +// Only for use by Connector, Acceptor +// +Transceiver::Transceiver(const IceInternal::TransceiverPtr& transceiver) : + _transceiver(transceiver), + _configuration(Configuration::getInstance()), + _initialized(false) +{ +} diff --git a/cpp/test/Ice/background/Transceiver.h b/cpp/test/Ice/background/Transceiver.h new file mode 100644 index 00000000000..1872f86bfc1 --- /dev/null +++ b/cpp/test/Ice/background/Transceiver.h @@ -0,0 +1,43 @@ +// ********************************************************************** +// +// 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_TRANSCEIVER_H +#define TEST_TRANSCEIVER_H + +#include <Ice/Transceiver.h> +#include <Configuration.h> + +class Transceiver : public IceInternal::Transceiver +{ +public: + + virtual SOCKET fd(); + virtual void close(); + virtual void shutdownWrite(); + virtual void shutdownReadWrite(); + virtual bool write(IceInternal::Buffer&, int); + virtual bool read(IceInternal::Buffer&, int); + virtual std::string type() const; + virtual std::string toString() const; + virtual IceInternal::SocketStatus initialize(int); + virtual void checkSendSize(const IceInternal::Buffer&, size_t); + +private: + + Transceiver(const IceInternal::TransceiverPtr&); + friend class Connector; + friend class Acceptor; + friend class EndpointI; + + const IceInternal::TransceiverPtr _transceiver; + const ConfigurationPtr _configuration; + bool _initialized; +}; + +#endif diff --git a/cpp/test/Ice/background/run.py b/cpp/test/Ice/background/run.py new file mode 100755 index 00000000000..598f980ea26 --- /dev/null +++ b/cpp/test/Ice/background/run.py @@ -0,0 +1,29 @@ +#!/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", "background") +testdir = os.path.join(toplevel, "test", name) + +TestUtil.addLdPath(testdir) + +TestUtil.clientServerTest(name) +sys.exit(0) diff --git a/cpp/test/Ice/operations/AllTests.cpp b/cpp/test/Ice/operations/AllTests.cpp index 799560a8d5d..1c89beb032e 100644 --- a/cpp/test/Ice/operations/AllTests.cpp +++ b/cpp/test/Ice/operations/AllTests.cpp @@ -29,6 +29,11 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) derived->opDerived(); cout << "ok" << endl; + cout << "testing oneway operations... " << flush; + void oneways(const Ice::CommunicatorPtr&, const Test::MyClassPrx&); + oneways(communicator, cl); + cout << "ok" << endl; + if(!collocated) { cout << "testing twoway operations with AMI... " << flush; @@ -37,6 +42,11 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) twowaysAMI(communicator, derived); cout << "ok" << endl; + cout << "testing oneway operations with AMI... " << flush; + void onewaysAMI(const Ice::CommunicatorPtr&, const Test::MyClassPrx&); + onewaysAMI(communicator, cl); + cout << "ok" << endl; + cout << "testing batch oneway operations... " << flush; void batchOneways(const Test::MyClassPrx&); batchOneways(cl); diff --git a/cpp/test/Ice/operations/BatchOneways.cpp b/cpp/test/Ice/operations/BatchOneways.cpp index f5242c3dee4..f315b0c065d 100644 --- a/cpp/test/Ice/operations/BatchOneways.cpp +++ b/cpp/test/Ice/operations/BatchOneways.cpp @@ -19,7 +19,6 @@ batchOneways(const Test::MyClassPrx& p) const Test::ByteS bs1(10 * 1024); const Test::ByteS bs2(99 * 1024); const Test::ByteS bs3(100 * 1024); - try { p->opByteSOneway(bs1); diff --git a/cpp/test/Ice/operations/Makefile b/cpp/test/Ice/operations/Makefile index 9f6fcb227ba..7b435d3989a 100644 --- a/cpp/test/Ice/operations/Makefile +++ b/cpp/test/Ice/operations/Makefile @@ -20,7 +20,9 @@ COBJS = Test.o \ Client.o \ AllTests.o \ Twoways.o \ + Oneways.o \ TwowaysAMI.o \ + OnewaysAMI.o \ BatchOneways.o SOBJS = Test.o \ @@ -36,7 +38,9 @@ COLOBJS = Test.o \ Collocated.o \ AllTests.o \ Twoways.o \ + Oneways.o \ TwowaysAMI.o \ + OnewaysAMI.o \ BatchOneways.o SRCS = $(COBJS:.o=.cpp) \ diff --git a/cpp/test/Ice/operations/Makefile.mak b/cpp/test/Ice/operations/Makefile.mak index f646d70ae33..ca773b8661a 100644 --- a/cpp/test/Ice/operations/Makefile.mak +++ b/cpp/test/Ice/operations/Makefile.mak @@ -20,7 +20,9 @@ COBJS = Test.obj \ Client.obj \ AllTests.obj \ Twoways.obj \ + Oneways.obj \ TwowaysAMI.obj \ + OnewaysAMI.obj \ BatchOneways.obj SOBJS = Test.obj \ @@ -36,7 +38,9 @@ COLOBJS = Test.obj \ Collocated.obj \ AllTests.obj \ Twoways.obj \ + Oneways.obj \ TwowaysAMI.obj \ + OnewaysAMI.obj \ BatchOneways.obj SRCS = $(COBJS:.obj=.cpp) \ diff --git a/cpp/test/Ice/operations/Oneways.cpp b/cpp/test/Ice/operations/Oneways.cpp new file mode 100644 index 00000000000..fcf890b0e50 --- /dev/null +++ b/cpp/test/Ice/operations/Oneways.cpp @@ -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. +// +// ********************************************************************** + +#include <Ice/Ice.h> +#include <TestCommon.h> +#include <Test.h> + +using namespace std; + +void +oneways(const Ice::CommunicatorPtr& communicator, const Test::MyClassPrx& proxy) +{ + Test::MyClassPrx p = Test::MyClassPrx::uncheckedCast(proxy->ice_oneway()); + + { + p->opVoid(); + } + + { + Ice::Byte b; + Ice::Byte r; + + try + { + r = p->opByte(Ice::Byte(0xff), Ice::Byte(0x0f), b); + test(false); + } + catch(const Ice::TwowayOnlyException&) + { + } + } + +} diff --git a/cpp/test/Ice/operations/OnewaysAMI.cpp b/cpp/test/Ice/operations/OnewaysAMI.cpp new file mode 100644 index 00000000000..20a6445b839 --- /dev/null +++ b/cpp/test/Ice/operations/OnewaysAMI.cpp @@ -0,0 +1,145 @@ +// ********************************************************************** +// +// 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> +#include <limits> + +using namespace std; + +class CallbackBase : public IceUtil::Monitor<IceUtil::Mutex> +{ +public: + + CallbackBase() : + _called(false) + { + } + + virtual ~CallbackBase() + { + } + + bool check() + { + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + while(!_called) + { + if(!timedWait(IceUtil::Time::seconds(5))) + { + return false; + } + } + _called = false; + return true; + } + +protected: + + void called() + { + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + assert(!_called); + _called = true; + notify(); + } + +private: + + bool _called; +}; + +class AMI_MyClass_onewayOpVoidI : public Test::AMI_MyClass_opVoid, public CallbackBase +{ +public: + + virtual void ice_response() + { + called(); + } + + virtual void ice_exception(const ::Ice::Exception&) + { + test(false); + } +}; + +typedef IceUtil::Handle<AMI_MyClass_onewayOpVoidI> AMI_MyClass_onewayOpVoidIPtr; + +class AMI_MyClass_onewayOpVoidExI : public Test::AMI_MyClass_opVoid, public CallbackBase +{ +public: + + virtual void ice_response() + { + test(false); + } + + virtual void ice_exception(const ::Ice::Exception& ex) + { + test(dynamic_cast<const ::Ice::NoEndpointException*>(&ex)); + called(); + } +}; + +typedef IceUtil::Handle<AMI_MyClass_onewayOpVoidExI> AMI_MyClass_onewayOpVoidExIPtr; + +class AMI_MyClass_onewayOpByteExI : public Test::AMI_MyClass_opByte, public CallbackBase +{ +public: + + virtual void ice_response(::Ice::Byte r, ::Ice::Byte b) + { + test(false); + } + + virtual void ice_exception(const ::Ice::Exception& ex) + { + test(dynamic_cast<const ::Ice::TwowayOnlyException*>(&ex)); + called(); + } +}; + +typedef IceUtil::Handle<AMI_MyClass_onewayOpByteExI> AMI_MyClass_onewayOpByteExIPtr; + +void +onewaysAMI(const Ice::CommunicatorPtr& communicator, const Test::MyClassPrx& proxy) +{ + Test::MyClassPrx p = Test::MyClassPrx::uncheckedCast(proxy->ice_oneway()); + + { + AMI_MyClass_onewayOpVoidIPtr cb = new AMI_MyClass_onewayOpVoidI(); + p->opVoid_async(cb); + // Let's check if we can reuse the same callback object for another call. + p->opVoid_async(cb); + } + + { + // Check that a call to a void operation raises NoEndpointException + // in the ice_exception() callback instead of at the point of call. + Test::MyClassPrx indirect = Test::MyClassPrx::uncheckedCast(p->ice_adapterId("dummy")); + AMI_MyClass_onewayOpVoidExIPtr cb = new AMI_MyClass_onewayOpVoidExI(); + try + { + indirect->opVoid_async(cb); + } + catch(const Ice::Exception&) + { + test(false); + } + test(cb->check()); + } + + { + AMI_MyClass_onewayOpByteExIPtr cb = new AMI_MyClass_onewayOpByteExI(); + p->opByte_async(cb, 0, 0); + test(cb->check()); + } +} diff --git a/cpp/test/Ice/operations/TestAMDI.cpp b/cpp/test/Ice/operations/TestAMDI.cpp index 0227c30075f..f3baed1e676 100644 --- a/cpp/test/Ice/operations/TestAMDI.cpp +++ b/cpp/test/Ice/operations/TestAMDI.cpp @@ -37,10 +37,13 @@ private: void MyDerivedClassI::shutdown_async(const Test::AMD_MyClass_shutdownPtr& cb, const Ice::Current& current) { - if(_opVoidThread) { - _opVoidThread->getThreadControl().join(); - _opVoidThread = 0; + IceUtil::Mutex::Lock sync(_opVoidMutex); + if(_opVoidThread) + { + _opVoidThread->getThreadControl().join(); + _opVoidThread = 0; + } } current.adapter->getCommunicator()->shutdown(); @@ -50,6 +53,7 @@ MyDerivedClassI::shutdown_async(const Test::AMD_MyClass_shutdownPtr& cb, const I void MyDerivedClassI::opVoid_async(const Test::AMD_MyClass_opVoidPtr& cb, const Ice::Current&) { + IceUtil::Mutex::Lock sync(_opVoidMutex); if(_opVoidThread) { _opVoidThread->getThreadControl().join(); diff --git a/cpp/test/Ice/operations/TestAMDI.h b/cpp/test/Ice/operations/TestAMDI.h index 7931398b7e8..bad7823a570 100644 --- a/cpp/test/Ice/operations/TestAMDI.h +++ b/cpp/test/Ice/operations/TestAMDI.h @@ -135,6 +135,7 @@ public: private: IceUtil::ThreadPtr _opVoidThread; + IceUtil::Mutex _opVoidMutex; }; #endif diff --git a/cpp/test/Ice/operations/TwowaysAMI.cpp b/cpp/test/Ice/operations/TwowaysAMI.cpp index 158f0c6df25..fb81868048f 100644 --- a/cpp/test/Ice/operations/TwowaysAMI.cpp +++ b/cpp/test/Ice/operations/TwowaysAMI.cpp @@ -42,7 +42,7 @@ public: IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); while(!_called) { - if(!timedWait(IceUtil::Time::seconds(5))) + if(!timedWait(IceUtil::Time::seconds(50000))) { return false; } @@ -50,7 +50,7 @@ public: _called = false; return true; } - + protected: void called() @@ -94,7 +94,7 @@ public: virtual void ice_exception(const ::Ice::Exception& ex) { - test(dynamic_cast<const ::Ice::TwowayOnlyException*>(&ex)); + test(dynamic_cast<const ::Ice::NoEndpointException*>(&ex)); called(); } }; @@ -131,7 +131,7 @@ public: virtual void ice_exception(const ::Ice::Exception& ex) { - test(dynamic_cast<const ::Ice::TwowayOnlyException*>(&ex)); + test(dynamic_cast<const ::Ice::NoEndpointException*>(&ex)); called(); } }; @@ -875,12 +875,13 @@ void twowaysAMI(const Ice::CommunicatorPtr& communicator, const Test::MyClassPrx& p) { { - // Check that a call to a void operation raises TwowayOnlyException + // Check that a call to a void operation raises NoEndpointException // in the ice_exception() callback instead of at the point of call. - Test::MyClassPrx oneway = Test::MyClassPrx::uncheckedCast(p->ice_oneway()); + Test::MyClassPrx indirect = Test::MyClassPrx::uncheckedCast(p->ice_adapterId("dummy")); AMI_MyClass_opVoidExIPtr cb = new AMI_MyClass_opVoidExI; - try { - oneway->opVoid_async(cb); + try + { + indirect->opVoid_async(cb); } catch(const Ice::Exception&) { @@ -890,13 +891,13 @@ twowaysAMI(const Ice::CommunicatorPtr& communicator, const Test::MyClassPrx& p) } { - // Check that a call to a twoway operation raises TwowayOnlyException + // Check that a call to a twoway operation raises NoEndpointException // in the ice_exception() callback instead of at the point of call. - Test::MyClassPrx oneway = Test::MyClassPrx::uncheckedCast(p->ice_oneway()); + Test::MyClassPrx indirect = Test::MyClassPrx::uncheckedCast(p->ice_adapterId("dummy")); AMI_MyClass_opByteExIPtr cb = new AMI_MyClass_opByteExI; try { - oneway->opByte_async(cb, 0, 0); + indirect->opByte_async(cb, 0, 0); } catch(const Ice::Exception&) { @@ -1345,7 +1346,7 @@ twowaysAMI(const Ice::CommunicatorPtr& communicator, const Test::MyClassPrx& p) Test::MyClassPrx p = Test::MyClassPrx::uncheckedCast( - ic->stringToProxy("test:default -p 12010 -t 10000")); + ic->stringToProxy("test:default -p 12010")); ic->getImplicitContext()->setContext(ctx); diff --git a/cpp/test/Ice/timeout/AllTests.cpp b/cpp/test/Ice/timeout/AllTests.cpp index 694604304f9..78ac425ad95 100644 --- a/cpp/test/Ice/timeout/AllTests.cpp +++ b/cpp/test/Ice/timeout/AllTests.cpp @@ -242,9 +242,6 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "testing AMI read timeout... " << flush; { // - // The resolution of AMI timeouts is limited by the connection monitor - // thread. We set Ice.MonitorConnections=1 (one second) in main(). - // // Expect TimeoutException. // TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(500)); @@ -267,9 +264,6 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "testing AMI write timeout... " << flush; { // - // The resolution of AMI timeouts is limited by the connection monitor - // thread. We set Ice.MonitorConnections=1 (one second) in main(). - // // Expect TimeoutException. // TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(500)); diff --git a/cpp/test/Ice/timeout/Client.cpp b/cpp/test/Ice/timeout/Client.cpp index b3c9c744c72..9cdc8a39d76 100644 --- a/cpp/test/Ice/timeout/Client.cpp +++ b/cpp/test/Ice/timeout/Client.cpp @@ -44,11 +44,6 @@ main(int argc, char* argv[]) // initData.properties->setProperty("Ice.Warn.Connections", "0"); - // - // Check for AMI timeouts every second. - // - initData.properties->setProperty("Ice.MonitorConnections", "1"); - communicator = Ice::initialize(argc, argv, initData); status = run(argc, argv, communicator); } diff --git a/cpp/test/IceStorm/federation2/run.py b/cpp/test/IceStorm/federation2/run.py index 737b106fbac..a960fbbc95f 100755 --- a/cpp/test/IceStorm/federation2/run.py +++ b/cpp/test/IceStorm/federation2/run.py @@ -298,6 +298,11 @@ sys.stdout.flush() onewayStatus = doTest(0, iceStormReference) print "ok" +# +# Give some time for the error to be reported +# +time.sleep(2) + if onewayStatus or expectorThread.matches(index) != 1: TestUtil.killServers() sys.exit(1) diff --git a/cpp/test/IceUtil/timer/Client.cpp b/cpp/test/IceUtil/timer/Client.cpp index 382a95175d1..d1e4a2ed474 100644 --- a/cpp/test/IceUtil/timer/Client.cpp +++ b/cpp/test/IceUtil/timer/Client.cpp @@ -28,7 +28,7 @@ public: } virtual void - run() + runTimerTask() { Lock sync(*this); ++_count; @@ -83,6 +83,13 @@ public: } } + void + clear() + { + _run = IceUtil::Time(); + _count = 0; + } + private: IceUtil::Time _run; @@ -101,19 +108,20 @@ int main(int argc, char* argv[]) TestTaskPtr task = new TestTask(); timer->schedule(task, IceUtil::Time()); task->waitForRun(); + task->clear(); while(true) { - TestTaskPtr task = new TestTask(); - timer->schedule(task, IceUtil::Time::milliSeconds(-10)); try { + timer->schedule(task, IceUtil::Time::milliSeconds(-10)); timer->schedule(task, IceUtil::Time()); - test(task->hasRun()); } catch(const IceUtil::IllegalArgumentException&) { break; } + task->waitForRun(); + task->clear(); } } |