Sha256: 7549ab93431a4e89baeb26f0267c10d5aa529ec0d0af96378e4aff5f31450917
Contents?: true
Size: 1.78 KB
Versions: 2
Compression:
Stored size: 1.78 KB
Contents
# $Id$ # # Author:: Francis Cianfrocca (gmail: blackhedd) # Homepage:: http://rubyeventmachine.com # Date:: 8 April 2006 # # See EventMachine and EventMachine::Connection for documentation and # usage examples. # #---------------------------------------------------------------------------- # # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved. # Gmail: blackhedd # # This program is free software; you can redistribute it and/or modify # it under the terms of either: 1) the GNU General Public License # as published by the Free Software Foundation; either version 2 of the # License, or (at your option) any later version; or 2) Ruby's License. # # See the file COPYING for complete licensing information. # #--------------------------------------------------------------------------- # # # $:.unshift File.expand_path(File.dirname(__FILE__) + "/../lib") require 'eventmachine' require 'test/unit' class TestBind < Test::Unit::TestCase TestHost = '127.0.0.1' TestPort = 9621 def setup assert(!EM.reactor_running?) end def teardown assert(!EM.reactor_running?) end module BrsTestSrv def receive_data data $received << data end def unbind EM.stop end end module BrsTestCli def post_init send_data $sent close_connection_after_writing end end def test_bind $received = '' $sent = (0..255).to_a.pack('C*') EM::run { EM::start_server TestHost, TestPort, BrsTestSrv EM::connect2 TestHost, TestPort, BrsTestCli, :bind => "127.0.0.1" assert_raise(RuntimeError) { EM::connect2 TestHost, TestPort, BrsTestCli, :bind_host => "128.0.0.1" } EM::add_timer(0.5) { assert(false, 'test timed out'); EM.stop; Kernel.warn "test timed out!" } } assert_equal($sent, $received) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
libc-eventmachine-0.12.5.42 | tests/test_bind.rb |
libc-eventmachine-0.12.7.42 | tests/test_bind.rb |