Sha256: 3e32bd450f7c592d54c9bb28edc75ab5e121c1773f9ed879e6950b1d50fb5d0d

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'

if Concurrent::TestHelpers.jruby?

  require_relative 'cached_thread_pool_shared'

  module Concurrent

    describe JavaCachedThreadPool do

      subject { described_class.new(overflow_policy: :discard) }

      after(:each) do
        subject.kill
        sleep(0.1)
      end

      it_should_behave_like :cached_thread_pool

      context '#initialize' do

        it 'sets :overflow_policy correctly' do
          clazz = java.util.concurrent.ThreadPoolExecutor::DiscardPolicy
          policy = clazz.new
          clazz.should_receive(:new).at_least(:once).with(any_args).and_return(policy)

          subject = JavaCachedThreadPool.new(overflow_policy: :discard)
          subject.overflow_policy.should eq :discard
        end

        it 'defaults :overflow_policy to :abort' do
          subject = JavaCachedThreadPool.new
          subject.overflow_policy.should eq :abort
        end

        it 'raises an exception if given an invalid :overflow_policy' do
          expect {
            JavaCachedThreadPool.new(overflow_policy: :bogus)
          }.to raise_error(ArgumentError)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
concurrent-ruby-0.6.1 spec/concurrent/executor/java_cached_thread_pool_spec.rb
concurrent-ruby-0.6.0 spec/concurrent/executor/java_cached_thread_pool_spec.rb