Back to index

nordugrid-arc-nox  1.1.0~rc6
RegisteredServiceTest.cpp
Go to the documentation of this file.
00001 #ifdef HAVE_CONFIG_H
00002 #include <config.h>
00003 #endif
00004 
00005 #include <iostream>
00006 #include <string>
00007 #include <fstream>
00008 
00009 #include <cppunit/extensions/HelperMacros.h>
00010 
00011 #include <arc/ArcConfig.h>
00012 #include <arc/message/SOAPEnvelope.h>
00013 #include <arc/message/PayloadRaw.h>
00014 #include <arc/infosys//RegisteredService.h>
00015 
00016 
00017 class RegisteredServiceTest
00018   : public CppUnit::TestFixture {
00019 
00020   CPPUNIT_TEST_SUITE(RegisteredServiceTest);
00021   CPPUNIT_TEST(TestRegisteredService);
00022   CPPUNIT_TEST_SUITE_END();
00023 
00024 public:
00025   void setUp();
00026   void tearDown();
00027   void TestRegisteredService();
00028 };
00029 
00030 static const char* xml_str = "\
00031 <?xml version=\"1.0\" encoding=\"UTF-8\"?>\
00032 <SOAP-ENV:Envelope \
00033 xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" \
00034 xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" \
00035 xmlns:a-rex=\"http://www.nordugrid.org/schemas/a-rex\" \
00036 xmlns:bes-factory=\"http://schemas.ggf.org/bes/2006/08/bes-factory\" \
00037 xmlns:jsdl=\"http://schemas.ggf.org/jsdl/2005/11/jsdl\" \
00038 xmlns:wsa=\"http://www.w3.org/2005/08/addressing\" \
00039 xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" \
00040 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><SOAP-ENV:Body><bes-factory:CreateActivity><bes-factory:ActivityDocument><JobDefinition xmlns=\"http://schemas.ggf.org/jsdl/2005/11/jsdl\"> \
00041     <JobDescription> \
00042         <JobIdentification> \
00043             <JobName>Demo</JobName> \
00044             <JobProject>HPCPInterop</JobProject> \
00045         </JobIdentification> \
00046         <Application> \
00047             <HPCProfileApplication xmlns=\"http://schemas.ggf.org/jsdl/2006/07/jsdl-hpcpa\"> \
00048                 <Executable>/home/interop/demo_job.sh</Executable> \
00049                 <Argument>60</Argument> \
00050                 <Output>demo_job.out.%J</Output> \
00051                 <WorkingDirectory>/home/interop/username</WorkingDirectory> \
00052             </HPCProfileApplication> \
00053         </Application> \
00054         <Resources> \
00055             <TotalCPUCount> \
00056                 <Exact>1</Exact> \
00057             </TotalCPUCount> \
00058         </Resources> \
00059     </JobDescription> \
00060 </JobDefinition></bes-factory:ActivityDocument></bes-factory:CreateActivity></SOAP-ENV:Body></SOAP-ENV:Envelope>";
00061 
00062   class MyRegisteredService: public Arc::RegisteredService
00063   {
00064       public:
00066           MyRegisteredService(Arc::Config* cfg):RegisteredService(cfg) 
00067                       { std::cout << "My Service called!" << std::endl;
00068                         // VERBOSE                    
00069                         std::string config_str;
00070                         cfg->GetXML(config_str, true);
00071                         logger.msg(Arc::VERBOSE, "The config: \n%s \n", config_str);
00072                       };
00073 
00074           virtual ~MyRegisteredService(void) { };
00075           virtual Arc::MCC_Status process(Arc::Message&,Arc::Message&) {return Arc::MCC_Status(Arc::STATUS_OK);};
00076   };
00077 
00078 
00079 void RegisteredServiceTest::setUp() {
00080 }
00081 
00082 
00083 void RegisteredServiceTest::tearDown() {
00084 }
00085 
00086 
00087 void RegisteredServiceTest::TestRegisteredService() {
00088   Arc::Logger logger(Arc::Logger::rootLogger, "RegisteredService-Test");
00089   Arc::LogStream logcerr(std::cerr);
00090   Arc::Logger::rootLogger.addDestination(logcerr);
00091 
00092   Arc::SOAPEnvelope soap(xml_str);
00093 
00094 
00095   Arc::MessagePayload *m = new Arc::PayloadRaw();
00096 
00097   std::string cfg_str="";
00098   cfg_str +="\n";
00099   cfg_str +="    <ArcConfig\n";
00100   cfg_str +="      xmlns=\"http://www.nordugrid.org/schemas/ArcConfig/2007\"\n";
00101   cfg_str +="      xmlns:tcp=\"http://www.nordugrid.org/schemas/ArcMCCTCP/2007\">\n";
00102   cfg_str +="     <ModuleManager>\n";
00103   cfg_str +="        <Path>.libs/</Path>\n";
00104   cfg_str +="        <Path>../../hed/mcc/http/.libs/</Path>\n";
00105   cfg_str +="        <Path>../../hed/mcc/soap/.libs/</Path>\n";
00106   cfg_str +="        <Path>../../hed/mcc/tls/.libs/</Path>\n";
00107   cfg_str +="        <Path>../../hed/mcc/tcp/.libs/</Path>\n";
00108   cfg_str +="     </ModuleManager>\n";
00109   cfg_str +="     <Plugins><Name>mcctcp</Name></Plugins>\n";
00110   cfg_str +="     <Plugins><Name>mcctls</Name></Plugins>\n";
00111   cfg_str +="     <Plugins><Name>mcchttp</Name></Plugins>\n";
00112   cfg_str +="     <Plugins><Name>mccsoap</Name></Plugins>\n";
00113   cfg_str +="     <Chain>\n";
00114   cfg_str +="      <Component name='tcp.client' id='tcp'><tcp:Connect><tcp:Host>knowarc1.grid.niif.hu</tcp:Host><tcp:Port>50000</tcp:Port></tcp:Connect></Component>\n";
00115   cfg_str +="      <Component name='http.client' id='http'><next id='tcp'/><Method>POST</Method><Endpoint>echo</Endpoint></Component>\n";
00116   cfg_str +="      <Component name='soap.client' id='soap' entry='soap'><next id='http'/></Component>\n";
00117   cfg_str +="     </Chain>\n";
00118   cfg_str +="    </ArcConfig>";
00119   
00120   Arc::Config cfg(cfg_str);
00121   MyRegisteredService myservice(&cfg);
00122 
00123   CPPUNIT_ASSERT(true);
00124 }
00125 
00126 
00127 CPPUNIT_TEST_SUITE_REGISTRATION(RegisteredServiceTest);
00128