xmpp4r 0.3.2 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. data/{ChangeLog → CHANGELOG} +33 -0
  2. data/LICENSE +9 -9
  3. data/README.rdoc +110 -0
  4. data/README_ruby19.txt +43 -0
  5. data/Rakefile +235 -74
  6. data/data/doc/xmpp4r/examples/advanced/adventure/README +0 -1
  7. data/data/doc/xmpp4r/examples/advanced/adventure/adventure.rb +1 -1
  8. data/data/doc/xmpp4r/examples/advanced/adventure/adventuremuc.rb +12 -12
  9. data/data/doc/xmpp4r/examples/advanced/adventure/world.rb +10 -11
  10. data/data/doc/xmpp4r/examples/advanced/fileserve.rb +11 -11
  11. data/data/doc/xmpp4r/examples/advanced/getonline.rb +7 -7
  12. data/data/doc/xmpp4r/examples/advanced/gtkmucclient.rb +3 -3
  13. data/data/doc/xmpp4r/examples/advanced/migrate.rb +21 -22
  14. data/data/doc/xmpp4r/examples/advanced/minimuc.rb +22 -22
  15. data/data/doc/xmpp4r/examples/advanced/pep-aggregator/index.xsl +235 -0
  16. data/data/doc/xmpp4r/examples/advanced/pep-aggregator/pep-aggregator.rb +147 -0
  17. data/data/doc/xmpp4r/examples/advanced/recvfile.rb +0 -1
  18. data/data/doc/xmpp4r/examples/advanced/rosterdiscovery.rb +2 -3
  19. data/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr.rb +3 -3
  20. data/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr_jabber.rb +10 -10
  21. data/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr_test.rb +2 -2
  22. data/data/doc/xmpp4r/examples/advanced/versionpoll.rb +12 -12
  23. data/data/doc/xmpp4r/examples/advanced/xmpping.rb +2 -3
  24. data/data/doc/xmpp4r/examples/basic/change_password.rb +3 -3
  25. data/data/doc/xmpp4r/examples/basic/client.rb +5 -3
  26. data/data/doc/xmpp4r/examples/basic/component.rb +1 -1
  27. data/data/doc/xmpp4r/examples/basic/{echo_threaded.rb → echo.rb} +8 -7
  28. data/data/doc/xmpp4r/examples/basic/jabbersend.rb +5 -5
  29. data/data/doc/xmpp4r/examples/basic/mass_sender.rb +11 -11
  30. data/data/doc/xmpp4r/examples/basic/muc_owner_config.rb +0 -1
  31. data/data/doc/xmpp4r/examples/basic/mucinfo.rb +3 -1
  32. data/data/doc/xmpp4r/examples/basic/mucsimplebot.rb +0 -1
  33. data/data/doc/xmpp4r/examples/basic/register.rb +21 -4
  34. data/data/doc/xmpp4r/examples/basic/roster.rb +7 -5
  35. data/data/doc/xmpp4r/examples/basic/rosterprint.rb +0 -0
  36. data/data/doc/xmpp4r/examples/basic/rosterrename.rb +2 -2
  37. data/data/doc/xmpp4r/examples/basic/rosterwatch.rb +6 -7
  38. data/data/doc/xmpp4r/examples/basic/send_vcard.rb +3 -4
  39. data/data/doc/xmpp4r/examples/basic/tune_client.rb +56 -0
  40. data/data/doc/xmpp4r/examples/basic/tune_server.rb +58 -0
  41. data/data/doc/xmpp4r/examples/basic/versionbot.rb +1 -1
  42. data/lib/xmpp4r.rb +4 -4
  43. data/lib/xmpp4r/base64.rb +32 -0
  44. data/lib/xmpp4r/bytestreams/helper/filetransfer.rb +10 -11
  45. data/lib/xmpp4r/bytestreams/helper/ibb/base.rb +6 -8
  46. data/lib/xmpp4r/bytestreams/helper/ibb/initiator.rb +3 -6
  47. data/lib/xmpp4r/bytestreams/helper/ibb/target.rb +0 -1
  48. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb +8 -11
  49. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/initiator.rb +4 -7
  50. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/server.rb +7 -3
  51. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/socks5.rb +10 -5
  52. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb +14 -4
  53. data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb.orig +62 -0
  54. data/lib/xmpp4r/bytestreams/iq/bytestreams.rb +0 -1
  55. data/lib/xmpp4r/callbacks.rb +5 -5
  56. data/lib/xmpp4r/caps.rb +1 -0
  57. data/lib/xmpp4r/caps/c.rb +53 -0
  58. data/lib/xmpp4r/caps/helper/generator.rb +160 -0
  59. data/lib/xmpp4r/caps/helper/helper.rb +87 -0
  60. data/lib/xmpp4r/client.rb +111 -40
  61. data/lib/xmpp4r/command/iq/command.rb +1 -1
  62. data/lib/xmpp4r/component.rb +8 -8
  63. data/lib/xmpp4r/connection.rb +25 -9
  64. data/lib/xmpp4r/dataforms/x/data.rb +17 -5
  65. data/lib/xmpp4r/debuglog.rb +13 -5
  66. data/lib/xmpp4r/delay/x/delay.rb +1 -1
  67. data/lib/xmpp4r/discovery.rb +3 -2
  68. data/lib/xmpp4r/discovery/helper/responder.rb +165 -0
  69. data/lib/xmpp4r/discovery/iq/discoinfo.rb +11 -12
  70. data/lib/xmpp4r/discovery/iq/discoitems.rb +12 -4
  71. data/lib/xmpp4r/{error.rb → errors.rb} +66 -10
  72. data/lib/xmpp4r/framework/base.rb +55 -0
  73. data/lib/xmpp4r/framework/bot.rb +148 -0
  74. data/lib/xmpp4r/httpbinding/client.rb +1 -1
  75. data/lib/xmpp4r/idgenerator.rb +1 -1
  76. data/lib/xmpp4r/iq.rb +34 -23
  77. data/lib/xmpp4r/jid.rb +2 -2
  78. data/lib/xmpp4r/message.rb +1 -1
  79. data/lib/xmpp4r/muc.rb +2 -0
  80. data/lib/xmpp4r/muc/helper/mucbrowser.rb +4 -19
  81. data/lib/xmpp4r/muc/helper/mucclient.rb +54 -23
  82. data/lib/xmpp4r/muc/helper/simplemucclient.rb +107 -1
  83. data/lib/xmpp4r/muc/iq/mucadmin.rb +23 -0
  84. data/lib/xmpp4r/muc/iq/mucadminitem.rb +20 -0
  85. data/lib/xmpp4r/muc/iq/mucowner.rb +5 -1
  86. data/lib/xmpp4r/muc/item.rb +143 -0
  87. data/lib/xmpp4r/muc/x/mucuserinvite.rb +2 -2
  88. data/lib/xmpp4r/muc/x/mucuseritem.rb +3 -117
  89. data/lib/xmpp4r/presence.rb +2 -1
  90. data/lib/xmpp4r/pubsub.rb +7 -0
  91. data/lib/xmpp4r/pubsub/children/configuration.rb +86 -0
  92. data/lib/xmpp4r/pubsub/{stanzas → children}/event.rb +13 -13
  93. data/lib/xmpp4r/pubsub/{stanzas → children}/item.rb +9 -1
  94. data/lib/xmpp4r/pubsub/{stanzas → children}/items.rb +10 -1
  95. data/lib/xmpp4r/pubsub/children/node_config.rb +48 -0
  96. data/lib/xmpp4r/pubsub/children/publish.rb +24 -0
  97. data/lib/xmpp4r/pubsub/{stanzas → children}/subscription.rb +16 -12
  98. data/lib/xmpp4r/pubsub/children/subscription_config.rb +67 -0
  99. data/lib/xmpp4r/pubsub/children/unsubscribe.rb +48 -0
  100. data/lib/xmpp4r/pubsub/helper/nodebrowser.rb +49 -93
  101. data/lib/xmpp4r/pubsub/helper/nodehelper.rb +39 -36
  102. data/lib/xmpp4r/pubsub/helper/servicehelper.rb +253 -162
  103. data/lib/xmpp4r/pubsub/iq/pubsub.rb +1 -1
  104. data/lib/xmpp4r/rexmladdons.rb +56 -28
  105. data/lib/xmpp4r/roster.rb +0 -1
  106. data/lib/xmpp4r/roster/helper/roster.rb +26 -15
  107. data/lib/xmpp4r/roster/iq/roster.rb +19 -19
  108. data/lib/xmpp4r/roster/x/roster.rb +10 -10
  109. data/lib/xmpp4r/rpc/helper/client.rb +17 -8
  110. data/lib/xmpp4r/rpc/helper/server.rb +1 -2
  111. data/lib/xmpp4r/rpc/helper/xmlrpcaddons.rb +14 -4
  112. data/lib/xmpp4r/rpc/iq/rpc.rb +0 -1
  113. data/lib/xmpp4r/sasl.rb +27 -6
  114. data/lib/xmpp4r/stream.rb +39 -44
  115. data/lib/xmpp4r/streamparser.rb +4 -4
  116. data/lib/xmpp4r/tune.rb +2 -0
  117. data/lib/xmpp4r/tune/helper/helper.rb +58 -0
  118. data/lib/xmpp4r/tune/tune.rb +113 -0
  119. data/lib/xmpp4r/vcard.rb +0 -1
  120. data/lib/xmpp4r/vcard/helper/vcard.rb +1 -3
  121. data/lib/xmpp4r/vcard/iq/vcard.rb +14 -0
  122. data/lib/xmpp4r/version/iq/version.rb +0 -1
  123. data/lib/xmpp4r/x.rb +1 -1
  124. data/lib/xmpp4r/xhtml.rb +1 -0
  125. data/lib/xmpp4r/xhtml/html.rb +115 -0
  126. data/lib/xmpp4r/xmpp4r.rb +7 -5
  127. data/lib/xmpp4r/xmppelement.rb +21 -5
  128. data/lib/xmpp4r/xmppstanza.rb +6 -6
  129. data/setup.rb +4 -4
  130. data/test/bytestreams/tc_ibb.rb +2 -2
  131. data/test/bytestreams/tc_socks5bytestreams.rb +12 -2
  132. data/test/caps/tc_helper.rb +156 -0
  133. data/test/dataforms/tc_data.rb +0 -0
  134. data/test/delay/tc_xdelay.rb +2 -2
  135. data/test/discovery/tc_responder.rb +91 -0
  136. data/test/lib/assert_equal_xml.rb +14 -0
  137. data/test/lib/clienttester.rb +31 -24
  138. data/test/muc/tc_muc_mucclient.rb +249 -13
  139. data/test/muc/tc_muc_simplemucclient.rb +41 -2
  140. data/test/muc/tc_mucowner.rb +0 -0
  141. data/test/pubsub/tc_helper.rb +486 -51
  142. data/test/pubsub/tc_nodeconfig.rb +54 -0
  143. data/test/pubsub/tc_subscriptionconfig.rb +41 -0
  144. data/test/roster/tc_helper.rb +6 -7
  145. data/test/roster/tc_iqqueryroster.rb +16 -16
  146. data/test/roster/tc_xroster.rb +1 -1
  147. data/test/rpc/tc_helper.rb +15 -3
  148. data/test/tc_callbacks.rb +7 -7
  149. data/test/tc_class_names.rb +15 -6
  150. data/test/tc_client.rb +3 -3
  151. data/test/{tc_error.rb → tc_errors.rb} +54 -12
  152. data/test/tc_idgenerator.rb +0 -0
  153. data/test/tc_iq.rb +32 -29
  154. data/test/tc_iqquery.rb +2 -2
  155. data/test/tc_jid.rb +44 -42
  156. data/test/tc_message.rb +13 -12
  157. data/test/tc_presence.rb +25 -24
  158. data/test/tc_rexml.rb +81 -2
  159. data/test/tc_stream.rb +15 -13
  160. data/test/tc_streamComponent.rb +6 -5
  161. data/test/tc_streamError.rb +21 -15
  162. data/test/tc_streamSend.rb +9 -9
  163. data/test/tc_streamparser.rb +112 -0
  164. data/test/tc_xmppstanza.rb +19 -9
  165. data/test/ts_xmpp4r.rb +10 -1
  166. data/test/tune/tc_helper_recv.rb +84 -0
  167. data/test/tune/tc_helper_send.rb +74 -0
  168. data/test/tune/tc_tune.rb +79 -0
  169. data/test/vcard/tc_helper.rb +2 -2
  170. data/test/vcard/tc_iqvcard.rb +13 -3
  171. data/test/version/tc_helper.rb +2 -2
  172. data/test/version/tc_iqqueryversion.rb +10 -10
  173. data/test/xhtml/tc_html.rb +41 -0
  174. data/tools/gen_requires.bash +29 -8
  175. data/tools/xmpp4r-gemspec-test.rb +11 -0
  176. data/xmpp4r.gemspec +291 -0
  177. metadata +277 -218
  178. data/README +0 -28
  179. data/UPDATING +0 -40
  180. data/data/doc/xmpp4r/examples/buggy/jabber2jabber/jabber2jabber.rb +0 -18
  181. data/data/doc/xmpp4r/examples/buggy/miniedgarr_cgi.rb +0 -192
  182. data/data/doc/xmpp4r/examples/buggy/miniedgarr_watch.rb +0 -82
  183. data/lib/xmpp4r/authenticationfailure.rb +0 -13
  184. data/lib/xmpp4r/errorexception.rb +0 -32
  185. data/tools/doctoweb.bash +0 -30
