Sha256: 494614a4a21cc9176d2c59c28939257690b4f73ea366fcac5d56e6a62969127a

Contents?: true

Size: 1.84 KB

Versions: 37

Compression:

Stored size: 1.84 KB

Contents

# encoding: ascii-8bit

# Copyright 2014 Ball Aerospace & Technologies Corp.
# All Rights Reserved.
#
# This program is free software; you can modify and/or redistribute it
# under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 3 with
# attribution addendums as found in the LICENSE.txt

require 'spec_helper'
require 'cosmos/streams/tcpip_client_stream'

module Cosmos

  describe TcpipClientStream do
    before(:all) do
      addr = Socket.pack_sockaddr_in(8888, "0.0.0.0")
      if RUBY_ENGINE == 'ruby'
        @listen_socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
      else
        @listen_socket = ServerSocket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
      end
      @listen_socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, 1) unless Kernel.is_windows?
      if RUBY_ENGINE == 'ruby'
        @listen_socket.bind(addr)
        @listen_socket.listen(5)
      else
        @listen_socket.bind(addr, 5)
      end
    end

    after(:all) do
      @listen_socket.close
    end

    describe "initialize" do
      it "complains if the host is bad" do
        expect { TcpipClientStream.new('asdf',8888,8888,nil,nil) }.to raise_error(/Invalid hostname/)
      end

      it "uses the same socket if read_port == write_port" do
        ss = TcpipClientStream.new('localhost',8888,8888,nil,nil)
        ss.connect
        expect(ss.connected?).to be true
        ss.disconnect
      end

      it "creates the write socket" do
        ss = TcpipClientStream.new('localhost',8888,nil,nil,nil)
        ss.connect
        expect(ss.connected?).to be true
        ss.disconnect
      end

      it "creates the read socket" do
        ss = TcpipClientStream.new('localhost',nil,8888,nil,nil)
        ss.connect
        expect(ss.connected?).to be true
        ss.disconnect
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
cosmos-4.5.2-java spec/streams/tcpip_client_stream_spec.rb
cosmos-4.5.2 spec/streams/tcpip_client_stream_spec.rb
cosmos-4.5.1-java spec/streams/tcpip_client_stream_spec.rb
cosmos-4.5.1 spec/streams/tcpip_client_stream_spec.rb
cosmos-4.5.0-java spec/streams/tcpip_client_stream_spec.rb
cosmos-4.5.0 spec/streams/tcpip_client_stream_spec.rb
cosmos-4.4.2-java spec/streams/tcpip_client_stream_spec.rb
cosmos-4.4.2 spec/streams/tcpip_client_stream_spec.rb
cosmos-4.4.1-java spec/streams/tcpip_client_stream_spec.rb
cosmos-4.4.1 spec/streams/tcpip_client_stream_spec.rb
cosmos-4.4.0-java spec/streams/tcpip_client_stream_spec.rb
cosmos-4.4.0 spec/streams/tcpip_client_stream_spec.rb
cosmos-4.3.0-java spec/streams/tcpip_client_stream_spec.rb
cosmos-4.3.0 spec/streams/tcpip_client_stream_spec.rb
cosmos-4.2.4-java spec/streams/tcpip_client_stream_spec.rb
cosmos-4.2.4 spec/streams/tcpip_client_stream_spec.rb
cosmos-4.2.3-java spec/streams/tcpip_client_stream_spec.rb
cosmos-4.2.3 spec/streams/tcpip_client_stream_spec.rb
cosmos-4.2.2-java spec/streams/tcpip_client_stream_spec.rb
cosmos-4.2.2 spec/streams/tcpip_client_stream_spec.rb