test/ruby_procdef_test.rb in ruote-0.9.18 vs test/ruby_procdef_test.rb in ruote-0.9.19
- old
+ new
@@ -16,117 +16,117 @@
require 'openwfe/engine/file_persisted_engine'
require 'openwfe/participants/storeparticipants'
#
-# fighting bug at :
+# fighting bug at :
# http://rubyforge.org/tracker/index.php?func=detail&aid=13238&group_id=2609&atid=10023
#
class RubyProcDefTest < Test::Unit::TestCase
- def setup
+ def setup
- @engine = OpenWFE::CachedFilePersistedEngine.new(
- :definition_in_launchitem_allowed => true)
+ @engine = OpenWFE::CachedFilePersistedEngine.new(
+ :definition_in_launchitem_allowed => true)
- @engine.register_participant :alpha, OpenWFE::HashParticipant
- end
+ @engine.register_participant :alpha, OpenWFE::HashParticipant
+ end
- def teardown
+ def teardown
- @engine.stop if @engine
- end
+ @engine.stop if @engine
+ end
- #
- # TESTS
+ #
+ # TESTS
- class Test0 < OpenWFE::ProcessDefinition
- sequence do
- alpha
- end
+ class Test0 < OpenWFE::ProcessDefinition
+ sequence do
+ alpha
end
+ end
- def test_0
+ def test_0
- fei0 = @engine.launch Test0
- sleep 0.100
- fei1 = @engine.launch Test0
- sleep 0.200
+ fei0 = @engine.launch Test0
+ sleep 0.100
+ fei1 = @engine.launch Test0
+ sleep 0.200
- stack0 = @engine.process_stack fei0.wfid
- stack1 = @engine.process_stack fei1.wfid
+ stack0 = @engine.process_stack fei0.wfid
+ stack1 = @engine.process_stack fei1.wfid
- assert_equal 3, stack0.size
- assert_equal 3, stack1.size
+ assert_equal 3, stack0.size
+ assert_equal 3, stack1.size
- assert_equal 4, count_files(fei0.wfid)
- assert_equal 4, count_files(fei1.wfid)
+ assert_equal 4, count_files(fei0.wfid)
+ assert_equal 4, count_files(fei1.wfid)
- @engine.cancel_process(fei0.wfid)
- @engine.cancel_process(fei1.wfid)
+ @engine.cancel_process(fei0.wfid)
+ @engine.cancel_process(fei1.wfid)
- sleep 0.350
- end
+ sleep 0.350
+ end
- TEST1 = """
+ TEST1 = """
class Test1 < OpenWFE::ProcessDefinition
- sequence do
- alpha
- end
+ sequence do
+ alpha
+ end
end
- """
+ """
- def test_1
+ def test_1
- fei0 = launch TEST1
- sleep 0.100
- fei1 = launch TEST1
- sleep 0.200
+ fei0 = launch TEST1
+ sleep 0.100
+ fei1 = launch TEST1
+ sleep 0.200
- assert_equal(
- OpenWFE::ProcessDefinition::Test1,
- OpenWFE::ProcessDefinition.extract_class(TEST1))
+ assert_equal(
+ OpenWFE::ProcessDefinition::Test1,
+ OpenWFE::ProcessDefinition.extract_class(TEST1))
- stack0 = @engine.process_stack fei0.wfid
- #puts stack0
- stack1 = @engine.process_stack fei1.wfid
- #puts stack1
+ stack0 = @engine.process_stack fei0.wfid
+ #puts stack0
+ stack1 = @engine.process_stack fei1.wfid
+ #puts stack1
- assert_equal 3, stack0.size
- assert_equal 3, stack1.size
+ assert_equal 3, stack0.size
+ assert_equal 3, stack1.size
- assert_equal 4, count_files(fei0.wfid)
- assert_equal 4, count_files(fei1.wfid)
+ assert_equal 4, count_files(fei0.wfid)
+ assert_equal 4, count_files(fei1.wfid)
- @engine.cancel_process(fei0.wfid)
- @engine.cancel_process(fei1.wfid)
+ @engine.cancel_process(fei0.wfid)
+ @engine.cancel_process(fei1.wfid)
- sleep 0.350
- end
+ sleep 0.350
+ end
- protected
+ protected
- def launch (test_string)
+ def launch (test_string)
- filename = "work/procdef.rb"
+ filename = "work/procdef.rb"
- File.open(filename, "w") do |f|
- f.puts test_string
- end
- @engine.launch filename
- end
+ File.open(filename, "w") do |f|
+ f.puts test_string
+ end
+ @engine.launch filename
+ end
- def count_files (wfid)
+ def count_files (wfid)
- count = 0
+ count = 0
- Find.find("work/expool/") do |path|
- next unless path.match(wfid+"__.*\.yaml")
- count += 1
- end
+ Find.find("work/expool/") do |path|
+ next unless path.match(wfid+"__.*\.yaml")
+ count += 1
+ end
- count
- end
+ count
+ end
end