xmpp4r 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. data/ChangeLog +12 -0
  2. data/Rakefile +2 -4
  3. data/data/doc/xmpp4r/examples/advanced/adventure/adventuremuc.rb +6 -6
  4. data/data/doc/xmpp4r/examples/advanced/adventure/world.rb +3 -3
  5. data/data/doc/xmpp4r/examples/advanced/minimuc.rb +5 -5
  6. data/data/doc/xmpp4r/examples/advanced/xmpping.rb +17 -4
  7. data/data/doc/xmpp4r/examples/advanced/xmppingrc.sample +5 -0
  8. data/data/doc/xmpp4r/examples/basic/echo_threaded.rb +6 -2
  9. data/data/doc/xmpp4r/examples/basic/muc_owner_config.rb +13 -0
  10. data/lib/xmpp4r.rb +0 -6
  11. data/lib/xmpp4r/bytestreams/helper/filetransfer.rb +6 -7
  12. data/lib/xmpp4r/bytestreams/helper/ibb/base.rb +5 -6
  13. data/lib/xmpp4r/bytestreams/helper/ibb/target.rb +3 -5
  14. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb +1 -1
  15. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/server.rb +10 -8
  16. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb +3 -5
  17. data/lib/xmpp4r/bytestreams/iq/bytestreams.rb +11 -17
  18. data/lib/xmpp4r/bytestreams/iq/si.rb +13 -32
  19. data/lib/xmpp4r/callbacks.rb +124 -0
  20. data/lib/xmpp4r/client.rb +2 -5
  21. data/lib/xmpp4r/command/helper/responder.rb +53 -0
  22. data/lib/xmpp4r/command/iq/command.rb +154 -0
  23. data/lib/xmpp4r/connection.rb +49 -12
  24. data/lib/xmpp4r/dataforms/x/data.rb +66 -29
  25. data/lib/xmpp4r/delay/x/delay.rb +2 -3
  26. data/lib/xmpp4r/discovery/iq/discoinfo.rb +20 -33
  27. data/lib/xmpp4r/discovery/iq/discoitems.rb +5 -28
  28. data/lib/xmpp4r/error.rb +5 -10
  29. data/lib/xmpp4r/feature_negotiation/iq/feature.rb +2 -20
  30. data/lib/xmpp4r/httpbinding.rb +5 -0
  31. data/lib/xmpp4r/httpbinding/client.rb +285 -0
  32. data/lib/xmpp4r/iq.rb +22 -41
  33. data/lib/xmpp4r/message.rb +8 -38
  34. data/lib/xmpp4r/muc.rb +2 -0
  35. data/lib/xmpp4r/muc/helper/mucclient.rb +50 -1
  36. data/lib/xmpp4r/muc/helper/simplemucclient.rb +2 -2
  37. data/lib/xmpp4r/muc/iq/mucowner.rb +11 -0
  38. data/lib/xmpp4r/muc/x/muc.rb +2 -30
  39. data/lib/xmpp4r/muc/x/mucuserinvite.rb +4 -2
  40. data/lib/xmpp4r/muc/x/mucuseritem.rb +4 -2
  41. data/lib/xmpp4r/presence.rb +7 -35
  42. data/lib/xmpp4r/pubsub.rb +1 -0
  43. data/lib/xmpp4r/pubsub/helper/nodebrowser.rb +174 -0
  44. data/lib/xmpp4r/pubsub/helper/nodehelper.rb +153 -0
  45. data/lib/xmpp4r/pubsub/helper/servicehelper.rb +326 -0
  46. data/lib/xmpp4r/pubsub/iq/pubsub.rb +19 -0
  47. data/lib/xmpp4r/pubsub/stanzas/event.rb +49 -0
  48. data/lib/xmpp4r/pubsub/stanzas/item.rb +27 -0
  49. data/lib/xmpp4r/pubsub/stanzas/items.rb +35 -0
  50. data/lib/xmpp4r/pubsub/stanzas/subscription.rb +58 -0
  51. data/lib/xmpp4r/query.rb +4 -32
  52. data/lib/xmpp4r/rexmladdons.rb +7 -772
  53. data/lib/xmpp4r/roster/helper/roster.rb +29 -50
  54. data/lib/xmpp4r/roster/iq/roster.rb +6 -35
  55. data/lib/xmpp4r/roster/x/roster.rb +13 -30
  56. data/lib/xmpp4r/rpc.rb +2 -0
  57. data/lib/xmpp4r/rpc/helper/client.rb +114 -0
  58. data/lib/xmpp4r/rpc/helper/server.rb +75 -0
  59. data/lib/xmpp4r/rpc/helper/xmlrpcaddons.rb +57 -0
  60. data/lib/xmpp4r/rpc/iq/rpc.rb +24 -0
  61. data/lib/xmpp4r/sasl.rb +1 -1
  62. data/lib/xmpp4r/semaphore.rb +38 -0
  63. data/lib/xmpp4r/stream.rb +104 -165
  64. data/lib/xmpp4r/streamparser.rb +2 -2
  65. data/lib/xmpp4r/vcard/iq/vcard.rb +5 -12
  66. data/lib/xmpp4r/version/helper/responder.rb +2 -1
  67. data/lib/xmpp4r/version/iq/version.rb +6 -18
  68. data/lib/xmpp4r/x.rb +20 -26
  69. data/lib/xmpp4r/xmpp4r.rb +1 -1
  70. data/lib/xmpp4r/xmppelement.rb +152 -0
  71. data/lib/xmpp4r/{xmlstanza.rb → xmppstanza.rb} +17 -29
  72. data/setup.rb +1 -0
  73. data/test/bytestreams/tc_ibb.rb +8 -8
  74. data/test/dataforms/tc_data.rb +81 -0
  75. data/test/lib/clienttester.rb +20 -17
  76. data/test/muc/tc_muc_mucclient.rb +48 -23
  77. data/test/muc/tc_muc_simplemucclient.rb +7 -4
  78. data/test/muc/tc_mucowner.rb +50 -0
  79. data/test/pubsub/tc_helper.rb +227 -0
  80. data/test/roster/tc_helper.rb +181 -55
  81. data/test/roster/tc_iqqueryroster.rb +33 -0
  82. data/test/roster/tc_xroster.rb +6 -3
  83. data/test/rpc/tc_helper.rb +84 -0
  84. data/test/tc_callbacks.rb +2 -1
  85. data/test/tc_class_names.rb +9 -1
  86. data/test/tc_error.rb +1 -0
  87. data/test/tc_iq.rb +13 -12
  88. data/test/tc_message.rb +1 -0
  89. data/test/tc_presence.rb +1 -0
  90. data/test/tc_rexml.rb +1 -1
  91. data/test/tc_stream.rb +147 -102
  92. data/test/tc_streamComponent.rb +94 -0
  93. data/test/tc_streamError.rb +67 -29
  94. data/test/tc_streamSend.rb +1 -1
  95. data/test/tc_xmppstanza.rb +125 -0
  96. data/test/ts_xmpp4r.rb +37 -28
  97. data/test/version/tc_helper.rb +14 -0
  98. data/test/version/tc_iqqueryversion.rb +4 -3
  99. metadata +163 -123
  100. data/data/doc/xmpp4r/examples/basic/echo_nonthreaded.rb +0 -32
  101. data/lib/callbacks.rb +0 -122
  102. data/test/tc_streamThreaded.rb +0 -168
  103. data/test/tc_xmlstanza.rb +0 -76
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/ruby
2
+
3
+ $:.unshift File::dirname(__FILE__) + '/../../lib'
4
+
5
+ require 'test/unit'
6
+ require 'xmpp4r/dataforms'
7
+ include Jabber
8
+
9
+ class DataFormsTest < Test::Unit::TestCase
10
+
11
+ def test_create_defaults
12
+ v = Dataforms::XDataTitle.new
13
+ assert_nil(v.title)
14
+ assert_equal("", v.to_s)
15
+
16
+ v = Dataforms::XDataInstructions.new
17
+ assert_nil(v.instructions)
18
+ assert_equal("", v.to_s)
19
+
20
+ v = Dataforms::XDataField.new
21
+ assert_nil(v.label)
22
+ assert_nil(v.var)
23
+ assert_nil(v.type)
24
+ assert_equal(false, v.required?)
25
+ assert_equal([], v.values)
26
+ assert_equal({}, v.options)
27
+
28
+ v = Dataforms::XData.new
29
+ assert_equal([], v.fields)
30
+ assert_nil(v.type)
31
+ end
32
+
33
+ def test_create
34
+ v = Dataforms::XDataTitle.new "This is the title"
35
+ assert_equal("This is the title",v.title)
36
+ assert_equal("This is the title", v.to_s)
37
+
38
+ v = Dataforms::XDataInstructions.new "Instructions"
39
+ assert_equal("Instructions",v.instructions)
40
+ assert_equal("Instructions", v.to_s)
41
+
42
+ f = Dataforms::XDataField.new "botname", :text_single
43
+ assert_nil(f.label)
44
+ assert_equal("botname", f.var)
45
+ assert_equal(:text_single, f.type)
46
+ assert_equal(false, f.required?)
47
+ assert_equal([], f.values)
48
+ assert_equal({}, f.options)
49
+ f.label = "The name of your bot"
50
+ assert_equal("The name of your bot", f.label)
51
+ [:boolean, :fixed, :hidden, :jid_multi, :jid_single,
52
+ :list_multi, :list_single, :text_multi, :text_private,
53
+ :text_single].each do |type|
54
+ f.type = type
55
+ assert_equal(type, f.type)
56
+ end
57
+ f.type = :wrong_type
58
+ assert_nil(f.type)
59
+ f.required= true
60
+ assert_equal(true, f.required?)
61
+ f.values = ["the value"]
62
+ assert_equal(["the value"], f.values)
63
+ f.options = { "option 1" => "Label 1", "option 2" => "Label 2", "option 3" => nil }
64
+ assert_equal({ "option 1" => "Label 1", "option 2" => "Label 2", "option 3" => nil }, f.options)
65
+
66
+
67
+ f = Dataforms::XDataField.new "test", :text_single
68
+ v = Dataforms::XData.new :form
69
+ assert_equal([], v.fields)
70
+ assert_equal(:form, v.type)
71
+ [:form, :result, :submit, :cancel].each do |type|
72
+ v.type = type
73
+ assert_equal(type, v.type)
74
+ end
75
+ v.add f
76
+ assert_equal(f, v.field('test'))
77
+ assert_nil(v.field('wrong field'))
78
+ assert_equal([f], v.fields)
79
+ end
80
+
81
+ end
@@ -2,6 +2,7 @@ $:.unshift '../lib'
2
2
  require 'xmpp4r'
