TestOutputNode.cpp
Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00027 
00028 #include "../include/TestOutputNode.h"
00029 #include "../../include/PCMFileSystemManager.h"
00030 
00031 namespace ParCompMarkTest
00032 {
00033 
00034   void TestOutputNode::setUp()
00035   {
00036         std::string currentLogFile = "logs/TestOutputNode.log";
00037 
00038         if(Logger::getInstance() && Logger::getInstance()->getLogFileName() != currentLogFile)
00039          Logger::destroyInstance();
00040 
00041         if(!FileSystemManager::getInstance())
00042         {
00043          FileSystemManager::createInstance();
00044          FileSystemManager::getInstance()->setAppDirectory("./");
00045          FileSystemManager::getInstance()->initialize();
00046         }
00047 
00048         if(!Logger::getInstance())
00049         {
00050          Logger::createInstance();
00051          Logger::getInstance()->setLogFileName(currentLogFile);
00052          Logger::getInstance()->initialize();
00053         }
00054   }
00055 
00056  
00057 
00058   void TestOutputNode::tearDown()
00059   {
00060   }
00061 
00062  
00063 
00064   
00065   
00066   
00067 
00068   void TestOutputNode::test_constructor_cstd__string_cNodeType()
00069   {
00070 
00071         
00072 
00073 
00074 
00075 
00076 
00077         
00078         OutputNode *node1 = 0;
00079 
00080         CPPUNIT_ASSERT_NO_THROW(node1 = new OutputNode("name", OutputNode::DEFINITION));
00081         CPPUNIT_ASSERT(node1->mName == "name");
00082         CPPUNIT_ASSERT(node1->mType == OutputNode::DEFINITION);
00083         CPPUNIT_ASSERT(node1->mText == "");
00084         CPPUNIT_ASSERT_NO_THROW(delete node1);
00085 
00086         
00087         OutputNode::Pointer node2;
00088 
00089         CPPUNIT_ASSERT_NO_THROW(node2 = new OutputNode("name", OutputNode::DEFINITION));
00090         CPPUNIT_ASSERT(node2->mName == "name");
00091         CPPUNIT_ASSERT(node2->mType == OutputNode::DEFINITION);
00092         CPPUNIT_ASSERT(node2->mText == "");
00093   }
00094 
00095  
00096 
00097   void TestOutputNode::test_constructor_cstd__string()
00098   {
00099 
00100         
00101 
00102 
00103 
00104 
00105 
00106         
00107         OutputNode *node1 = 0;
00108 
00109         CPPUNIT_ASSERT_NO_THROW(node1 = new OutputNode("This is the text."));
00110         CPPUNIT_ASSERT(node1->mName == OutputNode::TEXTNODENAME);
00111         CPPUNIT_ASSERT(node1->mType == OutputNode::TEXT);
00112         CPPUNIT_ASSERT(node1->mText == "This is the text.");
00113         CPPUNIT_ASSERT_NO_THROW(delete node1);
00114 
00115         
00116         OutputNode::Pointer node2;
00117 
00118         CPPUNIT_ASSERT_NO_THROW(node2 = new OutputNode("This is the text."));
00119         CPPUNIT_ASSERT(node2->mName == OutputNode::TEXTNODENAME);
00120         CPPUNIT_ASSERT(node2->mType == OutputNode::TEXT);
00121         CPPUNIT_ASSERT(node2->mText == "This is the text.");
00122   }
00123 
00124  
00125 
00126   void TestOutputNode::test_destructor()
00127   {
00128         
00129   }
00130 
00131  
00132 
00133   
00134   
00135   
00136 
00137   void TestOutputNode::test_parseFromXML_std__string()
00138   {
00139 
00140         
00141 
00142 
00143 
00144 
00145 
00146         CPPUNIT_FAIL("Implement this test!");
00147   }
00148 
00149  
00150 
00151   void TestOutputNode::test__testXMLName_cstd__string()
00152   {
00153 
00154         
00155 
00156 
00157 
00158 
00159 
00160         CPPUNIT_FAIL("Implement this test!");
00161   }
00162 
00163  
00164 
00165   void TestOutputNode::test__convertSpecialChars_cstd__string()
00166   {
00167 
00168         
00169 
00170 
00171 
00172 
00173 
00174         CPPUNIT_FAIL("Implement this test!");
00175   }
00176 
00177  
00178 
00179   
00180   
00181   
00182 
00183   void TestOutputNode::test_createChildNode_cstd__string_cNodeType()
00184   {
00185 
00186         
00187 
00188 
00189 
00190 
00191 
00192         OutputNode::Pointer parent, child;
00193 
00194         
00195         CPPUNIT_ASSERT_NO_THROW(parent = new OutputNode("parent", OutputNode::DEFINITION));
00196         CPPUNIT_ASSERT_NO_THROW(child = parent->createChildNode("child", OutputNode::INFORMATION));
00197         CPPUNIT_ASSERT(child->mName == "child");
00198         CPPUNIT_ASSERT(child->mType == OutputNode::INFORMATION);
00199         CPPUNIT_ASSERT(child->mText == "");
00200 
00201         
00202         CPPUNIT_ASSERT_NO_THROW(parent->createChildNode("child2", OutputNode::INFORMATION));
00203 
00204         
00205         CPPUNIT_ASSERT_NO_THROW(parent = new OutputNode("This is a text."));
00206         CPPUNIT_ASSERT_THROW(parent->createChildNode("child", OutputNode::INFORMATION), ParCompMark::Exception);
00207   }
00208 
00209  
00210 
00211   void TestOutputNode::test_createChildNode_cstd__string()
00212   {
00213 
00214         
00215 
00216 
00217 
00218 
00219 
00220         OutputNode::Pointer parent, child;
00221 
00222         
00223         CPPUNIT_ASSERT_NO_THROW(parent = new OutputNode("parent", OutputNode::DEFINITION));
00224         CPPUNIT_ASSERT_NO_THROW(child = parent->createChildNode("This is a text."));
00225         CPPUNIT_ASSERT(child->mName == OutputNode::TEXTNODENAME);
00226         CPPUNIT_ASSERT(child->mType == OutputNode::TEXT);
00227         CPPUNIT_ASSERT(child->mText == "This is a text.");
00228 
00229         
00230         CPPUNIT_ASSERT_NO_THROW(parent = new OutputNode("This is a text."));
00231         CPPUNIT_ASSERT_THROW(parent->createChildNode("This is a text."), ParCompMark::Exception);
00232   }
00233 
00234  
00235 
00236   void TestOutputNode::test_addChildNode_OutputNode__Pointer()
00237   {
00238 
00239         
00240 
00241 
00242 
00243 
00244 
00245         OutputNode::Pointer parent, child1, child2;
00246 
00247         
00248         CPPUNIT_ASSERT_NO_THROW(child1 = new OutputNode("child", OutputNode::INFORMATION));
00249 
00250         
00251         CPPUNIT_ASSERT_NO_THROW(child2 = new OutputNode("This is a text."));
00252 
00253         
00254         CPPUNIT_ASSERT_NO_THROW(parent = new OutputNode("parent", OutputNode::DEFINITION));
00255 
00256         
00257         CPPUNIT_ASSERT_NO_THROW(parent->addChildNode(child1));
00258         CPPUNIT_ASSERT_NO_THROW(parent->addChildNode(child2));
00259 
00260         
00261         CPPUNIT_ASSERT_THROW(parent->addChildNode(parent), ParCompMark::Exception);
00262 
00263         
00264         CPPUNIT_ASSERT_NO_THROW(parent = new OutputNode("This is a text."));
00265         CPPUNIT_ASSERT_THROW(parent->addChildNode(child1), ParCompMark::Exception);
00266         CPPUNIT_ASSERT_THROW(parent->addChildNode(child2), ParCompMark::Exception);
00267   }
00268 
00269  
00270 
00271   void TestOutputNode::test_getChildCount()
00272   {
00273 
00274         
00275 
00276 
00277 
00278 
00279 
00280         CPPUNIT_FAIL("Implement this test!");
00281   }
00282 
00283  
00284 
00285   void TestOutputNode::test_getFirstChildNode()
00286   {
00287 
00288         
00289 
00290 
00291 
00292 
00293 
00294         CPPUNIT_FAIL("Implement this test!");
00295   }
00296 
00297  
00298 
00299   void TestOutputNode::test_hasAttribute_cstd__string()
00300   {
00301 
00302         
00303 
00304 
00305 
00306 
00307 
00308         
00309         OutputNode::Pointer node;
00310 
00311         CPPUNIT_ASSERT_NO_THROW(node = new OutputNode("node", OutputNode::DEFINITION));
00312         CPPUNIT_ASSERT(!node->hasAttribute("attribute"));
00313 
00314         
00315         CPPUNIT_ASSERT_NO_THROW(node = new OutputNode("This is a text."));
00316         CPPUNIT_ASSERT_THROW(node->hasAttribute("attribute"), ParCompMark::Exception);
00317 
00318         
00319   }
00320 
00321  
00322 
00323   void TestOutputNode::test_getAttribute_cstd__string()
00324   {
00325 
00326         
00327 
00328 
00329 
00330 
00331 
00332         
00333         OutputNode::Pointer node;
00334 
00335         CPPUNIT_ASSERT_NO_THROW(node = new OutputNode("node", OutputNode::DEFINITION));
00336         CPPUNIT_ASSERT_THROW(node->getAttribute("attribute"), ParCompMark::Exception);
00337 
00338         
00339         CPPUNIT_ASSERT_NO_THROW(node = new OutputNode("This is a text."));
00340         CPPUNIT_ASSERT_THROW(node->getAttribute("attribute"), ParCompMark::Exception);
00341 
00342         
00343   }
00344 
00345  
00346 
00347   void TestOutputNode::test_setAttribute_cstd__string_cstd__string()
00348   {
00349 
00350         
00351 
00352 
00353 
00354 
00355 
00356         
00357         OutputNode::Pointer node;
00358 
00359         CPPUNIT_ASSERT_NO_THROW(node = new OutputNode("node", OutputNode::DEFINITION));
00360         CPPUNIT_ASSERT(!node->hasAttribute("attribute"));
00361         CPPUNIT_ASSERT_NO_THROW(node->setAttribute("attribute", "value"));
00362         CPPUNIT_ASSERT(node->hasAttribute("attribute"));
00363         CPPUNIT_ASSERT(node->getAttribute("attribute") == "value");
00364         CPPUNIT_ASSERT_NO_THROW(node->setAttribute("attribute", "another value"));
00365         CPPUNIT_ASSERT(node->hasAttribute("attribute"));
00366         CPPUNIT_ASSERT(node->getAttribute("attribute") == "another value");
00367   }
00368 
00369  
00370 
00371   void TestOutputNode::test_serialize2XML_std__ostringstream()
00372   {
00373 
00374         
00375 
00376 
00377 
00378 
00379 
00380         OutputNode::Pointer node, child;
00381         std::ostringstream osstr1, osstr2;
00382         osstr1 << "testing ";
00383 
00384         
00385         CPPUNIT_ASSERT_NO_THROW(node = new OutputNode("This is a text."));
00386         CPPUNIT_ASSERT(node->serialize2XML(osstr1).str() == "testing This is a text.");
00387         CPPUNIT_ASSERT(node->serialize2XML(osstr1).str() == "testing This is a text.This is a text.");
00388 
00389         
00390         CPPUNIT_ASSERT_NO_THROW(node = new OutputNode("parent", OutputNode::DEFINITION));
00391         CPPUNIT_ASSERT_NO_THROW(node->setAttribute("attribute1", "value1"));
00392         CPPUNIT_ASSERT_NO_THROW(node->setAttribute("attribute2", "value2"));
00393         CPPUNIT_ASSERT_NO_THROW(child = node->createChildNode("child1", OutputNode::INFORMATION));
00394         CPPUNIT_ASSERT_NO_THROW(child = node->createChildNode("child2", OutputNode::STATISTICS));
00395         CPPUNIT_ASSERT_NO_THROW(child->setAttribute("attribute3", "value3"));
00396         CPPUNIT_ASSERT(node->serialize2XML(osstr2).str() ==
00397                    "<def:parent attribute1=\"value1\" attribute2=\"value2\"><info:child1/><stat:child2 attribute3=\"value3\"/></def:parent>");
00398 
00399   }
00400 
00401  
00402 
00403   void TestOutputNode::test_serialize2XML()
00404   {
00405 
00406         
00407 
00408 
00409 
00410 
00411 
00412         
00413   }
00414 
00415  
00416 
00417   void TestOutputNode::test_refreshData()
00418   {
00419 
00420         
00421 
00422 
00423 
00424 
00425 
00426         
00427   }
00428 
00429  
00430 
00431   void TestOutputNode::test_clean()
00432   {
00433 
00434         
00435 
00436 
00437 
00438 
00439 
00440         CPPUNIT_FAIL("Implement this test!");
00441   }
00442 
00443  
00444 
00445   
00447   CPPUNIT_TEST_SUITE_REGISTRATION(TestOutputNode);
00448 }