|
From: <mik...@us...> - 2003-12-30 10:45:14
|
Update of /cvsroot/sharedaemon/sharedaemon-ui-web/src/test
In directory sc8-pr-cvs1:/tmp/cvs-serv7723/src/test
Modified Files:
TestHttpSocket.cpp
Added Files:
TestHttpManager.cpp TestHttpManager.h
Log Message:
30/12/2003 Mikael Barbeaux
* Implemented a Http processor thread object.
* Implemented a Http connections manager object.
* Modified configure script for pthread library.
--- NEW FILE: TestHttpManager.cpp ---
/*
* This file is part of webInterface.
* Copyright (C) 2003 Mikael Barbeaux <mik...@us...>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "TestHttpManager.h"
#include "../exceptions/Exception.h"
#include "../server/http/HttpServerSocket.h"
#include "../server/http/manager/HttpManager.h"
#include "../server/http/manager/HttpProcessor.h"
#include "../thread/Thread.h"
#include <iostream>
using namespace std;
#include <stdio.h>
/**
* Constructor for TestHttpManager.
*/
TestHttpManager::TestHttpManager() : TestHandler() {
}
/**
* Destructor for TestHttpManager.
*/
TestHttpManager::~TestHttpManager() {
}
/**
* Runs the tester
*/
void TestHttpManager::test() {
/** This test tries to launch the http connections manager
* and goes on working. */
cout << endl;
cout << "ShareDaemon Web Interface - Test" << endl << endl;
cout << "Test for Http connections manager... " << endl;
cout << "The tester will launch the HttpManager and a http" << endl;
cout << "server listening connections on port 4589. The server" << endl;
cout << "will send connections to the manager which will process" << endl;
cout << "them thanks to the Http processors objects." << endl;
cout << "Press enter to continue" << endl;
getchar();
cout << endl << endl;
try {
cout << "Creates a http server socket on port 4589..." << endl;
HttpServerSocket *server = new HttpServerSocket(4589);
cout << "Creates the Http manager" << endl;
HttpManager *manager = HttpManager::getInstance();
cout << "Creates 5 Http processors" << endl;
HttpProcessor *p1 = new HttpProcessor(1);
HttpProcessor *p2 = new HttpProcessor(2);
HttpProcessor *p3 = new HttpProcessor(3);
HttpProcessor *p4 = new HttpProcessor(4);
HttpProcessor *p5 = new HttpProcessor(5);
cout << "Starts the processors" << endl;
p1->start();
p2->start();
p3->start();
p4->start();
p5->start();
cout << "Starts the server for 20 seconds" << endl;
server->start();
for(int i=0;i<20;i++) {
cout << "Waited " << i << " seconds..." <<endl;
Thread::sleep(1);
}
cout << "Stop the server" << endl;
server->stop();
cout << "Stop the processors" << endl;
p1->cancel();
p2->cancel();
p3->cancel();
p4->cancel();
p5->cancel();
manager->release();
cout << "Delete processors" << endl;
delete p1;
delete p2;
delete p3;
delete p4;
delete p5;
cout << "Delete the manager" << endl;
delete manager;
cout << "Delete the server" << endl;
delete server;
}
catch(Exception& e) {
// display the exception message
cout << e.getMessage() << endl;
}
cout << "Could you connect to the socket and did you see the response ?" << endl;
cout << " If no => VERY BAD :(" << endl;
cout << " If yes => Test worked !! :D" << endl << endl;
cout << "Press enter to continue" << endl;
getchar();
}
--- NEW FILE: TestHttpManager.h ---
/*
* This file is part of webInterface.
* Copyright (C) 2003 Mikael Barbeaux <mik...@us...>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _TEST_HTTP_MANAGER_H_
#define _TEST_HTTP_MANAGER_H_
#include "TestHandler.h"
/**
* Defines a test class for HttpManager.
*/
class TestHttpManager : public TestHandler {
public:
/**
* Creates a test for http manager.
*/
TestHttpManager();
/**
* Destructor for TestHttpManager
*/
~TestHttpManager();
/**
* Runs the tester.
*/
virtual void test();
};
#endif
Index: TestHttpSocket.cpp
===================================================================
RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/src/test/TestHttpSocket.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- TestHttpSocket.cpp 27 Dec 2003 11:42:39 -0000 1.2
+++ TestHttpSocket.cpp 30 Dec 2003 10:45:10 -0000 1.3
@@ -57,7 +57,7 @@
try {
cout << "Creates a http server on port 4589..." << endl;
HttpServerSocket *server = new HttpServerSocket(4589);
- cout << "Starts the server for 30 seconds..." << endl;
+ cout << "Starts the server for 20 seconds..." << endl;
server->start();
for(int i=0;i<20;i++) {
cout << "Waited " << i << " seconds..." <<endl;
|