Changeset 999
- Timestamp:
- 03/31/08 03:19:11 (5 months ago)
- Files:
-
- branches/stable_1-2 (modified) (3 props)
- branches/stable_1-2/test/test_helper.rb (modified) (1 diff)
- branches/stable_1-2/test/unit/test_conditional.rb (modified) (1 diff)
- branches/stable_1-2/test/unit/test_configurator.rb (modified) (4 diffs)
- branches/stable_1-2/test/unit/test_handlers.rb (modified) (7 diffs)
- branches/stable_1-2/test/unit/test_redirect_handler.rb (modified) (1 diff)
- branches/stable_1-2/test/unit/test_request_progress.rb (modified) (4 diffs)
- branches/stable_1-2/test/unit/test_ws.rb (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/stable_1-2
- Property bzr:revision-id:v3-trunk0 set to
814 luislavena@gmail.com-20080331074345-8r7ghwi05bwwqz7f - Property bzr:file-ids set
- Property bzr:revision-info set to
timestamp: 2008-03-31 04:43:45.765000105 -0300
committer: Luis Lavena <luislavena@gmail.com>
properties:
branch-nick: stable_1-2
- Property bzr:revision-id:v3-trunk0 set to
branches/stable_1-2/test/test_helper.rb
r973 r999 65 65 return results 66 66 end 67 68 # process_based_port provides a port number, usable for TCP and UDP 69 # connections based on $$ and with a 5000 as base. 70 # this is required if you perform several builds of mongrel in parallel 71 # (like continuous integration systems) 72 def process_based_port 73 5000 + $$ % 1000 74 end 75 76 # Platform check helper ;-) 77 def windows? 78 result = RUBY_PLATFORM =~ /djgpp|(cyg|ms|bcc)win|mingw/ 79 end branches/stable_1-2/test/unit/test_conditional.rb
r973 r999 11 11 class ConditionalResponseTest < Test::Unit::TestCase 12 12 def setup 13 @server = HttpServer.new('127.0.0.1', 3501)13 @server = HttpServer.new('127.0.0.1', process_based_port) 14 14 @server.register('/', Mongrel::DirHandler.new('.')) 15 15 @server.run branches/stable_1-2/test/unit/test_configurator.rb
r973 r999 30 30 31 31 def test_base_handler_config 32 @port = process_based_port 32 33 @config = nil 33 34 34 35 redirect_test_io do 35 36 @config = Mongrel::Configurator.new :host => "localhost" do 36 listener :port => 4501do37 listener :port => process_based_port do 37 38 # 2 in front should run, but the sentinel shouldn't since dirhandler processes the request 38 39 uri "/", :handler => plugin("/handlers/testplugin") … … 56 57 end 57 58 end 58 59 59 60 # pp @config.listeners.values.first.classifier.routes 60 61 … … 65 66 end 66 67 67 res = Net::HTTP.get(URI.parse( 'http://localhost:4501/test'))68 res = Net::HTTP.get(URI.parse("http://localhost:#{@port}/test")) 68 69 assert res != nil, "Didn't get a response" 69 70 assert $test_plugin_fired == 3, "Test filter plugin didn't run 3 times." 70 71 71 72 redirect_test_io do 72 res = Net::HTTP.get(URI.parse( 'http://localhost:4501/'))73 res = Net::HTTP.get(URI.parse("http://localhost:#{@port}/")) 73 74 74 75 assert res != nil, "Didn't get a response" … … 81 82 82 83 assert_raise Errno::EBADF, Errno::ECONNREFUSED do 83 res = Net::HTTP.get(URI.parse("http://localhost: 4501/"))84 res = Net::HTTP.get(URI.parse("http://localhost:#{@port}/")) 84 85 end 85 86 end branches/stable_1-2/test/unit/test_handlers.rb
r995 r999 35 35 36 36 def setup 37 @port = process_based_port 37 38 stats = Mongrel::StatisticsFilter.new(:sample_rate => 1) 38 39 39 @config = Mongrel::Configurator.new :host => '127.0.0.1' , :port => 9998do40 listener do40 @config = Mongrel::Configurator.new :host => '127.0.0.1' do 41 listener :port => process_based_port do 41 42 uri "/", :handler => SimpleHandler.new 42 43 uri "/", :handler => stats … … 51 52 end 52 53 53 File.open("/tmp/testfile", 'w') do 54 # Do nothing 54 unless windows? 55 File.open('/tmp/testfile', 'w') do 56 # Do nothing 57 end 55 58 end 56 59 … … 60 63 def teardown 61 64 @config.stop(false, true) 62 File.delete "/tmp/testfile"65 File.delete '/tmp/testfile' unless windows? 63 66 end 64 67 … … 74 77 75 78 def test_more_web_server 76 res = hit([ "http://localhost: 9998/test",77 "http://localhost: 9998/dumb",78 "http://localhost: 9998/404",79 "http://localhost: 9998/files/rdoc/index.html",80 "http://localhost: 9998/files/rdoc/nothere.html",81 "http://localhost: 9998/files/rdoc/",82 "http://localhost: 9998/files_nodir/rdoc/",83 "http://localhost: 9998/status",79 res = hit([ "http://localhost:#{@port}/test", 80 "http://localhost:#{@port}/dumb", 81 "http://localhost:#{@port}/404", 82 "http://localhost:#{@port}/files/rdoc/index.html", 83 "http://localhost:#{@port}/files/rdoc/nothere.html", 84 "http://localhost:#{@port}/files/rdoc/", 85 "http://localhost:#{@port}/files_nodir/rdoc/", 86 "http://localhost:#{@port}/status", 84 87 ]) 85 88 check_status res, String … … 87 90 88 91 def test_nil_dirhandler 92 return if windows? 89 93 # Camping uses this internally 90 94 handler = Mongrel::DirHandler.new(nil, false) … … 103 107 104 108 def test_deflate 105 Net::HTTP.start("localhost", 9998) do |h|109 Net::HTTP.start("localhost", @port) do |h| 106 110 # Test that no accept-encoding returns a non-deflated response 107 111 req = h.get("/dumb") … … 121 125 # TODO: find out why this fails on win32 but nowhere else 122 126 #def test_posting_fails_dirhandler 123 # req = Net::HTTP::Post.new("http://localhost: 9998/files/rdoc/")127 # req = Net::HTTP::Post.new("http://localhost:#{@port}/files/rdoc/") 124 128 # req.set_form_data({'from'=>'2005-01-01', 'to'=>'2005-03-31'}, ';') 125 # res = hit [["http://localhost: 9998/files/rdoc/",req]]129 # res = hit [["http://localhost:#{@port}/files/rdoc/",req]] 126 130 # check_status res, Net::HTTPNotFound 127 131 #end 128 132 129 133 def test_unregister 130 @config.listeners["127.0.0.1: 9998"].unregister("/")134 @config.listeners["127.0.0.1:#{@port}"].unregister("/") 131 135 end 132 136 end 133 branches/stable_1-2/test/unit/test_redirect_handler.rb
r973 r999 10 10 11 11 def setup 12 @port = process_based_port 12 13 redirect_test_io do 13 @server = Mongrel::HttpServer.new('127.0.0.1', 9998)14 @server = Mongrel::HttpServer.new('127.0.0.1', @port) 14 15 end 15 16 @server.run 16 @client = Net::HTTP.new('127.0.0.1', 9998)17 @client = Net::HTTP.new('127.0.0.1', @port) 17 18 end 18 19 branches/stable_1-2/test/unit/test_request_progress.rb
r973 r999 39 39 class RequestProgressTest < Test::Unit::TestCase 40 40 def setup 41 @port = process_based_port 41 42 redirect_test_io do 42 @server = Mongrel::HttpServer.new("127.0.0.1", 9998)43 @server = Mongrel::HttpServer.new("127.0.0.1", @port) 43 44 end 44 45 @handler = UploadBeginHandler.new … … 52 53 53 54 def test_begin_end_progress 54 Net::HTTP.get("localhost", "/upload", 9998)55 Net::HTTP.get("localhost", "/upload", @port) 55 56 assert @handler.request_began 56 57 assert @handler.request_progressed … … 63 64 64 65 # make the call 65 Net::HTTP.get("localhost", "/upload", 9998)66 Net::HTTP.get("localhost", "/upload", @port) 66 67 67 68 # assert that each one was fired … … 89 90 @server.unregister("/upload") 90 91 handlers.each { |h| h.reset } 91 Net::HTTP.get("localhost", "/upload", 9998)92 Net::HTTP.get("localhost", "/upload", @port) 92 93 handlers.each { |h| 93 94 assert !h.request_began && !h.request_progressed && !h.request_processed branches/stable_1-2/test/unit/test_ws.rb
r986 r999 23 23 def setup 24 24 @valid_request = "GET / HTTP/1.1\r\nHost: www.zedshaw.com\r\nContent-Type: text/plain\r\n\r\n" 25 @port = process_based_port 25 26 26 27 redirect_test_io do 27 28 # We set num_processors=1 so that we can test the reaping code 28 @server = HttpServer.new("127.0.0.1", 9998, num_processors=1)29 @server = HttpServer.new("127.0.0.1", @port, num_processors=1) 29 30 end 30 31 … … 43 44 44 45 def test_simple_server 45 hit([ 'http://localhost:9998/test'])46 hit(["http://localhost:#{@port}/test"]) 46 47 assert @tester.ran_test, "Handler didn't really run" 47 48 end … … 50 51 def do_test(string, chunk, close_after=nil, shutdown_delay=0) 51 52 # Do not use instance variables here, because it needs to be thread safe 52 socket = TCPSocket.new("127.0.0.1", 9998);53 socket = TCPSocket.new("127.0.0.1", @port); 53 54 request = StringIO.new(string) 54 55 chunks_out = 0
