Sha256: 42abe8e2382010cfc8cbc6755ca6efb99270e7d5f93dc895da7b25bc30720202

Contents?: true

Size: 1.09 KB

Versions: 63

Compression:

Stored size: 1.09 KB

Contents

class TestThreadedResource < Test::Unit::TestCase
  def object
    @object ||= {}
  end

  def resource
    @resource = EM::ThreadedResource.new do
      object
    end
  end

  def teardown
    resource.shutdown
  end

  def test_dispatch_completion
    EM.run do
      completion = resource.dispatch do |o|
        o[:foo] = :bar
        :foo
      end
      completion.callback do |result|
        assert_equal :foo, result
        EM.stop
      end
    end
    assert_equal :bar, object[:foo]
  end

  def test_dispatch_failure
    completion = resource.dispatch do |o|
      raise 'boom'
    end
    completion.errback do |error|
      assert_kind_of RuntimeError, error
      assert_equal 'boom', error.message
    end
  end

  def test_dispatch_threading
    main = Thread.current
    resource.dispatch do |o|
      o[:dispatch_thread] = Thread.current
    end
    assert_not_equal main, object[:dispatch_thread]
  end

  def test_shutdown
    # This test should get improved sometime. The method returning thread is
    # NOT an api that will be maintained.
    assert !resource.shutdown.alive?
  end
end

Version data entries

63 entries across 63 versions & 5 rubygems

Version Path
sensu-em-2.4.1-java tests/test_threaded_resource.rb
sensu-em-2.4.1 tests/test_threaded_resource.rb
eventmachine-1.0.4-java tests/test_threaded_resource.rb
eventmachine-1.0.4 tests/test_threaded_resource.rb
sensu-em-2.4.0-x86-mingw32 tests/test_threaded_resource.rb
sonixlabs-eventmachine-java-1.0.3.2-java tests/test_threaded_resource.rb
sonixlabs-eventmachine-java-1.0.3.1-java tests/test_threaded_resource.rb
sonixlabs-eventmachine-java-1.0.3.1 tests/test_threaded_resource.rb
sensu-em-2.4.0-java tests/test_threaded_resource.rb
sensu-em-2.4.0 tests/test_threaded_resource.rb
sensu-em-2.3.0-java tests/test_threaded_resource.rb
sensu-em-2.3.0 tests/test_threaded_resource.rb
sensu-em-2.2.0-java tests/test_threaded_resource.rb
sensu-em-2.2.0 tests/test_threaded_resource.rb
sensu-em-2.1.0-java tests/test_threaded_resource.rb
sensu-em-2.1.0 tests/test_threaded_resource.rb
sensu-em-2.0.0-java tests/test_threaded_resource.rb
sensu-em-2.0.0 tests/test_threaded_resource.rb
sonixlabs-eventmachine-java-1.0.0.rc.7-java tests/test_threaded_resource.rb
eventmachine-1.0.3-x86-mswin32-60 tests/test_threaded_resource.rb