stark 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.autotest +23 -0
- data/.gemtest +0 -0
- data/History.txt +6 -0
- data/Manifest.txt +31 -0
- data/README.txt +63 -0
- data/Rakefile +21 -0
- data/bin/stark +17 -0
- data/lib/stark/ast.rb +47 -0
- data/lib/stark/client.rb +63 -0
- data/lib/stark/converters.rb +29 -0
- data/lib/stark/field.rb +21 -0
- data/lib/stark/log_transport.rb +20 -0
- data/lib/stark/parser.rb +4 -0
- data/lib/stark/processor.rb +50 -0
- data/lib/stark/raw_parser.rb +4019 -0
- data/lib/stark/ruby.rb +468 -0
- data/lib/stark/struct.rb +26 -0
- data/lib/stark/thrift.kpeg +330 -0
- data/lib/stark.rb +37 -0
- data/stark.gemspec +40 -0
- data/test/ThriftSpec.thrift +183 -0
- data/test/gen-rb/profile_constants.rb +8 -0
- data/test/gen-rb/profile_types.rb +36 -0
- data/test/gen-rb/user_storage.rb +451 -0
- data/test/leg.rb +77 -0
- data/test/legacy_profile/profile_constants.rb +8 -0
- data/test/legacy_profile/profile_types.rb +36 -0
- data/test/legacy_profile/user_storage.rb +451 -0
- data/test/profile.thrift +24 -0
- data/test/test_client.rb +184 -0
- data/test/test_parser.rb +278 -0
- data/test/test_server.rb +175 -0
- metadata +134 -0
@@ -0,0 +1,451 @@
|
|
1
|
+
#
|
2
|
+
# Autogenerated by Thrift Compiler (0.8.0)
|
3
|
+
#
|
4
|
+
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'thrift'
|
8
|
+
require 'profile_types'
|
9
|
+
|
10
|
+
module UserStorage
|
11
|
+
class Client
|
12
|
+
include ::Thrift::Client
|
13
|
+
|
14
|
+
def store(xuser)
|
15
|
+
send_store(xuser)
|
16
|
+
recv_store()
|
17
|
+
end
|
18
|
+
|
19
|
+
def send_store(xuser)
|
20
|
+
send_message('store', Store_args, :xuser => xuser)
|
21
|
+
end
|
22
|
+
|
23
|
+
def recv_store()
|
24
|
+
result = receive_message(Store_result)
|
25
|
+
return
|
26
|
+
end
|
27
|
+
|
28
|
+
def retrieve(xuid)
|
29
|
+
send_retrieve(xuid)
|
30
|
+
return recv_retrieve()
|
31
|
+
end
|
32
|
+
|
33
|
+
def send_retrieve(xuid)
|
34
|
+
send_message('retrieve', Retrieve_args, :xuid => xuid)
|
35
|
+
end
|
36
|
+
|
37
|
+
def recv_retrieve()
|
38
|
+
result = receive_message(Retrieve_result)
|
39
|
+
return result.success unless result.success.nil?
|
40
|
+
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'retrieve failed: unknown result')
|
41
|
+
end
|
42
|
+
|
43
|
+
def set_map(m)
|
44
|
+
send_set_map(m)
|
45
|
+
recv_set_map()
|
46
|
+
end
|
47
|
+
|
48
|
+
def send_set_map(m)
|
49
|
+
send_message('set_map', Set_map_args, :m => m)
|
50
|
+
end
|
51
|
+
|
52
|
+
def recv_set_map()
|
53
|
+
result = receive_message(Set_map_result)
|
54
|
+
return
|
55
|
+
end
|
56
|
+
|
57
|
+
def last_map()
|
58
|
+
send_last_map()
|
59
|
+
return recv_last_map()
|
60
|
+
end
|
61
|
+
|
62
|
+
def send_last_map()
|
63
|
+
send_message('last_map', Last_map_args)
|
64
|
+
end
|
65
|
+
|
66
|
+
def recv_last_map()
|
67
|
+
result = receive_message(Last_map_result)
|
68
|
+
return result.success unless result.success.nil?
|
69
|
+
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'last_map failed: unknown result')
|
70
|
+
end
|
71
|
+
|
72
|
+
def set_list(l)
|
73
|
+
send_set_list(l)
|
74
|
+
recv_set_list()
|
75
|
+
end
|
76
|
+
|
77
|
+
def send_set_list(l)
|
78
|
+
send_message('set_list', Set_list_args, :l => l)
|
79
|
+
end
|
80
|
+
|
81
|
+
def recv_set_list()
|
82
|
+
result = receive_message(Set_list_result)
|
83
|
+
return
|
84
|
+
end
|
85
|
+
|
86
|
+
def last_list()
|
87
|
+
send_last_list()
|
88
|
+
return recv_last_list()
|
89
|
+
end
|
90
|
+
|
91
|
+
def send_last_list()
|
92
|
+
send_message('last_list', Last_list_args)
|
93
|
+
end
|
94
|
+
|
95
|
+
def recv_last_list()
|
96
|
+
result = receive_message(Last_list_result)
|
97
|
+
return result.success unless result.success.nil?
|
98
|
+
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'last_list failed: unknown result')
|
99
|
+
end
|
100
|
+
|
101
|
+
def set_status(s)
|
102
|
+
send_set_status(s)
|
103
|
+
recv_set_status()
|
104
|
+
end
|
105
|
+
|
106
|
+
def send_set_status(s)
|
107
|
+
send_message('set_status', Set_status_args, :s => s)
|
108
|
+
end
|
109
|
+
|
110
|
+
def recv_set_status()
|
111
|
+
result = receive_message(Set_status_result)
|
112
|
+
return
|
113
|
+
end
|
114
|
+
|
115
|
+
def last_status()
|
116
|
+
send_last_status()
|
117
|
+
return recv_last_status()
|
118
|
+
end
|
119
|
+
|
120
|
+
def send_last_status()
|
121
|
+
send_message('last_status', Last_status_args)
|
122
|
+
end
|
123
|
+
|
124
|
+
def recv_last_status()
|
125
|
+
result = receive_message(Last_status_result)
|
126
|
+
return result.success unless result.success.nil?
|
127
|
+
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'last_status failed: unknown result')
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
class Processor
|
133
|
+
include ::Thrift::Processor
|
134
|
+
|
135
|
+
def process_store(seqid, iprot, oprot)
|
136
|
+
args = read_args(iprot, Store_args)
|
137
|
+
result = Store_result.new()
|
138
|
+
@handler.store(args.xuser)
|
139
|
+
write_result(result, oprot, 'store', seqid)
|
140
|
+
end
|
141
|
+
|
142
|
+
def process_retrieve(seqid, iprot, oprot)
|
143
|
+
args = read_args(iprot, Retrieve_args)
|
144
|
+
result = Retrieve_result.new()
|
145
|
+
result.success = @handler.retrieve(args.xuid)
|
146
|
+
write_result(result, oprot, 'retrieve', seqid)
|
147
|
+
end
|
148
|
+
|
149
|
+
def process_set_map(seqid, iprot, oprot)
|
150
|
+
args = read_args(iprot, Set_map_args)
|
151
|
+
result = Set_map_result.new()
|
152
|
+
@handler.set_map(args.m)
|
153
|
+
write_result(result, oprot, 'set_map', seqid)
|
154
|
+
end
|
155
|
+
|
156
|
+
def process_last_map(seqid, iprot, oprot)
|
157
|
+
args = read_args(iprot, Last_map_args)
|
158
|
+
result = Last_map_result.new()
|
159
|
+
result.success = @handler.last_map()
|
160
|
+
write_result(result, oprot, 'last_map', seqid)
|
161
|
+
end
|
162
|
+
|
163
|
+
def process_set_list(seqid, iprot, oprot)
|
164
|
+
args = read_args(iprot, Set_list_args)
|
165
|
+
result = Set_list_result.new()
|
166
|
+
@handler.set_list(args.l)
|
167
|
+
write_result(result, oprot, 'set_list', seqid)
|
168
|
+
end
|
169
|
+
|
170
|
+
def process_last_list(seqid, iprot, oprot)
|
171
|
+
args = read_args(iprot, Last_list_args)
|
172
|
+
result = Last_list_result.new()
|
173
|
+
result.success = @handler.last_list()
|
174
|
+
write_result(result, oprot, 'last_list', seqid)
|
175
|
+
end
|
176
|
+
|
177
|
+
def process_set_status(seqid, iprot, oprot)
|
178
|
+
args = read_args(iprot, Set_status_args)
|
179
|
+
result = Set_status_result.new()
|
180
|
+
@handler.set_status(args.s)
|
181
|
+
write_result(result, oprot, 'set_status', seqid)
|
182
|
+
end
|
183
|
+
|
184
|
+
def process_last_status(seqid, iprot, oprot)
|
185
|
+
args = read_args(iprot, Last_status_args)
|
186
|
+
result = Last_status_result.new()
|
187
|
+
result.success = @handler.last_status()
|
188
|
+
write_result(result, oprot, 'last_status', seqid)
|
189
|
+
end
|
190
|
+
|
191
|
+
end
|
192
|
+
|
193
|
+
# HELPER FUNCTIONS AND STRUCTURES
|
194
|
+
|
195
|
+
class Store_args
|
196
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
197
|
+
XUSER = 1
|
198
|
+
|
199
|
+
FIELDS = {
|
200
|
+
XUSER => {:type => ::Thrift::Types::STRUCT, :name => 'xuser', :class => UserProfile}
|
201
|
+
}
|
202
|
+
|
203
|
+
def struct_fields; FIELDS; end
|
204
|
+
|
205
|
+
def validate
|
206
|
+
end
|
207
|
+
|
208
|
+
::Thrift::Struct.generate_accessors self
|
209
|
+
end
|
210
|
+
|
211
|
+
class Store_result
|
212
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
213
|
+
|
214
|
+
FIELDS = {
|
215
|
+
|
216
|
+
}
|
217
|
+
|
218
|
+
def struct_fields; FIELDS; end
|
219
|
+
|
220
|
+
def validate
|
221
|
+
end
|
222
|
+
|
223
|
+
::Thrift::Struct.generate_accessors self
|
224
|
+
end
|
225
|
+
|
226
|
+
class Retrieve_args
|
227
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
228
|
+
XUID = 1
|
229
|
+
|
230
|
+
FIELDS = {
|
231
|
+
XUID => {:type => ::Thrift::Types::I32, :name => 'xuid'}
|
232
|
+
}
|
233
|
+
|
234
|
+
def struct_fields; FIELDS; end
|
235
|
+
|
236
|
+
def validate
|
237
|
+
end
|
238
|
+
|
239
|
+
::Thrift::Struct.generate_accessors self
|
240
|
+
end
|
241
|
+
|
242
|
+
class Retrieve_result
|
243
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
244
|
+
SUCCESS = 0
|
245
|
+
|
246
|
+
FIELDS = {
|
247
|
+
SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => UserProfile}
|
248
|
+
}
|
249
|
+
|
250
|
+
def struct_fields; FIELDS; end
|
251
|
+
|
252
|
+
def validate
|
253
|
+
end
|
254
|
+
|
255
|
+
::Thrift::Struct.generate_accessors self
|
256
|
+
end
|
257
|
+
|
258
|
+
class Set_map_args
|
259
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
260
|
+
M = 1
|
261
|
+
|
262
|
+
FIELDS = {
|
263
|
+
M => {:type => ::Thrift::Types::MAP, :name => 'm', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}}
|
264
|
+
}
|
265
|
+
|
266
|
+
def struct_fields; FIELDS; end
|
267
|
+
|
268
|
+
def validate
|
269
|
+
end
|
270
|
+
|
271
|
+
::Thrift::Struct.generate_accessors self
|
272
|
+
end
|
273
|
+
|
274
|
+
class Set_map_result
|
275
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
276
|
+
|
277
|
+
FIELDS = {
|
278
|
+
|
279
|
+
}
|
280
|
+
|
281
|
+
def struct_fields; FIELDS; end
|
282
|
+
|
283
|
+
def validate
|
284
|
+
end
|
285
|
+
|
286
|
+
::Thrift::Struct.generate_accessors self
|
287
|
+
end
|
288
|
+
|
289
|
+
class Last_map_args
|
290
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
291
|
+
|
292
|
+
FIELDS = {
|
293
|
+
|
294
|
+
}
|
295
|
+
|
296
|
+
def struct_fields; FIELDS; end
|
297
|
+
|
298
|
+
def validate
|
299
|
+
end
|
300
|
+
|
301
|
+
::Thrift::Struct.generate_accessors self
|
302
|
+
end
|
303
|
+
|
304
|
+
class Last_map_result
|
305
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
306
|
+
SUCCESS = 0
|
307
|
+
|
308
|
+
FIELDS = {
|
309
|
+
SUCCESS => {:type => ::Thrift::Types::MAP, :name => 'success', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}}
|
310
|
+
}
|
311
|
+
|
312
|
+
def struct_fields; FIELDS; end
|
313
|
+
|
314
|
+
def validate
|
315
|
+
end
|
316
|
+
|
317
|
+
::Thrift::Struct.generate_accessors self
|
318
|
+
end
|
319
|
+
|
320
|
+
class Set_list_args
|
321
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
322
|
+
L = 1
|
323
|
+
|
324
|
+
FIELDS = {
|
325
|
+
L => {:type => ::Thrift::Types::LIST, :name => 'l', :element => {:type => ::Thrift::Types::STRING}}
|
326
|
+
}
|
327
|
+
|
328
|
+
def struct_fields; FIELDS; end
|
329
|
+
|
330
|
+
def validate
|
331
|
+
end
|
332
|
+
|
333
|
+
::Thrift::Struct.generate_accessors self
|
334
|
+
end
|
335
|
+
|
336
|
+
class Set_list_result
|
337
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
338
|
+
|
339
|
+
FIELDS = {
|
340
|
+
|
341
|
+
}
|
342
|
+
|
343
|
+
def struct_fields; FIELDS; end
|
344
|
+
|
345
|
+
def validate
|
346
|
+
end
|
347
|
+
|
348
|
+
::Thrift::Struct.generate_accessors self
|
349
|
+
end
|
350
|
+
|
351
|
+
class Last_list_args
|
352
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
353
|
+
|
354
|
+
FIELDS = {
|
355
|
+
|
356
|
+
}
|
357
|
+
|
358
|
+
def struct_fields; FIELDS; end
|
359
|
+
|
360
|
+
def validate
|
361
|
+
end
|
362
|
+
|
363
|
+
::Thrift::Struct.generate_accessors self
|
364
|
+
end
|
365
|
+
|
366
|
+
class Last_list_result
|
367
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
368
|
+
SUCCESS = 0
|
369
|
+
|
370
|
+
FIELDS = {
|
371
|
+
SUCCESS => {:type => ::Thrift::Types::LIST, :name => 'success', :element => {:type => ::Thrift::Types::STRING}}
|
372
|
+
}
|
373
|
+
|
374
|
+
def struct_fields; FIELDS; end
|
375
|
+
|
376
|
+
def validate
|
377
|
+
end
|
378
|
+
|
379
|
+
::Thrift::Struct.generate_accessors self
|
380
|
+
end
|
381
|
+
|
382
|
+
class Set_status_args
|
383
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
384
|
+
S = 1
|
385
|
+
|
386
|
+
FIELDS = {
|
387
|
+
S => {:type => ::Thrift::Types::I32, :name => 's', :enum_class => Status}
|
388
|
+
}
|
389
|
+
|
390
|
+
def struct_fields; FIELDS; end
|
391
|
+
|
392
|
+
def validate
|
393
|
+
unless @s.nil? || Status::VALID_VALUES.include?(@s)
|
394
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field s!')
|
395
|
+
end
|
396
|
+
end
|
397
|
+
|
398
|
+
::Thrift::Struct.generate_accessors self
|
399
|
+
end
|
400
|
+
|
401
|
+
class Set_status_result
|
402
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
403
|
+
|
404
|
+
FIELDS = {
|
405
|
+
|
406
|
+
}
|
407
|
+
|
408
|
+
def struct_fields; FIELDS; end
|
409
|
+
|
410
|
+
def validate
|
411
|
+
end
|
412
|
+
|
413
|
+
::Thrift::Struct.generate_accessors self
|
414
|
+
end
|
415
|
+
|
416
|
+
class Last_status_args
|
417
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
418
|
+
|
419
|
+
FIELDS = {
|
420
|
+
|
421
|
+
}
|
422
|
+
|
423
|
+
def struct_fields; FIELDS; end
|
424
|
+
|
425
|
+
def validate
|
426
|
+
end
|
427
|
+
|
428
|
+
::Thrift::Struct.generate_accessors self
|
429
|
+
end
|
430
|
+
|
431
|
+
class Last_status_result
|
432
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
433
|
+
SUCCESS = 0
|
434
|
+
|
435
|
+
FIELDS = {
|
436
|
+
SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success', :enum_class => Status}
|
437
|
+
}
|
438
|
+
|
439
|
+
def struct_fields; FIELDS; end
|
440
|
+
|
441
|
+
def validate
|
442
|
+
unless @success.nil? || Status::VALID_VALUES.include?(@success)
|
443
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field success!')
|
444
|
+
end
|
445
|
+
end
|
446
|
+
|
447
|
+
::Thrift::Struct.generate_accessors self
|
448
|
+
end
|
449
|
+
|
450
|
+
end
|
451
|
+
|
data/test/profile.thrift
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
struct UserProfile {
|
2
|
+
1: i32 uid,
|
3
|
+
2: string name,
|
4
|
+
3: string blurb
|
5
|
+
}
|
6
|
+
|
7
|
+
enum Status {
|
8
|
+
ON
|
9
|
+
OFF
|
10
|
+
DEAD
|
11
|
+
ALIVE
|
12
|
+
}
|
13
|
+
|
14
|
+
service UserStorage {
|
15
|
+
void store(1: UserProfile xuser),
|
16
|
+
UserProfile retrieve(1: i32 xuid),
|
17
|
+
void set_map(1: map<string, string> m),
|
18
|
+
map<string, string> last_map(),
|
19
|
+
void set_list(1: list<string> l),
|
20
|
+
list<string> last_list(),
|
21
|
+
void set_status(1: Status s),
|
22
|
+
Status last_status()
|
23
|
+
}
|
24
|
+
|
data/test/test_client.rb
ADDED
@@ -0,0 +1,184 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
require 'stark'
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'thrift'
|
7
|
+
|
8
|
+
$: << "test/legacy_profile"
|
9
|
+
|
10
|
+
require 'user_storage'
|
11
|
+
|
12
|
+
class TestClient < Test::Unit::TestCase
|
13
|
+
def setup
|
14
|
+
@client_t, @server_t = Stark.pipe_transport
|
15
|
+
@client_p = Thrift::BinaryProtocol.new @client_t
|
16
|
+
@server_p = Thrift::BinaryProtocol.new @server_t
|
17
|
+
|
18
|
+
@n = Module.new
|
19
|
+
Stark.materialize "test/profile.thrift", @n
|
20
|
+
|
21
|
+
@client = @n::UserStorage::Client.new @client_p, @client_p
|
22
|
+
@handler = Handler.new
|
23
|
+
@server = UserStorage::Processor.new @handler
|
24
|
+
end
|
25
|
+
|
26
|
+
def teardown
|
27
|
+
@client_t.close
|
28
|
+
@server_t.close
|
29
|
+
end
|
30
|
+
|
31
|
+
class Handler
|
32
|
+
def initialize
|
33
|
+
@users = {}
|
34
|
+
@last_map = nil
|
35
|
+
@last_list = nil
|
36
|
+
@last_status = nil
|
37
|
+
end
|
38
|
+
|
39
|
+
attr_accessor :last_map, :last_list, :last_status
|
40
|
+
|
41
|
+
def store(obj)
|
42
|
+
@users[obj.uid] = obj
|
43
|
+
end
|
44
|
+
|
45
|
+
def retrieve(id)
|
46
|
+
@users[id]
|
47
|
+
end
|
48
|
+
|
49
|
+
def set_map(m)
|
50
|
+
@last_map = m
|
51
|
+
end
|
52
|
+
|
53
|
+
def set_list(l)
|
54
|
+
@last_list = l
|
55
|
+
end
|
56
|
+
|
57
|
+
def set_status(s)
|
58
|
+
@last_status = s
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_store_and_retrieve
|
63
|
+
st = Thread.new do
|
64
|
+
@server.process @server_p, @server_p
|
65
|
+
end
|
66
|
+
|
67
|
+
xuser = @n::UserProfile.new 'uid' => 0, 'name' => 'root', 'blurb' => 'god'
|
68
|
+
|
69
|
+
@client.store xuser
|
70
|
+
|
71
|
+
st.join
|
72
|
+
|
73
|
+
st = Thread.new do
|
74
|
+
@server.process @server_p, @server_p
|
75
|
+
end
|
76
|
+
|
77
|
+
obj = @client.retrieve 0
|
78
|
+
|
79
|
+
st.join
|
80
|
+
|
81
|
+
assert_equal 0, obj.uid
|
82
|
+
assert_equal "root", obj.name
|
83
|
+
assert_equal "god", obj.blurb
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_set_map
|
87
|
+
st = Thread.new do
|
88
|
+
@server.process @server_p, @server_p
|
89
|
+
end
|
90
|
+
|
91
|
+
m = { "blah" => "foo", "a" => "b" }
|
92
|
+
|
93
|
+
@client.set_map m
|
94
|
+
|
95
|
+
st.join
|
96
|
+
|
97
|
+
assert_equal "foo", @handler.last_map["blah"]
|
98
|
+
assert_equal "b", @handler.last_map["a"]
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_last_map
|
102
|
+
st = Thread.new do
|
103
|
+
@server.process @server_p, @server_p
|
104
|
+
end
|
105
|
+
|
106
|
+
@handler.last_map = { "blah" => "foo", "a" => "b" }
|
107
|
+
|
108
|
+
m = @client.last_map
|
109
|
+
|
110
|
+
st.join
|
111
|
+
|
112
|
+
assert_equal "foo", m["blah"]
|
113
|
+
assert_equal "b", m["a"]
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_set_list
|
117
|
+
st = Thread.new do
|
118
|
+
@server.process @server_p, @server_p
|
119
|
+
end
|
120
|
+
|
121
|
+
m = [ "blah", "foo", "a", "b" ]
|
122
|
+
|
123
|
+
@client.set_list m
|
124
|
+
|
125
|
+
st.join
|
126
|
+
|
127
|
+
assert_equal m, @handler.last_list
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_last_list
|
131
|
+
st = Thread.new do
|
132
|
+
@server.process @server_p, @server_p
|
133
|
+
end
|
134
|
+
|
135
|
+
l = [ "blah", "foo", "a", "b" ]
|
136
|
+
@handler.last_list = l
|
137
|
+
|
138
|
+
begin
|
139
|
+
assert_equal l, @client.last_list
|
140
|
+
rescue Interrupt => e
|
141
|
+
puts e.backtrace
|
142
|
+
end
|
143
|
+
|
144
|
+
st.join
|
145
|
+
end
|
146
|
+
|
147
|
+
def test_last_list_is_nil
|
148
|
+
st = Thread.new do
|
149
|
+
@server.process @server_p, @server_p
|
150
|
+
end
|
151
|
+
|
152
|
+
begin
|
153
|
+
assert_equal nil, @client.last_list
|
154
|
+
rescue Interrupt => e
|
155
|
+
puts e.backtrace
|
156
|
+
end
|
157
|
+
|
158
|
+
st.join
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_enum
|
162
|
+
st = Thread.new do
|
163
|
+
@server.process @server_p, @server_p
|
164
|
+
end
|
165
|
+
|
166
|
+
@client.set_status :ON
|
167
|
+
|
168
|
+
st.join
|
169
|
+
|
170
|
+
assert_equal 0, @handler.last_status
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_enum_recv
|
174
|
+
st = Thread.new do
|
175
|
+
@server.process @server_p, @server_p
|
176
|
+
end
|
177
|
+
|
178
|
+
@handler.last_status = 0
|
179
|
+
|
180
|
+
assert_equal :ON, @client.last_status
|
181
|
+
|
182
|
+
st.join
|
183
|
+
end
|
184
|
+
end
|