Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions net/http/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ if(WIN32)
return()
endif()

# curl is required for tests
# curl and gunzip are required for tests
find_program(CURL_EXECUTABLE curl)
find_program(GUNZIP_EXECUTABLE gunzip)

if(NOT CURL_EXECUTABLE)
if(NOT CURL_EXECUTABLE OR NOT GUNZIP_EXECUTABLE)
return()
endif()

Expand Down
37 changes: 34 additions & 3 deletions net/http/test/test_suite.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ TString server_url;
TString unix_socket;

// submit requests to server
std::string execute_request(const char *url, const char *post = nullptr)
std::string execute_request(const char *url, const char *post = nullptr, bool isgzip = false)
{
TString fname = TString::Format("http_server_%d.output", server_hash),
TString fname = TString::Format("http_server_%d.output%s", server_hash, isgzip ? ".gz" : ""),
pname, exec;

if (post) {
Expand All @@ -25,8 +25,19 @@ std::string execute_request(const char *url, const char *post = nullptr)

if (gSystem->Exec(exec) != 0)
res = "<fail>";
else
else if (isgzip) {
exec = TString::Format("gunzip %s", fname.Data());
printf("Execute %s\n", exec.Data());
if (gSystem->Exec(exec) != 0)
res = "<fail>";
else {
fname.Resize(fname.Length() - 3);
res = THttpServer::ReadFileContent(fname.Data());
}

} else {
res = THttpServer::ReadFileContent(fname.Data());
}

gSystem->Unlink(fname);
if (!pname.IsNull())
Expand Down Expand Up @@ -57,6 +68,17 @@ void test_suite(THttpServer &serv)
" \"fTitle\" : \"title1\"\n"
"}") << "result of root.json request";

// check GZIP JSON representation for the object
res = execute_request("/obj1/root.json.gz", nullptr, true);
EXPECT_EQ(res, "{\n"
" \"_typename\" : \"TNamed\",\n"
" \"fUniqueID\" : 0,\n"
" \"fBits\" : 8,\n"
" \"fName\" : \"obj1\",\n"
" \"fTitle\" : \"title1\"\n"
"}") << "result of root.json,gz request";


// check XML representation for the object
res = execute_request("/obj1/root.xml");
EXPECT_EQ(res, "<Object class=\"TNamed\">\n"
Expand Down Expand Up @@ -88,6 +110,15 @@ void test_suite(THttpServer &serv)
" \"_title\" : \"title1\"\n"
"}") << "result of item.json request";

// check item.json.gz request hierarchy request
res = execute_request("/obj1/item.json.gz", nullptr, true);

EXPECT_EQ(res, "{\n"
" \"_name\" : \"obj1\",\n"
" \"_root_version\" : " + std::to_string(gROOT->GetVersionCode()) + ",\n"
" \"_kind\" : \"ROOT.TNamed\",\n"
" \"_title\" : \"title1\"\n"
"}") << "result of item.json.gz request";

// check multi request to several objects
res = execute_request("/multi.json?number=2", "/obj1/root.json\n/obj2/root.json\n");
Expand Down
Loading