Skip to content

Commit

Permalink
Cleanup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
raggi committed Jan 27, 2009
1 parent 5394f05 commit f56ec55
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 55 deletions.
4 changes: 3 additions & 1 deletion tests/test_epoll.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def test_datagrams


def test_unix_domain
fn = "/tmp/xxx.chain"
EM.epoll
s = EM.set_descriptor_table_size 60000
EM.run {
Expand All @@ -143,7 +144,6 @@ def test_unix_domain
# Let's not sweat the Unix-ness of the filename, since this test can't possibly
# work on Windows anyway.
#
fn = "/tmp/xxx.chain"
File.unlink(fn) if File.exist?(fn)
EM.start_unix_domain_server fn, TestEchoServer
$n = 0
Expand All @@ -155,6 +155,8 @@ def test_unix_domain
}
assert_equal(0, $n)
assert_equal(50, $max)
ensure
File.unlink(fn) if File.exist?(fn)
end

end
Expand Down
19 changes: 14 additions & 5 deletions tests/test_httpclient2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,52 +68,61 @@ def test_bad_port
end

def test_bad_server
err = nil
EM.run {
http = EM::P::HttpClient2.connect Localhost, 9999
d = http.get "/"
d.errback {p d.internal_error; EM.stop }
d.errback { err = true; d.internal_error; EM.stop }
}
assert(err)
end

def test_get
content = nil
EM.run {
http = EM::P::HttpClient2.connect "www.bayshorenetworks.com", 80
d = http.get "/"
d.callback {
p d.content
content = d.content
EM.stop
}
}
assert(content)
end

# Not a pipelined request because we wait for one response before we request the next.
def test_get_multiple
content = nil
EM.run {
http = EM::P::HttpClient2.connect "www.bayshorenetworks.com", 80
d = http.get "/"
d.callback {
e = http.get "/"
e.callback {
p e.content
content = e.content
EM.stop
}
}
}
assert(content)
end

def test_get_pipeline
headers, headers2 = nil, nil
EM.run {
http = EM::P::HttpClient2.connect "www.microsoft.com", 80
d = http.get("/")
d.callback {
p d.headers
headers = d.headers
}
e = http.get("/")
e.callback {
p e.headers
headers2 = e.headers
}
EM::Timer.new(1) {EM.stop}
}
assert(headers)
assert(headers2)
end


Expand Down
4 changes: 0 additions & 4 deletions tests/test_ltp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def test_simple_lines
assert( RUBY_PLATFORM !~ /java/ )

lines_received = []
Thread.abort_on_exception = true
EventMachine.run {
EventMachine.start_server( TestHost, TestPort, SimpleLineTest ) do |conn|
conn.instance_eval "@line_buffer = lines_received"
Expand Down Expand Up @@ -90,7 +89,6 @@ def test_overlength_lines
assert( RUBY_PLATFORM !~ /java/ )

lines_received = []
Thread.abort_on_exception = true
EventMachine.run {
EventMachine.start_server( TestHost, TestPort, SimpleLineTest ) do |conn|
conn.instance_eval "@error_message = lines_received"
Expand Down Expand Up @@ -130,7 +128,6 @@ def test_lines_and_text
output = ''
lines_received = []
text_received = []
Thread.abort_on_exception = true
EventMachine.run {
EventMachine.start_server( TestHost, TestPort, LineAndTextTest ) do |conn|
conn.instance_eval "@lines = lines_received; @text = text_received"
Expand Down Expand Up @@ -171,7 +168,6 @@ def test_binary_text
output = ''
lines_received = []
text_received = []
Thread.abort_on_exception = true
EventMachine.run {
EventMachine.start_server( TestHost, TestPort, BinaryTextTest ) do |conn|
conn.instance_eval "@lines = lines_received; @text = text_received"
Expand Down
2 changes: 0 additions & 2 deletions tests/test_send_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ def test_stream_large_file_data
begin
require 'fastfilereaderext'
rescue LoadError
$stderr.puts "no fastfilereaderext, not running test_stream_large_file_data"
return
end
File.open( TestFilename, "w" ) {|f|
Expand All @@ -214,7 +213,6 @@ def test_stream_large_chunked_file_data
begin
require 'fastfilereaderext'
rescue LoadError
$stderr.puts "no fastfilereaderext, not running test_stream_large_chunked_file_data"
return
end
File.open( TestFilename, "w" ) {|f|
Expand Down
88 changes: 45 additions & 43 deletions tests/test_smtpclient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,52 +30,54 @@

class TestSmtpClient < Test::Unit::TestCase

Localhost = "127.0.0.1"
Localport = 9801
Localhost = "127.0.0.1"
Localport = 9801

def setup
end
def setup
end

def teardown
end
def teardown
end

def test_a
# No real tests until we have a server implementation to test against.
# This is what the call looks like, though:
def test_a
# No real tests until we have a server implementation to test against.
# This is what the call looks like, though:
err = nil
EM.run {
d = EM::Protocols::SmtpClient.send :domain=>"example.com",
:host=>Localhost,
:port=>Localport, # optional, defaults 25
:starttls=>true,
:from=>"[email protected]",
:to=> ["[email protected]", "[email protected]"],
:header=> {"Subject" => "This is a subject line"},
:body=> "This is the body of the email",
:verbose=>true
d.errback {|e|
err = e
EM.stop
}
}
assert(err)
end

EM.run {
d = EM::Protocols::SmtpClient.send :domain=>"example.com",
:host=>Localhost,
:port=>Localport, # optional, defaults 25
:starttls=>true,
:from=>"[email protected]",
:to=> ["[email protected]", "[email protected]"],
:header=> {"Subject" => "This is a subject line"},
:body=> "This is the body of the email",
:verbose=>true
d.errback {|e|
p e
EM.stop
}
}
end

def test_content

EM.run {
d = EM::Protocols::SmtpClient.send :domain=>"example.com",
:host=>Localhost,
:port=>Localport, # optional, defaults 25
:starttls=>true,
:from=>"[email protected]",
:to=> ["[email protected]", "[email protected]"],
:content => ["Subject: xxx\r\n\r\ndata\r\n.\r\n"],
:verbose=>true
d.errback {|e|
p e
EM.stop
}
}
end
def test_content
err = nil
EM.run {
d = EM::Protocols::SmtpClient.send :domain=>"example.com",
:host=>Localhost,
:port=>Localport, # optional, defaults 25
:starttls=>true,
:from=>"[email protected]",
:to=> ["[email protected]", "[email protected]"],
:content => ["Subject: xxx\r\n\r\ndata\r\n.\r\n"],
:verbose=>true
d.errback {|e|
err = e
EM.stop
}
}
assert(err)
end

end

0 comments on commit f56ec55

Please sign in to comment.