# #-- # Copyright (c) 2005-2007, John Mettraux, OpenWFE.org # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # . Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. # # . Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # . Neither the name of the "OpenWFE" nor the names of its contributors may be # used to endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. #-- # # $Id: test.rb 3454 2006-10-08 16:51:00Z jmettraux $ # # # "hecho en Costa Rica" # "Rewritten as a unit test in Japan" # require 'test/unit' require 'worklistclient' require 'controlclient' # # TESTING THE WORKLIST AND THE CONTROL INTERFACES # OWFE_HOST = ENV['OWFE_HOST'] OWFE_HOST = "127.0.0.1" if not OWFE_HOST class RestTest < Test::Unit::TestCase #def setup #end #def teardown #end def test_worklist_0 #def xxxx_worklist_0 client = OpenWFE::WorklistClient\ .new("http://#{OWFE_HOST}:5080/worklist", "alice", "alice") puts "session_id : #{client.session_id}" #puts client.get('getstorenames', nil, nil) puts "Stores :" l = client.list_stores() l.each do |s| puts " - store name : '#{s.name}' wi count : #{s.workitem_count} permissions : #{s.permissions}" end puts puts "launching a flow" li = OpenWFE::LaunchItem.new() li.workflow_definition_url = "http://localhost:7079/flow__1.0.xml" li.attributes["__subject__"] = "openwfe-ruby" fei = client.launch_flow("mainEngine", li) puts fei puts feiToFetch = nil puts "Store.alpha's headers :" l = client.get_headers("Store.alpha") l.each do |h| puts " - header lastModified : #{h.last_modified} locked : #{h.locked} ac : #{h.attributes.length}" puts " fei : #{h.flow_expression_id}" feiToFetch = h.flow_expression_id end puts "Fetching the first workitem :" wi = client.get_workitem("Store.alpha", feiToFetch) #puts wi.inspect() puts puts "Fetching (and locking) the first workitem :" wi = client.get_and_lock_workitem("Store.alpha", feiToFetch) puts wi.inspect() puts puts "Releasing the workitem :" puts "ok" if client.release_workitem(wi) puts puts "Listing launchables :" client.list_launchables().each do |l| puts " - launchable #{l.engine_id} :: #{l.url}" end puts puts "Closing worklist worksession" client.close() end def test_control_0 #def xxxx_control_0 puts "Testing the control interface..." # # launching a test flow #TEST_NAME = '-- testing ruby control (0) --' #client = OpenWFE::WorklistClient\ # .new("http://127.0.0.1:5080/worklist", "alice", "alice") #li = OpenWFE::LaunchItem.new() #li.workflowDefinitionUrl = "http://localhost:7079/flow__1.0.xml" #li.attributes["__subject__"] = TEST_NAME #fei = client.launchFlow("mainEngine", li) #puts "launched : #{fei}" #client.close() # # controlling the test flow client = OpenWFE::ControlClient\ .new("http://#{OWFE_HOST}:6080/engine", "admin", "admin") puts "sessionId : #{client.session_id}" puts puts "listing expressions :" exps = client.list_expressions() display_expressions(exps) puts wfid = exps[-1].id.workflow_instance_id puts "get_flow_position() for flow #{wfid}" exps = client.get_flow_position(wfid) display_expressions(exps) client.close() end protected def display_expressions (exps) i = 0 exps.each do |exp| print " - exp #{i} : #{exp.id}" print " / #{exp.apply_time}" if exp.apply_time print "\n" i = i+1 end end end