test/wfid_test.rb in openwferu-0.9.6 vs test/wfid_test.rb in openwferu-0.9.7
- old
+ new
@@ -12,11 +12,11 @@
#require "fastthread"
require 'test/unit'
require 'openwfe/utils'
-require 'openwfe/expool/expressionpool'
+require 'openwfe/expool/wfidgen'
#
# testing otime and the scheduler (its cron aspect)
#
@@ -28,41 +28,97 @@
#def teardown
#end
def test_wfid_0
- expool = OpenWFE::ExpressionPool.new("expool", nil)
+ gen = OpenWFE::DefaultWfidGenerator.new("wfidgen", nil)
- class << expool
- public :new_workflow_instance_id
- end
+ thread = nil
- n = 21
+ n = 777
+ #n = 1000000
map = {}
n.times do |i|
- Thread.new do
+ thread = Thread.new do
- #begin
- wfid = expool.new_workflow_instance_id()
- #rescue Exception => e
- # OpenWFE::die(e.to_s)
- #end
+ wfid = gen.generate
#puts wfid
OpenWFE::die("\nduplicate workflow_instance_id found !!!") \
if map[wfid]
map[wfid] = true
+
+ #puts wfid if i == n-1
end
end
- sleep(2)
+ thread.join
+
+ sleep(0.1)
#puts
+
+ assert_equal map.size, n
assert true
+ end
+
+ def test_wfid_1
+
+ gen = OpenWFE::DefaultWfidGenerator.new("wfidgen", nil)
+
+ a = %w{ 1 2 3 4 5 }
+ s = a.join
+
+ #a2 = gen.split_wfid(s)
+ a2 = OpenWFE::split_wfid(s)
+
+ assert_equal a, a2
+ end
+
+ def test_wfid_2
+
+ gen = OpenWFE::UuidWfidGenerator.new("wfidgen", nil)
+
+ id = gen.generate
+
+ #puts id
+
+ #assert_equal gen.split_wfid(id).join, id[0, 8]
+ assert_equal OpenWFE::split_wfid(id).join, id[0, 8]
+ end
+
+ def test_kotoba_wfid
+
+ gen = OpenWFE::KotobaWfidGenerator.new("wfidgen", nil)
+
+ t = Time.now.gmtime
+ kid = gen.generate
+
+ #puts "now : #{t}"
+ #puts "kid : #{kid}"
+
+ t2 = OpenWFE::KotobaWfidGenerator.to_time(kid)
+
+ #puts "t2 : #{t2}"
+
+ 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
end