| 732 | |
| 733 | template <typename ServerTraits, typename TemplateTraits> |
| 734 | void testExpectedError() { |
| 735 | typedef ServiceState<ServerTraits, ChildServiceTraits<TemplateTraits> > State; |
| 736 | |
| 737 | // Start the server |
| 738 | std::shared_ptr<State> state(new State); |
| 739 | ServerThread serverThread(state, true); |
| 740 | |
| 741 | const std::shared_ptr<EventLog>& log = state->getLog(); |
| 742 | |
| 743 | // Create a client |
| 744 | std::shared_ptr<typename State::Client> client = state->createClient(); |
| 745 | uint32_t connId = checkNewConnEvents(log); |
| 746 | |
| 747 | // Send the exceptionWait() call |
| 748 | state->getHandler()->prepareTriggeredCall(); |
| 749 | string message = "test 1234 test"; |
| 750 | client->send_exceptionWait(message); |
| 751 | string callName = "ParentService.exceptionWait"; |
| 752 | uint32_t callId = checkCallHandlerEvents(log, connId, EventLog::ET_CALL_EXCEPTION_WAIT, callName); |
| 753 | |
| 754 | // There shouldn't be any more events |
| 755 | checkNoEvents(log); |
| 756 | |
| 757 | // Trigger the handler to return |
| 758 | state->getHandler()->triggerPendingCalls(); |
| 759 | |
| 760 | // The handler will log an ET_WAIT_RETURN event when it wakes up |
| 761 | Event event = log->waitForEvent(); |
| 762 | BOOST_CHECK_EQUAL(EventLog::ET_WAIT_RETURN, event.type); |
| 763 | |
| 764 | // Now receive the response |
| 765 | try { |
| 766 | client->recv_exceptionWait(); |
| 767 | BOOST_FAIL("expected MyError to be thrown"); |
| 768 | } catch (const MyError& e) { |
| 769 | BOOST_CHECK_EQUAL(message, e.message); |
| 770 | // Check if std::exception::what() is handled properly |
| 771 | size_t message_pos = string(e.what()).find("TException - service has thrown: MyError"); |
| 772 | BOOST_CHECK_NE(message_pos, string::npos); |
| 773 | } |
| 774 | |
| 775 | // Now we should see the events for a normal call finish |
| 776 | checkCallPostHandlerEvents(log, connId, callId, callName); |
| 777 | |
| 778 | // There shouldn't be any more events |
| 779 | checkNoEvents(log); |
| 780 | |
| 781 | // Destroy the client, and check for connection closed events |
| 782 | client.reset(); |
| 783 | checkCloseEvents(log, connId); |
| 784 | |
| 785 | checkNoEvents(log); |
| 786 | } |
| 787 | |
| 788 | template <typename ServerTraits, typename TemplateTraits> |
| 789 | void testUnexpectedError() { |
nothing calls this directly
no test coverage detected