File without changes
@@ -6,52 +6,55 @@ require 'test/unit'
6
6
  require 'socket'
7
7
  require 'xmpp4r/rexmladdons'
8
8
  require 'xmpp4r/iq'
9
+ require 'xmpp4r/errors'
9
10
  include Jabber
10
11
 
12
+ require File::dirname(__FILE__) + '/lib/assert_equal_xml'
13
+
11
14
  class IqTest < Test::Unit::TestCase
12
15
  def test_create
13
- x = Iq::new()
16
+ x = Iq.new()
14
17
  assert_equal("iq", x.name)
15
18
  assert_equal("jabber:client", x.namespace)
16
- assert_equal("<iq xmlns='jabber:client'/>", x.to_s)
19
+ assert_equal_xml("<iq xmlns='jabber:client'/>", x)
17
20
  end
18
21
 
19
22
  def test_iqauth
20
- x = Iq::new_authset(JID::new('node@domain/resource'), 'password')
21
- assert_equal("<iq type='set' xmlns='jabber:client'><query xmlns='jabber:iq:auth'><username>node</username><password>password</password><resource>resource</resource></query></iq>", x.to_s)
23
+ x = Iq.new_authset(JID.new('node@domain/resource'), 'password')
24
+ assert_equal_xml("<iq type='set' xmlns='jabber:client'><query xmlns='jabber:iq:auth'><username>node</username><password>password</password><resource>resource</resource></query></iq>", x)
22
25
  end
23
26
 
24
27
  def test_iqauth_digest
25
- x = Iq::new_authset_digest(JID::new('node@domain/resource'), '', 'password')
26
- assert_equal("<iq type='set' xmlns='jabber:client'><query xmlns='jabber:iq:auth'><username>node</username><digest>#{Digest::SHA1.hexdigest('password')}</digest><resource>resource</resource></query></iq>", x.to_s)
28
+ x = Iq.new_authset_digest(JID.new('node@domain/resource'), '', 'password')
29
+ assert_equal_xml("<iq type='set' xmlns='jabber:client'><query xmlns='jabber:iq:auth'><username>node</username><digest>#{Digest::SHA1.hexdigest('password')}</digest><resource>resource</resource></query></iq>", x)
27
30
  end
28
31
 
29
32
  def test_register
30
- x1 = Iq::new_register
31
- assert_equal("<iq type='set' xmlns='jabber:client'><query xmlns='jabber:iq:register'/></iq>", x1.to_s)
32
- x2 = Iq::new_register('node')
33
- assert_equal("<iq type='set' xmlns='jabber:client'><query xmlns='jabber:iq:register'><username>node</username></query></iq>", x2.to_s)
34
- x3 = Iq::new_register('node', 'password')
35
- assert_equal("<iq type='set' xmlns='jabber:client'><query xmlns='jabber:iq:register'><username>node</username><password>password</password></query></iq>", x3.to_s)
33
+ x1 = Iq.new_register
34
+ assert_equal_xml("<iq type='set' xmlns='jabber:client'><query xmlns='jabber:iq:register'/></iq>", x1)
35
+ x2 = Iq.new_register('node')
36
+ assert_equal_xml("<iq type='set' xmlns='jabber:client'><query xmlns='jabber:iq:register'><username>node</username></query></iq>", x2)
37
+ x3 = Iq.new_register('node', 'password')
38
+ assert_equal_xml("<iq type='set' xmlns='jabber:client'><query xmlns='jabber:iq:register'><username>node</username><password>password</password></query></iq>", x3)
36
39
  end
