Sha256: 598156cf807d199bd9a4b6b637da196a594a0237c674845053216cb97e9f0df7

Contents?: true

Size: 1.37 KB

Versions: 3

Compression:

Stored size: 1.37 KB

Contents

require 'pione/test-helper'

describe "Pione::Agent::TupleSpaceReceiver" do
  before do
    @tuple_space = TestHelper::TupleSpace.create(self)
    Global.expressional_features = Util.parse_features("*")
    @broker = Agent::Broker.start(task_worker_resource: 5, spawn_task_worker: false)
    @provider_front = Front::TupleSpaceProviderFront.new(@tuple_space)
  end

  after do
    @broker.terminate
    @tuple_space.terminate
    @provider_front.terminate
    Global.expressional_features = nil
  end

  it "should run and terminate receiver" do
    receiver = Agent::TupleSpaceReceiver.start(@broker)
    receiver.wait_until(:receive_packet)
    receiver.terminate
    receiver.wait_until_terminated
    receiver.should.terminated
  end

  it "should receive tuple space servers" do
    provider = Agent::TupleSpaceProvider.start(@provider_front)
    receiver = Agent::TupleSpaceReceiver.start(@broker)

    # wait receiver to handle notification
    receiver.wait_until_after(:receive_packet, 10)
    receiver.notification_handlers.list.each {|thread| thread.join}

    # test tuple spaces
    spaces = receiver.tuple_spaces
    spaces.size.should == 1
    spaces.first.should == @tuple_space

    # terminate agents
    provider.terminate
    receiver.terminate
    provider.wait_until_terminated
    receiver.wait_until_terminated
    provider.should.terminated
    receiver.should.terminated
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pione-0.3.2 test/agent/spec_tuple-space-receiver.rb
pione-0.3.1 test/agent/spec_tuple-space-receiver.rb
pione-0.3.0 test/agent/spec_tuple-space-receiver.rb