| #!/usr/bin/env ruby |
| |
| $:.push('gen-rb') |
| $:.push('../../lib/rb/lib') |
| |
| require 'thrift/transport/tsocket' |
| require 'thrift/protocol/tbinaryprotocol' |
| require 'thrift/server/tserver' |
| require 'ThriftTest' |
| |
| class TestHandler |
| def testVoid() |
| print "testVoid()\n" |
| end |
| |
| def testString(thing) |
| print "testString(#{thing})\n" |
| return thing |
| end |
| |
| def testByte(thing) |
| print "testByte(#{thing})\n" |
| return thing |
| end |
| |
| def testI32(thing) |
| print "testI32(#{thing})\n" |
| return thing |
| end |
| |
| def testI64(thing) |
| print "testI64(#{thing})\n" |
| return thing |
| end |
| |
| def testDouble(thing) |
| print "testDouble(#{thing})\n" |
| return thing |
| end |
| |
| def testStruct(thing) |
| print "testStruct(#{thing})\n" |
| print " with attrs: #{thing.string_thing}, #{thing.byte_thing}, #{thing.i32_thing}" |
| return thing |
| end |
| |
| def testMap(thing) |
| print "testMap(#{thing})\n" |
| return thing |
| end |
| |
| def testSet(thing) |
| print "testSet(#{thing})\n" |
| return thing |
| end |
| |
| def testList(thing) |
| print "testList(#{thing})\n" |
| return thing |
| end |
| |
| def testNest(thing) |
| print "testNest(#{thing})\n" |
| puts " i32_thing: #{thing.i32_thing}" |
| puts " with struct: " |
| %w{ string_thing byte_thing i32_thing }.each do |t| |
| puts " #{t}: #{thing.struct_thing.send(t)}" |
| end |
| return thing |
| end |
| |
| def testNest(thing) |
| print "testNest(#{thing})\n" |
| puts " i32_thing: #{thing.i32_thing}" |
| puts " with struct: " |
| %w{ string_thing byte_thing i32_thing }.each do |t| |
| puts " #{t}: #{thing.struct_thing.send(t)}" |
| end |
| return thing |
| end |
| |
| def testInsanity(thing) |
| puts "insanity:" |
| puts " #{thing.inspect}" |
| num, uid = thing.userMap.find { true } |
| return {uid => {num => thing}} |
| end |
| |
| def testMapMap(thing) |
| puts "got: #{thing}" |
| return {thing => {thing => thing}} |
| end |
| |
| end |
| |
| handler = TestHandler.new() |
| processor = Thrift::Test::ThriftTest::Processor.new(handler) |
| transport = TServerSocket.new(9090) |
| server = TSimpleServer.new(processor, transport) |
| server.serve() |