37
40
 
38
41
  def test_rosterget
39
- x = Iq::new_rosterget
40
- assert_equal("<iq type='get' xmlns='jabber:client'><query xmlns='jabber:iq:roster'/></iq>", x.to_s)
42
+ x = Iq.new_rosterget
43
+ assert_equal_xml("<iq type='get' xmlns='jabber:client'><query xmlns='jabber:iq:roster'/></iq>", x)
41
44
  end
42
45
 
43
46
  def test_rosterset
44
- x = Iq::new_rosterset
45
- assert_equal("<iq type='set' xmlns='jabber:client'><query xmlns='jabber:iq:roster'/></iq>", x.to_s)
47
+ x = Iq.new_rosterset
48
+ assert_equal_xml("<iq type='set' xmlns='jabber:client'><query xmlns='jabber:iq:roster'/></iq>", x)
46
49
  end
47
50
 
48
51
  def test_browseget
49
- x = Iq::new_browseget
50
- assert_equal("<iq type='get' xmlns='jabber:client'><query xmlns='jabber:iq:browse'/></iq>", x.to_s)
52
+ x = Iq.new_browseget
53
+ assert_equal_xml("<iq type='get' xmlns='jabber:client'><query xmlns='jabber:iq:browse'/></iq>", x)
51
54
  end
52
55
 
53
56
  def test_types
54
- iq = Iq::new
57
+ iq = Iq.new
55
58
  assert_equal(nil, iq.type)
56
59
  iq.type = :get
57
60
  assert_equal(:get, iq.type)
@@ -66,16 +69,16 @@ class IqTest < Test::Unit::TestCase
66
69
  end
67
70
 
68
71
  def test_query
69
- x = Iq::new(:set)
72
+ x = Iq.new(:set)
70
73
  assert_equal(nil, x.queryns)
71
- query = REXML::Element::new('query')
74
+ query = REXML::Element.new('query')
72
75
  x.add(query)
73
76
  assert_equal('jabber:client', x.queryns)
74
77
  query.add_namespace('jabber:iq:auth')
75
78
  assert_equal(query.to_s, x.query.to_s)
76
79
  assert_equal('jabber:iq:auth', x.queryns)
77
80
 
78
- query2 = REXML::Element::new('query')
81
+ query2 = REXML::Element.new('query')
79
82
  x.query = query2
80
83
  assert_equal('jabber:client', x.queryns)
81
84
  query2.add_namespace('jabber:iq:register')
@@ -83,24 +86,24 @@ class IqTest < Test::Unit::TestCase
83
86
  end
84
87
 
85
88
  def test_vcard
86
- x = Iq::new
89
+ x = Iq.new
87
90
  assert_equal(nil, x.vcard)
88
91
  x.add(vcard = REXML::Element.new('vCard'))
89
92
  assert_equal(vcard, x.vcard)
90
93
  end
91
94
 
92
95
  def test_error
93
- x = Iq::new(:set)
94
- e = REXML::Element::new('error')
96
+ x = Iq.new(:set)
97
+ e = REXML::Element.new('error')
95
98
  x.add(e)
96
99
  # test if, after an import, the error element is successfully changed
97
- # into an Error object.
98
- x2 = Iq::new.import(x)
99
- assert_equal(Error, x2.first_element('error').class)
100
+ # into an ErrorResponse object.
101
+ x2 = Iq.new.import(x)
102
+ assert_equal(ErrorResponse, x2.first_element('error').class)
100
103
  end
101
104
 
102
105
  def test_new_query
103
- x = Iq::new_query(:get, JID.new('a@b/c'))
106
+ x = Iq.new_query(:get, JID.new('a@b/c'))
104
107
  assert_equal(:get, x.type)
105
108
  assert_equal(nil, x.from)
106
109
  assert_equal(JID.new('a@b/c'), x.to)
@@ -9,13 +9,13 @@ include Jabber
9
9
 
10
10
  class IqQueryTest < Test::Unit::TestCase
11
11
  def test_create
12
- x = IqQuery::new()
12
+ x = IqQuery.new()
13
13
  assert_equal("query", x.name)
14
14
  assert_equal("<query/>", x.to_s)
15
15
  end
16
16
 
17
17
  def test_import
18
- q = IqQuery::new
18
+ q = IqQuery.new
19
19
  assert_equal(IqQuery, q.class)
20
20
 
21
21
  e = REXML::Element.new('query')
