MCPcopy Create free account
hub / github.com/apache/thrift / testUnexpectedError

Function testUnexpectedError

lib/cpp/test/processor/ProcessorTest.cpp:789–852  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

787
788template <typename ServerTraits, typename TemplateTraits>
789void testUnexpectedError() {
790 typedef ServiceState<ServerTraits, ChildServiceTraits<TemplateTraits> > State;
791
792 // Start the server
793 std::shared_ptr<State> state(new State);
794 ServerThread serverThread(state, true);
795
796 const std::shared_ptr<EventLog>& log = state->getLog();
797
798 // Create a client
799 std::shared_ptr<typename State::Client> client = state->createClient();
800 uint32_t connId = checkNewConnEvents(log);
801
802 // Send the unexpectedExceptionWait() call
803 state->getHandler()->prepareTriggeredCall();
804 string message = "1234 test 5678";
805 client->send_unexpectedExceptionWait(message);
806 string callName = "ParentService.unexpectedExceptionWait";
807 uint32_t callId
808 = checkCallHandlerEvents(log, connId, EventLog::ET_CALL_UNEXPECTED_EXCEPTION_WAIT, callName);
809
810 // There shouldn't be any more events
811 checkNoEvents(log);
812
813 // Trigger the handler to return
814 state->getHandler()->triggerPendingCalls();
815
816 // The handler will log an ET_WAIT_RETURN event when it wakes up
817 Event event = log->waitForEvent();
818 BOOST_CHECK_EQUAL(EventLog::ET_WAIT_RETURN, event.type);
819
820 // Now receive the response
821 try {
822 client->recv_unexpectedExceptionWait();
823 BOOST_FAIL("expected TApplicationError to be thrown");
824 } catch (const TApplicationException&) {
825 }
826
827 // Now we should see a handler error event
828 event = log->waitForEvent();
829 BOOST_CHECK_EQUAL(EventLog::ET_HANDLER_ERROR, event.type);
830 BOOST_CHECK_EQUAL(connId, event.connectionId);
831 BOOST_CHECK_EQUAL(callId, event.callId);
832 BOOST_CHECK_EQUAL(callName, event.message);
833
834 // pre-write and post-write events aren't generated after a handler error
835 // (Even for non-oneway calls where a response is written.)
836 //
837 // A call finished event is logged when the call context is destroyed
838 event = log->waitForEvent();
839 BOOST_CHECK_EQUAL(EventLog::ET_CALL_FINISHED, event.type);
840 BOOST_CHECK_EQUAL(connId, event.connectionId);
841 BOOST_CHECK_EQUAL(callId, event.callId);
842 BOOST_CHECK_EQUAL(callName, event.message);
843
844 // There shouldn't be any more events
845 checkNoEvents(log);
846

Callers

nothing calls this directly

Calls 10

checkNewConnEventsFunction · 0.85
checkCallHandlerEventsFunction · 0.85
checkNoEventsFunction · 0.85
checkCloseEventsFunction · 0.85
prepareTriggeredCallMethod · 0.80
triggerPendingCallsMethod · 0.80
createClientMethod · 0.45
getHandlerMethod · 0.45
waitForEventMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected