Sha256: ad0a3fc4fb636e73ae878fe6dc665a8ed1907eb26e2e3fc030b69e068b359c46

Contents?: true

Size: 1.19 KB

Versions: 3

Compression:

Stored size: 1.19 KB

Contents

require "logstash/devutils/rspec/spec_helper"
require "logstash/inputs/stomp"

describe LogStash::Inputs::Stomp do
  let(:host) { "localhost" }
  let(:destination) { "/foo" }
  let(:stomp_settings) {
    {
      "host" => host,
      "destination" => destination
    }
  }
  subject(:instance) { described_class.new(stomp_settings) }
  let(:client) { double("client") }

  before do
    allow(instance).to receive(:new_client).and_return(client)
    allow(client).to receive(:on_connection_closed)
    allow(instance).to receive(:new_client).and_return(client)
  end

  context "when registered" do
    it "should register without error" do
      instance.register
    end
  end

  context "connecting and disconnecting" do
    before do
      allow(client).to receive(:connect)
      allow(client).to receive(:connected?).and_return(true)
      allow(client).to receive(:subscribe)
      allow(client).to receive(:disconnect)
    end

    it "should connect and disconnect" do
      instance.register
      t = Thread.new { instance.run(Queue.new) }
      sleep 5
      expect(client).to have_received(:connect)
      instance.do_stop
      expect(client).to have_received(:disconnect)
      t.join
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
logstash-input-stomp-3.0.8 spec/inputs/stomp_spec.rb
logstash-input-stomp-3.0.7 spec/inputs/stomp_spec.rb
logstash-input-stomp-3.0.6 spec/inputs/stomp_spec.rb