Sha256: 35d587d2308e445473aac8b81a19171f82dcdcfce60a86d1e709cf92c4105cad

Contents?: true

Size: 1.88 KB

Versions: 2

Compression:

Stored size: 1.88 KB

Contents

require 'spec_helper'

if Concurrent::TestHelpers.jruby?

  require_relative 'thread_pool_executor_shared'

  module Concurrent

    describe JavaThreadPoolExecutor do

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

      subject do
        JavaThreadPoolExecutor.new(
          min_threads: 2,
          max_threads: 5,
          idletime: 60,
          max_queue: 10,
          overflow_policy: :discard
        )
      end

      it_should_behave_like :thread_pool_executor

      context '#overload_policy' do

        specify ':abort maps to AbortPolicy' do
          clazz = java.util.concurrent.ThreadPoolExecutor::AbortPolicy
          policy = clazz.new
          clazz.should_receive(:new).at_least(:once).with(any_args).and_return(policy)
          JavaThreadPoolExecutor.new(
            min_threads: 2,
            max_threads: 5,
            idletime: 60,
            max_queue: 10,
            overflow_policy: :abort
          )
        end

        specify ':discard maps to DiscardPolicy' do
          clazz = java.util.concurrent.ThreadPoolExecutor::DiscardPolicy
          policy = clazz.new
          clazz.should_receive(:new).at_least(:once).with(any_args).and_return(policy)
          JavaThreadPoolExecutor.new(
            min_threads: 2,
            max_threads: 5,
            idletime: 60,
            max_queue: 10,
            overflow_policy: :discard
          )
        end

        specify ':caller_runs maps to CallerRunsPolicy' do
          clazz = java.util.concurrent.ThreadPoolExecutor::CallerRunsPolicy
          policy = clazz.new
          clazz.should_receive(:new).at_least(:once).with(any_args).and_return(policy)
          JavaThreadPoolExecutor.new(
            min_threads: 2,
            max_threads: 5,
            idletime: 60,
            max_queue: 10,
            overflow_policy: :caller_runs
          )
        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_thread_pool_executor_spec.rb
concurrent-ruby-0.6.0 spec/concurrent/executor/java_thread_pool_executor_spec.rb