From 9a7d68cfce5f71cf9d89536431d72941dc369749 Mon Sep 17 00:00:00 2001 From: Dave Hiller Date: Thu, 31 Jul 2008 12:15:15 +0000 Subject: svn merge -r93014:93396 svn+ssh://svn.lindenlab.com/svn/linden/branches/mono-r93014-qar633 dataserver-is-deprecated --- indra/test/mock_http_client.cpp | 66 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 indra/test/mock_http_client.cpp (limited to 'indra/test/mock_http_client.cpp') diff --git a/indra/test/mock_http_client.cpp b/indra/test/mock_http_client.cpp new file mode 100644 index 0000000000..6b273ee7b5 --- /dev/null +++ b/indra/test/mock_http_client.cpp @@ -0,0 +1,66 @@ +/** + * @file mock_http_client.cpp + * @brief Framework for testing HTTP requests + * Copyright (c) 2007, Linden Research, Inc. + * + * $LicenseInfo:firstyear=2007&license=viewergpl$ + * $/LicenseInfo$ + */ + +#include "linden_common.h" +#include "llsdhttpserver.h" +#include "lliohttpserver.h" + +namespace tut +{ + class SuccessNode : public LLHTTPNode + { + public: + void get(ResponsePtr r, const LLSD& context) const + { + LLSD result; + result["state"] = "complete"; + result["test"] = "test"; + r->result(result); + } + void post(ResponsePtr r, const LLSD& context, const LLSD& input) const + { + LLSD result; + result["state"] = "complete"; + result["test"] = "test"; + r->result(result); + } + }; + + class ErrorNode : public LLHTTPNode + { + public: + void get(ResponsePtr r, const LLSD& context) const + { r->status(599, "Intentional error"); } + void post(ResponsePtr r, const LLSD& context, const LLSD& input) const + { r->status(input["status"], input["reason"]); } + }; + + class TimeOutNode : public LLHTTPNode + { + public: + void get(ResponsePtr r, const LLSD& context) const + { + /* do nothing, the request will eventually time out */ + } + }; + + LLSD storage; + + class LLSDStorageNode : public LLHTTPNode + { + public: + LLSD get() const{ return storage; } + LLSD put(const LLSD& value) const{ storage = value; return LLSD(); } + }; + + LLHTTPRegistration gStorageNode("/test/storage"); + LLHTTPRegistration gSuccessNode("/test/success"); + LLHTTPRegistration gErrorNode("/test/error"); + LLHTTPRegistration gTimeOutNode("/test/timeout"); +} -- cgit v1.2.3