blob: d505e9f0101d918b6501158d861bbe5bb227882e [file] [log] [blame]
Kevin Clark4bd89162008-07-08 00:47:49 +00001$:.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
5require 'thrift'
6require 'thrift/protocol/binaryprotocolaccelerated'
7require 'ThriftTest'
8
9class 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
40end
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