blob: 892037ec7b1c13c0431cd82b69ba1e6aef8e625e [file] [log] [blame]
Mark Slee02d1edc2007-03-07 05:17:25 +00001#!/usr/bin/env ruby
Mark Slee157d9f72007-02-07 06:03:53 +00002
3$:.push('gen-rb')
4$:.push('../../lib/rb/lib')
5
6require 'thrift/transport/tsocket'
7require 'thrift/protocol/tbinaryprotocol'
8require 'thrift/server/tserver'
9require 'ThriftTest'
10
11class TestHandler
Mark Slee157d9f72007-02-07 06:03:53 +000012 def testVoid()
13 print "testVoid()\n"
14 end
15
16 def testString(thing)
17 print "testString(#{thing})\n"
18 return thing
19 end
20
21 def testByte(thing)
22 print "testByte(#{thing})\n"
23 return thing
24 end
25
26 def testI32(thing)
27 print "testI32(#{thing})\n"
28 return thing
29 end
30
31 def testI64(thing)
32 print "testI64(#{thing})\n"
33 return thing
34 end
35
36 def testDouble(thing)
37 print "testDouble(#{thing})\n"
38 return thing
39 end
40
41 def testStruct(thing)
42 print "testStruct(#{thing})\n"
Mark Slee58dfb4f2007-07-06 02:45:25 +000043 print " with attrs: #{thing.string_thing}, #{thing.byte_thing}, #{thing.i32_thing}"
Mark Slee157d9f72007-02-07 06:03:53 +000044 return thing
45 end
46
47 def testMap(thing)
48 print "testMap(#{thing})\n"
49 return thing
50 end
51
52 def testSet(thing)
53 print "testSet(#{thing})\n"
54 return thing
55 end
56
57 def testList(thing)
58 print "testList(#{thing})\n"
59 return thing
60 end
61
Mark Slee477a5802007-06-30 01:18:12 +000062 def testNest(thing)
63 print "testNest(#{thing})\n"
64 puts " i32_thing: #{thing.i32_thing}"
65 puts " with struct: "
66 %w{ string_thing byte_thing i32_thing }.each do |t|
67 puts " #{t}: #{thing.struct_thing.send(t)}"
68 end
69 return thing
70 end
Mark Slee58dfb4f2007-07-06 02:45:25 +000071
72 def testNest(thing)
73 print "testNest(#{thing})\n"
74 puts " i32_thing: #{thing.i32_thing}"
75 puts " with struct: "
76 %w{ string_thing byte_thing i32_thing }.each do |t|
77 puts " #{t}: #{thing.struct_thing.send(t)}"
78 end
79 return thing
80 end
81
82 def testInsanity(thing)
83 puts "insanity:"
84 puts " #{thing.inspect}"
85 num, uid = thing.userMap.find { true }
86 return {uid => {num => thing}}
87 end
88
89 def testMapMap(thing)
90 puts "got: #{thing}"
91 return {thing => {thing => thing}}
92 end
Mark Slee477a5802007-06-30 01:18:12 +000093
Mark Slee157d9f72007-02-07 06:03:53 +000094end
95
96handler = TestHandler.new()
Mark Slee58dfb4f2007-07-06 02:45:25 +000097processor = Thrift::Test::ThriftTest::Processor.new(handler)
Mark Slee157d9f72007-02-07 06:03:53 +000098transport = TServerSocket.new(9090)
99server = TSimpleServer.new(processor, transport)
100server.serve()