3
3
  require 'test/unit'
4
4
  require 'socket'
5
+ require 'xmpp4r/semaphore'
5
6
 
6
7
  # Turn $VERBOSE off to suppress warnings about redefinition
7
8
  oldverbose = $VERBOSE
@@ -22,53 +23,50 @@ module Jabber
22
23
  @@SOCKET_PORT = 65223
23
24
 
24
25
  def setup
25
- Thread::abort_on_exception = true
26
-
27
26
  servlisten = TCPServer.new(@@SOCKET_PORT)
28
- serverwait = Mutex.new
29
- serverwait.lock
30
- Thread.new {
27
+ serverwait = Semaphore.new
28
+ Thread.new do
29
+ Thread.current.abort_on_exception = true
31
30
  serversock = servlisten.accept
32
31
  servlisten.close
33
32
  serversock.sync = true
34
33
  @server = Stream.new(true)
35
- @server.add_xml_callback { |xml|
34
+ @server.add_xml_callback do |xml|
36
35
  if xml.prefix == 'stream' and xml.name == 'stream'
37
36
  send('<stream:stream>')
38
37
  true
39
38
  else
40
39
  false
41
40
  end
42
- }
41
+ end
43
42
  @server.start(serversock)
44
43
 
45
- serverwait.unlock
46
- }
44
+ serverwait.run
45
+ end
47
46
 
