Mantid
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
Mantid::FrameworkTestHelpers::MockONCatAPI Class Reference

#include <ONCatHelper.h>

Inheritance diagram for Mantid::FrameworkTestHelpers::MockONCatAPI:
Mantid::Kernel::InternetHelper

Public Member Functions

bool allResponsesCalled () const
 
bool allResponsesCalledOnce () const
 
 MockONCatAPI ()=delete
 
 MockONCatAPI (const MockResponseMap &responseMap)
 
 ~MockONCatAPI () override
 
- Public Member Functions inherited from Mantid::Kernel::InternetHelper
void addHeader (const std::string &key, const std::string &value)
 Adds a header.
 
void clearHeaders ()
 Clears all headers.
 
void clearProxy ()
 Clears cached proxy details.
 
virtual HTTPStatus downloadFile (const std::string &urlFile, const std::string &localFilePath="")
 Download a url and fetch it inside the local path given.
 
const std::string & getBody ()
 Gets the body set for future requests.
 
std::streamsize getContentLength ()
 Gets the content length.
 
const std::string & getContentType ()
 Gets the Content Type.
 
const std::string & getHeader (const std::string &key)
 Gets the value of a header.
 
const std::string & getMethod ()
 Gets the method.
 
Kernel::ProxyInfogetProxy (const std::string &url)
 Gets proxy details for a system and a url.
 
const std::string & getResponseReason ()
 Gets the body set for future requests.
 
HTTPStatus getResponseStatus ()
 Gets the body set for future requests.
 
int getTimeout ()
 Gets the timeout in seconds.
 
StringToStringMapheaders ()
 Returns a reference to the headers map.
 
 InternetHelper ()
 Constructor.
 
 InternetHelper (const Kernel::ProxyInfo &proxy)
 Constructor.
 
void removeHeader (const std::string &key)
 Removes a header.
 
virtual void reset ()
 Resets properties to defaults (except the proxy)
 
virtual HTTPStatus sendRequest (const std::string &url, std::ostream &responseStream)
 Performs a request using http or https depending on the url.
 
void setBody (const std::ostringstream &body)
 Sets the body & content length for future requests, this will also set the method to POST is the body is not empty and GET if it is.
 
void setBody (const std::string &body)
 Sets the body & content length for future requests, this will also set the method to POST is the body is not empty and GET if it is.
 
void setBody (Poco::Net::HTMLForm &form)
 Sets the body & content length for future requests, this will also set the method to POST is the body is not empty and GET if it is.
 
void setContentLength (std::streamsize length)
 Sets the content length.
 
void setContentType (const std::string &contentType)
 Sets the Content Type.
 
void setMethod (const std::string &method)
 Sets the Method.
 
void setProxy (const Kernel::ProxyInfo &proxy)
 sets the proxy details.
 
void setTimeout (int seconds)
 Sets the timeout in seconds.
 
virtual ~InternetHelper ()
 Destructor.
 

Protected Member Functions

InternetHelper::HTTPStatus sendHTTPRequest (const std::string &url, std::ostream &responseStream) override
 Performs a request using http.
 
InternetHelper::HTTPStatus sendHTTPSRequest (const std::string &url, std::ostream &responseStream) override
 Performs a request using https.
 
- Protected Member Functions inherited from Mantid::Kernel::InternetHelper
void createRequest (Poco::URI &uri)
 
bool isRelocated (const HTTPStatus &response)
 Checks the HTTP status to decide if this is a relocation.
 
void logDebugRequestSending (const std::string &schemeName, const std::string &url) const
 Helper to log (debug level) the request being sent (careful not to print blatant passwords, etc.).
 
virtual HTTPStatus processErrorStates (const Poco::Net::HTTPResponse &res, std::istream &rs, const std::string &url)
 Process any HTTP errors states.
 
InternetHelper::HTTPStatus processRelocation (const Poco::Net::HTTPResponse &response, std::ostream &responseStream)
 
virtual void processResponseHeaders (const Poco::Net::HTTPResponse &res)
 Process any headers from the response stream Basic implementation does nothing.
 
virtual HTTPStatus sendRequestAndProcess (Poco::Net::HTTPClientSession &session, Poco::URI &uri, std::ostream &responseStream)
 
void setupProxyOnSession (Poco::Net::HTTPClientSession &session, const std::string &proxyUrl)
 
void throwNotConnected (const std::string &url, const Poco::Net::HostNotFoundException &ex)
 Throw an exception occurs when the computer is not connected to the internet.
 

Private Attributes

MockResponseCallCounts m_responseCallCounts
 
MockResponseMap m_responseMap
 

Additional Inherited Members

