Sha256: 2056d974670f2ea2d0ac1d690eeaad2ad601b6cc93699639f1427d7d052e7737

Contents?: true

Size: 1.69 KB

Versions: 1

Compression:

Stored size: 1.69 KB

Contents

#
# Testing OpenWFE
#
# John Mettraux at openwfe.org
#
# Thu Nov 22 11:53:13 JST 2007
#

require 'flowtestbase'
require 'openwfe/def'


class FlowTest9b < Test::Unit::TestCase
  include FlowTestBase

  #def setup
  #end

  #def teardown
  #end

  #
  # Test 0
  #

  class Test0 < OpenWFE::ProcessDefinition
    cursor do
      set :v => "v0", :val => "x"
      _print "${v0}"
    end
  end

  def test_0

    dotest Test0, "x"
  end

  #
  # Test 1
  #

  #class Test1 < OpenWFE::ProcessDefinition
  #  cursor do
  #    my_participant
  #  end
  #end
  #def test_1
  #  @engine.register_participant :my_participant do |fexp, wi|
  #    #puts fexp.to_s
  #    #puts fexp.environment_id.to_s
  #    @tracer << "ok0\n" if fexp.environment_id.expid != fexp.fei.expid
  #    @tracer << "ok1\n" if fexp.environment_id.expid == "0.0"
  #    @tracer << "ok2\n" if fexp.environment_id.wfid + ".0" == fexp.fei.wfid
  #  end
  #  dotest Test1, "ok0\nok1\nok2"
  #end

  #
  # Test 2
  #

  class Test2 < OpenWFE::ProcessDefinition
    cursor do
      my_participant
    end
  end
  class MyParticipant
    include OpenWFE::LocalParticipant

    def initialize (tracer)
      @tracer = tracer
    end
    def consume (workitem)
      @tracer << "consume\n"
      @workitem = workitem
    end
    def cancel (cancelitem)
      @tracer << "cancel\n"
    end
  end

  def test_2

    #log_level_to_debug

    @engine.register_participant :my_participant, MyParticipant.new(@tracer)

    fei = launch Test2

    sleep 0.350

    @engine.cancel_process fei

    sleep 0.350

    assert(
      [ "consume\ncancel",
        "consume\ncancel\ncancel" ].include?(@tracer.to_s))

    assert_equal 1, @engine.get_expression_storage.size
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruote-0.9.19 test/ft_9b_cursor.rb