From: <mik...@us...> - 2003-12-26 22:56:46
|
Update of /cvsroot/sharedaemon/sharedaemon-ui-web/src/test In directory sc8-pr-cvs1:/tmp/cvs-serv3848/src/test Modified Files: TestSocket.cpp Added Files: TestHttpSocket.h TestHttpSocket.cpp Log Message: 26/12/2003 Mikael Barbeaux * Added a test program for Http sockets. * Fixed a problem about accepting sockets which were an infinite process. * Implemented main http controls : HttpRequest, HttpResponse, HttpSocket, HttpServerSocket and Writers --- NEW FILE: TestHttpSocket.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_SOCKET_H_ #define _TEST_HTTP_SOCKET_H_ #include "TestHandler.h" /** * Defines a test class for http sockets. */ class TestHttpSocket : public TestHandler { public: /** * Creates a test for http sockets. */ TestHttpSocket(); /** * Destructor for TestHttpSocket */ ~TestHttpSocket(); /** * Runs the tester. */ virtual void test(); }; #endif --- NEW FILE: TestHttpSocket.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 "TestHttpSocket.h" #include "../exceptions/Exception.h" #include "../server/http/HttpServerSocket.h" #include "../server/http/HttpSocket.h" #include <iostream> using namespace std; #include <stdio.h> /** * Constructor for TestHttpSocket. */ TestHttpSocket::TestHttpSocket() : TestHandler() { } /** * Destructor for TestHttpSocket. */ TestHttpSocket::~TestHttpSocket() { } /** * Runs the tester */ void TestHttpSocket::test() { /** This test tries to launch a thread * and goes on working. */ cout << endl; cout << "ShareDaemon Web Interface - Test" << endl << endl; cout << "Test for HTTP sockets... " << endl; cout << "The tester will create a socket, listening for connections on " << endl; cout << "port 4589, that will handler http connections. Open your " << endl; cout << "favourite browser and wait for the socket to start. Then, try" << endl; cout << "to open \"http://localhost:4589\" with your browser to test" << endl; cout << "the socket." << endl; cout << "Press enter to continue" << endl; getchar(); cout << endl << endl; try { cout << "Creates a http server on port 4589..." << endl; HttpServerSocket server(4589); cout << "Starts the server for 30 seconds..." << endl; server.start(); for(int i=0;i<20;i++) { cout << "Waited " << i << " seconds..." <<endl; Thread::sleep(1); } cout << "Closing server..." << endl; server.stop(); } 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(); } Index: TestSocket.cpp =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/src/test/TestSocket.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- TestSocket.cpp 26 Dec 2003 10:04:51 -0000 1.1 +++ TestSocket.cpp 26 Dec 2003 22:56:42 -0000 1.2 @@ -78,7 +78,7 @@ } catch(Exception& e) { // display the exception message - cout << e.getMessage() << endl; + //cout << e.getMessage() << endl; } cout << "Could you connect to the socket and did you see the response ?" << endl; cout << " If no => VERY BAD :(" << endl; |