test/orest_test.rb in openwferu-0.9.11 vs test/orest_test.rb in openwferu-0.9.12

- old
+ new

@@ -29,10 +29,13 @@ FileUtils.mkdir "logs" unless File.exist?("logs") logger = WEBrick::Log.new "logs/orest_test.webrick.log" logger.level = WEBrick::Log::DEBUG + # + # preparing a worklist + @worklist = OpenWFE::Worklist.new( @engine.application_context, :auth_system => { "foo" => "bar" }) #:launchables => {}) @@ -42,14 +45,21 @@ OpenWFE::StoreWithLocks.new(OpenWFE::HashParticipant)) @worklist.add_store( "bravo", "bravo", OpenWFE::StoreWithLocks.new(OpenWFE::HashParticipant)) + + # + # registering the worklist (behind two participants) @engine.register_participant :alpha, @worklist @engine.register_participant :bravo, @worklist + # + # preparing and starting the webserver + # (it's a REST interface after all) + @server = WEBrick::HTTPServer.new( :Port => 5080, :BindAddress => "0.0.0.0", :Logger => logger, :AccessLog => [[ @@ -79,10 +89,13 @@ def test_0 #sleep 0.1 + + # + # just checking that we get bounced in case of wrong credentials assert_raise RuntimeError do client = OpenWFE::WorklistClient.new( "http://localhost:5080/worklist", "foo", "foo") end @@ -92,31 +105,33 @@ assert client.session_id > 0 assert_equal get_servlet.instance_variable_get(:@sessions).size, 1 + # + # are there two stores in this worklist ? + l = client.list_stores - #l.each do |s| - # require 'pp'; pp s - #end assert_equal l.size, 2 store = l[0] assert_equal store.name, "alpha" + # + # playing with a mock workitem + assert_raise RuntimeError do client.get_headers "nada" end actual_store = @worklist.get_store "alpha" actual_store.consume(new_workitem()) headers = client.get_headers "alpha" - #puts headers[0].fei assert_equal headers.length, 1 assert_equal headers[0].attributes["nada"], "surf" assert_equal headers[0].nada, "surf" # @@ -142,19 +157,23 @@ #require 'pp'; pp headers assert_equal headers.size, 2 + # yes, the workitem of our newly launched process has arrived... + fei.expression_id = "0.0.0" fei.expression_name = "participant" wi = client.get_workitem "alpha", fei assert_equal wi.myfield, "myvalue" wi = client.get_and_lock_workitem "alpha", fei + # got the workitem and made sure others can't modify / forward it + assert_equal wi.myfield, "myvalue" headers = client.get_headers "alpha" h = nil @@ -169,18 +188,22 @@ feis = client.find_flow_instance "alpha", fei.wfid assert_equal feis.size, 1 + # releasing the fish... + client.release_workitem wi headers = client.get_headers "alpha" assert (not (headers[0].locked or headers[1].locked)) assert_raise RuntimeError do client.save_workitem wi end + + # catching it again wi = client.get_and_lock_workitem "alpha", fei wi.got_forwarded = true