diff options
Diffstat (limited to 'cpp/test/Ice/timeout/AllTests.cpp')
-rw-r--r-- | cpp/test/Ice/timeout/AllTests.cpp | 462 |
1 files changed, 231 insertions, 231 deletions
diff --git a/cpp/test/Ice/timeout/AllTests.cpp b/cpp/test/Ice/timeout/AllTests.cpp index 71af9e97b60..694604304f9 100644 --- a/cpp/test/Ice/timeout/AllTests.cpp +++ b/cpp/test/Ice/timeout/AllTests.cpp @@ -19,7 +19,7 @@ class CallbackBase : public IceUtil::Monitor<IceUtil::Mutex> public: CallbackBase() : - _called(false) + _called(false) { } @@ -29,26 +29,26 @@ public: bool check() { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - while(!_called) - { - if(!timedWait(IceUtil::Time::seconds(5))) - { - return false; - } - } - _called = false; - return true; + 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(); + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + assert(!_called); + _called = true; + notify(); } private: @@ -62,12 +62,12 @@ public: virtual void ice_response() { - called(); + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } }; typedef IceUtil::Handle<AMISendData> AMISendDataPtr; @@ -78,13 +78,13 @@ public: virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const ::Ice::Exception& ex) { - test(dynamic_cast<const Ice::TimeoutException*>(&ex)); - called(); + test(dynamic_cast<const Ice::TimeoutException*>(&ex)); + called(); } }; typedef IceUtil::Handle<AMISendDataEx> AMISendDataExPtr; @@ -95,12 +95,12 @@ public: virtual void ice_response() { - called(); + called(); } virtual void ice_exception(const ::Ice::Exception&) { - test(false); + test(false); } }; typedef IceUtil::Handle<AMISleep> AMISleepPtr; @@ -111,13 +111,13 @@ public: virtual void ice_response() { - test(false); + test(false); } virtual void ice_exception(const ::Ice::Exception& ex) { - test(dynamic_cast<const Ice::TimeoutException*>(&ex)); - called(); + test(dynamic_cast<const Ice::TimeoutException*>(&ex)); + called(); } }; typedef IceUtil::Handle<AMISleepEx> AMISleepExPtr; @@ -134,249 +134,249 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "testing connect timeout... " << flush; { - // - // Expect ConnectTimeoutException. - // - TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(500)); - to->holdAdapter(750); - to->ice_getConnection()->close(true); // Force a reconnect. - try - { - to->op(); - test(false); - } - catch(const Ice::ConnectTimeoutException&) - { - // Expected. - } + // + // Expect ConnectTimeoutException. + // + TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(500)); + to->holdAdapter(750); + to->ice_getConnection()->close(true); // Force a reconnect. + try + { + to->op(); + test(false); + } + catch(const Ice::ConnectTimeoutException&) + { + // Expected. + } } { - // - // Expect success. - // - timeout->op(); // Ensure adapter is active. - TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(1000)); - to->holdAdapter(500); - to->ice_getConnection()->close(true); // Force a reconnect. - try - { - to->op(); - } - catch(const Ice::ConnectTimeoutException&) - { - test(false); - } + // + // Expect success. + // + timeout->op(); // Ensure adapter is active. + TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(1000)); + to->holdAdapter(500); + to->ice_getConnection()->close(true); // Force a reconnect. + try + { + to->op(); + } + catch(const Ice::ConnectTimeoutException&) + { + test(false); + } } cout << "ok" << endl; cout << "testing read timeout... " << flush; { - // - // Expect TimeoutException. - // - TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(500)); - try - { - to->sleep(750); - test(false); - } - catch(const Ice::TimeoutException&) - { - // Expected. - } + // + // Expect TimeoutException. + // + TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(500)); + try + { + to->sleep(750); + test(false); + } + catch(const Ice::TimeoutException&) + { + // Expected. + } } { - // - // Expect success. - // - timeout->op(); // Ensure adapter is active. - TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(1000)); - try - { - to->sleep(500); - } - catch(const Ice::TimeoutException&) - { - test(false); - } + // + // Expect success. + // + timeout->op(); // Ensure adapter is active. + TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(1000)); + try + { + to->sleep(500); + } + catch(const Ice::TimeoutException&) + { + test(false); + } } cout << "ok" << endl; cout << "testing write timeout... " << flush; { - // - // Expect TimeoutException. - // - TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(500)); - to->holdAdapter(750); - try - { - ByteSeq seq(100000); - to->sendData(seq); - test(false); - } - catch(const Ice::TimeoutException&) - { - // Expected. - } + // + // Expect TimeoutException. + // + TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(500)); + to->holdAdapter(750); + try + { + ByteSeq seq(100000); + to->sendData(seq); + test(false); + } + catch(const Ice::TimeoutException&) + { + // Expected. + } } { - // - // Expect success. - // - timeout->op(); // Ensure adapter is active. - TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(1000)); - to->holdAdapter(500); - try - { - ByteSeq seq(100000); - to->sendData(seq); - } - catch(const Ice::TimeoutException&) - { - test(false); - } + // + // Expect success. + // + timeout->op(); // Ensure adapter is active. + TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(1000)); + to->holdAdapter(500); + try + { + ByteSeq seq(100000); + to->sendData(seq); + } + catch(const Ice::TimeoutException&) + { + test(false); + } } cout << "ok" << endl; 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)); - AMISleepExPtr cb = new AMISleepEx; - to->sleep_async(cb, 2000); - test(cb->check()); + // + // 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)); + AMISleepExPtr cb = new AMISleepEx; + to->sleep_async(cb, 2000); + test(cb->check()); } { - // - // Expect success. - // - timeout->op(); // Ensure adapter is active. - TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(1000)); - AMISleepPtr cb = new AMISleep; - to->sleep_async(cb, 500); - test(cb->check()); + // + // Expect success. + // + timeout->op(); // Ensure adapter is active. + TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(1000)); + AMISleepPtr cb = new AMISleep; + to->sleep_async(cb, 500); + test(cb->check()); } cout << "ok" << endl; 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)); - to->holdAdapter(2000); - ByteSeq seq(100000); - AMISendDataExPtr cb = new AMISendDataEx; - to->sendData_async(cb, seq); - test(cb->check()); + // + // 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)); + to->holdAdapter(2000); + ByteSeq seq(100000); + AMISendDataExPtr cb = new AMISendDataEx; + to->sendData_async(cb, seq); + test(cb->check()); } { - // - // Expect success. - // - timeout->op(); // Ensure adapter is active. - TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(1000)); - to->holdAdapter(500); - ByteSeq seq(100000); - AMISendDataPtr cb = new AMISendData; - to->sendData_async(cb, seq); - test(cb->check()); + // + // Expect success. + // + timeout->op(); // Ensure adapter is active. + TimeoutPrx to = TimeoutPrx::uncheckedCast(obj->ice_timeout(1000)); + to->holdAdapter(500); + ByteSeq seq(100000); + AMISendDataPtr cb = new AMISendData; + to->sendData_async(cb, seq); + test(cb->check()); } cout << "ok" << endl; cout << "testing timeout overrides... " << flush; { - // - // Test Ice.Override.Timeout. This property overrides all - // endpoint timeouts. - // - Ice::InitializationData initData; - initData.properties = communicator->getProperties()->clone(); - initData.properties->setProperty("Ice.Override.Timeout", "500"); - Ice::CommunicatorPtr comm = Ice::initialize(initData); - TimeoutPrx to = TimeoutPrx::checkedCast(comm->stringToProxy(sref)); - try - { - to->sleep(750); - test(false); - } - catch(const Ice::TimeoutException&) - { - // Expected. - } - // - // Calling ice_timeout() should have no effect. - // - timeout->op(); // Ensure adapter is active. - to = TimeoutPrx::checkedCast(to->ice_timeout(1000)); - try - { - to->sleep(750); - test(false); - } - catch(const Ice::TimeoutException&) - { - // Expected. - } - comm->destroy(); + // + // Test Ice.Override.Timeout. This property overrides all + // endpoint timeouts. + // + Ice::InitializationData initData; + initData.properties = communicator->getProperties()->clone(); + initData.properties->setProperty("Ice.Override.Timeout", "500"); + Ice::CommunicatorPtr comm = Ice::initialize(initData); + TimeoutPrx to = TimeoutPrx::checkedCast(comm->stringToProxy(sref)); + try + { + to->sleep(750); + test(false); + } + catch(const Ice::TimeoutException&) + { + // Expected. + } + // + // Calling ice_timeout() should have no effect. + // + timeout->op(); // Ensure adapter is active. + to = TimeoutPrx::checkedCast(to->ice_timeout(1000)); + try + { + to->sleep(750); + test(false); + } + catch(const Ice::TimeoutException&) + { + // Expected. + } + comm->destroy(); } { - // - // Test Ice.Override.ConnectTimeout. - // - Ice::InitializationData initData; - initData.properties = communicator->getProperties()->clone(); - initData.properties->setProperty("Ice.Override.ConnectTimeout", "750"); - Ice::CommunicatorPtr comm = Ice::initialize(initData); - timeout->holdAdapter(1000); - TimeoutPrx to = TimeoutPrx::uncheckedCast(comm->stringToProxy(sref)); - try - { - to->op(); - test(false); - } - catch(const Ice::ConnectTimeoutException&) - { - // Expected. - } - // - // Calling ice_timeout() should have no effect on the connect timeout. - // - timeout->op(); // Ensure adapter is active. - timeout->holdAdapter(1000); - to = TimeoutPrx::uncheckedCast(to->ice_timeout(1250)); - try - { - to->op(); - test(false); - } - catch(const Ice::ConnectTimeoutException&) - { - // Expected. - } - // - // Verify that timeout set via ice_timeout() is still used for requests. - // - to->op(); // Force connection. - try - { - to->sleep(1500); - test(false); - } - catch(const Ice::TimeoutException&) - { - // Expected. - } - comm->destroy(); + // + // Test Ice.Override.ConnectTimeout. + // + Ice::InitializationData initData; + initData.properties = communicator->getProperties()->clone(); + initData.properties->setProperty("Ice.Override.ConnectTimeout", "750"); + Ice::CommunicatorPtr comm = Ice::initialize(initData); + timeout->holdAdapter(1000); + TimeoutPrx to = TimeoutPrx::uncheckedCast(comm->stringToProxy(sref)); + try + { + to->op(); + test(false); + } + catch(const Ice::ConnectTimeoutException&) + { + // Expected. + } + // + // Calling ice_timeout() should have no effect on the connect timeout. + // + timeout->op(); // Ensure adapter is active. + timeout->holdAdapter(1000); + to = TimeoutPrx::uncheckedCast(to->ice_timeout(1250)); + try + { + to->op(); + test(false); + } + catch(const Ice::ConnectTimeoutException&) + { + // Expected. + } + // + // Verify that timeout set via ice_timeout() is still used for requests. + // + to->op(); // Force connection. + try + { + to->sleep(1500); + test(false); + } + catch(const Ice::TimeoutException&) + { + // Expected. + } + comm->destroy(); } cout << "ok" << endl; |