diff options
author | Steve Kemp <steve@steve.org.uk> | 2012-11-13 16:37:00 +0000 |
---|---|---|
committer | Steve Kemp <steve@steve.org.uk> | 2012-11-13 16:37:00 +0000 |
commit | f648ea5db6ee8129dee0c3570eca161d9dc9cfe2 (patch) | |
tree | c2a657c0cecdd30e2d904fb53cfa3c9e97905fb4 /t | |
parent | 81be23b84c0c7f4ddd3b3c9aff2d4767bc2c2e94 (diff) |
Added a HTTP server stub for the protocol test.
Diffstat (limited to 't')
-rwxr-xr-x | t/test-protocol-http.rb | 56 |
1 files changed, 54 insertions, 2 deletions
diff --git a/t/test-protocol-http.rb b/t/test-protocol-http.rb index e8e4dcc..fb6305b 100755 --- a/t/test-protocol-http.rb +++ b/t/test-protocol-http.rb @@ -2,6 +2,7 @@ require 'test/unit' +require 'webrick' require 'http' @@ -12,16 +13,32 @@ require 'http' # class TestHTTPProtocolProbe < Test::Unit::TestCase + + # + # Holder for the new thread we launch, and the servr + # we run within it. # - # Create the test suite environment: NOP. + attr_reader :server, :server_thread + + + # + # Create the test suite environment: Launch a HTTP server in a new thread. # def setup + @server_thread = Thread.new do + @server = WEBrick::HTTPServer.new( :Port => 12000, + :DocumentRoot => "/tmp", + :AccessLog => []) + @server.start + end end + # - # Destroy the test suite environment: NOP. + # Destroy the test suite environment: Kill the HTTP-Server # def teardown + @server_thread.kill! end @@ -94,4 +111,39 @@ class TestHTTPProtocolProbe < Test::Unit::TestCase + # + # Test we can make a HTTP fetch, and retrieve the status code + # against our stub-Webbrick server. + # + def test_http_fetch + + test_probe = { + "target_host" => "http://localhost:12000/", + "test_type" => "http", + "verbose" => 1, + "test_port" => 12000, + "http_status" => "200" + } + + # + # Create a new HTTPTest object. This should succeed + # + test = HTTPTest.new( test_probe ) + assert( test ) + + + # + # Make the test - ensure that: + # + # a. There is no error before it is tested. + # + # b. The test method "run_test" returns true. + # + # c. There is no error logged after completion. + # + assert( test.error().nil? ) + assert( test.run_test() ) + assert( test.error().nil? ) + end + end |