test/wfid_test.rb in ruote-0.9.18 vs test/wfid_test.rb in ruote-0.9.19
- old
+ new
@@ -5,11 +5,11 @@
# John Mettraux at openwfe.org
#
# Sun Oct 29 16:18:25 JST 2006
#
-#require "rubygems"
+require "rubygems"
#require "thread"
#require "fastthread"
require 'test/unit'
@@ -23,153 +23,153 @@
#
# testing otime and the scheduler (its cron aspect)
#
class WfidTest < Test::Unit::TestCase
- #def setup
- #end
+ #def setup
+ #end
- #def teardown
- #end
+ #def teardown
+ #end
- def test_wfid_0
+ def test_wfid_0
- gen = OpenWFE::DefaultWfidGenerator.new("wfidgen", nil)
+ gen = OpenWFE::DefaultWfidGenerator.new('wfidgen', nil)
- thread = nil
+ thread = nil
- n = 777
- #n = 1000000
+ n = 777
+ #n = 1000000
- map = {}
+ map = {}
- n.times do |i|
+ n.times do |i|
- thread = Thread.new do
+ thread = Thread.new do
- wfid = gen.generate
+ wfid = gen.generate
- #puts wfid
+ #puts wfid
- abort "\nduplicate workflow_instance_id found !!!" \
- if map[wfid]
+ abort "\nduplicate workflow_instance_id found !!!" \
+ if map[wfid]
- map[wfid] = true
+ map[wfid] = true
- #puts wfid if i == n-1
- end
- end
+ #puts wfid if i == n-1
+ end
+ end
- thread.join
+ thread.join
- sleep(0.1)
- #puts
-
- assert_equal map.size, n
+ sleep(0.1)
+ #puts
- assert true
- end
+ assert_equal map.size, n
- def test_wfid_1
+ assert true
+ end
- gen = OpenWFE::DefaultWfidGenerator.new("wfidgen", nil)
+ def test_wfid_1
- a = %w{ 1 2 3 4 5 }
- s = a.join
+ gen = OpenWFE::DefaultWfidGenerator.new('wfidgen', nil)
- #a2 = gen.split_wfid(s)
- a2 = OpenWFE::split_wfid(s)
+ a = %w{ 1 2 3 4 5 }
+ s = a.join
- assert_equal a, a2
- end
+ #a2 = gen.split_wfid(s)
+ a2 = OpenWFE::split_wfid(s)
- def test_wfid_2
+ assert_equal a, a2
+ end
- gen = OpenWFE::UuidWfidGenerator.new("wfidgen", nil)
+ def test_wfid_2
- id = gen.generate
+ gen = OpenWFE::UuidWfidGenerator.new('wfidgen', nil)
- #puts id
+ id = gen.generate
- #assert_equal gen.split_wfid(id).join, id[0, 8]
- assert_equal OpenWFE::split_wfid(id).join, id[0, 8]
- end
+ #puts id
- def test_kotoba_wfid
+ #assert_equal gen.split_wfid(id).join, id[0, 8]
+ assert_equal OpenWFE::split_wfid(id).join, id[0, 8]
+ end
- gen = OpenWFE::KotobaWfidGenerator.new("wfidgen", nil)
+ def test_kotoba_wfid
- t = Time.now.gmtime
- kid = gen.generate
+ gen = OpenWFE::KotobaWfidGenerator.new('wfidgen', nil)
- #puts "now : #{t}"
- #puts "kid : #{kid}"
+ t = Time.now.gmtime
+ kid = gen.generate
- t2 = OpenWFE::KotobaWfidGenerator.to_time(kid)
+ #puts "now : #{t}"
+ #puts "kid : #{kid}"
- #puts "t2 : #{t2}"
+ t2 = OpenWFE::KotobaWfidGenerator.to_time(kid)
- assert_equal t.to_s, t2.to_s
+ #puts "t2 : #{t2}"
- #t = Time.utc(2007, 03, 20, 23, 59, 59)
- #kid = OpenWFE::KotobaWfidGenerator.from_time(t)
- #puts t
- #puts kid
- #kid = "20070320-nayozumuja"
- #puts OpenWFE::KotobaWfidGenerator.to_time(kid)
- #kid = "20070320-nayozumuje"
- #puts OpenWFE::KotobaWfidGenerator.to_time(kid)
- #kid = "20070320-nayozunuje"
- #puts OpenWFE::KotobaWfidGenerator.to_time(kid)
- #kid = "20070320-nazazunuje"
- #puts OpenWFE::KotobaWfidGenerator.to_time(kid)
- end
+ assert_equal t.to_s, t2.to_s
+ #t = Time.utc(2007, 03, 20, 23, 59, 59)
+ #kid = OpenWFE::KotobaWfidGenerator.from_time(t)
+ #puts t
+ #puts kid
+ #kid = "20070320-nayozumuja"
+ #puts OpenWFE::KotobaWfidGenerator.to_time(kid)
+ #kid = "20070320-nayozumuje"
+ #puts OpenWFE::KotobaWfidGenerator.to_time(kid)
+ #kid = "20070320-nayozunuje"
+ #puts OpenWFE::KotobaWfidGenerator.to_time(kid)
+ #kid = "20070320-nazazunuje"
+ #puts OpenWFE::KotobaWfidGenerator.to_time(kid)
+ end
- #
- # test FieldWfidGenerator
- class MyEngine < OpenWFE::Engine
+ #
+ # test FieldWfidGenerator
- def initialize
+ class MyEngine < OpenWFE::Engine
- super
+ def initialize
- self.ac[:definition_in_launchitem_allowed] = true
- end
+ super
- def build_wfid_generator
+ self.ac[:definition_in_launchitem_allowed] = true
+ end
- g = FieldWfidGenerator.new(
- S_WFID_GENERATOR, @application_context, "wfid")
- end
+ def build_wfid_generator
+
+ OpenWFE::FieldWfidGenerator.new(
+ :s_wfid_generator, @application_context, 'wfid')
end
+ end
- class MyProcDef < OpenWFE::ProcessDefinition
- sequence do
- # do nothing
- end
+ class MyProcDef < OpenWFE::ProcessDefinition
+ sequence do
+ # do nothing
end
+ end
- def test_field_wfid
+ def test_field_wfid
- eng = MyEngine.new
+ eng = MyEngine.new
- li = OpenWFE::LaunchItem.new MyProcDef
- li.wfid = "toto"
- fei = eng.launch(li)
+ li = OpenWFE::LaunchItem.new MyProcDef
+ li.wfid = 'toto'
+ fei = eng.launch(li)
- assert_equal fei.wfid, "toto"
+ assert_equal fei.wfid, 'toto'
- li = OpenWFE::LaunchItem.new(MyProcDef)
- fei = eng.launch(li)
+ li = OpenWFE::LaunchItem.new(MyProcDef)
+ fei = eng.launch(li)
- #puts fei.wfid
+ #puts fei.wfid
- assert_not_equal fei.wfid, "toto"
+ assert_not_equal fei.wfid, 'toto'
- t = OpenWFE::KotobaWfidGenerator.to_time(fei.wfid)
+ t = OpenWFE::KotobaWfidGenerator.to_time(fei.wfid)
- assert t.is_a?(Time)
- end
+ assert t.is_a?(Time)
+ end
end