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

Function testSeparateConnections

lib/cpp/test/processor/ProcessorTest.cpp:634–679  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

632
633template <typename ServerTraits, typename TemplateTraits>
634void testSeparateConnections() {
635 typedef ServiceState<ServerTraits, ChildServiceTraits<TemplateTraits> > State;
636
637 // Start the server
638 std::shared_ptr<State> state(new State);
639 ServerThread serverThread(state, true);
640
641 const std::shared_ptr<EventLog>& log = state->getLog();
642
643 // Create a client
644 std::shared_ptr<typename State::Client> client1 = state->createClient();
645
646 // Make sure the expected events were logged
647 uint32_t client1Id = checkNewConnEvents(log);
648
649 // Create a second client
650 std::shared_ptr<typename State::Client> client2 = state->createClient();
651
652 // Make sure the expected events were logged
653 uint32_t client2Id = checkNewConnEvents(log);
654
655 // The two connections should have different IDs
656 BOOST_CHECK_NE(client1Id, client2Id);
657
658 // Make a call, and check for the proper events
659 int32_t value = 5;
660 client1->setValue(value);
661 uint32_t call1
662 = checkCallEvents(log, client1Id, EventLog::ET_CALL_SET_VALUE, "ChildService.setValue");
663
664 // Make a call with client2
665 int32_t v = client2->getValue();
666 BOOST_CHECK_EQUAL(value, v);
667 checkCallEvents(log, client2Id, EventLog::ET_CALL_GET_VALUE, "ChildService.getValue");
668
669 // Make another call with client1
670 v = client1->getValue();
671 BOOST_CHECK_EQUAL(value, v);
672 uint32_t call2
673 = checkCallEvents(log, client1Id, EventLog::ET_CALL_GET_VALUE, "ChildService.getValue");
674 BOOST_CHECK_NE(call1, call2);
675
676 // Close the second client, and check for the appropriate events
677 client2.reset();
678 checkCloseEvents(log, client2Id);
679}
680
681template <typename ServerTraits, typename TemplateTraits>
682void testOnewayCall() {

Callers

nothing calls this directly

Calls 7

checkNewConnEventsFunction · 0.85
checkCallEventsFunction · 0.85
checkCloseEventsFunction · 0.85
getValueMethod · 0.65
createClientMethod · 0.45
setValueMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected