Sha256: ed433f8baf6c0edf7ce53b15619986db3d82991972898390122478b543a035cf

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

#
# testing ruote
#
# Wed Jul 21 13:37:59 JST 2010
#

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

require 'ruote/part/local_participant'


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

  class MyParticipant
    include Ruote::LocalParticipant

    def initialize (opts)
      @opts = opts
    end

    def accept? (workitem)
      workitem.participant_name.match(@opts['filter'] || '.?')
    end

    def consume (workitem)
      @context.tracer << 'filtered:'
      @context.tracer << workitem.participant_name
      @context.tracer << "\n"
      reply(workitem)
    end
  end

  class MyOtherParticipant
    include Ruote::LocalParticipant

    def consume (workitem)
      @context.tracer << workitem.participant_name
      @context.tracer << "\n"
      reply(workitem)
    end
  end

  def test_participant_on_reply

    pdef = Ruote.process_definition do
      sequence do
        absolute
        aberrant
        aloof
        nada
      end
    end

    @engine.register_participant 'a.+', MyParticipant, 'filter' => '^ab'
    @engine.register_participant '.+', MyOtherParticipant

    #noisy

    assert_trace %w[ filtered:absolute filtered:aberrant aloof nada ], pdef
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruote-2.1.11 test/functional/ft_45_participant_accept.rb