Permalink
Browse files

Added teardown clean up code

  • Loading branch information...
1 parent cd99ea5 commit 84d92bba1a58f0bb65cfe073f0e12537c02601ad @wadealcorn wadealcorn committed Jan 12, 2012
@@ -18,15 +18,15 @@
require 'curb'
class TC_DynamicReconstruction < Test::Unit::TestCase
-
+
@@port = 20000 + rand(10000)
-
+
def setup
$root_dir="../../"
$:.unshift File.join( %w{ ../../ } )
require 'core/loader'
require 'core/main/network_stack/handlers/dynamicreconstruction.rb'
-
+
@@port += 1 # cycle through ports because the tcp teardown process is too slow
@port = @@port
@@ -45,9 +45,10 @@ def setup
@server.start!
end
end
-
+
def teardown
Process.kill("INT",@pid)
+ $root_dir = nil
end
# the server doesn't offer a mutex or callback
@@ -66,46 +67,46 @@ def wait_for_server
def test_delete
wait_for_server
response = Curl::Easy.http_delete("http://127.0.0.1:" + @port.to_s + "/test")
- assert_equal 404, response.response_code
+ assert_equal 404, response.response_code
end
-
+
def test_put
wait_for_server
response = Curl::Easy.http_put("http://127.0.0.1:" + @port.to_s + "/test", nil)
- assert_equal 404, response.response_code
+ assert_equal 404, response.response_code
end
-
+
def test_head
wait_for_server
response = Curl::Easy.http_head("http://127.0.0.1:" + @port.to_s + "/test")
- assert_equal 404, response.response_code
+ assert_equal 404, response.response_code
end
-
+
def test_no_params
wait_for_server
response = Curl::Easy.http_get("http://127.0.0.1:" + @port.to_s + "/test")
assert_equal 404, response.response_code
end
-
+
def test_zero_values
wait_for_server
response = Curl::Easy.http_get("http://127.0.0.1:" + @port.to_s + "/test?bh=0&sid=0&pid=0&pc=0&d=0")
assert_equal 200, response.response_code
assert_equal "", response.body_str
- end
-
+ end
+
def test_one_values
wait_for_server
response = Curl::Easy.http_get("http://127.0.0.1:" + @port.to_s + "/test?bh=1&sid=1&pid=1&pc=1&d=1")
assert_equal 200, response.response_code
assert_equal "", response.body_str
- end
-
+ end
+
def test_neg_one_values
wait_for_server
response = Curl::Easy.http_get("http://127.0.0.1:" + @port.to_s + "/test?bh=-1&sid=-1&pid=-1&pc=-1&d=-1")
assert_equal 200, response.response_code
assert_equal "", response.body_str
- end
-
+ end
+
end
View
@@ -18,10 +18,14 @@
class TC_Api < Test::Unit::TestCase
def setup
- $root_dir="../../"
+ $root_dir = "../../"
$:.unshift File.join( %w{ ../../ } )
end
+ def teardown
+ $root_dir = nil
+ end
+
#
# Test the api is functional
#
@@ -18,10 +18,14 @@
class TC_Core < Test::Unit::TestCase
def setup
- $root_dir="../../"
+ $root_dir = "../../"
$:.unshift File.join( %w{ ../../ } )
end
+ def teardown
+ $root_dir = nil
+ end
+
#
# Test the core is functional
#
@@ -32,3 +36,4 @@ def test_core
end
end
+
@@ -18,10 +18,14 @@
class TC_Loader < Test::Unit::TestCase
def setup
- $root_dir="../../"
+ $root_dir = "../../"
$:.unshift File.join( %w{ ../../ } )
end
+ def teardown
+ $root_dir = nil
+ end
+
#
# Test the loader is functional
#

0 comments on commit 84d92bb

Please sign in to comment.