Skip to content

Commit b564d41

Browse files
committed
Added tests for thread pool executor classes.
1 parent a80e1ff commit b564d41

File tree

2 files changed

+55
-100
lines changed

2 files changed

+55
-100
lines changed
Lines changed: 29 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,29 @@
1-
#require 'spec_helper'
2-
#
3-
#if jruby?
4-
#
5-
# require_relative 'cached_thread_pool_shared'
6-
# require_relative 'fixed_thread_pool_shared'
7-
#
8-
# module Concurrent
9-
#
10-
# describe JavaThreadPoolExecutor do
11-
#
12-
# after(:each) do
13-
# subject.kill
14-
# sleep(0.1)
15-
# end
16-
#
17-
# context 'cached thread pool emulation' do
18-
#
19-
# let(:described_class) do
20-
# Class.new(JavaThreadPoolExecutor) do
21-
# def initialize(opts = {})
22-
# max_length = opts.fetch(:max_threads, JavaThreadPoolExecutor::DEFAULT_MAX_POOL_SIZE).to_i
23-
# idletime = opts.fetch(:idletime, JavaThreadPoolExecutor::DEFAULT_THREAD_IDLETIMEOUT).to_i
24-
# raise ArgumentError.new('idletime must be greater than zero') if idletime <= 0
25-
# raise ArgumentError.new('max_threads must be greater than zero') if max_length <= 0
26-
# super(opts)
27-
# end
28-
# end
29-
# end
30-
#
31-
# subject { described_class.new(max_threads: 5) }
32-
#
33-
# it_should_behave_like :cached_thread_pool
34-
# end
35-
#
36-
# context 'fixed thread pool emulation' do
37-
#
38-
# let(:described_class) do
39-
# Class.new(JavaThreadPoolExecutor) do
40-
# def initialize(max_threads)
41-
# super(min_threads: max_threads, max_threads: max_threads, idletime: 0)
42-
# end
43-
# end
44-
# end
45-
#
46-
# subject { described_class.new(max_threads: 5) }
47-
#
48-
# it_should_behave_like :fixed_thread_pool
49-
# end
50-
# end
51-
# end
52-
#end
1+
require 'spec_helper'
2+
3+
if jruby?
4+
5+
require_relative 'thread_pool_shared'
6+
7+
module Concurrent
8+
9+
describe JavaThreadPoolExecutor do
10+
11+
after(:each) do
12+
subject.kill
13+
sleep(0.1)
14+
end
15+
16+
subject do
17+
JavaThreadPoolExecutor.new(
18+
min_threads: 2,
19+
max_threads: 5,
20+
idletime: 1,
21+
max_queue: 10,
22+
overflow_policy: :abort
23+
)
24+
end
25+
26+
it_should_behave_like :thread_pool
27+
end
28+
end
29+
end
Lines changed: 26 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,26 @@
1-
#require 'spec_helper'
2-
#require_relative 'cached_thread_pool_shared'
3-
#require_relative 'fixed_thread_pool_shared'
4-
#
5-
#module Concurrent
6-
#
7-
# describe RubyThreadPoolExecutor do
8-
#
9-
# after(:each) do
10-
# subject.kill
11-
# sleep(0.1)
12-
# end
13-
#
14-
# context 'cached thread pool emulation' do
15-
#
16-
# let(:described_class) do
17-
# Class.new(RubyThreadPoolExecutor) do
18-
# def initialize(opts = {})
19-
# max_length = opts.fetch(:max_threads, RubyThreadPoolExecutor::DEFAULT_MAX_POOL_SIZE).to_i
20-
# idletime = opts.fetch(:idletime, RubyThreadPoolExecutor::DEFAULT_THREAD_IDLETIMEOUT).to_i
21-
# raise ArgumentError.new('idletime must be greater than zero') if idletime <= 0
22-
# raise ArgumentError.new('max_threads must be greater than zero') if max_length <= 0
23-
# super(opts)
24-
# end
25-
# end
26-
# end
27-
#
28-
# subject { described_class.new(max_threads: 5) }
29-
#
30-
# it_should_behave_like :cached_thread_pool
31-
# end
32-
#
33-
# context 'fixed thread pool emulation' do
34-
#
35-
# let(:described_class) do
36-
# Class.new(RubyThreadPoolExecutor) do
37-
# def initialize(max_threads)
38-
# super(min_threads: max_threads, max_threads: max_threads, idletime: 0)
39-
# end
40-
# end
41-
# end
42-
#
43-
# subject { described_class.new(max_threads: 5) }
44-
#
45-
# it_should_behave_like :fixed_thread_pool
46-
# end
47-
# end
48-
#end
1+
require 'spec_helper'
2+
3+
require_relative 'thread_pool_shared'
4+
5+
module Concurrent
6+
7+
describe RubyThreadPoolExecutor do
8+
9+
after(:each) do
10+
subject.kill
11+
sleep(0.1)
12+
end
13+
14+
subject do
15+
RubyThreadPoolExecutor.new(
16+
min_threads: 2,
17+
max_threads: 5,
18+
idletime: 1,
19+
max_queue: 10,
20+
overflow_policy: :abort
21+
)
22+
end
23+
24+
it_should_behave_like :thread_pool
25+
end
26+
end

0 commit comments

Comments
 (0)