48
47
  clientsock = TCPSocket.new('localhost', @@SOCKET_PORT)
49
48
  clientsock.sync = true
50
49
  @client = Stream.new(true)
51
50
  @client.start(clientsock)
52
51
 
53
- @client.send('<stream:stream>') { |reply|
54
- true
55
- }
52
+ @client.send('<stream:stream>') { |reply| true }
56
53
 
57
54
  @state = 0
58
55
  @states = []
59
- @state_wait = Mutex.new
60
- @state_wait.lock
56
+ @state_wait = Semaphore.new
57
+ @state_wait2 = Semaphore.new
61
58
  @server.add_stanza_callback { |stanza|
62
59
  if @state < @states.size
63
60
  @states[@state].call(stanza)
64
61
  @state += 1
62
+ @state_wait2.wait
63
+ @state_wait.run
65
64
  end
66
- @state_wait.unlock
67
65
 
68
66
  false
69
67
  }
70
68
 
71
- serverwait.lock
69
+ serverwait.wait
72
70
  end
73
71
 
74
72
  def teardown
@@ -101,7 +99,12 @@ module Jabber
101
99
  end
102
100
 
103
101
  def wait_state
104
- @state_wait.lock
102
+ @state_wait2.run
103
+ @state_wait.wait
104
+ end
105
+
106
+ def skip_state
107
+ @state_wait2.run
105
108
  end
