aboutsummaryrefslogtreecommitdiffstats
path: root/configutil
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@oath.com>2018-12-13 10:47:54 +0000
committerHåvard Pettersen <havardpe@oath.com>2018-12-13 10:49:52 +0000
commit016bbe8b730482768b69b21504f6942750e0050b (patch)
treea23134384c8f07c0f37a652a8d1551e59d44f776 /configutil
parent6e9384c64f0325f45619ba9ac9e057afdf18794e (diff)
use portal server for unit test
Diffstat (limited to 'configutil')
-rw-r--r--configutil/src/tests/config_status/config_status_test.cpp41
1 files changed, 18 insertions, 23 deletions
diff --git a/configutil/src/tests/config_status/config_status_test.cpp b/configutil/src/tests/config_status/config_status_test.cpp
index 5d2ade442df..304d4518b41 100644
--- a/configutil/src/tests/config_status/config_status_test.cpp
+++ b/configutil/src/tests/config_status/config_status_test.cpp
@@ -1,49 +1,44 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/vespalib/testkit/testapp.h>
+#include <vespa/vespalib/testkit/test_kit.h>
#include <lib/configstatus.h>
-#include <vespa/fastlib/net/httpserver.h>
+#include <vespa/vespalib/portal/portal.h>
#include <vespa/config-model.h>
#include <vespa/config/config.h>
#include <vespa/config/subscription/sourcespec.h>
using namespace config;
+using vespalib::Portal;
+using vespalib::NullCryptoEngine;
-class HTTPStatus : private Fast_HTTPServer {
+auto create_server() { return Portal::create(std::make_shared<NullCryptoEngine>(), 0); }
+
+class HTTPStatus : public vespalib::Portal::GetHandler {
private:
+ Portal::SP _server;
std::string _reply;
bool _fail;
+ Portal::Token::UP _root;
- void onGetRequest(const string &, const string &, Fast_HTTPConnection &conn) override {
+ void get(Portal::GetRequest request) const override {
if (_fail) {
- conn.Output(conn.GetHTTPVersion().c_str());
- conn.Output(" 500 Error\r\n");
- conn.Output("Connection: close\r\n");
- conn.Output("\r\n");
+ request.respond_with_error(500, "Error");
} else {
- conn.Output(conn.GetHTTPVersion().c_str());
- conn.Output(" 200 OK\r\n");
- conn.Output("Content-Type: application/json\r\n\r\n");
- conn.Output(_reply.c_str());
+ request.respond_with_content("application/json", _reply);
}
};
-
public:
HTTPStatus(std::string reply)
- : Fast_HTTPServer(0), _reply(reply), _fail(false)
- {
- Start();
- };
+ : _server(create_server()), _reply(reply), _fail(false),
+ _root(_server->bind("/", *this)) {}
HTTPStatus(bool fail)
- : Fast_HTTPServer(0), _reply(""), _fail(fail)
- {
- Start();
- };
+ : _server(create_server()), _reply(""), _fail(fail),
+ _root(_server->bind("/", *this)) {}
- int getListenPort() { return Fast_HTTPServer::getListenPort(); }
+ int getListenPort() { return _server->listen_port(); }
~HTTPStatus() {
- Stop();
+ _root.reset();
};
};