Project

General

Profile

Actions

Bug #4227

closed

Webrick tests use deprecated :RequestHandler option

Added by pweldon (Peter Weldon) over 13 years ago. Updated about 13 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.3dev (2010-12-30 trunk 30432) [i386-mingw32]
Backport:
[ruby-core:34010]

Description

=begin
Patch removes usage of deprecated :RequestHandler option in tests. A test of the deprecation behaviour is also added.

From dc216679bab208a71c4cb3d65fe18bc625c119d9 Mon Sep 17 00:00:00 2001
From: Peter Weldon
Date: Thu, 30 Dec 2010 13:07:58 -0800
Subject: [PATCH] test/webrick/test_(cgi|httpproxy).rb: s/:RequestHandler/:RequestCallback/g - don't use deprecated :RequestHandler


test/webrick/test_cgi.rb | 2 +-
test/webrick/test_httpproxy.rb | 10 +++++-----
test/webrick/test_httpserver.rb | 18 ++++++++++++++++++
3 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/test/webrick/test_cgi.rb b/test/webrick/test_cgi.rb
index 4bfb3df..1185316 100644
--- a/test/webrick/test_cgi.rb
+++ b/test/webrick/test_cgi.rb
@@ -10,7 +10,7 @@ class TestWEBrickCGI < Test::Unit::TestCase
: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)
    

diff --git a/test/webrick/test_httpproxy.rb b/test/webrick/test_httpproxy.rb
index 58b834f..cab7095 100644
--- a/test/webrick/test_httpproxy.rb
+++ b/test/webrick/test_httpproxy.rb
@@ -33,7 +33,7 @@ class TestWEBrickHTTPProxy < Test::Unit::TestCase
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 @@ class TestWEBrickHTTPProxy < Test::Unit::TestCase
    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 @@ class TestWEBrickHTTPProxy < Test::Unit::TestCase
    }
    config = {
    :ServerName => "localhost.localdomain",
  •  :RequestHandler => Proc.new{|req, res|
    
  •  :RequestCallback => Proc.new{|req, res|
       assert_equal("CONNECT", req.request_method)
     },
    
    }
    @@ -185,7 +185,7 @@ class TestWEBrickHTTPProxy < Test::Unit::TestCase
    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 @@ class TestWEBrickHTTPProxy < Test::Unit::TestCase
    :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)
    

diff --git a/test/webrick/test_httpserver.rb b/test/webrick/test_httpserver.rb
index e0c2ae3..b4bdd84 100644
--- a/test/webrick/test_httpserver.rb
+++ b/test/webrick/test_httpserver.rb
@@ -257,4 +257,22 @@ class TestWEBrickHTTPServer < Test::Unit::TestCase
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
    --
    1.7.1.msysgit.0
    =end
Actions #1

Updated by naruse (Yui NARUSE) over 13 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
This issue was solved with changeset r30516.
Peter, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Actions

Also available in: Atom PDF

Like0
Like0