Class: Iudex::HTTP::Test::BrokenServer
- Inherits:
-
Object
- Object
- Iudex::HTTP::Test::BrokenServer
- Defined in:
- lib/iudex-http-test/broken_server.rb
Instance Attribute Summary collapse
-
#port ⇒ Object
Returns the value of attribute port.
Instance Method Summary collapse
- #accept ⇒ Object
- #accept_thread(&block) ⇒ Object
-
#initialize ⇒ BrokenServer
constructor
A new instance of BrokenServer.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize ⇒ BrokenServer
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
#port ⇒ Object
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
#accept ⇒ Object
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 |
#start ⇒ Object
33 34 35 |
# File 'lib/iudex-http-test/broken_server.rb', line 33 def start @server = TCPServer.new( @port ) end |
#stop ⇒ Object
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 |