test/functional/eft_6_concurrence.rb in ruote-2.1.11 vs test/functional/eft_6_concurrence.rb in ruote-2.2.0
- old
+ new
@@ -5,11 +5,11 @@
# Thu Jun 11 15:24:47 JST 2009
#
require File.join(File.dirname(__FILE__), 'base')
-require 'ruote/part/hash_participant'
+#require 'ruote/part/hash_participant'
class EftConcurrenceTest < Test::Unit::TestCase
include FunctionalBase
@@ -40,24 +40,24 @@
alpha
end
bravo
end
- count = 0
+ @engine.context.instance_eval do
+ @count = 0
+ end
+ # since block participants are evaluated in the context context
- alpha = @engine.register_participant :alpha do |workitem|
- workitem.fields['seen'] = 'indeed' if count == 1
+ alpha = @engine.register_participant :alpha, 'do_not_thread' => true do |wi|
+ wi.fields['seen'] = 'indeed' if @count == 1
@tracer << "alpha\n"
- count = count + 1
+ @count = @count + 1
nil
end
- alpha.do_not_thread = true
- fields = nil
-
@engine.register_participant :bravo do |workitem|
- fields = workitem.fields
+ stash[:fields] = workitem.fields
nil
end
#noisy
@@ -65,14 +65,14 @@
#assert_equal(
# {'1'=>{"seen"=>"indeed"}, '0'=>{}, "params"=>{"ref"=>"bravo"}},
# fields)
- params = fields.delete('params')
+ params = @engine.context.stash[:fields].delete('params')
assert_equal({ 'ref' => 'bravo' }, params)
- assert_match /seen/, fields.inspect
+ assert_match /seen/, @engine.context.stash[:fields].inspect
end
def test_over_unless
pdef = Ruote.process_definition do
@@ -83,21 +83,23 @@
alpha
end
echo 'done.'
end
- count = 0
+ @engine.context.instance_eval do
+ @count = 0
+ end
+ # since block participants are evaluated in the context context
- alpha = @engine.register_participant :alpha do |workitem|
- if count > 1
- workitem.fields['ok'] = false
+ alpha = @engine.register_participant :alpha, 'do_not_thread' => true do |wi|
+ if @count > 1
+ wi.fields['ok'] = false
else
@tracer << "a\n"
- count = count + 1
+ @count = @count + 1
end
end
- alpha.do_not_thread = true
fields = nil
@engine.register_participant :bravo do |workitem|
fields = workitem.fields
@@ -123,11 +125,11 @@
assert_trace %w[ a b done. ], %w[ b a done. ], pdef
end
# helper
#
- def run_concurrence (concurrence_attributes, noise)
+ def run_concurrence(concurrence_attributes, noise)
pdef = Ruote.process_definition do
sequence do
concurrence(concurrence_attributes) do
alpha
@@ -135,11 +137,11 @@
end
end
alpha
end
- alpha = @engine.register_participant :alpha, Ruote::HashParticipant.new
+ alpha = @engine.register_participant :alpha, Ruote::StorageParticipant
noisy if noise
wfid = @engine.launch(pdef)
@@ -204,29 +206,28 @@
assert_equal(%w[ seen ], wi.fields['stack'][1].keys)
end
# helper
#
- def run_test_count (remaining, noise)
+ def run_test_count(remaining, noise)
pdef = Ruote.process_definition do
concurrence :count => 1, :remaining => remaining do
alpha
bravo
end
end
- @alpha = @engine.register_participant :alpha, Ruote::HashParticipant.new
- @bravo = @engine.register_participant :bravo, Ruote::HashParticipant.new
+ @engine.register_participant '.+', Ruote::StorageParticipant
noisy if noise
wfid = @engine.launch(pdef)
wait_for(:alpha)
- @alpha.reply(@alpha.first)
+ @engine.storage_participant.reply(@engine.storage_participant.first)
wait_for(wfid)
wfid
end
@@ -242,31 +243,30 @@
#puts
assert_equal 1, logger.log.select { |e| e['action'] == 'cancel' }.size
sleep 0.350 # since now dispatch_cancel occurs asynchronously...
- assert_equal 0, @alpha.size
- assert_equal 0, @bravo.size
+ assert_equal 0, @engine.storage_participant.size
end
def test_count_remaining_forget
#noisy
wfid = run_test_count('forget', false)
#assert_equal 1, logger.log.select { |e| e['action'] == 'forget' }.size
- assert_equal 0, @alpha.size
- assert_equal 1, @bravo.size
+ assert_equal 1, @engine.storage_participant.size
+ assert_equal 'bravo', @engine.storage_participant.first.participant_name
#@engine.context.storage.get_many('expressions').each { |e| p e['fei'] }
#puts @engine.context.storage.dump('expressions')
assert_equal 2, @engine.context.storage.get_many('expressions').size
assert_not_nil @engine.process(wfid)
- @bravo.reply(@bravo.first)
+ @engine.storage_participant.reply(@engine.storage_participant.first)
wait_for(wfid)
@engine.context.storage.get_many('expressions').each { |e| p e['fei'] }
assert_equal 0, @engine.context.storage.get_many('expressions').size
@@ -279,10 +279,10 @@
alpha
alpha
end
end
- alpha = @engine.register_participant :alpha, Ruote::HashParticipant.new
+ alpha = @engine.register_participant :alpha, Ruote::StorageParticipant
#noisy
wfid = @engine.launch(pdef)