Sha256: 506fbaa833da6b467a97c38238e091c6fbd3cbc7e8cbf484e2e7d1e2dedb6cf2

Contents?: true

Size: 934 Bytes

Versions: 6

Compression:

Stored size: 934 Bytes

Contents

#
# Testing OpenWFE
#
# John Mettraux at openwfe.org
#
# Sun Oct 29 16:18:25 JST 2006
#

require 'test/unit'

require 'openwfe/util/otime'
require 'openwfe/util/scheduler'


#
# testing otime and the scheduler (its cron aspect)
#
class CronTest < Test::Unit::TestCase

    #def setup
    #end

    #def teardown
    #end

    def test_cron_0

        $var = 0

        scheduler = OpenWFE::Scheduler.new
        scheduler.start

        sid = scheduler.schedule(
            '* * * * *',
            :schedulable => CounterSchedulable.new)

        assert sid, "scheduler did not return a job id"

        sleep 120
        scheduler.stop

        #puts ">#{$var}<"

        assert_equal $var, 2, "$var should be at 2, it's at #{$var}"
    end

    protected

        class CounterSchedulable
            include OpenWFE::Schedulable

            def trigger (params)
                $var = $var + 1
            end
        end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
openwferu-0.9.11 test/cron_test.rb
openwferu-0.9.12 test/cron_test.rb
openwferu-0.9.12.863 test/cron_test.rb
openwferu-0.9.13 test/cron_test.rb
openwferu-0.9.14 test/cron_test.rb
openwferu-0.9.15 test/cron_test.rb