From fe0fac5c040a44b5262852ffe59392d5c55ec747 Mon Sep 17 00:00:00 2001 From: zedshaw Date: Wed, 28 Jun 2006 15:51:06 +0000 Subject: Test for request progress functionality git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@262 19e92222-5c0b-0410-8929-a290d50e31e9 --- test/test_request_progress.rb | 71 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 test/test_request_progress.rb diff --git a/test/test_request_progress.rb b/test/test_request_progress.rb new file mode 100644 index 0000000..bca2d33 --- /dev/null +++ b/test/test_request_progress.rb @@ -0,0 +1,71 @@ + +# Mongrel Web Server - A Mostly Ruby HTTP server and Library +# +# Copyright (C) 2005 Zed A. Shaw zedshaw AT zedshaw dot com +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +require 'test/unit' +require 'mongrel' +require 'net/http' +require File.dirname(__FILE__) + '/testhelp.rb' + + +class UploadBeginHandler < Mongrel::HttpHandler + attr_reader :request_began, :request_progressed, :request_processed + + def initialize + @request_notify = true + end + + def request_begins(params) + @request_began = true + end + + def request_progress(params,len,total) + @request_progressed = true + end + + def process(request, response) + @request_processed = true + response.start do |head,body| + body.write("test") + end + end + +end + + +class RequestProgressTest < Test::Unit::TestCase + + def setup + @server = Mongrel::HttpServer.new("127.0.0.1", 9998) + @handler = UploadBeginHandler.new + @server.register("/upload", @handler) + @server.run + end + + def teardown + @server.stop + end + + def test_begin_end_progress + Net::HTTP.get("localhost", "/upload", 9998) + assert @handler.request_began + assert @handler.request_progressed + assert @handler.request_processed + end + +end -- cgit v1.2.3-24-ge0c7