File: java_thread_pool_executor_spec.rb

package info (click to toggle)
ruby-concurrent 1.1.6%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 30,284 kB
  • sloc: ruby: 30,875; java: 6,117; javascript: 1,114; ansic: 288; makefile: 10; sh: 6
file content (71 lines) | stat: -rw-r--r-- 2,038 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
if Concurrent.on_jruby?

  require_relative 'thread_pool_executor_shared'

  module Concurrent

    RSpec.describe JavaThreadPoolExecutor, :type => :jruby do

      after(:each) do
        subject.shutdown
        expect(subject.wait_for_termination(pool_termination_timeout)).to eq true
      end

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

      it_should_behave_like :thread_pool

      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
          expect(clazz).to receive(:new).at_least(:once).with(any_args).and_return(policy)
          JavaThreadPoolExecutor.new(
            min_threads: 2,
            max_threads: 5,
            idletime: 60,
            max_queue: 10,
            fallback_policy: :abort
          )
        end

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

        specify ':caller_runs maps to CallerRunsPolicy' do
          clazz = java.util.concurrent.ThreadPoolExecutor::CallerRunsPolicy
          policy = clazz.new
          expect(clazz).to receive(:new).at_least(:once).with(any_args).and_return(policy)
          JavaThreadPoolExecutor.new(
            min_threads: 2,
            max_threads: 5,
            idletime: 60,
            max_queue: 10,
            fallback_policy: :caller_runs
          )
        end
      end
    end
  end
end