public
Description: the [OpenWFEru] workflow and BPM engine (ruby)
Homepage: http://openwferu.rubyforge.org
Clone URL: git://github.com/jmettraux/ruote.git
ruote / test / eno_test.rb
100644 77 lines (53 sloc) 1.367 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
#
# Testing OpenWFEru
#
# John Mettraux at openwfe.org
#
# Tue Jan 2 13:14:37 JST 2007
#
 
require 'test/unit'
 
require 'openwfe/workitem'
require 'openwfe/engine/engine'
require 'openwfe/def'
require 'openwfe/participants/participants'
require 'openwfe/participants/enoparticipants'
 
require 'rubygems'
require 'mailtrap'
 
 
class EnoTest < Test::Unit::TestCase
 
  #def setup
  #end
 
  #def teardown
  #end
 
  #
  # Test 0
  #
 
  class TestDefinition0 < OpenWFE::ProcessDefinition
    email_notification_participant
  end
 
  def test_eno
 
    mailfile = "work/mailtrap.txt"
 
    FileUtils.mkdir "work" unless File.exist?("work")
    FileUtils.rm mailfile if File.exist?(mailfile)
    Thread.new do
      Mailtrap.new 'localhost', 2525, true, "work/mailtrap.txt"
    end
 
    engine = Engine.new
 
    eno = OpenWFE::MailParticipant.new(
      :smtp_server => "localhost",
      :smtp_port => 2525,
      :from_address => "eno@outoftheblue.co.jp"
    ) do
 
      s = ""
      s << "Subject: test 0\n"
      s << "\n"
      s << "konnichiwa. #{Time.now.to_s}\n\n"
 
      s
    end
 
    engine.register_participant("email_notification_participant", eno)
 
    li = OpenWFE::LaunchItem.new TestDefinition0
 
    li.email_target = 'john@localhost'
 
    fei = engine.launch li
    engine.wait_for fei
 
    assert_equal 1, OpenWFE.grep("konnichiwa", mailfile).size
  end
end