Back to index

nordugrid-arc-nox  1.1.0~rc6
InformationInterfaceTest.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 
00008 #include <cppunit/extensions/HelperMacros.h>
00009 
00010 #include <arc/infosys/InformationInterface.h>
00011 
00012 
00013 class InformationInterfaceTest
00014   : public CppUnit::TestFixture {
00015 
00016   CPPUNIT_TEST_SUITE(InformationInterfaceTest);
00017   CPPUNIT_TEST(TestInformationInterface);
00018   CPPUNIT_TEST_SUITE_END();
00019 
00020 public:
00021   void setUp();
00022   void tearDown();
00023   void TestInformationInterface();
00024 };
00025 
00026 
00027 void InformationInterfaceTest::setUp() {
00028 }
00029 
00030 
00031 void InformationInterfaceTest::tearDown() {
00032 }
00033 
00034 
00035 void InformationInterfaceTest::TestInformationInterface() {
00036 
00037   // Service description document
00038   Arc::XMLNode infodoc("\
00039 <?xml version=\"1.0\"?>\n\
00040 <InfoDoc xmlns=\"urn:info\">\n\
00041   <Resource>\n\
00042     <Memory>A lot</Memory>\n\
00043     <Performance>Turltle-like</Performance>\n\
00044   </Resource>\n\
00045   <Owner>\n\
00046       <Name>Unknown</Name>\n\
00047   </Owner>\n\
00048   <Resource>\n\
00049       <Memory>640kb enough for everyone</Memory>\n\
00050       <Performance>Quantum computer</Performance>\n\
00051   </Resource>\n\
00052 </InfoDoc>\n");
00053 
00054   // Creating service container
00055   Arc::InformationContainer container(infodoc);
00056   //std::cout<<"Document:\n"<<doc<<std::endl;
00057 
00058   // Creating client request
00059   std::list<std::string> name;
00060   name.push_back("Resource");
00061   //std::cout<<"Request for elements: "<<*(name.begin())<<std::endl;
00062   Arc::InformationRequest request(name);
00063   CPPUNIT_ASSERT((bool)request);
00064 
00065   // Processing request at server side
00066   Arc::SOAPEnvelope* response = container.Process(*(request.SOAP()));
00067   CPPUNIT_ASSERT(response);
00068   CPPUNIT_ASSERT((bool)*response);
00069 
00070   // Extracting result at client
00071   Arc::InformationResponse res(*response);
00072   CPPUNIT_ASSERT((bool)res);
00073 
00074   std::list<Arc::XMLNode> results = res.Result();
00075   CPPUNIT_ASSERT_EQUAL((int)results.size(), int(2));
00076   std::list<Arc::XMLNode>::iterator r = results.begin();
00077   CPPUNIT_ASSERT_EQUAL((std::string)(*r)["Memory"], std::string("A lot"));
00078   ++r;
00079   CPPUNIT_ASSERT_EQUAL((std::string)(*r)["Performance"], std::string("Quantum computer"));
00080 }
00081 
00082 CPPUNIT_TEST_SUITE_REGISTRATION(InformationInterfaceTest);
00083