本文整理汇总了C++中TestThriftServerFactory类的典型用法代码示例。如果您正苦于以下问题:C++ TestThriftServerFactory类的具体用法?C++ TestThriftServerFactory怎么用?C++ TestThriftServerFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestThriftServerFactory类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST
TEST(ThriftServer, CompressionClientTest) {
TestThriftServerFactory<TestInterface> factory;
ScopedServerThread sst(factory.create());
folly::EventBase base;
std::shared_ptr<TAsyncSocket> socket(
TAsyncSocket::newSocket(&base, *sst.getAddress()));
TestServiceAsyncClient client(
std::unique_ptr<HeaderClientChannel,
folly::DelayedDestruction::Destructor>(
new HeaderClientChannel(socket)));
auto channel =
boost::polymorphic_downcast<HeaderClientChannel*>(client.getChannel());
channel->setTransform(apache::thrift::transport::THeader::ZLIB_TRANSFORM);
channel->setMinCompressBytes(1);
std::string response;
client.sync_sendResponse(response, 64);
EXPECT_EQ(response, "test64");
auto trans = channel->getWriteTransforms();
EXPECT_EQ(trans.size(), 1);
for (auto& tran : trans) {
EXPECT_EQ(tran, apache::thrift::transport::THeader::ZLIB_TRANSFORM);
}
}
示例2: TEST
TEST(ThriftServer, IdleServerTimeout) {
TestThriftServerFactory<TestInterface> factory;
auto server = factory.create();
auto thriftServer = dynamic_cast<ThriftServer *>(server.get());
thriftServer->setIdleServerTimeout(std::chrono::milliseconds(50));
ScopedServerThread scopedServer(server);
scopedServer.join();
}
示例3: TEST
TEST(ThriftServer, BadSendTest) {
TestThriftServerFactory<TestInterface> factory;
ScopedServerThread sst(factory.create());
folly::EventBase base;
std::shared_ptr<TAsyncSocket> socket(
TAsyncSocket::newSocket(&base, *sst.getAddress()));
TestServiceAsyncClient client(HeaderClientChannel::newChannel(socket));
client.sendResponse(std::unique_ptr<RequestCallback>(new Callback), 64);
socket->shutdownWriteNow();
base.loop();
std::string response;
EXPECT_THROW(client.sync_sendResponse(response, 64), TTransportException);
}