@@ -4,19 +4,21 @@ $:.unshift '../lib'
4
4
 
5
5
  require 'test/unit'
6
6
  require 'xmpp4r/jid'
7
+ require 'xmpp4r/xmppelement'
8
+ require 'xmpp4r/errors'
7
9
  include Jabber
8
10
 
9
11
  class JIDTest < Test::Unit::TestCase
10
12
  def test_create1
11
- j = JID::new('a', 'b', 'c')
13
+ j = JID.new('a', 'b', 'c')
12
14
  assert_equal('a', j.node)
13
15
  assert_equal('b', j.domain)
14
16
  assert_equal('c', j.resource)
15
17
  end
16
18
 
17
19
  def test_create2
18
- j = JID::new('a', 'b', 'c')
19
- j2 = JID::new(j)
20
+ j = JID.new('a', 'b', 'c')
21
+ j2 = JID.new(j)
20
22
  assert_equal('a', j2.node)
21
23
  assert_equal('b', j2.domain)
22
24
  assert_equal('c', j2.resource)
@@ -24,7 +26,7 @@ class JIDTest < Test::Unit::TestCase
24
26
  end
25
27
 
26
28
  def test_create3
27
- j = JID::new('a@b/c')
29
+ j = JID.new('a@b/c')
28
30
  assert_equal('a', j.node)
29
31
  assert_equal('b', j.domain)
30
32
  assert_equal('c', j.resource)
@@ -32,7 +34,7 @@ class JIDTest < Test::Unit::TestCase
32
34
  end
33
35
 
34
36
  def test_create4
35
- j = JID::new('a@b')
37
+ j = JID.new('a@b')
36
38
  assert_equal('a', j.node)
37
39
  assert_equal('b', j.domain)
38
40
  assert_equal(nil, j.resource)
@@ -40,7 +42,7 @@ class JIDTest < Test::Unit::TestCase
40
42
  end
41
43
 
42
44
  def test_create5
43
- j = JID::new
45
+ j = JID.new
44
46
  assert_equal(nil, j.node)
45
47
  assert_equal(nil, j.domain)
46
48
  assert_equal(nil, j.resource)
@@ -48,7 +50,7 @@ class JIDTest < Test::Unit::TestCase
48
50
  end
49
51
 
50
52
  def test_create6
51
- j = JID::new('dom')
53
+ j = JID.new('dom')
52
54
  assert_equal(nil, j.node)
53
55
  assert_equal('dom', j.domain)
54
56
  assert_equal(nil, j.resource)
@@ -56,7 +58,7 @@ class JIDTest < Test::Unit::TestCase
56
58
  end
57
59
 
58
60
  def test_create7
59
- j = JID::new('dom/res')
61
+ j = JID.new('dom/res')
60
62
  assert_equal(nil, j.node)
61
63
  assert_equal('dom', j.domain)
62
64
  assert_equal('res', j.resource)
@@ -64,7 +66,7 @@ class JIDTest < Test::Unit::TestCase
64
66
  end
65
67
 
66
68
  def test_create8
67
- j = JID::new('dom/a@b')
69
+ j = JID.new('dom/a@b')
68
70
  assert_equal(nil, j.node)
69
71
  assert_equal('dom', j.domain)
70
72
  assert_equal('a@b', j.resource)
@@ -72,14 +74,14 @@ class JIDTest < Test::Unit::TestCase
72
74
  end
73
75
 
74
76
  def test_create9
75
- assert_nothing_raised { JID::new("#{'n'*1023}@#{'d'*1023}/#{'r'*1023}") }
76
- assert_raises(ArgumentError) { JID::new("#{'n'*1024}@#{'d'*1023}/#{'r'*1023}") }
77
- assert_raises(ArgumentError) { JID::new("#{'n'*1023}@#{'d'*1024}/#{'r'*1023}") }
78
- assert_raises(ArgumentError) { JID::new("#{'n'*1023}@#{'d'*1023}/#{'r'*1024}") }
77
+ assert_nothing_raised { JID.new("#{'n'*1023}@#{'d'*1023}/#{'r'*1023}") }
78
+ assert_raises(Jabber::ArgumentError) { JID.new("#{'n'*1024}@#{'d'*1023}/#{'r'*1023}") }
79
+ assert_raises(Jabber::ArgumentError) { JID.new("#{'n'*1023}@#{'d'*1024}/#{'r'*1023}") }
80
+ assert_raises(Jabber::ArgumentError) { JID.new("#{'n'*1023}@#{'d'*1023}/#{'r'*1024}") }
79
81
  end
80
82
 
81
83
  def test_create10
82
- j = JID::new('@b/c')
84
+ j = JID.new('@b/c')
83
85
  assert_equal('', j.node)
84
86
  assert_equal('b', j.domain)
85
87
  assert_equal('c', j.resource)
@@ -87,7 +89,7 @@ class JIDTest < Test::Unit::TestCase
87
89
  end
88
90
 
89
91
  def test_create11
90
- j = JID::new('@b')
92
+ j = JID.new('@b')
91
93
  assert_equal('', j.node)
92
94
  assert_equal('b', j.domain)
93
95
  assert_equal(nil, j.resource)
@@ -95,7 +97,7 @@ class JIDTest < Test::Unit::TestCase
95
97
  end
96
98
 
97
99
  def test_create12
98
- j = JID::new('@b/')
100
+ j = JID.new('@b/')
99
101
  assert_equal('', j.node)
