proxygen
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
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
*/
10
#include <
proxygen/lib/http/codec/DefaultHTTPCodecFactory.h
>
11
#include <
folly/portability/GTest.h
>
12
#include <limits>
13
#include <
proxygen/lib/http/codec/HTTP1xCodec.h
>
14
#include <
proxygen/lib/http/codec/HTTP2Codec.h
>
15
#include <
proxygen/lib/http/codec/HTTP2Constants.h
>
16
#include <
proxygen/lib/http/codec/SPDYCodec.h
>
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
28
codec
= factory.
getCodec
(
http2::kProtocolString
,
TransportDirection::UPSTREAM
,
true
);
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
}
testing
Definition:
gmock-actions.h:53
HTTP1xCodec.h
proxygen::http2::kProtocolString
const std::string kProtocolString
codec
CodecFactory codec
Definition:
Compression.cpp:2018
TEST
TEST(DefaultHTTPCodecFactoryTest, GetCodec)
Definition:
DefaultHTTPCodecFactoryTest.cpp:21
SPDYCodec.h
proxygen::DefaultHTTPCodecFactory
Definition:
DefaultHTTPCodecFactory.h:15
GTest.h
DefaultHTTPCodecFactory.h
HTTP2Codec.h
proxygen::HTTP1xCodec
Definition:
HTTP1xCodec.h:21
proxygen::HTTP2Codec
Definition:
HTTP2Codec.h:29
proxygen::TransportDirection::UPSTREAM
EXPECT_NE
#define EXPECT_NE(val1, val2)
Definition:
gtest.h:1926
proxygen
Definition:
ExMessageHandler.h:14
HTTP2Constants.h
proxygen::SPDYCodec
Definition:
SPDYCodec.h:36
proxygen::DefaultHTTPCodecFactory::getCodec
std::unique_ptr< HTTPCodec > getCodec(const std::string &nextProtocol, TransportDirection direction, bool isTLS) override
Definition:
DefaultHTTPCodecFactory.cpp:24
proxygen
lib
http
codec
test
DefaultHTTPCodecFactoryTest.cpp
Generated by
1.8.11