proxygen
RequestHandlerAdaptorTest.cpp File Reference

Go to the source code of this file.

Classes

struct  StubRequestHandlerAdaptor
 

Functions

void testExpectHandling (bool handlerResponds)
 
 TEST (RequestHandlerAdaptorTest, Expect)
 
 TEST (RequestHandlerAdaptorTest, onError)
 

Function Documentation

TEST ( RequestHandlerAdaptorTest  ,
Expect   
)

Definition at line 47 of file RequestHandlerAdaptorTest.cpp.

References testExpectHandling().

47  {
48  testExpectHandling(true /* handlerResponds */);
49  testExpectHandling(false /* handlerResponds */);
50 }
void testExpectHandling(bool handlerResponds)
TEST ( RequestHandlerAdaptorTest  ,
onError   
)

Definition at line 52 of file RequestHandlerAdaptorTest.cpp.

References proxygen::kErrorTimeout, proxygen::HTTPTransaction::onError(), proxygen::HTTPTransaction::setHandler(), and proxygen::Exception::setProxygenError().

52  {
53  NiceMock<MockRequestHandler> requestHandler_;
54  auto adaptor = new RequestHandlerAdaptor(&requestHandler_);
56  HTTP2PriorityQueue egressQueue;
57  HTTPTransaction txn(TransportDirection::DOWNSTREAM,
58  1, 1, transport, egressQueue);
59  txn.setHandler(adaptor);
60  // egress timeout error
61  HTTPException ex(HTTPException::Direction::EGRESS, "egress timeout");
62  ex.setProxygenError(kErrorTimeout);
63  txn.onError(ex);
64 }
void testExpectHandling ( bool  handlerResponds)

Definition at line 34 of file RequestHandlerAdaptorTest.cpp.

References testing::_, EXPECT_CALL, EXPECT_EQ, folly::gen::move, proxygen::HTTPTransactionHandler::onHeadersComplete(), and testing::Return().

Referenced by TEST().

34  {
35  StrictMock<MockRequestHandler> requestHandler_;
36  EXPECT_CALL(requestHandler_, canHandleExpect()).WillOnce(
37  Return(handlerResponds));
38  EXPECT_CALL(requestHandler_, onRequest(_));
39  auto adaptor = std::make_shared<StubRequestHandlerAdaptor>(&requestHandler_);
40  auto msg = std::make_unique<HTTPMessage>();
41  msg->getHeaders().add("Expect", "100-continue");
42  auto txHandler = std::dynamic_pointer_cast<HTTPTransactionHandler>(adaptor);
43  txHandler->onHeadersComplete(std::move(msg));
44  EXPECT_EQ(adaptor->headersSent_, !handlerResponds);
45 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
virtual void onHeadersComplete(std::unique_ptr< HTTPMessage > msg) noexcept=0
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
internal::ReturnAction< R > Return(R value)