00001 00002 #include <string> 00003 #include <iostream> 00004 #include <xmlrpc-c/base.hpp> 00005 #include <xmlrpc-c/client_simple.hpp> 00006 #define XMLRPC_C 00007 #include "tools.h" 00008 #include "mdClientBehavior.h" 00009 #include "mdClientDevice.h" 00010 #include "mdClientState.h" 00011 00012 #define MD_SERVER_URL "http://localhost:4243/RPC2" 00013 #define DEFAULT_DEVICE "ALX" 00014 #define EXPECTED_MACHINE_HANDLE 1 00015 #define PAUSE_SECS 3 00016 00017 #ifdef MDCLIENTMAIN 00018 00019 bool doSanityCheck = false, repeatableOnly = false; 00020 00021 xmlrpc_env env; 00022 xmlrpc_c::clientXmlTransport_libwww myTransport; 00023 xmlrpc_c::client_xml myClient(&myTransport); 00024 XmlRpcValue::int32 mdServerHandle = 0; 00025 00026 int pauseSecs=0; 00027 const char *defaultDevice,*serverURL; 00028 std::string phase; 00029 00030 #else 00031 00032 extern bool doSanityCheck, repeatableOnly; 00033 00034 extern xmlrpc_env env; 00035 extern xmlrpc_c::clientXmlTransport_libwww myTransport; 00036 extern xmlrpc_c::client_xml myClient; 00037 extern XmlRpcValue::int32 mdServerHandle; 00038 extern const char *defaultDevice,*serverURL; 00039 extern int pauseSecs; 00040 extern std::string phase; 00041 00042 #endif 00043 00044 class mdCoreAPITestSuite : public testSuite { 00045 00046 /*---------------------------------------------------------------------------- 00047 The object of this class tests the MD core API. 00048 00049 Some day, we would like to automate its generate 00050 with that of the client objects it tests. 00051 00052 Unlike the "new" xmlrpc-c test style, we do count 00053 successes and failures and attempt to execute the 00054 entire suite. 00055 -----------------------------------------------------------------------------*/ 00056 public: 00057 00058 mdClientState *testState; 00059 mdClientDevice *thisClient; 00060 mdClientBehavior *testBehavior; 00061 00062 virtual std::string suiteName() { 00063 return "Phase I UAT Suite"; 00064 } 00065 void bucket00(char const *title) { 00066 00067 std::cout << "\nTest Bucket: " << title << std::endl; 00068 TEST(mdServerHandle = thisClient->registeR( 0, defaultDevice)); 00069 00070 } 00071 void bucket01(char const *title); 00072 void bucket02(char const *title); 00073 void bucket03(char const *title); 00074 void bucket04(char const *title); 00075 void bucket05(char const *title); 00076 void bucket06(char const *title); 00077 00078 virtual void runtests(unsigned int const) { 00079 00080 char testContext[256]; 00081 mdClientState mdState(serverURL); 00082 mdClientDevice mdClient(serverURL); 00083 mdClientBehavior mdBehavior(serverURL); 00084 00085 testState = &mdState; 00086 thisClient = &mdClient; 00087 testBehavior = &mdBehavior; 00088 00089 tests = failures = 0; 00090 00091 sprintf(testContext,"Get handle for device: %s to test against: %s\n",defaultDevice,serverURL); 00092 if (!mdServerHandle) 00093 bucket00(testContext); 00094 bucket01("Check predefined observables access.\n"); 00095 bucket02("Check for required SCPI subsystems for the selected device.\n"); 00096 if (!repeatableOnly) 00097 bucket03("Check dynamic definition of remaining specified observables.\n"); 00098 bucket04("Check event/rule mechanism.\n"); 00099 bucket05("Check SCPI execution.\n"); 00100 bucket06("Check datagram layer operations.\n"); 00101 00102 } 00103 }; 00104
1.5.6