- Public Types inherited from Mantid::Kernel::InternetHelper
enum class  HTTPStatus {
  CONTINUE = 100 , SWITCHING_PROTOCOLS = 101 , OK = 200 , CREATED = 201 ,
  ACCEPTED = 202 , NONAUTHORITATIVE = 203 , NO_CONTENT = 204 , RESET_CONTENT = 205 ,
  PARTIAL_CONTENT = 206 , MULTIPLE_CHOICES = 300 , MOVED_PERMANENTLY = 301 , FOUND = 302 ,
  SEE_OTHER = 303 , NOT_MODIFIED = 304 , USEPROXY = 305 , TEMPORARY_REDIRECT = 307 ,
  BAD_REQUEST = 400 , UNAUTHORIZED = 401 , PAYMENT_REQUIRED = 402 , FORBIDDEN = 403 ,
  NOT_FOUND = 404 , METHOD_NOT_ALLOWED = 405 , NOT_ACCEPTABLE = 406 , PROXY_AUTHENTICATION_REQUIRED = 407 ,
  REQUEST_TIMEOUT = 408 , CONFLICT = 409 , GONE = 410 , LENGTH_REQUIRED = 411 ,
  PRECONDITION_FAILED = 412 , REQUESTENTITYTOOLARGE = 413 , REQUESTURITOOLONG = 414 , UNSUPPORTEDMEDIATYPE = 415 ,
  REQUESTED_RANGE_NOT_SATISFIABLE = 416 , EXPECTATION_FAILED = 417 , I_AM_A_TEAPOT = 418 , INTERNAL_SERVER_ERROR = 500 ,
  NOT_IMPLEMENTED = 501 , BAD_GATEWAY = 502 , SERVICE_UNAVAILABLE = 503 , GATEWAY_TIMEOUT = 504 ,
  VERSION_NOT_SUPPORTED = 505
}
 
using StringToStringMap = std::map< std::string, std::string >
 
- Protected Attributes inherited from Mantid::Kernel::InternetHelper
std::string m_body
 
std::streamsize m_contentLength
 
std::string m_contentType
 
StringToStringMap m_headers
 
bool m_isProxySet
 
bool m_isTimeoutSet
 
std::string m_method
 
Kernel::ProxyInfo m_proxyInfo
 
std::unique_ptr< Poco::Net::HTTPRequest > m_request
 
std::unique_ptr< Poco::Net::HTTPResponse > m_response
 
int m_timeout
 

Detailed Description

Definition at line 30 of file ONCatHelper.h.

Constructor & Destructor Documentation

◆ MockONCatAPI() [1/2]

Mantid::FrameworkTestHelpers::MockONCatAPI::MockONCatAPI ( )
delete

◆ MockONCatAPI() [2/2]

Mantid::FrameworkTestHelpers::MockONCatAPI::MockONCatAPI ( const MockResponseMap responseMap)

Definition at line 19 of file ONCatHelper.cpp.

References m_responseCallCounts.

◆ ~MockONCatAPI()

Mantid::FrameworkTestHelpers::MockONCatAPI::~MockONCatAPI ( )
overridedefault

Member Function Documentation

◆ allResponsesCalled()

bool Mantid::FrameworkTestHelpers::MockONCatAPI::allResponsesCalled ( ) const

Definition at line 33 of file ONCatHelper.cpp.

References m_responseCallCounts.

◆ allResponsesCalledOnce()

bool Mantid::FrameworkTestHelpers::MockONCatAPI::allResponsesCalledOnce ( ) const

Definition at line 28 of file ONCatHelper.cpp.

References m_responseCallCounts.

◆ sendHTTPRequest()

InternetHelper::HTTPStatus Mantid::FrameworkTestHelpers::MockONCatAPI::sendHTTPRequest ( const std::string &  url,
std::ostream &  responseStream 
)
overrideprotectedvirtual

Performs a request using http.

Parameters
urlthe address to the network resource
responseStreamThe stream to fill with the reply on success

Reimplemented from Mantid::Kernel::InternetHelper.

Definition at line 38 of file ONCatHelper.cpp.

References sendHTTPSRequest().

◆ sendHTTPSRequest()

InternetHelper::HTTPStatus Mantid::FrameworkTestHelpers::MockONCatAPI::sendHTTPSRequest ( const std::string &  url,
std::ostream &  responseStream 
)
overrideprotectedvirtual

Performs a request using https.

Parameters
urlthe address to the network resource
responseStreamThe stream to fill with the reply on success

Reimplemented from Mantid::Kernel::InternetHelper.

Definition at line 42 of file ONCatHelper.cpp.

References m_responseCallCounts, m_responseMap, and Mantid::Kernel::InternetHelper::OK.

Referenced by sendHTTPRequest().

Member Data Documentation

◆ m_responseCallCounts

MockResponseCallCounts Mantid::FrameworkTestHelpers::MockONCatAPI::m_responseCallCounts
private

◆ m_responseMap

MockResponseMap Mantid::FrameworkTestHelpers::MockONCatAPI::m_responseMap
private

Definition at line 44 of file ONCatHelper.h.

Referenced by sendHTTPSRequest().


The documentation for this class was generated from the following files: