Sha256: 3b698ed3fe7ccbf1936a0d3fbad3c51a9a8d1e10c8ab4f4b7c5a11283d16b9fc

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

#
# testing ruote
#
# Wed Jul  8 15:30:55 JST 2009
#

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

#require 'ruote/part/hash_participant'


class CtConcurrenceTest < Test::Unit::TestCase
  include ConcurrentBase

  def test_collision

    pdef = Ruote.process_definition do
      concurrence do
        echo 'a'
        echo 'b'
      end
    end

    #noisy

    wfid = @engine0.launch(pdef)
    @engine0.step 4

    $stderr.puts "*cough*" if @storage.get_msgs.size != 2

    t0 = Thread.new { @engine1.step! }
    t1 = Thread.new { @engine0.step! }
    t0.join
    t1.join

    #t0 = Thread.new { @engine1.step }
    #@engine0.step
    #t0.join

    msgs = @storage.get_msgs
    msg = msgs.first

    if msgs.size > 1 || (msg['fei'] && msg['fei']['expid'] != '0')

      msgs.each do |m|

        fei = m['fei'] ?
          Ruote::FlowExpressionId.to_s_id(m['fei']) : ''
        wi_fei = m['workitem'] ?
          Ruote::FlowExpressionId.to_s_id(m['workitem']['fei']) : ''

        p [ m['action'], fei, wi_fei ]
      end
    end

    if msg['action'] == 'error_intercepted'
      #p @engine0.process(wfid).errors.first
      puts @engine0.process(wfid).errors.first.message
      puts @engine0.process(wfid).errors.first.trace
    end

    assert_equal 1, msgs.size
    assert_equal 'reply', msg['action']
    assert_equal '0', msg['fei']['expid']
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruote-2.1.1 test/functional/ct_0_concurrence.rb