Sha256: 5432d452df9c85292c67f115fbc778a12f16c894ccc595ed7cac333364a94fa5

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 KB

Contents

#
# testing ruote
#
# Thu Apr 22 14:41:38 JST 2010
#

require File.join(File.dirname(__FILE__), 'base')

require 'ruote/part/local_participant'


class FtParticipantOnReplyTest < Test::Unit::TestCase
  include FunctionalBase

  class MyParticipant
    include Ruote::LocalParticipant
    def initialize(opts)
    end
    def consume(workitem)
      reply(workitem)
    end
    def on_reply(workitem)
      workitem.fields['message'] = 'hello'
    end
  end

  def test_participant_on_reply

    pdef = Ruote.process_definition do
      sequence do
        alpha
        echo '${f:message}'
      end
    end

    @engine.register_participant :alpha, MyParticipant

    #noisy

    assert_trace('hello', pdef)
  end

  class AwkwardParticipant
    include Ruote::LocalParticipant
    def initialize(opts)
    end
    def consume(workitem)
      reply(workitem)
    end
    def on_reply(workitem)
      return if workitem.fields['pass']
      raise "something went wrong"
    end
  end

  def test_participant_on_reply_error

    pdef = Ruote.process_definition do
      sequence do
        alpha
        echo 'over.'
      end
    end

    @engine.register_participant :alpha, AwkwardParticipant

    #noisy

    wfid = @engine.launch(pdef)

    wait_for(wfid)

    ps = @engine.process(wfid)

    assert_equal 1, ps.errors.size

    err = ps.errors.first
    err.fields['pass'] = true
    @engine.replay_at_error(err)

    wait_for(wfid)

    assert_equal 'over.', @tracer.to_s
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
ruote-maestrodev-2.2.1 test/functional/ft_43_participant_on_reply.rb
ruote-2.2.0 test/functional/ft_43_participant_on_reply.rb