diff options
| author | Pixel <pixel@nobis-crew.org> | 2011-11-21 13:27:53 -0800 | 
|---|---|---|
| committer | Pixel <pixel@nobis-crew.org> | 2011-11-21 13:27:53 -0800 | 
| commit | e10639753d7dbd368f5edc2555d75c4b5905ba3b (patch) | |
| tree | 34b6c4bc2990f48de30d26486426558d643e7ac8 /tests/test-Http.cc | |
| parent | 071e7f07901309a38c8cb5311aaecaa46c0c3542 (diff) | |
GeneralException() will now trace the callstack and store this, for debugging purposes.
Diffstat (limited to 'tests/test-Http.cc')
| -rw-r--r-- | tests/test-Http.cc | 21 | 
1 files changed, 18 insertions, 3 deletions
| 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<Handle> out); +    virtual bool Do(HttpServer * server, Http::Request & req, HttpServer::Action::ActionMatch & match, IO<Handle> out) throw (GeneralException);  }; -bool TestAction::Do(HttpServer * server, Http::Request & req, HttpServer::Action::ActionMatch & match, IO<Handle> out) { +bool TestAction::Do(HttpServer * server, Http::Request & req, HttpServer::Action::ActionMatch & match, IO<Handle> 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<Handle> out) throw (GeneralException); +}; + +bool TestFailure::Do(HttpServer * server, Http::Request & req, HttpServer::Action::ActionMatch & match, IO<Handle> 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(); | 
