about summary refs log tree commit homepage
path: root/test
diff options
context:
space:
mode:
authorEvan Weaver <eweaver@twitter.com>2009-01-31 12:02:36 -0800
committerEvan Weaver <eweaver@twitter.com>2009-01-31 12:02:36 -0800
commit30458a6d2a1bb30ac0de24f8a6131bc568adfac7 (patch)
tree71b3314a791aeef32dc4022845f5552f82a49e23 /test
parent3e1c8c363126814b60c164922ffa26b8227defda (diff)
parent0d838c607c0c709e5190b24aff116306f4d02255 (diff)
downloadunicorn-30458a6d2a1bb30ac0de24f8a6131bc568adfac7.tar.gz
Diffstat (limited to 'test')
-rw-r--r--test/unit/test_conditional.rb107
-rw-r--r--test/unit/test_configurator.rb88
-rw-r--r--test/unit/test_handlers.rb136
-rw-r--r--test/unit/test_redirect_handler.rb45
-rw-r--r--test/unit/test_request_progress.rb100
-rw-r--r--test/unit/test_response.rb97
-rw-r--r--test/unit/test_uriclassifier.rb261
-rw-r--r--test/unit/test_ws.rb21
8 files changed, 13 insertions, 842 deletions
diff --git a/test/unit/test_conditional.rb b/test/unit/test_conditional.rb
deleted file mode 100644
index 64517db..0000000
--- a/test/unit/test_conditional.rb
+++ /dev/null
@@ -1,107 +0,0 @@
-# Copyright (c) 2005 Zed A. Shaw
-# You can redistribute it and/or modify it under the same terms as Ruby.
-#
-# Additional work donated by contributors.  See http://mongrel.rubyforge.org/attributions.html
-# for more information.
-
-require 'test/test_helper'
-
-include Mongrel
-
-class ConditionalResponseTest < Test::Unit::TestCase
-  def setup
-    @server = HttpServer.new('127.0.0.1', process_based_port)
-    @server.register('/', Mongrel::DirHandler.new('.'))
-    @server.run
-    
-    @http = Net::HTTP.new(@server.host, @server.port)
-
-    # get the ETag and Last-Modified headers
-    @path = '/README'
-    res = @http.start { |http| http.get(@path) }
-    assert_not_nil @etag = res['ETag']
-    assert_not_nil @last_modified = res['Last-Modified']
-    assert_not_nil @content_length = res['Content-Length']
-  end
-
-  def teardown
-    @server.stop(true)
-  end
-
-  # status should be 304 Not Modified when If-None-Match is the matching ETag
-  def test_not_modified_via_if_none_match
-    assert_status_for_get_and_head Net::HTTPNotModified, 'If-None-Match' => @etag
-  end
-
-  # status should be 304 Not Modified when If-Modified-Since is the matching Last-Modified date
-  def test_not_modified_via_if_modified_since
-    assert_status_for_get_and_head Net::HTTPNotModified, 'If-Modified-Since' => @last_modified
-  end
-
-  # status should be 304 Not Modified when If-None-Match is the matching ETag
-  # and If-Modified-Since is the matching Last-Modified date
-  def test_not_modified_via_if_none_match_and_if_modified_since
-    assert_status_for_get_and_head Net::HTTPNotModified, 'If-None-Match' => @etag, 'If-Modified-Since' => @last_modified
-  end
-
-  # status should be 200 OK when If-None-Match is invalid
-  def test_invalid_if_none_match
-    assert_status_for_get_and_head Net::HTTPOK, 'If-None-Match' => 'invalid'
-    assert_status_for_get_and_head Net::HTTPOK, 'If-None-Match' => 'invalid', 'If-Modified-Since' => @last_modified
-  end
-
-  # status should be 200 OK when If-Modified-Since is invalid
-  def test_invalid_if_modified_since
-    assert_status_for_get_and_head Net::HTTPOK,                           'If-Modified-Since' => 'invalid'
-    assert_status_for_get_and_head Net::HTTPOK, 'If-None-Match' => @etag, 'If-Modified-Since' => 'invalid'
-  end
-
-  # status should be 304 Not Modified when If-Modified-Since is greater than the Last-Modified header, but less than the system time
-  def test_if_modified_since_greater_than_last_modified
-    sleep 2
-    last_modified_plus_1 = (Time.httpdate(@last_modified) + 1).httpdate
-    assert_status_for_get_and_head Net::HTTPNotModified,                           'If-Modified-Since' => last_modified_plus_1
-    assert_status_for_get_and_head Net::HTTPNotModified, 'If-None-Match' => @etag, 'If-Modified-Since' => last_modified_plus_1
-  end
-
-  # status should be 200 OK when If-Modified-Since is less than the Last-Modified header
-  def test_if_modified_since_less_than_last_modified
-    last_modified_minus_1 = (Time.httpdate(@last_modified) - 1).httpdate
-    assert_status_for_get_and_head Net::HTTPOK,                           'If-Modified-Since' => last_modified_minus_1
-    assert_status_for_get_and_head Net::HTTPOK, 'If-None-Match' => @etag, 'If-Modified-Since' => last_modified_minus_1
-  end
-
-  # status should be 200 OK when If-Modified-Since is a date in the future
-  def test_future_if_modified_since
-    the_future = Time.at(2**31-1).httpdate
-    assert_status_for_get_and_head Net::HTTPOK,                           'If-Modified-Since' => the_future
-    assert_status_for_get_and_head Net::HTTPOK, 'If-None-Match' => @etag, 'If-Modified-Since' => the_future
-  end
-
-  # status should be 200 OK when If-None-Match is a wildcard
-  def test_wildcard_match
-    assert_status_for_get_and_head Net::HTTPOK, 'If-None-Match' => '*'
-    assert_status_for_get_and_head Net::HTTPOK, 'If-None-Match' => '*', 'If-Modified-Since' => @last_modified
-  end
-
-  private
-
-    # assert the response status is correct for GET and HEAD
-    def assert_status_for_get_and_head(response_class, headers = {})
-      %w{ get head }.each do |method|
-        res = @http.send(method, @path, headers)
-        assert_kind_of response_class, res
-        assert_equal @etag, res['ETag']
-        case response_class.to_s
-          when 'Net::HTTPNotModified' then
-            assert_nil res['Last-Modified']
-            assert_nil res['Content-Length']
-          when 'Net::HTTPOK' then
-            assert_equal @last_modified, res['Last-Modified']
-            assert_equal @content_length, res['Content-Length']
-          else
-            fail "Incorrect response class: #{response_class}"
-        end
-      end
-    end
-end
diff --git a/test/unit/test_configurator.rb b/test/unit/test_configurator.rb
deleted file mode 100644
index dc9713a..0000000
--- a/test/unit/test_configurator.rb
+++ /dev/null
@@ -1,88 +0,0 @@
-# Copyright (c) 2005 Zed A. Shaw
-# You can redistribute it and/or modify it under the same terms as Ruby.
-#
-# Additional work donated by contributors.  See http://mongrel.rubyforge.org/attributions.html
-# for more information.
-
-require 'test/test_helper'
-
-$test_plugin_fired = 0
-
-class TestPlugin < GemPlugin::Plugin "/handlers"
-  include Mongrel::HttpHandlerPlugin
-
-  def process(request, response)
-    $test_plugin_fired += 1
-  end
-end
-
-
-class Sentinel < GemPlugin::Plugin "/handlers"
-  include Mongrel::HttpHandlerPlugin
-
-  def process(request, response)
-    raise "This Sentinel plugin shouldn't run."
-  end
-end
-
-
-class ConfiguratorTest < Test::Unit::TestCase
-
-  def test_base_handler_config
-    @port = process_based_port
-    @config = nil
-
-    redirect_test_io do
-      @config = Mongrel::Configurator.new :host => "localhost" do
-        listener :port => process_based_port do
-          # 2 in front should run, but the sentinel shouldn't since dirhandler processes the request
-          uri "/", :handler => plugin("/handlers/testplugin")
-          uri "/", :handler => plugin("/handlers/testplugin")
-          uri "/", :handler => Mongrel::DirHandler.new(".")
-          uri "/", :handler => plugin("/handlers/testplugin")
-
-          uri "/test", :handler => plugin("/handlers/testplugin")
-          uri "/test", :handler => plugin("/handlers/testplugin")
-          uri "/test", :handler => Mongrel::DirHandler.new(".")
-          uri "/test", :handler => plugin("/handlers/testplugin")
-
-          debug "/"
-          setup_signals
-
-          run_config(HERE + "/mongrel.conf")
-          load_mime_map(HERE + "/mime.yaml")
-
-          run
-        end
-      end
-    end
-    
-    # pp @config.listeners.values.first.classifier.routes
-
-    @config.listeners.each do |host,listener|
-      assert listener.classifier.uris.length == 3, "Wrong number of registered URIs"
-      assert listener.classifier.uris.include?("/"),  "/ not registered"
-      assert listener.classifier.uris.include?("/test"), "/test not registered"
-    end
-
-    res = Net::HTTP.get(URI.parse("http://localhost:#{@port}/test"))
-    assert res != nil, "Didn't get a response"
-    assert $test_plugin_fired == 3, "Test filter plugin didn't run 3 times."
-
-    redirect_test_io do
-      res = Net::HTTP.get(URI.parse("http://localhost:#{@port}/"))
-
-      assert res != nil, "Didn't get a response"
-      assert $test_plugin_fired == 6, "Test filter plugin didn't run 6 times."
-    end
-
-    redirect_test_io do
-      @config.stop(false, true)
-    end
-
-    assert_raise Errno::EBADF, Errno::ECONNREFUSED do
-      res = Net::HTTP.get(URI.parse("http://localhost:#{@port}/"))
-    end
-  end
-
-end
diff --git a/test/unit/test_handlers.rb b/test/unit/test_handlers.rb
deleted file mode 100644
index 66bf010..0000000
--- a/test/unit/test_handlers.rb
+++ /dev/null
@@ -1,136 +0,0 @@
-# Copyright (c) 2005 Zed A. Shaw
-# You can redistribute it and/or modify it under the same terms as Ruby.
-#
-# Additional work donated by contributors.  See http://mongrel.rubyforge.org/attributions.html
-# for more information.
-
-require 'test/test_helper'
-
-class SimpleHandler < Mongrel::HttpHandler
-  def process(request, response)
-    response.start do |head,out|
-      head["Content-Type"] = "text/html"
-      results = "<html><body>Your request:<br /><pre>#{request.params.to_yaml}</pre><a href=\"/files\">View the files.</a></body></html>"
-      out << results
-    end
-  end
-end
-
-class DumbHandler < Mongrel::HttpHandler
-  def process(request, response)
-    response.start do |head,out|
-      head["Content-Type"] = "text/html"
-      out.write("test")
-    end
-  end
-end
-
-def check_status(results, expecting)
-  results.each do |res|
-    assert(res.kind_of?(expecting), "Didn't get #{expecting}, got: #{res.class}")
-  end
-end
-
-class HandlersTest < Test::Unit::TestCase
-
-  def setup
-    @port = process_based_port
-    stats = Mongrel::StatisticsFilter.new(:sample_rate => 1)
-
-    @config = Mongrel::Configurator.new :host => '127.0.0.1' do
-      listener :port => process_based_port do
-        uri "/", :handler => SimpleHandler.new
-        uri "/", :handler => stats
-        uri "/404", :handler => Mongrel::Error404Handler.new("Not found")
-        uri "/dumb", :handler => Mongrel::DeflateFilter.new
-        uri "/dumb", :handler => DumbHandler.new, :in_front => true
-        uri "/files", :handler => Mongrel::DirHandler.new("doc")
-        uri "/files_nodir", :handler => Mongrel::DirHandler.new("doc", listing_allowed=false, index_html="none")
-        uri "/status", :handler => Mongrel::StatusHandler.new(:stats_filter => stats)
-        uri "/relative", :handler => Mongrel::DirHandler.new(nil, listing_allowed=false, index_html="none")
-      end
-    end
-    
-    unless windows?
-      File.open('/tmp/testfile', 'w') do
-        # Do nothing
-      end
-    end
-    
-    @config.run
-  end
-
-  def teardown
-    @config.stop(false, true)
-    File.delete '/tmp/testfile' unless windows?
-  end
-  
-  def test_registration_exception_is_not_lost
-    assert_raises(Mongrel::URIClassifier::RegistrationError) do      
-      @config = Mongrel::Configurator.new do
-        listener do
-          uri "bogus", :handler => SimpleHandler.new
-        end
-      end
-    end
-  end
-
-  def test_more_web_server
-    res = hit([ "http://localhost:#{@port}/test",
-          "http://localhost:#{@port}/dumb",
-          "http://localhost:#{@port}/404",
-          "http://localhost:#{@port}/files/rdoc/index.html",
-          "http://localhost:#{@port}/files/rdoc/nothere.html",
-          "http://localhost:#{@port}/files/rdoc/",
-          "http://localhost:#{@port}/files_nodir/rdoc/",
-          "http://localhost:#{@port}/status",
-    ])
-    check_status res, String
-  end
-  
-  def test_nil_dirhandler
-    return if windows?
-    # Camping uses this internally
-    handler = Mongrel::DirHandler.new(nil, false)  
-    assert handler.can_serve("/tmp/testfile")
-    # Not a bug! A nil @file parameter is the only circumstance under which
-    # we are allowed to serve any existing file
-    assert handler.can_serve("../../../../../../../../../../tmp/testfile")
-  end
-  
-  def test_non_nil_dirhandler_is_not_vulnerable_to_path_traversal
-    # The famous security bug of Mongrel 1.1.2
-    handler = Mongrel::DirHandler.new("/doc", false)
-    assert_nil handler.can_serve("/tmp/testfile")
-    assert_nil handler.can_serve("../../../../../../../../../../tmp/testfile")
-  end
-
-  def test_deflate
-    Net::HTTP.start("localhost", @port) do |h|
-      # Test that no accept-encoding returns a non-deflated response
-      req = h.get("/dumb")
-      assert(
-        !req['Content-Encoding'] ||
-        !req['Content-Encoding'].include?('deflate'))
-      assert_equal "test", req.body
-
-      req = h.get("/dumb", {"Accept-Encoding" => "deflate"})
-      # -MAX_WBITS stops zlib from looking for a zlib header
-      inflater = Zlib::Inflate.new(-Zlib::MAX_WBITS)
-      assert req['Content-Encoding'].include?('deflate')
-      assert_equal "test", inflater.inflate(req.body)
-    end
-  end
-
-  # TODO: find out why this fails on win32 but nowhere else
-  #def test_posting_fails_dirhandler
-  #  req = Net::HTTP::Post.new("http://localhost:#{@port}/files/rdoc/")
-  #  req.set_form_data({'from'=>'2005-01-01', 'to'=>'2005-03-31'}, ';')
-  #  res = hit [["http://localhost:#{@port}/files/rdoc/",req]]
-  #  check_status res, Net::HTTPNotFound
-  #end
-
-  def test_unregister
-    @config.listeners["127.0.0.1:#{@port}"].unregister("/")
-  end
-end
diff --git a/test/unit/test_redirect_handler.rb b/test/unit/test_redirect_handler.rb
deleted file mode 100644
index e990427..0000000
--- a/test/unit/test_redirect_handler.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-# Copyright (c) 2005 Zed A. Shaw
-# You can redistribute it and/or modify it under the same terms as Ruby.
-#
-# Additional work donated by contributors.  See http://mongrel.rubyforge.org/attributions.html
-# for more information.
-
-require 'test/test_helper'
-
-class RedirectHandlerTest < Test::Unit::TestCase
-
-  def setup
-    @port = process_based_port
-    redirect_test_io do
-      @server = Mongrel::HttpServer.new('127.0.0.1', @port)
-    end
-    @server.run
-    @client = Net::HTTP.new('127.0.0.1', @port)
-  end
-
-  def teardown
-    @server.stop(true)
-  end
-
-  def test_simple_redirect
-    tester = Mongrel::RedirectHandler.new('/yo')
-    @server.register("/test", tester)
-
-    sleep(1)
-    res = @client.request_get('/test')
-    assert res != nil, "Didn't get a response"
-    assert_equal ['/yo'], res.get_fields('Location')
-  end
-
-  def test_rewrite
-    tester = Mongrel::RedirectHandler.new(/(\w+)/, '+\1+')
-    @server.register("/test", tester)
-
-    sleep(1)
-    res = @client.request_get('/test/something')
-    assert_equal ['/+test+/+something+'], res.get_fields('Location')
-  end
-
-end
-
-
diff --git a/test/unit/test_request_progress.rb b/test/unit/test_request_progress.rb
deleted file mode 100644
index a100426..0000000
--- a/test/unit/test_request_progress.rb
+++ /dev/null
@@ -1,100 +0,0 @@
-# Copyright (c) 2005 Zed A. Shaw
-# You can redistribute it and/or modify it under the same terms as Ruby.
-#
-# Additional work donated by contributors.  See http://mongrel.rubyforge.org/attributions.html
-# for more information.
-
-require 'test/test_helper'
-
-class UploadBeginHandler < Mongrel::HttpHandler
-  attr_reader :request_began, :request_progressed, :request_processed
-
-  def initialize
-    @request_notify = true
-  end
-
-  def reset
-    @request_began = false
-    @request_progressed = false
-    @request_processed = false
-  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
-    @port = process_based_port
-    redirect_test_io do
-      @server = Mongrel::HttpServer.new("127.0.0.1", @port)
-    end
-    @handler = UploadBeginHandler.new
-    @server.register("/upload", @handler)
-    @server.run
-  end
-
-  def teardown
-    @server.stop(true)
-  end
-
-  def test_begin_end_progress
-    Net::HTTP.get("localhost", "/upload", @port)
-    assert @handler.request_began
-    assert @handler.request_progressed
-    assert @handler.request_processed
-  end
-
-  def call_and_assert_handlers_in_turn(handlers)
-    # reset all handlers
-    handlers.each { |h| h.reset }
-
-    # make the call
-    Net::HTTP.get("localhost", "/upload", @port)
-
-    # assert that each one was fired
-    handlers.each { |h|
-      assert h.request_began && h.request_progressed && h.request_processed,
-        "Callbacks NOT fired for #{h}"
-    }
-  end
-
-  def test_more_than_one_begin_end_progress
-    handlers = [@handler]
-
-    second = UploadBeginHandler.new
-    @server.register("/upload", second)
-    handlers << second
-    call_and_assert_handlers_in_turn(handlers)
-
-    # check three handlers
-    third = UploadBeginHandler.new
-    @server.register("/upload", third)
-    handlers << third
-    call_and_assert_handlers_in_turn(handlers)
-
-    # remove handlers to make sure they've all gone away
-    @server.unregister("/upload")
-    handlers.each { |h| h.reset }
-    Net::HTTP.get("localhost", "/upload", @port)
-    handlers.each { |h|
-      assert !h.request_began && !h.request_progressed && !h.request_processed
-    }
-
-    # re-register upload to the state before this test
-    @server.register("/upload", @handler)
-  end
-end
diff --git a/test/unit/test_response.rb b/test/unit/test_response.rb
index b49c9df..f0efdb1 100644
--- a/test/unit/test_response.rb
+++ b/test/unit/test_response.rb
@@ -12,11 +12,7 @@ class ResponseTest < Test::Unit::TestCase
   
   def test_response_headers
     out = StringIO.new
