Class: Iudex::HTTP::Test::BrokenServer

Inherits:
Object
  • Object
show all
Defined in:
lib/iudex-http-test/broken_server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBrokenServer

Returns a new instance of BrokenServer.



27
28
29
30
31
# File 'lib/iudex-http-test/broken_server.rb', line 27

def initialize
  @port = 19293
  @server = nil
  @log = RJack::SLF4J[ self.class ]
end

Instance Attribute Details

#portObject

Returns the value of attribute port.



25
26
27
# File 'lib/iudex-http-test/broken_server.rb', line 25

def port
  @port
end

Instance Method Details

#acceptObject



44
45
46
47
48
49
# File 'lib/iudex-http-test/broken_server.rb', line 44

def accept
  sock = @server.accept
  yield sock if block_given?
rescue Errno::EPIPE => x
  @log.warn( "In accept:", x )
end

#accept_thread(&block) ⇒ Object



37
38
39
40
41
42
# File 'lib/iudex-http-test/broken_server.rb', line 37

def accept_thread( &block )
  Thread.new do
    java.lang.Thread::currentThread.name = 'accept' # for logging
    accept( &block )
  end
end

#startObject



33
34
35
# File 'lib/iudex-http-test/broken_server.rb', line 33

def start
  @server = TCPServer.new( @port )
end

#stopObject



51
52
53
54
55
56
57
# File 'lib/iudex-http-test/broken_server.rb', line 51

def stop
  if @server
    @server.close
    @server = nil
    true
  end
end