100
102
  assert_equal('b', j.domain)
101
103
  assert_equal('', j.resource)
@@ -103,7 +105,7 @@ class JIDTest < Test::Unit::TestCase
103
105
  end
104
106
 
105
107
  def test_create13
106
- j = JID::new('a@b/')
108
+ j = JID.new('a@b/')
107
109
  assert_equal('a', j.node)
108
110
  assert_equal('b', j.domain)
109
111
  assert_equal('', j.resource)
@@ -111,7 +113,7 @@ class JIDTest < Test::Unit::TestCase
111
113
  end
112
114
 
113
115
  def test_create14
114
- j = JID::new('nOdE@dOmAiN/rEsOuRcE')
116
+ j = JID.new('nOdE@dOmAiN/rEsOuRcE')
115
117
  assert_equal('node', j.node)
116
118
  assert_equal('domain', j.domain)
117
119
  assert_equal('rEsOuRcE', j.resource)
@@ -119,44 +121,44 @@ class JIDTest < Test::Unit::TestCase
119
121
  end
120
122
 
121
123
  def test_tos
122
- assert_equal('', JID::new.to_s)
123
- assert_equal('domain.fr', JID::new('domain.fr').to_s)
124
- assert_equal('l@domain.fr', JID::new('l','domain.fr').to_s)
125
- assert_equal('l@domain.fr/res', JID::new('l','domain.fr','res').to_s)
126
- assert_equal('domain.fr/res', JID::new(nil,'domain.fr','res').to_s)
124
+ assert_equal('', JID.new.to_s)
125
+ assert_equal('domain.fr', JID.new('domain.fr').to_s)
126
+ assert_equal('l@domain.fr', JID.new('l','domain.fr').to_s)
127
+ assert_equal('l@domain.fr/res', JID.new('l','domain.fr','res').to_s)
128
+ assert_equal('domain.fr/res', JID.new(nil,'domain.fr','res').to_s)
127
129
  end
128
130
 
129
131
  def test_equal
130
- assert_equal(JID::new('domain.fr'), JID::new('domain.fr'))
131
- assert_equal(JID::new('domain.fr'), JID::new(nil, 'domain.fr'))
132
- assert_equal(JID::new('l@domain.fr'), JID::new('l@domain.fr'))
133
- assert_equal(JID::new('l@domain.fr'), JID::new('l', 'domain.fr'))
134
- assert_equal(JID::new('l@domain.fr/res'), JID::new('l@domain.fr/res'))
135
- assert_equal(JID::new('l@domain.fr/res'), JID::new('l', 'domain.fr', 'res'))
132
+ assert_equal(JID.new('domain.fr'), JID.new('domain.fr'))
133
+ assert_equal(JID.new('domain.fr'), JID.new(nil, 'domain.fr'))
134
+ assert_equal(JID.new('l@domain.fr'), JID.new('l@domain.fr'))
135
+ assert_equal(JID.new('l@domain.fr'), JID.new('l', 'domain.fr'))
136
+ assert_equal(JID.new('l@domain.fr/res'), JID.new('l@domain.fr/res'))
137
+ assert_equal(JID.new('l@domain.fr/res'), JID.new('l', 'domain.fr', 'res'))
136
138
  end
137
139
 
138
140
  def test_hash
139
141
  h = {}
140
- j = JID::new('l@domain.fr/res')
142
+ j = JID.new('l@domain.fr/res')
141
143
  h[j] = 'a'
142
- assert_equal(h[j], h[JID::new('l@domain.fr/res')])
144
+ assert_equal(h[j], h[JID.new('l@domain.fr/res')])
143
145
  end
144
146
 
145
147
  def test_strip
146
- assert_equal(JID::new('l@domain.fr'), JID::new('l@domain.fr/res').strip)
147
- assert_equal(JID::new('l@domain.fr'), JID::new('l@domain.fr').strip)
148
- assert_equal(JID::new('l@domain.fr'), JID::new('l@domain.fr/res').bare)
149
- jid = JID::new('l@domain.fr/res')
148
+ assert_equal(JID.new('l@domain.fr'), JID.new('l@domain.fr/res').strip)
149
+ assert_equal(JID.new('l@domain.fr'), JID.new('l@domain.fr').strip)
150
+ assert_equal(JID.new('l@domain.fr'), JID.new('l@domain.fr/res').bare)
151
+ jid = JID.new('l@domain.fr/res')
150
152
  jid.strip!
151
- assert_equal(JID::new('l@domain.fr'), jid)
153
+ assert_equal(JID.new('l@domain.fr'), jid)
152
154
 
153
- jid = JID::new('l@domain.fr/res')
155
+ jid = JID.new('l@domain.fr/res')
154
156
  jid.bare!
155
- assert_equal(JID::new('l@domain.fr'), jid)
157
+ assert_equal(JID.new('l@domain.fr'), jid)
156
158
  end
157
159
 
158
160
  def test_change1
159
- j = JID::new('a@b/c')
161
+ j = JID.new('a@b/c')
160
162
  j.node = 'd'
161
163
  assert_equal('d@b/c', j.to_s)
162
164
  j.domain = 'e'
@@ -166,14 +168,14 @@ class JIDTest < Test::Unit::TestCase
166
168
  end
167
169
 
168
170
  def test_escaping
