diff options
author | (no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-01-02 22:50:01 +0000 |
---|---|---|
committer | (no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-01-02 22:50:01 +0000 |
commit | 47c4c9f830082b8c8272832ee8568c1a3bd3a3c2 (patch) | |
tree | ad123cbf7356dc512af98cb00ec7eba78dc78a21 /test/xmlrpc/webrick_testing.rb | |
parent | 91af84cc66b5f5c5c67f87abb4f8f9233043f0bd (diff) |
This commit was manufactured by cvs2svn to create branch 'ruby_1_8'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/xmlrpc/webrick_testing.rb')
-rw-r--r-- | test/xmlrpc/webrick_testing.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/xmlrpc/webrick_testing.rb b/test/xmlrpc/webrick_testing.rb new file mode 100644 index 0000000000..a6830cece1 --- /dev/null +++ b/test/xmlrpc/webrick_testing.rb @@ -0,0 +1,37 @@ +require 'timeout' + +module WEBrick_Testing + class DummyLog < WEBrick::BasicLog + def initialize() super(self) end + def <<(*args) end + end + + def start_server(config={}) + raise "already started" if @__server + @__started = false + + Thread.new { + @__server = WEBrick::HTTPServer.new( + { + :Logger => DummyLog.new, + :AccessLog => [], + :StartCallback => proc { @__started = true } + }.update(config)) + yield @__server + @__server.start + @__started = false + } + + Timeout.timeout(5) { + nil until @__started # wait until the server is ready + } + end + + def stop_server + Timeout.timeout(5) { + @__server.shutdown + nil while @__started # wait until the server is down + } + @__server = nil + end +end |