diff options
author | zedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9> | 2006-03-25 21:15:30 +0000 |
---|---|---|
committer | zedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9> | 2006-03-25 21:15:30 +0000 |
commit | f4a5c938d461d9c5dc17f521c9efaaf352b931fa (patch) | |
tree | c8f5d6799e74a4b9dd6d533424ee093ef4d3beb4 /test/test_configurator.rb | |
parent | 8287106809a82ccd1afba674740486946509b856 (diff) | |
download | unicorn-f4a5c938d461d9c5dc17f521c9efaaf352b931fa.tar.gz |
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@121 19e92222-5c0b-0410-8929-a290d50e31e9
Diffstat (limited to 'test/test_configurator.rb')
-rw-r--r-- | test/test_configurator.rb | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/test/test_configurator.rb b/test/test_configurator.rb new file mode 100644 index 0000000..2fb9f85 --- /dev/null +++ b/test/test_configurator.rb @@ -0,0 +1,59 @@ +require 'test/unit' +require 'mongrel' + +$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 MongrelDbgTest < Test::Unit::TestCase + + def test_base_handler_config + config = Mongrel::Configurator.new :host => "localhost" do + listener :port => 3111 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(".", load_mime_map("examples/mime.yaml")) + uri "/", :handler => plugin("/handlers/sentinel") + + uri "/test", :handler => plugin("/handlers/testplugin") + uri "/test", :handler => plugin("/handlers/testplugin") + uri "/test", :handler => Mongrel::DirHandler.new(".", load_mime_map("examples/mime.yaml")) + uri "/test", :handler => plugin("/handlers/sentinel") + run + end + end + + res = Net::HTTP.get(URI.parse('http://localhost:3111/test')) + assert res != nil, "Didn't get a response" + assert $test_plugin_fired == 2, "Test filter plugin didn't run twice." + + + res = Net::HTTP.get(URI.parse('http://localhost:3111/')) + assert res != nil, "Didn't get a response" + assert $test_plugin_fired == 4, "Test filter plugin didn't run 4 times." + + config.stop + + assert_raise Errno::ECONNREFUSED do + res = Net::HTTP.get(URI.parse("http://localhost:3111/")) + end + end + +end |