Sha256: 9a6bd346beb4051960bd76fcdaf1748ca4ebbd64d1b476d4aac4a75cb0099b7a

Contents?: true

Size: 1.3 KB

Versions: 14

Compression:

Stored size: 1.3 KB

Contents

#!/usr/bin/env ruby
require 'test/unit'
require 'rubygems'; require 'require_relative'

# Unit test for io/tcpclient.rb
require_relative '../../io/tcpfns'
require_relative '../../io/tcpclient'

class TestTCPDbgClient < Test::Unit::TestCase

  include Trepanning::TCPPacking

  def test_basic
    client = Trepan::TCPDbgClient.new({ :open => false,
                                        :port => 1027,
                                        :host => 'localhost'
                                      })
    threads = []
    Thread.new do
      server = TCPServer.new('localhost', 1027)
      session = server.accept
      while 'quit' != (line = session.gets)
        session.puts line 
      end
      session.close
    end
    threads << Thread.new do 
      3.times do 
        begin
          client.open
        rescue IOError
        end
        break
      end
      assert client
      msgs = %w(four five six)
      msgs.each do |mess|
        begin
          break if client.disconnected?
          client.writeline(mess)
          assert_equal mess, client.read_msg.chomp
        rescue EOFError
          puts "In client: got EOF"
          break
        rescue Exception => e
          puts "In client: got #{e}"
          break
        end
      end
      client.close
    end
    threads.each {|t| t.join }
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
rbx-trepanning-0.2.1-universal-rubinius-2.0 test/unit/test-io-tcpclient.rb
rbx-trepanning-0.2.1-universal-rubinius-1.2 test/unit/test-io-tcpclient.rb
rbx-trepanning-0.2.0-universal-rubinius-2.0 test/unit/test-io-tcpclient.rb
rb8-trepanning-0.1.6 test/unit/test-io-tcpclient.rb
rb8-trepanning-0.1.5 test/unit/test-io-tcpclient.rb
rbx-trepanning-0.1.0-universal-rubinius-1.2 test/unit/test-io-tcpclient.rb
rb8-trepanning-0.1.4 test/unit/test-io-tcpclient.rb
rb8-trepanning-0.1.3 test/unit/test-io-tcpclient.rb
rb8-trepanning-0.1.3-universal-ruby-1.9.2 test/unit/test-io-tcpclient.rb
rb8-trepanning-0.1.3-universal-ruby-1.8.7 test/unit/test-io-tcpclient.rb
rbx-trepanning-0.0.8-universal-rubinius-1.2 test/unit/test-io-tcpclient.rb
rbx-trepanning-0.0.7-universal-rubinius-1.2 test/unit/test-io-tcpclient.rb
rbx-trepanning-0.0.6-universal-rubinius-1.2 test/unit/test-io-tcpclient.rb
rbx-trepanning-0.0.5-universal-rubinius-1.2.1 test/unit/test-io-tcpclient.rb