~ubuntu-branches/ubuntu/hardy/ruby1.8/hardy-updates

« back to all changes in this revision

Viewing changes to test/xmlrpc/webrick_testing.rb

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2007-03-13 22:11:58 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070313221158-h3oql37brlaf2go2
Tags: 1.8.6-1
* new upstream version, 1.8.6.
* libruby1.8 conflicts with libopenssl-ruby1.8 (< 1.8.6) (closes: #410018)
* changed packaging style to cdbs from dbs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require 'timeout'
 
2
 
 
3
module WEBrick_Testing
 
4
  class DummyLog < WEBrick::BasicLog
 
5
    def initialize() super(self) end
 
6
    def <<(*args) end
 
7
  end
 
8
  
 
9
  def start_server(config={})
 
10
    raise "already started" if @__server
 
11
    @__started = false
 
12
 
 
13
    Thread.new {
 
14
      @__server = WEBrick::HTTPServer.new(
 
15
        { 
 
16
          :Logger => DummyLog.new,
 
17
          :AccessLog => [],
 
18
          :StartCallback => proc { @__started = true }
 
19
        }.update(config))
 
20
      yield @__server 
 
21
      @__server.start
 
22
      @__started = false
 
23
    }
 
24
 
 
25
    Timeout.timeout(5) {
 
26
      nil until @__started # wait until the server is ready
 
27
    }
 
28
  end
 
29
 
 
30
  def stop_server
 
31
    Timeout.timeout(5) {
 
32
      @__server.shutdown
 
33
      nil while @__started # wait until the server is down
 
34
    }
 
35
    @__server = nil
 
36
  end
 
37
end