Sha256: 234de6e251267cc32b89d738c2095a6efc36d64f4501a524d569ff854dc2eabd

Contents?: true

Size: 1.83 KB

Versions: 1

Compression:

Stored size: 1.83 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 < ProcessDefinition
        cursor do
            set :v => "v0", :val => "x"
            _print "${v0}"
        end
    end

    def test_0

        dotest Test0, "x"
    end

    #
    # Test 1
    #

    class Test1 < 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 < ProcessDefinition
    #    cursor do
    #        my_participant
    #    end
    #end
    class MyParticipant
        include LocalParticipant

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

    def test_2

        log_level_to_debug

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

        fei = @engine.launch Test1

        sleep 0.350

        @engine.cancel_process fei

        sleep 0.350

        assert_equal "consume\n.0 cancel", @tracer.to_s
    end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
openwferu-0.9.17 test/ft_9b_cursor.rb