Sha256: c7badf1f959fa636a79f70c17b9a6f7a865fabf2251f36d45261d1a5988002cb

Contents?: true

Size: 1.55 KB

Versions: 8

Compression:

Stored size: 1.55 KB

Contents

#
# testing ruote
#
# Wed Aug 12 23:24:16 JST 2009
#

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

require 'ruote/participant'


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

  def setup

    super

    @pdef = Ruote.process_definition :name => 'test' do
      sequence do
        alpha
        echo '.'
      end
    end

    @alpha = @engine.register_participant 'alpha', MyParticipant.new
  end

  class MyParticipant
    include Ruote::LocalParticipant

    attr_accessor :wi

    def consume (workitem)

      @wi = workitem

      # no reply to the engine
    end

    # do not let the dispatch happen in its own thread, this makes
    # wait_for(:alpha) synchronous.
    #
    def do_not_thread

      true
    end
  end

  class MyReceiver < Ruote::Receiver
  end

  def test_my_receiver

    receiver = MyReceiver.new(@engine.storage)

    #noisy

    wfid = @engine.launch(@pdef)

    wait_for(:alpha)
    while @alpha.wi.nil? do
      Thread.pass
    end

    assert_equal 3, @engine.process(wfid).expressions.size

    receiver.receive(@alpha.wi)

    wait_for(wfid)

    assert_nil @engine.process(wfid)

    rcv = logger.log.select { |e| e['action'] == 'receive' }.first
    assert_equal 'FtReceiverTest::MyReceiver', rcv['receiver']
  end

  def test_engine_receive

    wfid = @engine.launch(@pdef)

    wait_for(:alpha)

    @engine.receive(@alpha.wi)

    wait_for(wfid)

    assert_nil @engine.process(wfid)

    rcv = logger.log.select { |e| e['action'] == 'receive' }.first
    assert_equal 'Ruote::Engine', rcv['receiver']
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ruote-2.1.9 test/functional/ft_25_receiver.rb
ruote-2.1.8 test/functional/ft_25_receiver.rb
ruote-2.1.7 test/functional/ft_25_receiver.rb
ruote-2.1.6 test/functional/ft_25_receiver.rb
ruote-2.1.5 test/functional/ft_25_receiver.rb
ruote-2.1.4 test/functional/ft_25_receiver.rb
ruote-2.1.3 test/functional/ft_25_receiver.rb
ruote-2.1.2 test/functional/ft_25_receiver.rb