public
Description: the [OpenWFEru] workflow and BPM engine (ruby)
Homepage: http://openwferu.rubyforge.org
Clone URL: git://github.com/jmettraux/ruote.git
ruote / test / ft_21b_cron_pause.rb
100644 83 lines (53 sloc) 1.233 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#
# Testing OpenWFEru
#
# John Mettraux at openwfe.org
#
# Sun Mar 23 13:26:15 JST 2008
#
 
require 'flowtestbase'
require 'openwfe/def'
 
 
class FlowTest21b < Test::Unit::TestCase
  include FlowTestBase
 
  #def setup
  #end
 
  #def teardown
  #end
 
  #
  # Test 0
  #
 
  class TestDefinition0 < OpenWFE::ProcessDefinition
    cron :tab => "* * * * * *", :name => "cron" do
      participant :cron_event
    end
  end
 
  #
  # this one tests whether a cron event is removed when his process
  # terminates, as should be.
  #
  def test_0
 
    #log_level_to_debug
 
    counter = 0
 
    @engine.register_participant(:cron_event) do
      counter += 1
    end
 
    #puts "start at #{Time.now.to_s}"
    #dotest TestDefinition0, "", 62
 
    fei = launch TestDefinition0
 
    sleep 0.350
 
    assert_equal "", @tracer.to_s
    assert_not_nil @engine.process_status(fei)
 
    sleep 3
 
    @engine.pause_process fei.wfid
 
    assert_equal 3, counter
 
    sleep 3
 
    assert_equal 3, counter
    assert_equal 0, @engine.process_status(fei).errors.size
 
    @engine.resume_process fei.wfid
 
    sleep 3
 
    assert_equal 6, counter
 
    @engine.cancel_process fei.wfid
 
    sleep 0.350
 
    assert_nil @engine.process_status(fei)
  end
 
end