169
- j = JID::new('user1@server1')
170
- j2 = JID::new(JID::escape(j), 'server2', 'res2')
171
+ j = JID.new('user1@server1')
172
+ j2 = JID.new(JID::escape(j), 'server2', 'res2')
171
173
  assert_equal('user1%server1@server2/res2', j2.to_s)
172
174
  end
173
175
 
174
176
  if defined?(libidnbug) # this crashes the interpreter
175
177
  def test_invalidnode
176
- # assert_raises(IDN::Stringprep::StringprepError) { JID::new('toto@a/a', 'server', 'res') }
178
+ # assert_raises(IDN::Stringprep::StringprepError) { JID.new('toto@a/a', 'server', 'res') }
177
179
  assert_raises(IDN::Stringprep::StringprepError) { IDN::Stringprep.nodeprep('toto@a/a') }
178
180
  end
179
181
  end
@@ -6,24 +6,25 @@ require 'test/unit'
6
6
  require 'socket'
7
7
  require 'xmpp4r/rexmladdons'
8
8
  require 'xmpp4r/message'
9
+ require 'xmpp4r/errors'
9
10
  include Jabber
10
11
 
11
12
  class MessageTest < Test::Unit::TestCase
12
13
  def test_create
13
- x = Message::new()
14
+ x = Message.new()
14
15
  assert_equal("message", x.name)
15
16
  assert_equal("jabber:client", x.namespace)
16
17
  assert_equal(nil, x.to)
17
18
  assert_equal(nil, x.body)
18
19
 
19
- x = Message::new("lucas@linux.ensimag.fr", "coucou")
20
+ x = Message.new("lucas@linux.ensimag.fr", "coucou")
20
21
  assert_equal("message", x.name)
21
22
  assert_equal("lucas@linux.ensimag.fr", x.to.to_s)
22
23
  assert_equal("coucou", x.body)
23
24
  end
24
25
 
25
26
  def test_import
26
- x = Message::new
27
+ x = Message.new
27
28
  assert_kind_of(REXML::Element, x.typed_add(REXML::Element.new('thread')))
28
29
  assert_kind_of(X, x.typed_add(REXML::Element.new('x')))
29
30
  assert_kind_of(X, x.x)
@@ -47,7 +48,7 @@ class MessageTest < Test::Unit::TestCase
47
48
  end
48
49
 
49
50
  def test_body
50
- x = Message::new()
51
+ x = Message.new()
51
52
  assert_equal(nil, x.body)
52
53
  assert_equal(x, x.set_body("trezrze ezfrezr ezr zer ezr ezrezrez ezr z"))
53
54
  assert_equal("trezrze ezfrezr ezr zer ezr ezrezrez ezr z", x.body)
@@ -56,7 +57,7 @@ class MessageTest < Test::Unit::TestCase
56
57
  end
57
58
 
58
59
  def test_subject
59
- x = Message::new
60
+ x = Message.new
60
61
  assert_equal(nil, x.subject)
61
62
  subject = REXML::Element.new('subject')
62
63
  subject.text = 'A'
@@ -70,7 +71,7 @@ class MessageTest < Test::Unit::TestCase
70
71
  end
71
72
 
72
73
  def test_thread
73
- x = Message::new
74
+ x = Message.new
74
75
  assert_equal(nil, x.thread)
75
76
  thread = REXML::Element.new('thread')
76
77
  thread.text = '123'
@@ -84,18 +85,18 @@ class MessageTest < Test::Unit::TestCase
84
85
  end
85
86
 
86
87
  def test_error
87
- x = Message::new()
88
+ x = Message.new()
88
89
  assert_equal(nil, x.error)
89
- e = REXML::Element::new('error')
90
+ e = REXML::Element.new('error')
90
91
  x.add(e)
91
92
  # test if, after an import, the error element is successfully changed
92
- # into an Error object.
93
- x2 = Message::new.import(x)
94
- assert_equal(Error, x2.first_element('error').class)
93
+ # into an ErrorResponse object.
94
+ x2 = Message.new.import(x)
95
+ assert_equal(ErrorResponse, x2.first_element('error').class)
95
96
  end
96
97
 
97
98
  def test_answer
98
- orig = Message::new
99
+ orig = Message.new
99
100
  orig.from = 'a@b'
100
101
  orig.to = 'b@a'
101
102
  orig.id = '123'
@@ -6,11 +6,12 @@ require 'test/unit'
6
6
  require 'socket'
7
7
  require 'xmpp4r/rexmladdons'
8
8
  require 'xmpp4r/presence'
9
+ require 'xmpp4r/errors'
9
10
  include Jabber
10
11
 
11
12
  class PresenceTest < Test::Unit::TestCase
12
13
  def test_create
13
- x = Presence::new()
14
+ x = Presence.new()
14
15
  assert_equal("presence", x.name)
15
16
  assert_equal("jabber:client", x.namespace)
16
17
  assert_equal(nil, x.to)
@@ -18,7 +19,7 @@ class PresenceTest < Test::Unit::TestCase
18
19
  assert_equal(nil, x.status)
19
20
  assert_equal(nil, x.priority)
20
21
 
21
- x = Presence::new(:away, "I am away", 23)
22
+ x = Presence.new(:away, "I am away", 23)
22
23
  assert_equal("presence", x.name)
23
24
  assert_equal(:away, x.show)
24
25
  assert_equal("away", x.show.to_s)
@@ -27,7 +28,7 @@ class PresenceTest < Test::Unit::TestCase
27
28
  end
28
29
 
29
30
  def test_show
