Kevin Clark | 4bd8916 | 2008-07-08 00:47:49 +0000 | [diff] [blame^] | 1 | $:.push File.dirname(__FILE__) + '/../gen-rb' |
| 2 | $:.push File.join(File.dirname(__FILE__), '../../../lib/rb/lib') |
| 3 | |
| 4 | require 'thrift' |
| 5 | require 'thrift/protocol/binaryprotocol' |
| 6 | require 'ThriftTest' |
| 7 | |
| 8 | class SimpleHandler |
| 9 | [:testString, :testByte, :testI32, :testI64, :testDouble, |
| 10 | :testStruct, :testMap, :testSet, :testList, :testNest, |
| 11 | :testEnum, :testTypedef].each do |meth| |
| 12 | |
| 13 | define_method(meth) do |thing| |
| 14 | thing |
| 15 | end |
| 16 | |
| 17 | end |
| 18 | |
| 19 | def testInsanity(thing) |
| 20 | num, uid = thing.userMap.find { true } |
| 21 | return {uid => {num => thing}} |
| 22 | end |
| 23 | |
| 24 | def testMapMap(thing) |
| 25 | return {thing => {thing => thing}} |
| 26 | end |
| 27 | |
| 28 | def testEnum(thing) |
| 29 | return thing |
| 30 | end |
| 31 | |
| 32 | def testTypedef(thing) |
| 33 | return thing |
| 34 | end |
| 35 | |
| 36 | def testException(thing) |
| 37 | raise Thrift::Test::Xception, :message => 'error' |
| 38 | end |
| 39 | end |
| 40 | |
| 41 | @handler = SimpleHandler.new |
| 42 | @processor = Thrift::Test::ThriftTest::Processor.new(@handler) |
| 43 | @transport = Thrift::ServerSocket.new(9090) |
| 44 | @server = Thrift::ThreadedServer.new(@processor, @transport) |
| 45 | |
| 46 | @server.serve |