proxygen
DefaultHTTPCodecFactoryTest.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree. An additional grant
7  * of patent rights can be found in the PATENTS file in the same directory.
8  *
9  */
12 #include <limits>
17 
18 using namespace proxygen;
19 using namespace testing;
20 
21 TEST(DefaultHTTPCodecFactoryTest, GetCodec) {
22  DefaultHTTPCodecFactory factory(false);
23 
24  auto codec = factory.getCodec("spdy/3.1", TransportDirection::UPSTREAM, true);
25  SPDYCodec* spdyCodec = dynamic_cast<SPDYCodec*>(codec.get());
26  EXPECT_NE(spdyCodec, nullptr);
27 
29  HTTP2Codec* http2Codec = dynamic_cast<HTTP2Codec*>(codec.get());
30  EXPECT_NE(http2Codec, nullptr);
31 
32  codec = factory.getCodec("http/1.1", TransportDirection::UPSTREAM, true);
33  HTTP1xCodec* http1xCodec = dynamic_cast<HTTP1xCodec*>(codec.get());
34  EXPECT_NE(http1xCodec, nullptr);
35 
36  codec = factory.getCodec("", TransportDirection::UPSTREAM, true);
37  http1xCodec = dynamic_cast<HTTP1xCodec*>(codec.get());
38  EXPECT_NE(http1xCodec, nullptr);
39 
40  codec = factory.getCodec("not/supported", TransportDirection::UPSTREAM, true);
41  http1xCodec = dynamic_cast<HTTP1xCodec*>(codec.get());
42  EXPECT_NE(http1xCodec, nullptr);
43 }
const std::string kProtocolString
CodecFactory codec
TEST(DefaultHTTPCodecFactoryTest, GetCodec)
#define EXPECT_NE(val1, val2)
Definition: gtest.h:1926
std::unique_ptr< HTTPCodec > getCodec(const std::string &nextProtocol, TransportDirection direction, bool isTLS) override