106
109
  end
107
110
  end
@@ -6,6 +6,7 @@ $:.unshift File::dirname(__FILE__) + '/../../lib'
6
6
  require 'test/unit'
7
7
  require File::dirname(__FILE__) + '/../lib/clienttester'
8
8
  require 'xmpp4r/muc'
9
+ require 'xmpp4r/semaphore'
9
10
  include Jabber
10
11
 
11
12
  class MUCClientTest < Test::Unit::TestCase
@@ -54,10 +55,12 @@ class MUCClientTest < Test::Unit::TestCase
54
55
  assert_raises(ErrorException) {
55
56
  m.join('darkcave@macbeth.shakespeare.lit/thirdwitch')
56
57
  }
58
+ wait_state
57
59
  assert(!m.active?)
58
60
  assert_nil(m.room)
59
61
 
60
62
  assert_equal(m, m.join('darkcave@macbeth.shakespeare.lit/thirdwitch'))
63
+ wait_state
61
64
  assert(m.active?)
62
65
  assert_equal('darkcave', m.room)
63
66
  assert_equal(3, m.roster.size)
@@ -104,15 +107,17 @@ class MUCClientTest < Test::Unit::TestCase
104
107
  "<x xmlns='http://jabber.org/protocol/muc#user'><item affiliation='member' role='participant'/></x>" +
105
108
  "</presence>")
106
109
  }
107
-
110
+
108
111
  m = MUC::MUCClient.new(@client)
109
112
  m.my_jid = 'hag66@shakespeare.lit/pda'
110
113
  assert_raises(ErrorException) {
111
114
  m.join('darkcave@macbeth.shakespeare.lit/thirdwitch')
112
115
  }
116
+ wait_state
113
117
  assert(!m.active?)
114
118
 
115
119
  assert_equal(m, m.join('darkcave@macbeth.shakespeare.lit/thirdwitch', 'cauldron'))
120
+ wait_state
116
121
  assert(m.active?)
117
122
  end
118
123
 
@@ -130,6 +135,8 @@ class MUCClientTest < Test::Unit::TestCase
130
135
  m.join('darkcave@macbeth.shakespeare.lit/thirdwitch')
131
136
  }
132
137
  assert(!m.active?)
138
+
139
+ wait_state
133
140
  end
134
141
 
135
142
  def test_banned_users
