TestNetServer.cpp

Go to the documentation of this file.
00001 
00002 //
00003 // This source file is a part of ParCompMark
00004 // Parallel Compositing Benchmark Framework
00005 //
00006 // for latest info see http://parcompmark.sourceforge.net
00007 
00008 //
00009 // Copyright (C) 2006 IT2 ParCompMark Dev. Team
00010 // 
00011 // This program is free software; you can redistribute it and/or
00012 // modify it under the terms of the GNU General Public License
00013 // as published by the Free Software Foundation; either version 2
00014 // of the License, or (at your option) any later version.
00015 // 
00016 // This program is distributed in the hope that it will be useful,
00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00019 // GNU General Public License for more details.
00020 // 
00021 // You should have received a copy of the GNU General Public License
00022 // along with this program; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00024 
00027 
00028 #include "../include/TestNetServer.h"
00029 
00030 namespace ParCompMarkTest
00031 {
00032 
00033   void TestNetServer::setUp()
00034   {
00035 
00036         std::string currentLogFile = "logs/TestNetServer.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 
00059   void TestNetServer::tearDown()
00060   {
00061   }
00062 
00063  /*----------------------------------------------------------------------*/
00064 
00065   //
00066   // Constructor & destructor tests
00067   //
00068 
00069   void TestNetServer::test_constructor_cstd__string()
00070   {
00071 
00072         /*
00073          * You have to verify the following:
00074          * 
00075          * Create network class.
00076          */
00077 
00078         NetServer::Pointer server;
00079 
00080         CPPUNIT_ASSERT_NO_THROW(server = new NetServer("Server"));
00081         Timer::sleep(0.2);
00082         CPPUNIT_ASSERT_NO_THROW(server.kill());
00083 
00084         CPPUNIT_ASSERT_NO_THROW(server = new NetServer("Server"));
00085         CPPUNIT_ASSERT_NO_THROW(server.kill());
00086   }
00087 
00088  /*----------------------------------------------------------------------*/
00089 
00090   void TestNetServer::test_destructor()
00091   {
00092 
00093         //Tested in constructor
00094   }
00095 
00096  /*----------------------------------------------------------------------*/
00097 
00098   //
00099   // Method tests
00100   //
00101 
00102   void TestNetServer::test_initialize()
00103   {
00104 
00105         /*
00106          * You have to verify the following:
00107          * 
00108          * Initialize the class (server thread, broadcast send).
00109          */
00110 
00111         //Tested in constructor
00112   }
00113 
00114  /*----------------------------------------------------------------------*/
00115 
00116   void TestNetServer::test_finalize()
00117   {
00118 
00119         /*
00120          * You have to verify the following:
00121          * 
00122          * Initialize the class (broadcast recieve thread).
00123          */
00124 
00125         //Tested in constructor
00126   }
00127 
00128  /*----------------------------------------------------------------------*/
00129 
00130   void TestNetServer::test_sendBroadcastMessage_cstd__string_cstd__string()
00131   {
00132 
00133         /*
00134          * You have to verify the following:
00135          * 
00136          * Send a broadcast message.
00137          */
00138 
00139         NetServer::Pointer server(new NetServer("Server"));
00140         NetClient::Pointer client(new NetClient("Client"));
00141 
00142         server->startThread();
00143         client->startThread();
00144 
00145         Timer::sleep(0.2);
00146 
00147         CPPUNIT_ASSERT_NO_THROW(server->sendBroadcastMessage("LOGIN", "152.66.243.165"));
00148 
00149         Timer::sleep(1.0);
00150 
00151   }
00152 
00153  /*----------------------------------------------------------------------*/
00154 
00155   void TestNetServer::test_buildCluster()
00156   {
00157 
00158         /*
00159          * You have to verify the following:
00160          * 
00161          * Build cluster information.
00162          */
00163 
00179   }
00180 
00181  /*----------------------------------------------------------------------*/
00182 
00183   void TestNetServer::test_task()
00184   {
00185 
00186         /*
00187          * You have to verify the following:
00188          * 
00189          * Thread for accept TCP/IP connection.
00190          */
00191 
00192         CPPUNIT_FAIL("Implement this test!");
00193   }
00194 
00195  /*----------------------------------------------------------------------*/
00196 
00197   // To register the suite we add:
00199   CPPUNIT_TEST_SUITE_REGISTRATION(TestNetServer);
00200 }