30
- x = Presence::new()
31
+ x = Presence.new()
31
32
  assert_equal(nil, x.show)
32
33
  assert_raise(RuntimeError) { x.show = "a" }
33
34
  assert_equal(nil, x.show)
@@ -49,7 +50,7 @@ class PresenceTest < Test::Unit::TestCase
49
50
  end
50
51
 
51
52
  def test_status
52
- x = Presence::new()
53
+ x = Presence.new()
53
54
  assert_equal(nil, x.status)
54
55
  x.status = "b"
55
56
  assert_equal("b", x.status)
@@ -62,7 +63,7 @@ class PresenceTest < Test::Unit::TestCase
62
63
  end
63
64
 
64
65
  def test_priority
65
- x = Presence::new()
66
+ x = Presence.new()
66
67
  assert_equal(nil, x.priority)
67
68
  x.priority = 5
68
69
  assert_equal(5, x.priority)
@@ -75,7 +76,7 @@ class PresenceTest < Test::Unit::TestCase
75
76
  end
76
77
 
77
78
  def test_type
78
- x = Presence::new()
79
+ x = Presence.new()
79
80
  assert_equal(nil, x.type)
80
81
  x.type = :delete
81
82
  assert_equal(nil, x.type)
@@ -90,7 +91,7 @@ class PresenceTest < Test::Unit::TestCase
90
91
  end
91
92
 
92
93
  def test_chaining
93
- x = Presence::new()
94
+ x = Presence.new()
94
95
  x.set_show(:xa).set_status("Plundering the fridge.").set_priority(0)
95
96
  assert_equal(:xa, x.show)
96
97
  assert_equal("Plundering the fridge.", x.status)
@@ -98,17 +99,17 @@ class PresenceTest < Test::Unit::TestCase
98
99
  end
99
100
 
100
101
  def test_error
101
- x = Presence::new()
102
- e = REXML::Element::new('error')
102
+ x = Presence.new()
103
+ e = REXML::Element.new('error')
103
104
  x.add(e)
104
- x2 = Presence::new.import(x)
105
+ x2 = Presence.new.import(x)
105
106
  # test if, after an import, the error element is successfully changed
106
- # into an Error object.
107
- assert_equal(Error, x2.first_element('error').class)
107
+ # into an ErrorResponse object.
108
+ assert_equal(ErrorResponse, x2.first_element('error').class)
108
109
  end
109
110
 
110
111
  def test_sample
111
- x = Presence::new
112
+ x = Presence.new
112
113
  require 'rexml/document'
113
114
  d = REXML::Document.new("<presence from='astro@spaceboyz.net/versionbot' to='astro@spaceboyz.net/edgarr' xmlns='jabber:client'>\n <x from='astro@spaceboyz.net/versionbot' stamp='20050823T02:18:42' xmlns='jabber:x:delay'/><show>xa</show>\n <status>I am the evil fingerprinting robot</status>\n </presence>")
114
115
  x.import(d.root)
@@ -129,21 +130,21 @@ class PresenceTest < Test::Unit::TestCase
129
130
  end
130
131
 
131
132
  def test_compare_prio
132
- assert_equal(0, Presence::new(:chat, '', 5) <=> Presence::new(:chat, '', 5))
133
- assert_equal(-1, Presence::new(:chat, '', 4) <=> Presence::new(:chat, '', 5))
134
- assert_equal(1, Presence::new(:chat, '', 4) <=> Presence::new(:chat, '', 3))
135
- assert_equal(-1, Presence::new(:chat, '', nil) <=> Presence::new(:chat, '', 3))
136
- assert_equal(1, Presence::new(:chat, '', 10) <=> Presence::new(:chat, '', nil))
137
- assert_equal(0, Presence::new(:chat, '', nil) <=> Presence::new(:chat, '', nil))
133
+ assert_equal(0, Presence.new(:chat, '', 5) <=> Presence.new(:chat, '', 5))
134
+ assert_equal(-1, Presence.new(:chat, '', 4) <=> Presence.new(:chat, '', 5))
135
+ assert_equal(1, Presence.new(:chat, '', 4) <=> Presence.new(:chat, '', 3))
136
+ assert_equal(-1, Presence.new(:chat, '', nil) <=> Presence.new(:chat, '', 3))
137
+ assert_equal(1, Presence.new(:chat, '', 10) <=> Presence.new(:chat, '', nil))
138
+ assert_equal(0, Presence.new(:chat, '', nil) <=> Presence.new(:chat, '', nil))
138
139
  end
139
140
 
140
141
  def test_compare_interest
141
- unav = Presence::new.set_type(:unavailable)
142
+ unav = Presence.new.set_type(:unavailable)
142
143
  assert_equal(0, unav.cmp_interest(unav))
143
- assert_equal(1, unav.cmp_interest(Presence::new))
144
- assert_equal(-1, Presence::new.cmp_interest(unav))
145
- assert_equal(1, Presence::new(:chat).cmp_interest(Presence::new))
146
- assert_equal(-1, Presence::new(:away).cmp_interest(Presence::new(:dnd)))
144
+ assert_equal(1, unav.cmp_interest(Presence.new))
145
+ assert_equal(-1, Presence.new.cmp_interest(unav))
146
+ assert_equal(1, Presence.new(:chat).cmp_interest(Presence.new))
147
+ assert_equal(-1, Presence.new(:away).cmp_interest(Presence.new(:dnd)))
147
148
  end
148
149
 
149
150
  end