# # Copyright (c) 2005-2006, 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" # require 'optparse' require 'worklistclient' require 'controlclient' # # PARSING OPTS # @has_options = false @test_worklist = true @test_control = true def flush_options () if not @has_options @test_worklist = false @test_control = false end @has_options = true end opts = OptionParser.new() opts.banner = "Usage: test.sh [options]" opts.separator("") opts.separator("options:") opts.on("-w", "--worklist", "tests the ruby lib to the worklist iface") do flush_options() @test_worklist = true end opts.on("-c", "--control", "tests the ruby lib to the control iface") do flush_options() @test_control = true end opts.on("-h", "--help", "displays this help/usage message") do puts puts opts.to_s() puts exit 0 end #opts_rest = opts.parse(ARGV) #questions = Integer(opts_rest[0]) if opts_rest.length > 0 opts.parse(ARGV) puts puts " testing worklist : #{@test_worklist}" puts " testing control : #{@test_control}" puts # # TESTING THE WORKLIST IFACE # if @test_worklist client = OpenWFE::WorklistClient\ .new("http://127.0.0.1:5080/worklist", "alice", "alice") puts "sessionId : #{client.sessionId}" #puts client.get('getstorenames', nil, nil) puts "Stores :" l = client.listStores() l.each do |s| puts " - store name : '#{s.name}' wi count : #{s.workitemCount} permissions : #{s.permissions}" end puts puts "launching a flow" li = OpenWFE::LaunchItem.new() li.workflowDefinitionUrl = "http://localhost:7079/flow__1.0.xml" li.attributes["__subject__"] = "openwfe-ruby" fei = client.launchFlow("mainEngine", li) puts fei puts feiToFetch = nil puts "Store.alpha's headers :" l = client.getHeaders("Store.alpha") l.each do |h| puts " - header lastModified : #{h.lastModified} locked : #{h.locked} ac : #{h.attributes.length}" puts " fei : #{h.flowExpressionId}" feiToFetch = h.flowExpressionId end puts "Fetching the first workitem :" wi = client.getWorkitem("Store.alpha", feiToFetch) #puts wi.inspect() puts puts "Fetching (and locking) the first workitem :" wi = client.getAndLockWorkitem("Store.alpha", feiToFetch) puts wi.inspect() puts puts "Releasing the workitem :" puts "ok" if client.releaseWorkitem(wi) puts puts "Listing launchables :" client.listLaunchables().each do |l| puts " - launchable #{l.engineId} :: #{l.url}" end puts puts "Closing worklist worksession" puts client.close() end # # TESTING THE CONTROL IFACE # if @test_control def display_expressions (exps) i = 0 exps.each do |exp| print " - exp #{i} : #{exp.id}" print " / #{exp.applyTime}" if exp.applyTime print "\n" i = i+1 end end 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://127.0.0.1:6080/engine", "admin", "admin") puts "sessionId : #{client.sessionId}" puts puts "listing expressions :" exps = client.listExpressions() display_expressions(exps) client.close() end