@@ -146,6 +153,8 @@ class MUCClientTest < Test::Unit::TestCase
146
153
  m.join('darkcave@macbeth.shakespeare.lit/thirdwitch')
147
154
  }
148
155
  assert(!m.active?)
156
+
157
+ wait_state
149
158
  end
150
159
 
151
160
  def test_nickname_conflict
@@ -162,6 +171,8 @@ class MUCClientTest < Test::Unit::TestCase
162
171
  m.join('darkcave@macbeth.shakespeare.lit/thirdwitch')
163
172
  }
164
173
  assert(!m.active?)
174
+
175
+ wait_state
165
176
  end
166
177
 
167
178
  def test_max_users
@@ -178,11 +189,12 @@ class MUCClientTest < Test::Unit::TestCase
178
189
  m.join('darkcave@macbeth.shakespeare.lit/thirdwitch')
179
190
  }
180
191
  assert(!m.active?)
192
+
193
+ wait_state
181
194
  end
182
195
 
183
196
  def test_locked_room
184
197
  state { |pres|
185
- assert_kind_of(Presence, pres)
186
198
  send("<presence from='darkcave@macbeth.shakespeare.lit' to='hag66@shakespeare.lit/pda' type='error'>" +
187
199
  "<error code='404' type='cancel'><item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error>" +
188
200
  "</presence>")
@@ -194,6 +206,7 @@ class MUCClientTest < Test::Unit::TestCase
194
206
  m.join('darkcave@macbeth.shakespeare.lit/thirdwitch')
195
207
  }
196
208
  assert(!m.active?)
209
+ wait_state
197
210
  end
198
211
 
199
212
  def test_exit_room
@@ -221,15 +234,17 @@ class MUCClientTest < Test::Unit::TestCase
221
234
  @client.add_stanza_callback { |stanza|
222
235
  ignored_stanzas += 1
223
236
  }
224
-
237
+
225
238
  m = MUC::MUCClient.new(@client)
226
239
  m.my_jid = 'hag66@shakespeare.lit/pda'
227
240
  assert_equal(0, ignored_stanzas)
228
241
  assert_equal(m, m.join('darkcave@macbeth.shakespeare.lit/thirdwitch'))
242
+ wait_state
229
243
  assert(m.active?)
230
244
 
231
245
  assert_equal(0, ignored_stanzas)
232
246
  assert_equal(m, m.exit)
247
+ wait_state
233
248
  assert(!m.active?)
234
249
  assert_equal(1, ignored_stanzas)
235
250
  end
@@ -251,14 +266,16 @@ class MUCClientTest < Test::Unit::TestCase
251
266
  "<x xmlns='http://jabber.org/protocol/muc#user'><item affiliation='member' role='none'/></x>" +
252
267
  "</presence>")
253
268
  }
254
-
269
+
255
270
  m = MUC::MUCClient.new(@client)
256
271
  m.my_jid = 'hag66@shakespeare.lit/pda'
257
272
  assert_equal(m, m.join('darkcave@macbeth.shakespeare.lit/thirdwitch'))
258
273
  assert(m.active?)
274
+ wait_state
259
275
 
260
276
  assert_equal(m, m.exit('gone where the goblins go'))
261
277
  assert(!m.active?)
278
+ wait_state
262
279
  end
263
280
 
264
281
  def test_joins
@@ -304,6 +321,7 @@ class MUCClientTest < Test::Unit::TestCase
304
321
  m = MUC::MUCClient.new(@client)
305
322
  m.my_jid = 'hag66@shakespeare.lit/pda'
306
323
  assert_equal(m, m.join('darkcave@macbeth.shakespeare.lit/thirdwitch'))
324
+ wait_state
307
325
  assert(m.active?)
308
326
 
309
327
  assert_raises(RuntimeError) { m.join('darkcave@macbeth.shakespeare.lit/thirdwitch') }
@@ -311,11 +329,13 @@ class MUCClientTest < Test::Unit::TestCase
311
329
  assert(m.active?)
312
330
 
313
331
  assert_equal(m, m.exit)
