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 ()
 
- Public Member Functions inherited from Mantid::Kernel::InternetHelper
void addHeader (const std::string &key, const std::string &value)
 Adds a header. More...
 
void clearHeaders ()
 Clears all headers. More...
 
void clearProxy ()
 Clears cached proxy details. More...
 
virtual HTTPStatus downloadFile (const std::string &urlFile, const std::string &localFilePath="")
 Download a url and fetch it inside the local path given. More...
 
const std::string & getBody ()
 Gets the body set for future requests. More...
 
std::streamsize getContentLength ()
 Gets the content length. More...
 
const std::string & getContentType ()
 Gets the Content Type. More...
 
const std::string & getHeader (const std::string &key)
 Gets the value of a header. More...
 
const std::string & getMethod ()
 Gets the method. More...
 
Kernel::ProxyInfogetProxy (const std::string &url)
 Gets proxy details for a system and a url. More...
 
const std::string & getResponseReason ()
 Gets the body set for future requests. More...
 
HTTPStatus getResponseStatus ()
 Gets the body set for future requests. More...
 
int getTimeout ()
 Gets the timeout in seconds. More...
 
StringToStringMapheaders ()
 Returns a reference to the headers map. More...
 
 InternetHelper ()
 Constructor. More...
 
 InternetHelper (const Kernel::ProxyInfo &proxy)
 Constructor. More...
 
void removeHeader (const std::string &key)
 Removes a header. More...
 
virtual void reset ()
 Resets properties to defaults (except the proxy) More...
 
virtual HTTPStatus sendRequest (const std::string &url, std::ostream &responseStream)
 Performs a request using http or https depending on the url. More...
 
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. More...
 
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. More...
 
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. More...
 
void setContentLength (std::streamsize length)
 Sets the content length. More...
 
void setContentType (const std::string &contentType)
 Sets the Content Type. More...
 
void setMethod (const std::string &method)
 Sets the Method. More...
 
void setProxy (const Kernel::ProxyInfo &proxy)
 sets the proxy details. More...
 
void setTimeout (int seconds)
 Sets the timeout in seconds. More...
 
virtual ~InternetHelper ()
 Destructor. More...
 

Protected Member Functions

InternetHelper::HTTPStatus sendHTTPRequest (const std::string &url, std::ostream &responseStream) override
 Performs a request using http. More...
 
InternetHelper::HTTPStatus sendHTTPSRequest (const std::string &url, std::ostream &responseStream) override
 Performs a request using https. More...
 
- 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. More...
 
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.). More...
 
virtual HTTPStatus processErrorStates (const Poco::Net::HTTPResponse &res, std::istream &rs, const std::string &url)
 Process any HTTP errors states. More...
 
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. More...
 
virtual HTTPStatus sendHTTPRequest (const std::string &url, std::ostream &responseStream)
 Performs a request using http. More...
 
virtual HTTPStatus sendHTTPSRequest (const std::string &url, std::ostream &responseStream)
 Performs a request using https. More...
 
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. More...
 

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 ( )
default

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: