From e10639753d7dbd368f5edc2555d75c4b5905ba3b Mon Sep 17 00:00:00 2001 From: Pixel Date: Mon, 21 Nov 2011 13:27:53 -0800 Subject: GeneralException() will now trace the callstack and store this, for debugging purposes. --- tests/test-Http.cc | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/test-Http.cc b/tests/test-Http.cc index de3c6f3..15ef7de 100644 --- a/tests/test-Http.cc +++ b/tests/test-Http.cc @@ -10,10 +10,10 @@ using namespace Balau; class TestAction : public HttpServer::Action { public: TestAction() : Action(Regexes::any) { } - virtual bool Do(HttpServer * server, Http::Request & req, HttpServer::Action::ActionMatch & match, IO out); + virtual bool Do(HttpServer * server, Http::Request & req, HttpServer::Action::ActionMatch & match, IO out) throw (GeneralException); }; -bool TestAction::Do(HttpServer * server, Http::Request & req, HttpServer::Action::ActionMatch & match, IO out) { +bool TestAction::Do(HttpServer * server, Http::Request & req, HttpServer::Action::ActionMatch & match, IO out) throw (GeneralException) { static const char str[] = "HTTP/1.1 200 Found\r\n" "Content-Type: text/html; charset=UTF-8\r\n" @@ -36,7 +36,20 @@ bool TestAction::Do(HttpServer * server, Http::Request & req, HttpServer::Action return true; } +Balau::Regex testFailureURL("^/failure.html$"); + +class TestFailure : public HttpServer::Action { + public: + TestFailure() : Action(testFailureURL) { } + virtual bool Do(HttpServer * server, Http::Request & req, HttpServer::Action::ActionMatch & match, IO out) throw (GeneralException); +}; + +bool TestFailure::Do(HttpServer * server, Http::Request & req, HttpServer::Action::ActionMatch & match, IO out) throw (GeneralException) { + throw GeneralException("Test..."); +} + void MainTask::Do() { + Printer::enable(M_DEBUG); Printer::log(M_STATUS, "Test::Http running."); Thread * tms[4]; @@ -45,8 +58,10 @@ void MainTask::Do() { tms[i] = TaskMan::createThreadedTaskMan(); HttpServer * s = new HttpServer(); - TestAction * a = new TestAction(); + HttpServer::Action * a = new TestAction(); + HttpServer::Action * f = new TestFailure(); a->registerMe(s); + f->registerMe(s); s->setPort(8080); s->setLocal("localhost"); s->start(); -- cgit v1.2.3