Skip to content

Commit

Permalink
De-lambda-ify
Browse files Browse the repository at this point in the history
  • Loading branch information
vjpai committed Jun 16, 2016
1 parent 679c75f commit e44d537
Showing 1 changed file with 84 additions and 85 deletions.
169 changes: 84 additions & 85 deletions test/cpp/end2end/hybrid_end2end_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -347,64 +347,66 @@ class HybridEnd2endTest : public ::testing::Test {
}

grpc::testing::UnimplementedService::Service unimplemented_service_;
std::vector<std::unique_ptr<ServerCompletionQueue> > cqs_;
std::vector<std::unique_ptr<ServerCompletionQueue>> cqs_;
std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_;
std::unique_ptr<Server> server_;
std::ostringstream server_address_;
};

TEST_F(HybridEnd2endTest, AsyncEcho) {
EchoTestService::WithAsyncMethod_Echo<TestServiceImpl> service;
typedef EchoTestService::WithAsyncMethod_Echo<TestServiceImpl> SType;
SType service;
SetUpServer(&service, nullptr, nullptr);
ResetStub();
std::thread echo_handler_thread(
[this, &service] { HandleEcho(&service, cqs_[0].get(), false); });
std::thread echo_handler_thread(HandleEcho<SType>, &service,
cqs_[0].get(), false);
TestAllMethods();
echo_handler_thread.join();
}

TEST_F(HybridEnd2endTest, AsyncEchoRequestStream) {
EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_Echo<TestServiceImpl> >
service;
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_Echo<TestServiceImpl>>
SType;
SType service;
SetUpServer(&service, nullptr, nullptr);
ResetStub();
std::thread echo_handler_thread(
[this, &service] { HandleEcho(&service, cqs_[0].get(), false); });
std::thread request_stream_handler_thread(
[this, &service] { HandleClientStreaming(&service, cqs_[1].get()); });
std::thread echo_handler_thread(HandleEcho<SType>, &service, cqs_[0].get(), false);
std::thread request_stream_handler_thread(HandleClientStreaming<SType>, &service, cqs_[1].get());
TestAllMethods();
echo_handler_thread.join();
request_stream_handler_thread.join();
}

TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream) {
EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl> >
service;
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>>
SType;
SType service;
SetUpServer(&service, nullptr, nullptr);
ResetStub();
std::thread response_stream_handler_thread(
[this, &service] { HandleServerStreaming(&service, cqs_[0].get()); });
std::thread request_stream_handler_thread(
[this, &service] { HandleClientStreaming(&service, cqs_[1].get()); });
std::thread response_stream_handler_thread(HandleServerStreaming<SType>,
&service, cqs_[0].get());
std::thread request_stream_handler_thread(HandleClientStreaming<SType>,
&service, cqs_[1].get());
TestAllMethods();
response_stream_handler_thread.join();
request_stream_handler_thread.join();
}

// Add a second service with one sync method.
TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_SyncDupService) {
EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl> >
service;
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>>
SType;
SType service;
TestServiceImplDupPkg dup_service;
SetUpServer(&service, &dup_service, nullptr);
ResetStub();
std::thread response_stream_handler_thread(
[this, &service] { HandleServerStreaming(&service, cqs_[0].get()); });
std::thread request_stream_handler_thread(
[this, &service] { HandleClientStreaming(&service, cqs_[1].get()); });
std::thread response_stream_handler_thread(HandleServerStreaming<SType>,
&service, cqs_[0].get());
std::thread request_stream_handler_thread(HandleClientStreaming<SType>,
&service, cqs_[1].get());
TestAllMethods();
SendEchoToDupService();
response_stream_handler_thread.join();
Expand All @@ -413,18 +415,18 @@ TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_SyncDupService) {

// Add a second service with one async method.
TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_AsyncDupService) {
EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl> >
service;
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>>
SType;
SType service;
duplicate::EchoTestService::AsyncService dup_service;
SetUpServer(&service, &dup_service, nullptr);
ResetStub();
std::thread response_stream_handler_thread(
[this, &service] { HandleServerStreaming(&service, cqs_[0].get()); });
std::thread request_stream_handler_thread(
[this, &service] { HandleClientStreaming(&service, cqs_[1].get()); });
std::thread echo_handler_thread(
[this, &dup_service] { HandleEcho(&dup_service, cqs_[2].get(), true); });
std::thread response_stream_handler_thread(HandleServerStreaming<SType>,
&service, cqs_[0].get());
std::thread request_stream_handler_thread(HandleClientStreaming<SType>,
&service, cqs_[1].get());
std::thread echo_handler_thread(HandleEcho<duplicate::EchoTestService::AsyncService>, &dup_service, cqs_[2].get(), true);
TestAllMethods();
SendEchoToDupService();
response_stream_handler_thread.join();
Expand All @@ -437,44 +439,43 @@ TEST_F(HybridEnd2endTest, GenericEcho) {
AsyncGenericService generic_service;
SetUpServer(&service, nullptr, &generic_service);
ResetStub();
std::thread generic_handler_thread([this, &generic_service] {
HandleGenericCall(&generic_service, cqs_[0].get());
});
std::thread generic_handler_thread(HandleGenericCall, &generic_service,
cqs_[0].get());
TestAllMethods();
generic_handler_thread.join();
}

TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStream) {
EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithGenericMethod_Echo<TestServiceImpl> >
service;
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithGenericMethod_Echo<TestServiceImpl>>
SType;
SType service;
AsyncGenericService generic_service;
SetUpServer(&service, nullptr, &generic_service);
ResetStub();
std::thread generic_handler_thread([this, &generic_service] {
HandleGenericCall(&generic_service, cqs_[0].get());
});
std::thread request_stream_handler_thread(
[this, &service] { HandleClientStreaming(&service, cqs_[1].get()); });
std::thread generic_handler_thread(HandleGenericCall, &generic_service,
cqs_[0].get());
std::thread request_stream_handler_thread(HandleClientStreaming<SType>,
&service, cqs_[1].get());
TestAllMethods();
generic_handler_thread.join();
request_stream_handler_thread.join();
}

