ReactOS 0.4.16-dev-1946-g52006dd
CWebService Class Referenceabstract

#include <CWebService.h>

Inheritance diagram for CWebService:

Public Member Functions

 CWebService ()
 
virtual ~CWebService ()
 
void Finish (const char *TestType)
 
void Submit (const char *TestType, CTestInfo *TestInfo)
 

Private Member Functions

virtual PCHAR DoRequest (const char *Hostname, INTERNET_PORT Port, const char *ServerFile, const string &InputData)=0
 
void GetTestID (const char *TestType)
 
PCHAR GetSuiteID (const char *TestType, CTestInfo *TestInfo)
 

Private Attributes

PCHAR m_TestID
 

Detailed Description

Definition at line 8 of file CWebService.h.

Constructor & Destructor Documentation

◆ CWebService()

CWebService::CWebService ( )

Constructs a CWebService object and immediately establishes a connection to the "testman" Web Service.

Definition at line 17 of file CWebService.cpp.

18{
19 /* Zero-initialize variables */
20 m_TestID = NULL;
21}
PCHAR m_TestID
Definition: CWebService.h:11
#define NULL
Definition: types.h:112

◆ ~CWebService()

CWebService::~CWebService ( )
virtual

Destructs a CWebService object and closes all connections to the Web Service.

Definition at line 26 of file CWebService.cpp.

27{
28 if(m_TestID)
29 delete m_TestID;
30}

Member Function Documentation

◆ DoRequest()

virtual PCHAR CWebService::DoRequest ( const char Hostname,
INTERNET_PORT  Port,
const char ServerFile,
const string InputData 
)
privatepure virtual

Implemented in CWebServiceLibCurl, and CWebServiceWinInet.

Referenced by Finish(), GetSuiteID(), GetTestID(), and Submit().

◆ Finish()

void CWebService::Finish ( const char TestType)

Interface to other classes for finishing this test run

Parameters
TestTypeConstant pointer to a char array containing the test type to be run (i.e. "wine")

Definition at line 39 of file CWebService.cpp.

40{
42 string Data;
44
45 if (!m_TestID)
46 EXCEPTION("CWebService::Finish was called, but not a single result had been submitted!\n");
47
48 Data = "action=finish";
49 Data += Configuration.GetAuthenticationRequestString();
50 Data += "&testtype=";
51 Data += TestType;
52 Data += "&testid=";
53 Data += m_TestID;
54
56
57 if (strcmp(Response, "OK"))
58 {
59 ss << "When finishing the test run, the server responded:" << endl << Response << endl;
61 }
62}
static const CHAR szServerFile[]
Definition: CWebService.cpp:12
static const CHAR szHostname[]
Definition: CWebService.cpp:10
static const INTERNET_PORT ServerPort
Definition: CWebService.cpp:11
basic_ostream< _CharT, _Traits > &_STLP_CALL endl(basic_ostream< _CharT, _Traits > &__os)
Definition: _ostream.h:357
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
virtual PCHAR DoRequest(const char *Hostname, INTERNET_PORT Port, const char *ServerFile, const string &InputData)=0
#define ss
Definition: i386-dis.c:441
#define SSEXCEPTION
Definition: precomp.h:60
#define EXCEPTION(Message)
Definition: precomp.h:58
Definition: ncftp.h:89
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_INTERRUPT_CONFIG Configuration
Definition: wdfinterrupt.h:374

◆ GetSuiteID()

PCHAR CWebService::GetSuiteID ( const char TestType,
CTestInfo TestInfo 
)
private

Gets a Suite ID from the Web Service for this module/test combination.

Parameters
TestTypeConstant pointer to a char array containing the test type to be run (i.e. "wine")
TestInfoPointer to a CTestInfo object containing information about the test
Returns
Returns a pointer to a char array containing the Suite ID received from the Web Service. The caller needs to free that pointer.

Definition at line 113 of file CWebService.cpp.

114{
115 auto_array_ptr<char> SuiteID;
116 string Data;
117
118 Data = "action=getsuiteid";
119 Data += Configuration.GetAuthenticationRequestString();
120 Data += "&testtype=";
121 Data += TestType;
122 Data += "&module=";
123 Data += TestInfo->Module;
124 Data += "&test=";
125 Data += TestInfo->Test;
126
128
129 /* Verify that this is really a number */
130 if(!IsNumber(SuiteID))
131 {
133
134 ss << "Expected Suite ID, but received:" << endl << SuiteID << endl;
136 }
137
138 return SuiteID.release();
139}
string Module
Definition: CTestInfo.h:12
string Test
Definition: CTestInfo.h:13
Type * release()
void reset(Type *Ptr=0)
bool IsNumber(const char *Input)
Definition: tools.cpp:74

Referenced by Submit().

◆ GetTestID()

void CWebService::GetTestID ( const char TestType)
private

Requests a Test ID from the Web Service for our test run.

Parameters
TestTypeConstant pointer to a char array containing the test type to be run (i.e. "wine")

Definition at line 71 of file CWebService.cpp.

72{
73 string Data;
74
75 Data = "action=gettestid";
76 Data += Configuration.GetAuthenticationRequestString();
77 Data += Configuration.GetSystemInfoRequestString();
78 Data += "&testtype=";
79 Data += TestType;
80
81 if(!Configuration.GetComment().empty())
82 {
83 Data += "&comment=";
84 Data += Configuration.GetComment();
85 }
86
88
89 /* Verify that this is really a number */
90 if(!IsNumber(m_TestID))
91 {
93
94 ss << "Expected Test ID, but received:" << endl << m_TestID << endl;
96 }
97}

Referenced by Submit().

◆ Submit()

void CWebService::Submit ( const char TestType,
CTestInfo TestInfo 
)

Interface to other classes for submitting a result of one test

Parameters
TestTypeConstant pointer to a char array containing the test type to be run (i.e. "wine")
TestInfoPointer to a CTestInfo object containing information about the test

Definition at line 151 of file CWebService.cpp.

152{
154 auto_array_ptr<char> SuiteID;
155 string Data;
157
158 if(!m_TestID)
159 GetTestID(TestType);
160
161 SuiteID.reset(GetSuiteID(TestType, TestInfo));
162
163 Data = "action=submit";
164 Data += Configuration.GetAuthenticationRequestString();
165 Data += "&testtype=";
166 Data += TestType;
167 Data += "&testid=";
168 Data += m_TestID;
169 Data += "&suiteid=";
170 Data += SuiteID;
171 Data += "&log=";
172 Data += EscapeString(TestInfo->Log);
173
175
176 if (strcmp(Response, "OK"))
177 {
178 ss << "When submitting the result, the server responded:" << endl << Response << endl;
180 }
181}
string Log
Definition: CTestInfo.h:14
void GetTestID(const char *TestType)
Definition: CWebService.cpp:71
PCHAR GetSuiteID(const char *TestType, CTestInfo *TestInfo)
string EscapeString(const char *Input)
Definition: tools.cpp:24

Member Data Documentation

◆ m_TestID

PCHAR CWebService::m_TestID
private

Definition at line 11 of file CWebService.h.

Referenced by CWebService(), Finish(), GetTestID(), Submit(), and ~CWebService().


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