ruby-changes:18493
From: naruse <ko1@a...>
Date: Wed, 12 Jan 2011 09:39:42 +0900 (JST)
Subject: [ruby-changes:18493] Ruby:r30516 (trunk): * test/webrick/test_cgi.rb: Removes usage of deprecated
naruse 2011-01-12 09:37:12 +0900 (Wed, 12 Jan 2011) New Revision: 30516 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30516 Log: * test/webrick/test_cgi.rb: Removes usage of deprecated :RequestHandler option. patched by Peter Weldon [ruby-core:34010] * test/webrick/test_httpproxy.rb: ditto. * test/webrick/test_httpserver.rb: Add a test of the deprecation behaviour. Modified files: trunk/ChangeLog trunk/test/webrick/test_cgi.rb trunk/test/webrick/test_httpproxy.rb trunk/test/webrick/test_httpserver.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 30515) +++ ChangeLog (revision 30516) @@ -1,3 +1,14 @@ +Wed Jan 12 03:59:36 2011 NARUSE, Yui <naruse@r...> + + * test/webrick/test_cgi.rb: Removes usage of deprecated + :RequestHandler option. + patched by Peter Weldon [ruby-core:34010] + + * test/webrick/test_httpproxy.rb: ditto. + + * test/webrick/test_httpserver.rb: Add a test of the deprecation + behaviour. + Wed Jan 12 08:37:07 2011 Nobuyoshi Nakada <nobu@r...> * hash.c (hash_i): return different values for inverse hash. Index: test/webrick/test_httpproxy.rb =================================================================== --- test/webrick/test_httpproxy.rb (revision 30515) +++ test/webrick/test_httpproxy.rb (revision 30516) @@ -33,7 +33,7 @@ config = { :ServerName => "localhost.localdomain", :ProxyContentHandler => Proc.new{|req, res| proxy_handler_called += 1 }, - :RequestHandler => Proc.new{|req, res| request_handler_called += 1 } + :RequestCallback => Proc.new{|req, res| request_handler_called += 1 } } TestWEBrick.start_httpproxy(config){|server, addr, port, log| server.mount_proc("/"){|req, res| @@ -78,7 +78,7 @@ config = { :ServerName => "localhost.localdomain", :ProxyContentHandler => Proc.new{|req, res| proxy_handler_called += 1 }, - :RequestHandler => Proc.new{|req, res| request_handler_called += 1 } + :RequestCallback => Proc.new{|req, res| request_handler_called += 1 } } TestWEBrick.start_httpproxy(config){|server, addr, port, log| server.mount_proc("/"){|req, res| @@ -143,7 +143,7 @@ } config = { :ServerName => "localhost.localdomain", - :RequestHandler => Proc.new{|req, res| + :RequestCallback => Proc.new{|req, res| assert_equal("CONNECT", req.request_method) }, } @@ -185,7 +185,7 @@ up_config = { :ServerName => "localhost.localdomain", :ProxyContentHandler => Proc.new{|req, res| up_proxy_handler_called += 1}, - :RequestHandler => Proc.new{|req, res| up_request_handler_called += 1} + :RequestCallback => Proc.new{|req, res| up_request_handler_called += 1} } TestWEBrick.start_httpproxy(up_config){|up_server, up_addr, up_port, up_log| up_server.mount_proc("/"){|req, res| @@ -195,7 +195,7 @@ :ServerName => "localhost.localdomain", :ProxyURI => URI.parse("http://localhost:#{up_port}"), :ProxyContentHandler => Proc.new{|req, res| proxy_handler_called += 1}, - :RequestHandler => Proc.new{|req, res| request_handler_called += 1}, + :RequestCallback => Proc.new{|req, res| request_handler_called += 1}, } TestWEBrick.start_httpproxy(config){|server, addr, port, log| http = Net::HTTP.new(up_addr, up_port, addr, port) Index: test/webrick/test_cgi.rb =================================================================== --- test/webrick/test_cgi.rb (revision 30515) +++ test/webrick/test_cgi.rb (revision 30516) @@ -10,7 +10,7 @@ :CGIInterpreter => TestWEBrick::RubyBin, :DocumentRoot => File.dirname(__FILE__), :DirectoryIndex => ["webrick.cgi"], - :RequestHandler => Proc.new{|req, res| + :RequestCallback => Proc.new{|req, res| def req.meta_vars meta = super meta["RUBYLIB"] = $:.join(File::PATH_SEPARATOR) Index: test/webrick/test_httpserver.rb =================================================================== --- test/webrick/test_httpserver.rb (revision 30515) +++ test/webrick/test_httpserver.rb (revision 30516) @@ -257,4 +257,22 @@ assert_equal(started, 1) assert_equal(stopped, 1) end + + def test_request_handler_callback_is_deprecated + requested = 0 + config = { + :ServerName => "localhost", + :RequestHandler => Proc.new{|req, res| requested += 1 }, + } + TestWEBrick.start_httpserver(config){|server, addr, port, log| + true while server.status != :Running + + http = Net::HTTP.new(addr, port) + req = Net::HTTP::Get.new("/") + req["Host"] = "localhost:#{port}" + http.request(req){|res| assert_equal("404", res.code, log.call)} + assert_match(%r{:RequestHandler is deprecated, please use :RequestCallback$}, log.call, log.call) + } + assert_equal(requested, 1) + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/