test/functional/ft_2_errors.rb in ruote-2.1.11 vs test/functional/ft_2_errors.rb in ruote-2.2.0
- old
+ new
@@ -5,11 +5,11 @@
# Fri May 15 09:51:28 JST 2009
#
require File.join(File.dirname(__FILE__), 'base')
-require 'ruote/part/hash_participant'
+require 'ruote/participant'
class FtErrorsTest < Test::Unit::TestCase
include FunctionalBase
@@ -135,16 +135,16 @@
alpha
echo 'done.'
end
end
- count = 0
+ @engine.context.stash[:count] = 0
@engine.register_participant :alpha do
- count += 1
+ stash[:count] += 1
@tracer << "alpha\n"
- raise "something went wrong" if count == 1
+ raise "something went wrong" if stash[:count] == 1
end
#noisy
wfid = @engine.launch(pdef)
@@ -171,19 +171,20 @@
alpha
echo 'done.'
end
end
- count = 0
+ @engine.context.stash[:count] = 0
- alpha = @engine.register_participant :alpha do
- count += 1
+ alpha = @engine.register_participant :alpha, 'do_not_thread' => true do
+ stash[:count] += 1
@tracer << "alpha\n"
- raise "something went wrong" if count == 1
+ raise "something went wrong" if stash[:count] == 1
end
- alpha.do_not_thread = true
+ #noisy
+
wfid = @engine.launch(pdef)
wait_for(wfid)
ps = @engine.process(wfid)
@@ -198,19 +199,19 @@
end
class WeakCancelParticipant
include Ruote::LocalParticipant
- def initialize (opts)
+ def initialize(opts)
end
- def consume (workitem)
+ def consume(workitem)
# losing it
end
def do_not_thread
true
end
- def cancel (fei, flavour)
+ def cancel(fei, flavour)
raise "failure in #cancel"
end
end
def test_error_in_participant_cancel
@@ -254,18 +255,17 @@
define 'sub0' do
alpha
end
end
- count = 0
+ @engine.context.stash[:count] = 0
- alpha = @engine.register_participant :alpha do
- count += 1
+ alpha = @engine.register_participant :alpha, :do_not_thread => true do
+ stash[:count] += 1
@tracer << "alpha\n"
- raise "something went wrong" if count == 1
+ raise "something went wrong" if stash[:count] == 1
end
- alpha.do_not_thread = true
#noisy
wfid = @engine.launch(pdef)
@@ -276,11 +276,11 @@
assert_equal 1, ps.errors.size
err = ps.errors.first
assert_equal wfid, err.fei.wfid
- assert_not_nil err.fei.sub_wfid
+ assert_not_nil err.fei.subid
@engine.replay_at_error(err)
wait_for(wfid)
@@ -335,37 +335,21 @@
wait_for(wfid)
assert_nil @engine.process(wfid)
end
- #def test_ps_to_h
- # pdef = Ruote.process_definition do
- # error 'nada'
- # end
- # #noisy
- # wfid = @engine.launch(pdef)
- # wait_for(wfid)
- # ps = @engine.process(wfid)
- # es = ps.to_h['errors']
- # e = es.first
- # assert_equal 1, es.size
- # assert_equal 'reply', e['msg']['action']
- # assert_equal wfid, e['msg']['fei']['wfid']
- # assert_equal 8, e.size
- #end
-
def test_error_intercepted
pdef = Ruote.process_definition do
nada
end
wfid = @engine.launch(pdef)
r = @engine.wait_for(wfid)
- assert_equal 'RuntimeError', r['error_class']
- assert_equal "unknown participant or subprocess 'nada'", r['error_message']
- assert_equal Array, r['error_backtrace'].class
+ assert_equal 'RuntimeError', r['error']['class']
+ assert_equal "unknown participant or subprocess 'nada'", r['error']['message']
+ assert_equal Array, r['error']['trace'].class
end
end