require 'test/unit' require 'openwfe/expressions/expressionmap' require 'openwfe/expool/expstorage' require 'openwfe/expool/yamlexpstorage' require 'openwfe/flowexpressionid' include OpenWFE class FilePersistenceTest < Test::Unit::TestCase # # test persistence using yaml def test_yaml_persistence fes = YamlFileExpressionStorage.new("yaml", nil) test_persistence(fes) end # # test cache persistence def test_cache_persistence fes = LruCachedExpressionStorage.new("lru", nil) test_persistence(fes) end # # flow expression check def test_flow_expression fei = new_fei() fes = YamlFileExpressionStorage.new("yaml", nil) fe = SequenceExpression.new(fei, nil, nil, nil, nil) test_persistence(fes,fe) end # # test UTF-8 data persistence def test_utf8_with_file workflow_definition_name = "みんなにARIGATOU★☆に関する最新の情報公開" fei = new_fei(workflow_definition_name) fe = SequenceExpression.new(fei, nil, nil, nil, nil) fes = YamlFileExpressionStorage.new("yaml", nil) loaded = test_persistence(fes,fe) #puts loaded.fei.workflow_definition_name assert loaded.fei.workflow_definition_name == fei.workflow_definition_name end protected def test_persistence (fes, fe=nil) fei = new_fei() fes.delete(fei) if (fes.has_key?(fei)) raw = if fe == nil RawExpression.new(fei, 'parent', 'env', nil, nil) else fe end assert \ (not fes.has_key?(fei)), "they key is present in the file system. "+ "Maybe a previous test did not delete the " fes[fei]=raw assert fes.has_key?(fei) loaded = fes[fei] fes.delete(fei) assert !(fes.has_key?(fei)) return loaded end def new_fei (definition_name = nil) fei = OpenWFE::FlowExpressionId.new() fei.owfe_version = OPENWFE_VERSION fei.engine_id = 'this' fei.initial_engine_id = 'that' fei.workflow_definition_url = 'http://test/test.xml' fei.workflow_definition_name = if definition_name == nil 'test' else definition_name end fei.workflow_definition_revision = '1.0' fei.workflow_instance_id = '1234568' fei.expression_name = 'do-test' fei.expression_id = '0.0' return fei end end