File tree Expand file tree Collapse file tree 2 files changed +20
-10
lines changed Expand file tree Collapse file tree 2 files changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,13 @@ def lowercase_keys(hash)
9797
9898 public
9999 def teardown
100- @server . stop ( true )
100+ if @server
101+ @server . stop ( true )
102+ begin
103+ @server . binder . close if @server . binder
104+ rescue IOError
105+ end
106+ end
101107 end
102108
103109end # class LogStash::Inputs::Http
Original file line number Diff line number Diff line change 66describe LogStash ::Inputs ::Http do
77
88 let ( :agent ) { FTW ::Agent . new }
9+ let ( :queue ) { Queue . new }
910
10- it "should read events with json codec" do
11- conf = <<-CONFIG
12- input {
13- http { codec => json }
14- }
15- CONFIG
11+ after :each do
12+ subject . teardown
13+ end
1614
17- event = input ( conf ) do |pipeline , queue |
18- agent . post! ( "http://127.0.0.1:8080/meh.json" , :body => { "message" => "Hello" } . to_json )
19- queue . pop
15+ context "with json codec" do
16+ subject { LogStash ::Inputs ::Http . new ( "codec" => "json" ) }
17+ it "should parse the json body" do
18+ subject . register
19+ Thread . new { subject . run ( queue ) }
20+ agent . post! ( "http://localhost:8080/meh.json" , :body => { "message" => "Hello" } . to_json )
21+ event = queue . pop
22+ expect ( event [ "message" ] ) . to eq ( "Hello" )
2023 end
24+ end
2125
2226 context "with :ssl => false" do
2327 subject { LogStash ::Inputs ::Http . new ( "ssl" => false ) }
You can’t perform that action at this time.
0 commit comments