Sha256: 50ce741407e5e7c7b6e72f65fd8371c2378f52efc237200d3ebf28c97b3a1f50

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require 'spec_helper'

if 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

1 entries across 1 versions & 1 rubygems

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