Sha256: fa3894c336d2191284020f42fdc9646b4e1763539d83d3eb043f328aa68d5bde

Contents?: true

Size: 756 Bytes

Versions: 2

Compression:

Stored size: 756 Bytes

Contents

require 'test/unit'
require 'radius'

class MultithreadTest < Test::Unit::TestCase

  def setup
    Thread.abort_on_exception
    @context = Radius::Context.new do |c|
      c.define_tag('thread') do |tag|
        "#{tag.locals.thread_id} / #{tag.globals.object_id}"
      end
    end
  end

  def test_runs_multithreaded
    threads = []
    1000.times do |t|
      threads << Thread.new do
        parser = Radius::Parser.new(@context, :tag_prefix => 'r')
        parser.context.globals.thread_id = Thread.current.object_id
        expected = "#{Thread.current.object_id} / #{parser.context.globals.object_id}"
        actual = parser.parse('<r:thread />')
        assert_equal expected, actual
      end
    end
    threads.each{|t| t.join }
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
radius-ts-1.1.0 test/multithreaded_test.rb
radius-ts-1.0.0 test/multithreaded_test.rb