-    resp = HttpResponse.new(out)
-    resp.status = 200
-    resp.header["Accept"] = "text/plain"
-    resp.header["X-Whatever"] = "stuff"
-    resp.body.write("test")
+    resp = HttpResponse.new(out,[200, {"X-Whatever" => "stuff"}, ["cool"]])
     resp.finished
 
     assert out.length > 0, "output didn't have data"
@@ -24,104 +20,19 @@ class ResponseTest < Test::Unit::TestCase
 
   def test_response_200
     io = StringIO.new
-    resp = HttpResponse.new(io)
-    resp.start do |head,out|
-      head["Accept"] = "text/plain"
-      out.write("tested")
-      out.write("hello!")
-    end
+    resp = HttpResponse.new(io, [200, {}, []])
 
     resp.finished
     assert io.length > 0, "output didn't have data"
   end
 
-  def test_response_duplicate_header_squash
-    io = StringIO.new
-    resp = HttpResponse.new(io)
-    resp.start do |head,out|
-      head["Content-Length"] = 30
-      head["Content-Length"] = 0
-    end
-
-    resp.finished
-
-    assert_equal io.length, 95, "too much output"
-  end
-
-
-  def test_response_some_duplicates_allowed
-    allowed_duplicates = ["Set-Cookie", "Set-Cookie2", "Warning", "WWW-Authenticate"]
-    io = StringIO.new
-    resp = HttpResponse.new(io)
-    resp.start do |head,out|
-      allowed_duplicates.each do |dup|
-        10.times do |i|
-          head[dup] = i
-        end
-      end
-    end
-
-    resp.finished
-
-    assert_equal io.length, 734, "wrong amount of output"
-  end
-
-  def test_response_404
-    io = StringIO.new
-
-    resp = HttpResponse.new(io)
-    resp.start(404) do |head,out|
-      head['Accept'] = "text/plain"
-      out.write("NOT FOUND")
-    end
-
-    resp.finished
-    assert io.length > 0, "output didn't have data"
-  end
-
-  def test_response_file
-    contents = "PLAIN TEXT\r\nCONTENTS\r\n"
-    require 'tempfile'
-    tmpf = Tempfile.new("test_response_file")
-    tmpf.binmode
-    tmpf.write(contents)
-    tmpf.rewind
-
-    io = StringIO.new
-    resp = HttpResponse.new(io)
-    resp.start(200) do |head,out|
-      head['Content-Type'] = 'text/plain'
-      resp.send_header
-      resp.send_file(tmpf.path)
-    end
-    io.rewind
-    tmpf.close
-    
-    assert io.length > 0, "output didn't have data"
-    assert io.read[-contents.length..-1] == contents, "output doesn't end with file payload"
-  end
-
-  def test_response_with_custom_reason
-    reason = "You made a bad request"
-    io = StringIO.new
-    resp = HttpResponse.new(io)
-    resp.start(400, false, reason) { |head,out| }
-    resp.finished
-
-    io.rewind
-    assert_match(/.* #{reason}$/, io.readline.chomp, "wrong custom reason phrase")
-  end
-
   def test_response_with_default_reason
     code = 400
     io = StringIO.new
-    resp = HttpResponse.new(io)
-    resp.start(code) { |head,out| }
-    resp.finished
-
+    resp = HttpResponse.new(io, [code, {}, []])
+    resp.start
     io.rewind
     assert_match(/.* #{HTTP_STATUS_CODES[code]}$/, io.readline.chomp, "wrong default reason phrase")
   end
-
 end
 
diff --git a/test/unit/test_uriclassifier.rb b/test/unit/test_uriclassifier.rb
deleted file mode 100644
index a438065..0000000
--- a/test/unit/test_uriclassifier.rb
+++ /dev/null
@@ -1,261 +0,0 @@
-# Copyright (c) 2005 Zed A. Shaw
-# You can redistribute it and/or modify it under the same terms as Ruby.
-#
-# Additional work donated by contributors.  See http://mongrel.rubyforge.org/attributions.html
-# for more information.
-
-require 'test/test_helper'
-
-include Mongrel
-
-class URIClassifierTest < Test::Unit::TestCase
-
-  def test_uri_finding
-    uri_classifier = URIClassifier.new
-    uri_classifier.register("/test", 1)
-    
-    script_name, path_info, value = uri_classifier.resolve("/test")
-    assert_equal 1, value
-    assert_equal "/test", script_name
-  end
-  
-  def test_root_handler_only
-    uri_classifier = URIClassifier.new
-    uri_classifier.register("/", 1)
-    
-    script_name, path_info, value = uri_classifier.resolve("/test")
-    assert_equal 1, value
-    assert_equal "/", script_name
-    assert_equal "/test", path_info
-  end
-
-  def test_uri_prefix_ops
-    test = "/pre/fix/test"
-    prefix = "/pre"
-
-    uri_classifier = URIClassifier.new
-    uri_classifier.register(prefix,1)
-
-    script_name, path_info, value = uri_classifier.resolve(prefix)
-    script_name, path_info, value = uri_classifier.resolve(test)
-    assert_equal 1, value
-    assert_equal prefix, script_name
-    assert_equal test[script_name.length .. -1], path_info
-
-    assert uri_classifier.inspect
-    assert_equal prefix, uri_classifier.uris[0]
-  end
-
-  def test_not_finding
-    test = "/cant/find/me"
-    uri_classifier = URIClassifier.new
-    uri_classifier.register(test, 1)
-
-    script_name, path_info, value = uri_classifier.resolve("/nope/not/here")
-    assert_nil script_name
-    assert_nil path_info
-    assert_nil value
-  end
-
-  def test_exceptions
-    uri_classifier = URIClassifier.new
-
-    uri_classifier.register("/test", 1)
-    
-    failed = false
-    begin
-      uri_classifier.register("/test", 1)
-    rescue => e
-      failed = true
-    end
-
-    assert failed
-
-    failed = false
-    begin
-      uri_classifier.register("", 1)
-    rescue => e
-      failed = true
-    end
-
-    assert failed
-  end
-
-
-  def test_register_unregister
-    uri_classifier = URIClassifier.new
-    
-    100.times do
-      uri_classifier.register("/stuff", 1)
-      value = uri_classifier.unregister("/stuff")
-      assert_equal 1, value
-    end
-
-    uri_classifier.register("/things",1)
-    script_name, path_info, value = uri_classifier.resolve("/things")
-    assert_equal 1, value
-
-    uri_classifier.unregister("/things")
-    script_name, path_info, value = uri_classifier.resolve("/things")
-    assert_nil value
-
-  end
-
-
-  def test_uri_branching
-    uri_classifier = URIClassifier.new
-    uri_classifier.register("/test", 1)
-    uri_classifier.register("/test/this",2)
-  
-    script_name, path_info, handler = uri_classifier.resolve("/test")
-    script_name, path_info, handler = uri_classifier.resolve("/test/that")
-    assert_equal "/test", script_name, "failed to properly find script off branch portion of uri"
-    assert_equal "/that", path_info
-    assert_equal 1, handler, "wrong result for branching uri"
-  end
-
-  def test_all_prefixing
-    tests = ["/test","/test/that","/test/this"]
-    uri = "/test/this/that"
-    uri_classifier = URIClassifier.new
-    
-    current = ""
-    uri.each_byte do |c|
-      current << c.chr
-      uri_classifier.register(current, c)
-    end
-    
-
-    # Try to resolve everything with no asserts as a fuzzing
-    tests.each do |prefix|
-      current = ""
-      prefix.each_byte do |c|
-        current << c.chr
-        script_name, path_info, handler = uri_classifier.resolve(current)
-        assert script_name
-        assert path_info
-        assert handler
-      end
-    end
-
-    # Assert that we find stuff
-    tests.each do |t|
-      script_name, path_info, handler = uri_classifier.resolve(t)
-      assert handler
-    end
-
-    # Assert we don't find stuff
-    script_name, path_info, handler = uri_classifier.resolve("chicken")
-    assert_nil handler
-    assert_nil script_name
-    assert_nil path_info
-  end
-
-
-  # Verifies that a root mounted ("/") handler resolves
-  # such that path info matches the original URI.
-  # This is needed to accommodate real usage of handlers.
-  def test_root_mounted
-    uri_classifier = URIClassifier.new
-    root = "/"
-    path = "/this/is/a/test"
-
-    uri_classifier.register(root, 1)
-
-    script_name, path_info, handler = uri_classifier.resolve(root)
-    assert_equal 1, handler
-    assert_equal root, path_info
-    assert_equal root, script_name
-
-    script_name, path_info, handler = uri_classifier.resolve(path)
-    assert_equal path, path_info
-    assert_equal root, script_name
-    assert_equal 1, handler
-  end
-
-  # Verifies that a root mounted ("/") handler
-  # is the default point, doesn't matter the order we use
-  # to register the URIs
-  def test_classifier_order
-    tests = ["/before", "/way_past"]
-    root = "/"
-    path = "/path"
-
-    uri_classifier = URIClassifier.new
-    uri_classifier.register(path, 1)
-    uri_classifier.register(root, 2)
-
-    tests.each do |uri|
-      script_name, path_info, handler = uri_classifier.resolve(uri)
-      assert_equal root, script_name, "#{uri} did not resolve to #{root}"
-      assert_equal uri, path_info
-      assert_equal 2, handler
-    end
-  end
-  
-  if ENV['BENCHMARK']
-    # Eventually we will have a suite of benchmarks instead of lamely installing a test
-    
-    def test_benchmark    
-
-      # This URI set should favor a TST. Both versions increase linearly until you hit 14
-      # URIs, then the TST flattens out.
-      @uris = %w(
-        /
-        /dag /dig /digbark /dog /dogbark /dog/bark /dug /dugbarking /puppy
-        /c /cat /cat/tree /cat/tree/mulberry /cats /cot /cot/tree/mulberry /kitty /kittycat
-#        /eag /eig /eigbark /eog /eogbark /eog/bark /eug /eugbarking /iuppy
-#        /f /fat /fat/tree /fat/tree/mulberry /fats /fot /fot/tree/mulberry /jitty /jittyfat
-#        /gag /gig /gigbark /gog /gogbark /gog/bark /gug /gugbarking /kuppy
-#        /h /hat /hat/tree /hat/tree/mulberry /hats /hot /hot/tree/mulberry /litty /littyhat
-#        /ceag /ceig /ceigbark /ceog /ceogbark /ceog/cbark /ceug /ceugbarking /ciuppy
-#        /cf /cfat /cfat/ctree /cfat/ctree/cmulberry /cfats /cfot /cfot/ctree/cmulberry /cjitty /cjittyfat
-#        /cgag /cgig /cgigbark /cgog /cgogbark /cgog/cbark /cgug /cgugbarking /ckuppy
-#        /ch /chat /chat/ctree /chat/ctree/cmulberry /chats /chot /chot/ctree/cmulberry /citty /cittyhat
-      )
-      
-      @requests = %w(
-        /
-        /dig
-        /digging
-        /dogging
-        /dogbarking/
-        /puppy/barking
-        /c
-        /cat
-        /cat/shrub
-        /cat/tree
-        /cat/tree/maple
-        /cat/tree/mulberry/tree
-        /cat/tree/oak
-        /cats/
-        /cats/tree
-        /cod
-        /zebra
-      )
-    
-      @classifier = URIClassifier.new
-      @uris.each do |uri|
-        @classifier.register(uri, 1)
-      end
-      
-      puts "#{@uris.size} URIs / #{@requests.size * 10000} requests"
-  
-      Benchmark.bm do |x|
-        x.report do
-  #        require 'ruby-prof'
-  #        profile = RubyProf.profile do
-            10000.times do
-              @requests.each do |request|
-                @classifier.resolve(request)
-              end
-            end
-  #        end
-  #        File.open("profile.html", 'w') { |file| RubyProf::GraphHtmlPrinter.new(profile).print(file, 0) }
-        end
-      end          
-    end
-  end
-  
-end
-
diff --git a/test/unit/test_ws.rb b/test/unit/test_ws.rb
index 9de8a45..7508c7f 100644
--- a/test/unit/test_ws.rb
+++ b/test/unit/test_ws.rb
@@ -8,13 +8,14 @@ require 'test/test_helper'
 
 include Mongrel
 
-class TestHandler < Mongrel::HttpHandler
+class TestHandler
   attr_reader :ran_test
 
-  def process(request, response)
+  def call(env)
     @ran_test = true
-    response.socket.write("HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\nhello!\n")
-  end
+  #   response.socket.write("HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\nhello!\n")
+    [200, { 'Content-Type' => 'text/plain' }, ['hello!\n']]
+   end
 end
 
 
@@ -23,16 +24,12 @@ class WebServerTest < Test::Unit::TestCase
   def setup
     @valid_request = "GET / HTTP/1.1\r\nHost: www.zedshaw.com\r\nContent-Type: text/plain\r\n\r\n"
     @port = process_based_port
-    
+    @tester = TestHandler.new
+    @app = Rack::URLMap.new('/test' => @tester)
     redirect_test_io do
       # We set num_processors=1 so that we can test the reaping code
-      @server = HttpServer.new("127.0.0.1", @port, num_processors=1)
-    end
-    
-    @tester = TestHandler.new
-    @server.register("/test", @tester)
-    redirect_test_io do
-      @server.run
+      @server = HttpServer.new("127.0.0.1", @port, @app, :num_processors => 1)
+      @server.start!
     end
   end