332
+ wait_state
314
333
  assert(!m.active?)
315
334
  assert_raises(RuntimeError) { m.exit }
316
335
  assert(!m.active?)
317
336
 
318
337
  assert_equal(m, m.join('darkcave@macbeth.shakespeare.lit/fourthwitch'))
338
+ wait_state
319
339
  assert(m.active?)
320
340
 
321
341
  assert_raises(RuntimeError) { m.join('darkcave@macbeth.shakespeare.lit/thirdwitch') }
@@ -323,6 +343,7 @@ class MUCClientTest < Test::Unit::TestCase
323
343
  assert(m.active?)
324
344
 
325
345
  assert_equal(m, m.exit('Exiting one last time'))
346
+ wait_state
326
347
  assert(!m.active?)
327
348
  assert_raises(RuntimeError) { m.exit }
328
349
  assert(!m.active?)
@@ -337,13 +358,12 @@ class MUCClientTest < Test::Unit::TestCase
337
358
  "</presence>")
338
359
  }
339
360
 
340
- message_lock = Mutex.new
341
- message_lock.lock
361
+ message_lock = Semaphore.new
342
362
 
343
363
  messages_client = 0
344
364
  @client.add_message_callback { |msg|
345
365
  messages_client += 1
346
- message_lock.unlock
366
+ message_lock.run
347
367
  }
348
368
 
349
369
  m = MUC::MUCClient.new(@client)
@@ -351,12 +371,12 @@ class MUCClientTest < Test::Unit::TestCase
351
371
  messages_muc = 0
352
372
  m.add_message_callback { |msg|
353
373
  messages_muc += 1
354
- message_lock.unlock
374
+ message_lock.run
355
375
  }
356
376
  messages_muc_private = 0
357
377
  m.add_private_message_callback { |msg|
358
378
  messages_muc_private += 1
359
- message_lock.unlock
379
+ message_lock.run
360
380
  }
361
381
 
362
382
  assert_equal(m, m.join('darkcave@macbeth.shakespeare.lit/thirdwitch', 'cauldron'))
@@ -367,26 +387,28 @@ class MUCClientTest < Test::Unit::TestCase
367
387
  assert_equal(0, messages_muc_private)
368
388
 
369
389
  send("<message from='darkcave@macbeth.shakespeare.lit/firstwitch' to='hag66@shakespeare.lit/pda'><body>Hello</body></message>")
370
- message_lock.lock
390
+ message_lock.wait
371
391
 
372
392
  assert_equal(0, messages_client)
373
393
  assert_equal(1, messages_muc)
374
394
  assert_equal(0, messages_muc_private)
375
395
 
376
396
  send("<message from='user@domain/resource' to='hag66@shakespeare.lit/pda'><body>Hello</body></message>")
377
- message_lock.lock
397
+ message_lock.wait
378
398
 
379
399
  assert_equal(1, messages_client)
380
400
  assert_equal(1, messages_muc)
381
401
  assert_equal(0, messages_muc_private)
382
402
 
383
403
  send("<message type='chat' from='darkcave@macbeth.shakespeare.lit/firstwitch' to='hag66@shakespeare.lit/pda'><body>Hello</body></message>")
384
- message_lock.lock
404
+ message_lock.wait
385
405
 
386
406
  assert_equal(1, messages_client)
387
407
  assert_equal(1, messages_muc)
388
408
  assert_equal(1, messages_muc_private)
389
- end
409
+
410
+ wait_state
411
+ end
390
412
 
391
413
  def test_presence_callbacks
392
414
  state { |pres|
@@ -397,30 +419,29 @@ class MUCClientTest < Test::Unit::TestCase
397
419
  "</presence>")
398
420
  }
399
421
 
400
- presence_lock = Mutex.new
401
- presence_lock.lock
422
+ presence_lock = Semaphore.new
402
423
 
403
424
  presences_client = 0
404
425
  @client.add_presence_callback { |pres|
405
426
  presences_client += 1
406
- presence_lock.unlock
427
+ presence_lock.run
407
428
  }
