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