require_relative '../test-util' $document = Component::Document.parse(< {$OUTPUT[1]} End Rule VariableBindingErrorTest input '*.a' output '*.b' Flow rule Test End DOCUMENT describe 'FlowHandler' do before do @ts = create_tuple_space_server @rule = doc['&main:Test'] write(Tuple[:rule].new('&main:Shell', doc['&main:Shell'])) location = Location[Temppath.create] location_a = location + "1.a" location_b = location + "1.b" location_a.create("1") location_b.create("2") @tuples = [ Tuple[:data].new(domain: "test", name: '1.a', location: location_a, time: Time.now), Tuple[:data].new(domain: "test", name: '1.b', location: location_b, time: Time.now) ] @tuples.each {|t| write(t) } @handler = @rule.make_handler(@ts, @tuples, Parameters.empty, [],domain: 'test') end after do @ts.terminate end it "should execute a flow" do # execute and get result quiet_mode do thread = Thread.new { @handler.execute } task = read(Tuple[:task].new) task.rule_path.should == '&main:Shell' task.inputs.map{|d|d.name}.sort.should == ['1.a', '1.b'] task.params.should.empty task.features.should.empty Agent[:task_worker].start(tuple_space_server) thread.join res = @handler.outputs.first res.name.should == '1.c' Resource[res.uri].read.chomp.should == "3" should.not.raise do read(Tuple[:data].new(name: '1.c', domain: @handler.domain)) end end end end