408
429
  m = MUC::MUCClient.new(@client)
409
430
  m.my_jid = 'hag66@shakespeare.lit/pda'
410
431
  presences_join = 0
411
432
  m.add_join_callback { |pres|
412
433
  presences_join += 1
413
- presence_lock.unlock
434
+ presence_lock.run
414
435
  }
415
436
  presences_leave = 0
416
437
  m.add_leave_callback { |pres|
417
438
  presences_leave += 1
418
- presence_lock.unlock
439
+ presence_lock.run
419
440
  }
420
441
  presences_muc = 0
421
442
  m.add_presence_callback { |pres|
422
443
  presences_muc += 1
423
- presence_lock.unlock
444
+ presence_lock.run
424
445
  }
425
446
 
426
447
  assert_equal(0, presences_client)
@@ -439,7 +460,7 @@ class MUCClientTest < Test::Unit::TestCase
439
460
  send("<presence from='darkcave@macbeth.shakespeare.lit/firstwitch' to='hag66@shakespeare.lit/pda'>" +
440
461
  "<x xmlns='http://jabber.org/protocol/muc#user'><item affiliation='member' role='participant'/></x>" +
441
462
  "</presence>")
442
- presence_lock.lock
463
+ presence_lock.wait
443
464
  assert_equal(0, presences_client)
444
465
  assert_equal(1, presences_join)
445
466
  assert_equal(0, presences_leave)
@@ -448,7 +469,7 @@ class MUCClientTest < Test::Unit::TestCase
448
469
  send("<presence from='user@domain/resource' to='hag66@shakespeare.lit/pda'>" +
449
470
  "<show>chat</show>" +
450
471
  "</presence>")
451
- presence_lock.lock
472
+ presence_lock.wait
452
473
  assert_equal(1, presences_client)
453
474
  assert_equal(1, presences_join)
454
475
  assert_equal(0, presences_leave)
@@ -457,18 +478,19 @@ class MUCClientTest < Test::Unit::TestCase
457
478
  send("<presence from='darkcave@macbeth.shakespeare.lit/firstwitch' to='hag66@shakespeare.lit/pda'>" +
458
479
  "<x xmlns='http://jabber.org/protocol/muc#user'><item affiliation='member' role='participant'/></x>" +
459
480
  "<show>away</show></presence>")
460
- presence_lock.lock
481
+ presence_lock.wait
461
482
  assert_equal(1, presences_client)
462
483
  assert_equal(1, presences_join)
463
484
  assert_equal(0, presences_leave)
464
485
  assert_equal(1, presences_muc)
465
486
 
466
487
  send("<presence from='darkcave@macbeth.shakespeare.lit/firstwitch' to='hag66@shakespeare.lit/pda' type='unavailable'/>")
467
- presence_lock.lock
488
+ presence_lock.wait
468
489
  assert_equal(1, presences_client)
469
490
  assert_equal(1, presences_join)
470
491
  assert_equal(1, presences_leave)
471
492
  assert_equal(1, presences_muc)
493
+ wait_state
472
494
  end
473
495
 
474
496
  def test_send
@@ -553,16 +575,19 @@ class MUCClientTest < Test::Unit::TestCase
553
575
  m.my_jid = 'hag66@shakespeare.lit/pda'
554
576
 
555
577
  assert_equal(m, m.join('darkcave@macbeth.shakespeare.lit/thirdwitch'))
578
+ wait_state
556
579
  assert(m.active?)
557
580
  assert_equal('thirdwitch', m.nick)
558
581
 
559
582
  assert_raises(ErrorException) {
560
583
  m.nick = 'secondwitch'
561
584
  }
585
+ wait_state
562
586
  assert(m.active?)
563
587
  assert_equal('thirdwitch', m.nick)
564
588
 
565
589
  m.nick = 'oldhag'
590
+ wait_state
566
591
  assert(m.active?)
567
592
  assert_equal('oldhag', m.nick)
568
593
  end