Sha256: d6a6dba372dc9ef26d40995eac353b1840dc87d31d70ac991a4d62cd1223c8b0

Contents?: true

Size: 1.52 KB

Versions: 2

Compression:

Stored size: 1.52 KB

Contents

#
# testing ruote
#
# Fri Sep 25 16:15:57 JST 2009
#
# By David Goldhirsch
#

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

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

 def test_equal_time_favors_first
   run_engine
   assert_equal 'first', @tracer.to_s
 end

 def test_second_is_faster
   #noisy
   run_engine :first_time => 0.5
   assert_equal 'second', @tracer.to_s
 end

 def test_first_is_faster
   run_engine  :second_time => 0.5
   assert_equal 'first', @tracer.to_s
 end

 protected

 def run_engine(options={})

   @engine.context.stash[:first_time] = options[:first_time] || 0.0
   @engine.context.stash[:second_time] = options[:second_time] || 0.0

   if @engine.context.stash[:first_time] == @engine.context.stash[:second_time]
     @engine.context.stash[:second_time] = @engine.context.stash[:first_time] + 0.1
   end

   pdef = Ruote.process_definition :name => 'simple' do
     sequence do
       concurrence do # spec says this is equivalent to :count => 1
         participant :ref => 'first'
         participant :ref => 'second'
       end
       participant :ref => 'trace'
     end
   end

   @engine.register_participant :first do |wi|
     sleep stash[:first_time]
     wi.fields['result'] = 'first'
   end

   @engine.register_participant :second do |wi|
     sleep stash[:second_time]
     wi.fields['result'] = 'second'
   end

   @engine.register_participant :trace do |wi|
     @tracer << "#{wi.fields['result']}"
   end

   wfid = @engine.launch(pdef)
   @engine.wait_for(wfid)

   wfid
 end
end

Version data entries

2 entries across 2 versions & 2 rubygems

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