// Add a second service with one sync method.
TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStream_SyncDupService) {
EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithGenericMethod_Echo<TestServiceImpl> >
service;
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithGenericMethod_Echo<TestServiceImpl>>
SType;
SType service;
AsyncGenericService generic_service;
TestServiceImplDupPkg dup_service;
SetUpServer(&service, &dup_service, &generic_service);
ResetStub();
std::thread generic_handler_thread([this, &generic_service] {
HandleGenericCall(&generic_service, cqs_[0].get());
});
std::thread request_stream_handler_thread(
[this, &service] { HandleClientStreaming(&service, cqs_[1].get()); });
std::thread generic_handler_thread(HandleGenericCall, &generic_service,
cqs_[0].get());
std::thread request_stream_handler_thread(HandleClientStreaming<SType>,
&service, cqs_[1].get());
TestAllMethods();
SendEchoToDupService();
generic_handler_thread.join();
Expand All @@ -483,20 +484,19 @@ TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStream_SyncDupService) {

// Add a second service with one async method.
TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStream_AsyncDupService) {
EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithGenericMethod_Echo<TestServiceImpl> >
service;
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithGenericMethod_Echo<TestServiceImpl>>
SType;
SType service;
AsyncGenericService generic_service;
duplicate::EchoTestService::AsyncService dup_service;
SetUpServer(&service, &dup_service, &generic_service);
ResetStub();
std::thread generic_handler_thread([this, &generic_service] {
HandleGenericCall(&generic_service, cqs_[0].get());
});
std::thread request_stream_handler_thread(
[this, &service] { HandleClientStreaming(&service, cqs_[1].get()); });
std::thread echo_handler_thread(
[this, &dup_service] { HandleEcho(&dup_service, cqs_[2].get(), true); });
std::thread generic_handler_thread(HandleGenericCall, &generic_service,
cqs_[0].get());
std::thread request_stream_handler_thread(HandleClientStreaming<SType>,
&service, cqs_[1].get());
std::thread echo_handler_thread(HandleEcho<duplicate::EchoTestService::AsyncService>, &dup_service, cqs_[2].get(), true);
TestAllMethods();
SendEchoToDupService();
generic_handler_thread.join();
Expand All @@ -505,42 +505,41 @@ TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStream_AsyncDupService) {
}

TEST_F(HybridEnd2endTest, GenericEchoAsyncRequestStreamResponseStream) {
EchoTestService::WithAsyncMethod_RequestStream<
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithGenericMethod_Echo<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl> > >
service;
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>>>
SType;
SType service;
AsyncGenericService generic_service;
SetUpServer(&service, nullptr, &generic_service);
ResetStub();
std::thread generic_handler_thread([this, &generic_service] {
HandleGenericCall(&generic_service, cqs_[0].get());
});
std::thread request_stream_handler_thread(
[this, &service] { HandleClientStreaming(&service, cqs_[1].get()); });
std::thread response_stream_handler_thread(
[this, &service] { HandleServerStreaming(&service, cqs_[2].get()); });
std::thread generic_handler_thread(HandleGenericCall, &generic_service,
cqs_[0].get());
std::thread request_stream_handler_thread(HandleClientStreaming<SType>,
&service, cqs_[1].get());
std::thread response_stream_handler_thread(HandleServerStreaming<SType>,
&service, cqs_[2].get());
TestAllMethods();
generic_handler_thread.join();
request_stream_handler_thread.join();
response_stream_handler_thread.join();
}

TEST_F(HybridEnd2endTest, GenericEchoRequestStreamAsyncResponseStream) {
EchoTestService::WithGenericMethod_RequestStream<
typedef EchoTestService::WithGenericMethod_RequestStream<
EchoTestService::WithGenericMethod_Echo<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl> > >
service;
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>>>
SType;
SType service;
AsyncGenericService generic_service;
SetUpServer(&service, nullptr, &generic_service);
ResetStub();
std::thread generic_handler_thread([this, &generic_service] {
HandleGenericCall(&generic_service, cqs_[0].get());
});
std::thread generic_handler_thread2([this, &generic_service] {
HandleGenericCall(&generic_service, cqs_[1].get());
});
std::thread response_stream_handler_thread(
[this, &service] { HandleServerStreaming(&service, cqs_[2].get()); });
std::thread generic_handler_thread(HandleGenericCall, &generic_service,
cqs_[0].get());
std::thread generic_handler_thread2(HandleGenericCall, &generic_service,
cqs_[1].get());
std::thread response_stream_handler_thread(HandleServerStreaming<SType>,
&service, cqs_[2].get());
TestAllMethods();
generic_handler_thread.join();
generic_handler_thread2.join();
Expand All @@ -552,7 +551,7 @@ TEST_F(HybridEnd2endTest, GenericEchoRequestStreamAsyncResponseStream) {
TEST_F(HybridEnd2endTest, GenericMethodWithoutGenericService) {
EchoTestService::WithGenericMethod_RequestStream<
EchoTestService::WithGenericMethod_Echo<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl> > >
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>>>
service;
SetUpServer(&service, nullptr, nullptr);
EXPECT_EQ(nullptr, server_.get());
Expand Down

0 comments on commit e44d537

Please sign in to comment.