| 787 | |
| 788 | template <typename ServerTraits, typename TemplateTraits> |
| 789 | void 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 |
nothing calls this directly
no test coverage detected