xmpp4r 0.3.2 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/{ChangeLog → CHANGELOG} +33 -0
- data/LICENSE +9 -9
- data/README.rdoc +110 -0
- data/README_ruby19.txt +43 -0
- data/Rakefile +235 -74
- data/data/doc/xmpp4r/examples/advanced/adventure/README +0 -1
- data/data/doc/xmpp4r/examples/advanced/adventure/adventure.rb +1 -1
- data/data/doc/xmpp4r/examples/advanced/adventure/adventuremuc.rb +12 -12
- data/data/doc/xmpp4r/examples/advanced/adventure/world.rb +10 -11
- data/data/doc/xmpp4r/examples/advanced/fileserve.rb +11 -11
- data/data/doc/xmpp4r/examples/advanced/getonline.rb +7 -7
- data/data/doc/xmpp4r/examples/advanced/gtkmucclient.rb +3 -3
- data/data/doc/xmpp4r/examples/advanced/migrate.rb +21 -22
- data/data/doc/xmpp4r/examples/advanced/minimuc.rb +22 -22
- data/data/doc/xmpp4r/examples/advanced/pep-aggregator/index.xsl +235 -0
- data/data/doc/xmpp4r/examples/advanced/pep-aggregator/pep-aggregator.rb +147 -0
- data/data/doc/xmpp4r/examples/advanced/recvfile.rb +0 -1
- data/data/doc/xmpp4r/examples/advanced/rosterdiscovery.rb +2 -3
- data/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr.rb +3 -3
- data/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr_jabber.rb +10 -10
- data/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr_test.rb +2 -2
- data/data/doc/xmpp4r/examples/advanced/versionpoll.rb +12 -12
- data/data/doc/xmpp4r/examples/advanced/xmpping.rb +2 -3
- data/data/doc/xmpp4r/examples/basic/change_password.rb +3 -3
- data/data/doc/xmpp4r/examples/basic/client.rb +5 -3
- data/data/doc/xmpp4r/examples/basic/component.rb +1 -1
- data/data/doc/xmpp4r/examples/basic/{echo_threaded.rb → echo.rb} +8 -7
- data/data/doc/xmpp4r/examples/basic/jabbersend.rb +5 -5
- data/data/doc/xmpp4r/examples/basic/mass_sender.rb +11 -11
- data/data/doc/xmpp4r/examples/basic/muc_owner_config.rb +0 -1
- data/data/doc/xmpp4r/examples/basic/mucinfo.rb +3 -1
- data/data/doc/xmpp4r/examples/basic/mucsimplebot.rb +0 -1
- data/data/doc/xmpp4r/examples/basic/register.rb +21 -4
- data/data/doc/xmpp4r/examples/basic/roster.rb +7 -5
- data/data/doc/xmpp4r/examples/basic/rosterprint.rb +0 -0
- data/data/doc/xmpp4r/examples/basic/rosterrename.rb +2 -2
- data/data/doc/xmpp4r/examples/basic/rosterwatch.rb +6 -7
- data/data/doc/xmpp4r/examples/basic/send_vcard.rb +3 -4
- data/data/doc/xmpp4r/examples/basic/tune_client.rb +56 -0
- data/data/doc/xmpp4r/examples/basic/tune_server.rb +58 -0
- data/data/doc/xmpp4r/examples/basic/versionbot.rb +1 -1
- data/lib/xmpp4r.rb +4 -4
- data/lib/xmpp4r/base64.rb +32 -0
- data/lib/xmpp4r/bytestreams/helper/filetransfer.rb +10 -11
- data/lib/xmpp4r/bytestreams/helper/ibb/base.rb +6 -8
- data/lib/xmpp4r/bytestreams/helper/ibb/initiator.rb +3 -6
- data/lib/xmpp4r/bytestreams/helper/ibb/target.rb +0 -1
- data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb +8 -11
- data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/initiator.rb +4 -7
- data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/server.rb +7 -3
- data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/socks5.rb +10 -5
- data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb +14 -4
- data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb.orig +62 -0
- data/lib/xmpp4r/bytestreams/iq/bytestreams.rb +0 -1
- data/lib/xmpp4r/callbacks.rb +5 -5
- data/lib/xmpp4r/caps.rb +1 -0
- data/lib/xmpp4r/caps/c.rb +53 -0
- data/lib/xmpp4r/caps/helper/generator.rb +160 -0
- data/lib/xmpp4r/caps/helper/helper.rb +87 -0
- data/lib/xmpp4r/client.rb +111 -40
- data/lib/xmpp4r/command/iq/command.rb +1 -1
- data/lib/xmpp4r/component.rb +8 -8
- data/lib/xmpp4r/connection.rb +25 -9
- data/lib/xmpp4r/dataforms/x/data.rb +17 -5
- data/lib/xmpp4r/debuglog.rb +13 -5
- data/lib/xmpp4r/delay/x/delay.rb +1 -1
- data/lib/xmpp4r/discovery.rb +3 -2
- data/lib/xmpp4r/discovery/helper/responder.rb +165 -0
- data/lib/xmpp4r/discovery/iq/discoinfo.rb +11 -12
- data/lib/xmpp4r/discovery/iq/discoitems.rb +12 -4
- data/lib/xmpp4r/{error.rb → errors.rb} +66 -10
- data/lib/xmpp4r/framework/base.rb +55 -0
- data/lib/xmpp4r/framework/bot.rb +148 -0
- data/lib/xmpp4r/httpbinding/client.rb +1 -1
- data/lib/xmpp4r/idgenerator.rb +1 -1
- data/lib/xmpp4r/iq.rb +34 -23
- data/lib/xmpp4r/jid.rb +2 -2
- data/lib/xmpp4r/message.rb +1 -1
- data/lib/xmpp4r/muc.rb +2 -0
- data/lib/xmpp4r/muc/helper/mucbrowser.rb +4 -19
- data/lib/xmpp4r/muc/helper/mucclient.rb +54 -23
- data/lib/xmpp4r/muc/helper/simplemucclient.rb +107 -1
- data/lib/xmpp4r/muc/iq/mucadmin.rb +23 -0
- data/lib/xmpp4r/muc/iq/mucadminitem.rb +20 -0
- data/lib/xmpp4r/muc/iq/mucowner.rb +5 -1
- data/lib/xmpp4r/muc/item.rb +143 -0
- data/lib/xmpp4r/muc/x/mucuserinvite.rb +2 -2
- data/lib/xmpp4r/muc/x/mucuseritem.rb +3 -117
- data/lib/xmpp4r/presence.rb +2 -1
- data/lib/xmpp4r/pubsub.rb +7 -0
- data/lib/xmpp4r/pubsub/children/configuration.rb +86 -0
- data/lib/xmpp4r/pubsub/{stanzas → children}/event.rb +13 -13
- data/lib/xmpp4r/pubsub/{stanzas → children}/item.rb +9 -1
- data/lib/xmpp4r/pubsub/{stanzas → children}/items.rb +10 -1
- data/lib/xmpp4r/pubsub/children/node_config.rb +48 -0
- data/lib/xmpp4r/pubsub/children/publish.rb +24 -0
- data/lib/xmpp4r/pubsub/{stanzas → children}/subscription.rb +16 -12
- data/lib/xmpp4r/pubsub/children/subscription_config.rb +67 -0
- data/lib/xmpp4r/pubsub/children/unsubscribe.rb +48 -0
- data/lib/xmpp4r/pubsub/helper/nodebrowser.rb +49 -93
- data/lib/xmpp4r/pubsub/helper/nodehelper.rb +39 -36
- data/lib/xmpp4r/pubsub/helper/servicehelper.rb +253 -162
- data/lib/xmpp4r/pubsub/iq/pubsub.rb +1 -1
- data/lib/xmpp4r/rexmladdons.rb +56 -28
- data/lib/xmpp4r/roster.rb +0 -1
- data/lib/xmpp4r/roster/helper/roster.rb +26 -15
- data/lib/xmpp4r/roster/iq/roster.rb +19 -19
- data/lib/xmpp4r/roster/x/roster.rb +10 -10
- data/lib/xmpp4r/rpc/helper/client.rb +17 -8
- data/lib/xmpp4r/rpc/helper/server.rb +1 -2
- data/lib/xmpp4r/rpc/helper/xmlrpcaddons.rb +14 -4
- data/lib/xmpp4r/rpc/iq/rpc.rb +0 -1
- data/lib/xmpp4r/sasl.rb +27 -6
- data/lib/xmpp4r/stream.rb +39 -44
- data/lib/xmpp4r/streamparser.rb +4 -4
- data/lib/xmpp4r/tune.rb +2 -0
- data/lib/xmpp4r/tune/helper/helper.rb +58 -0
- data/lib/xmpp4r/tune/tune.rb +113 -0
- data/lib/xmpp4r/vcard.rb +0 -1
- data/lib/xmpp4r/vcard/helper/vcard.rb +1 -3
- data/lib/xmpp4r/vcard/iq/vcard.rb +14 -0
- data/lib/xmpp4r/version/iq/version.rb +0 -1
- data/lib/xmpp4r/x.rb +1 -1
- data/lib/xmpp4r/xhtml.rb +1 -0
- data/lib/xmpp4r/xhtml/html.rb +115 -0
- data/lib/xmpp4r/xmpp4r.rb +7 -5
- data/lib/xmpp4r/xmppelement.rb +21 -5
- data/lib/xmpp4r/xmppstanza.rb +6 -6
- data/setup.rb +4 -4
- data/test/bytestreams/tc_ibb.rb +2 -2
- data/test/bytestreams/tc_socks5bytestreams.rb +12 -2
- data/test/caps/tc_helper.rb +156 -0
- data/test/dataforms/tc_data.rb +0 -0
- data/test/delay/tc_xdelay.rb +2 -2
- data/test/discovery/tc_responder.rb +91 -0
- data/test/lib/assert_equal_xml.rb +14 -0
- data/test/lib/clienttester.rb +31 -24
- data/test/muc/tc_muc_mucclient.rb +249 -13
- data/test/muc/tc_muc_simplemucclient.rb +41 -2
- data/test/muc/tc_mucowner.rb +0 -0
- data/test/pubsub/tc_helper.rb +486 -51
- data/test/pubsub/tc_nodeconfig.rb +54 -0
- data/test/pubsub/tc_subscriptionconfig.rb +41 -0
- data/test/roster/tc_helper.rb +6 -7
- data/test/roster/tc_iqqueryroster.rb +16 -16
- data/test/roster/tc_xroster.rb +1 -1
- data/test/rpc/tc_helper.rb +15 -3
- data/test/tc_callbacks.rb +7 -7
- data/test/tc_class_names.rb +15 -6
- data/test/tc_client.rb +3 -3
- data/test/{tc_error.rb → tc_errors.rb} +54 -12
- data/test/tc_idgenerator.rb +0 -0
- data/test/tc_iq.rb +32 -29
- data/test/tc_iqquery.rb +2 -2
- data/test/tc_jid.rb +44 -42
- data/test/tc_message.rb +13 -12
- data/test/tc_presence.rb +25 -24
- data/test/tc_rexml.rb +81 -2
- data/test/tc_stream.rb +15 -13
- data/test/tc_streamComponent.rb +6 -5
- data/test/tc_streamError.rb +21 -15
- data/test/tc_streamSend.rb +9 -9
- data/test/tc_streamparser.rb +112 -0
- data/test/tc_xmppstanza.rb +19 -9
- data/test/ts_xmpp4r.rb +10 -1
- data/test/tune/tc_helper_recv.rb +84 -0
- data/test/tune/tc_helper_send.rb +74 -0
- data/test/tune/tc_tune.rb +79 -0
- data/test/vcard/tc_helper.rb +2 -2
- data/test/vcard/tc_iqvcard.rb +13 -3
- data/test/version/tc_helper.rb +2 -2
- data/test/version/tc_iqqueryversion.rb +10 -10
- data/test/xhtml/tc_html.rb +41 -0
- data/tools/gen_requires.bash +29 -8
- data/tools/xmpp4r-gemspec-test.rb +11 -0
- data/xmpp4r.gemspec +291 -0
- metadata +277 -218
- data/README +0 -28
- data/UPDATING +0 -40
- data/data/doc/xmpp4r/examples/buggy/jabber2jabber/jabber2jabber.rb +0 -18
- data/data/doc/xmpp4r/examples/buggy/miniedgarr_cgi.rb +0 -192
- data/data/doc/xmpp4r/examples/buggy/miniedgarr_watch.rb +0 -82
- data/lib/xmpp4r/authenticationfailure.rb +0 -13
- data/lib/xmpp4r/errorexception.rb +0 -32
- data/tools/doctoweb.bash +0 -30
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift File::dirname(__FILE__) + '/../../lib'
|
4
|
+
|
5
|
+
require 'test/unit'
|
6
|
+
require File::dirname(__FILE__) + '/../lib/clienttester'
|
7
|
+
|
8
|
+
require 'xmpp4r'
|
9
|
+
require 'xmpp4r/pubsub/children/node_config'
|
10
|
+
require 'xmpp4r/dataforms'
|
11
|
+
include Jabber
|
12
|
+
|
13
|
+
# Jabber.debug = true
|
14
|
+
|
15
|
+
class PubSub::NodeConfigTest < Test::Unit::TestCase
|
16
|
+
include ClientTester
|
17
|
+
|
18
|
+
def test_create()
|
19
|
+
config = PubSub::NodeConfig.new()
|
20
|
+
assert_nil(config.form)
|
21
|
+
assert_nil(config.node)
|
22
|
+
assert_equal({}, config.options)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_create_with_options
|
26
|
+
options = {'pubsub#access_model'=>'open'}
|
27
|
+
|
28
|
+
config = PubSub::NodeConfig.new(nil, options)
|
29
|
+
assert_kind_of(Jabber::Dataforms::XData, config.form)
|
30
|
+
assert_equal(options, config.options)
|
31
|
+
assert_equal(:submit, config.form.type)
|
32
|
+
assert_equal('http://jabber.org/protocol/pubsub#node_config', config.form.field('FORM_TYPE').values.first)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_create_with_options_and_node
|
36
|
+
node = 'mynode'
|
37
|
+
options = {'pubsub#access_model'=>'open'}
|
38
|
+
|
39
|
+
config = PubSub::NodeConfig.new(node, options)
|
40
|
+
assert_equal(node, config.node)
|
41
|
+
assert_kind_of(Jabber::Dataforms::XData, config.form)
|
42
|
+
assert_equal(options, config.options)
|
43
|
+
assert_equal(:submit, config.form.type)
|
44
|
+
assert_equal('http://jabber.org/protocol/pubsub#node_config', config.form.field('FORM_TYPE').values.first)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_set_options
|
48
|
+
options = {'pubsub#access_model'=>'open'}
|
49
|
+
config = PubSub::NodeConfig.new()
|
50
|
+
config.options = options
|
51
|
+
assert_kind_of(Jabber::Dataforms::XData, config.form)
|
52
|
+
assert_equal(options, config.options)
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift File::dirname(__FILE__) + '/../../lib'
|
4
|
+
|
5
|
+
require 'test/unit'
|
6
|
+
require File::dirname(__FILE__) + '/../lib/clienttester'
|
7
|
+
|
8
|
+
require 'xmpp4r'
|
9
|
+
require 'xmpp4r/pubsub/children/subscription_config'
|
10
|
+
require 'xmpp4r/dataforms'
|
11
|
+
include Jabber
|
12
|
+
|
13
|
+
# Jabber.debug = true
|
14
|
+
|
15
|
+
class PubSub::SubscriptionConfigTest < Test::Unit::TestCase
|
16
|
+
include ClientTester
|
17
|
+
|
18
|
+
def test_create()
|
19
|
+
config = PubSub::SubscriptionConfig.new()
|
20
|
+
assert_nil(config.form)
|
21
|
+
assert_nil(config.node)
|
22
|
+
assert_equal({}, config.options)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_create_with_options
|
26
|
+
node = 'mynode'
|
27
|
+
jid = 'test@test.com'
|
28
|
+
options = {'pubsub#access_model'=>'open'}
|
29
|
+
subid = '004-yyy'
|
30
|
+
|
31
|
+
config = PubSub::SubscriptionConfig.new(node, jid, options, subid)
|
32
|
+
assert_equal(node, config.node)
|
33
|
+
assert_equal(subid, config.subid)
|
34
|
+
assert_kind_of(Jabber::JID, config.jid)
|
35
|
+
assert_equal(Jabber::JID.new(jid), config.jid)
|
36
|
+
assert_kind_of(Jabber::Dataforms::XData, config.form)
|
37
|
+
assert_equal(options, config.options)
|
38
|
+
assert_equal(:submit, config.form.type)
|
39
|
+
assert_equal('http://jabber.org/protocol/pubsub#subscribe_options', config.form.field('FORM_TYPE').values.first)
|
40
|
+
end
|
41
|
+
end
|
data/test/roster/tc_helper.rb
CHANGED
@@ -31,7 +31,7 @@ class Roster::HelperTest < Test::Unit::TestCase
|
|
31
31
|
}
|
32
32
|
|
33
33
|
query_waiter = Semaphore.new
|
34
|
-
h = Roster::Helper
|
34
|
+
h = Roster::Helper.new(@client)
|
35
35
|
h.add_query_callback { |iq|
|
36
36
|
query_waiter.run
|
37
37
|
}
|
@@ -74,7 +74,7 @@ class Roster::HelperTest < Test::Unit::TestCase
|
|
74
74
|
}
|
75
75
|
|
76
76
|
query_waiter = Semaphore.new
|
77
|
-
h = Roster::Helper
|
77
|
+
h = Roster::Helper.new(@client)
|
78
78
|
h.add_query_callback { |iq| query_waiter.run }
|
79
79
|
wait_state
|
80
80
|
query_waiter.wait
|
@@ -142,7 +142,7 @@ class Roster::HelperTest < Test::Unit::TestCase
|
|
142
142
|
|
143
143
|
query_waiter = Semaphore.new
|
144
144
|
presence_waiter = Semaphore.new
|
145
|
-
h = Roster::Helper
|
145
|
+
h = Roster::Helper.new(@client)
|
146
146
|
h.add_query_callback { |iq|
|
147
147
|
query_waiter.run
|
148
148
|
}
|
@@ -289,7 +289,7 @@ class Roster::HelperTest < Test::Unit::TestCase
|
|
289
289
|
}
|
290
290
|
|
291
291
|
query_waiter = Semaphore.new
|
292
|
-
h = Roster::Helper
|
292
|
+
h = Roster::Helper.new(@client)
|
293
293
|
h.add_query_callback { |iq| query_waiter.run }
|
294
294
|
wait_state
|
295
295
|
query_waiter.wait
|
@@ -326,7 +326,7 @@ class Roster::HelperTest < Test::Unit::TestCase
|
|
326
326
|
}
|
327
327
|
|
328
328
|
query_waiter = Semaphore.new
|
329
|
-
h = Roster::Helper
|
329
|
+
h = Roster::Helper.new(@client)
|
330
330
|
h.add_query_callback { |iq| query_waiter.run }
|
331
331
|
wait_state
|
332
332
|
query_waiter.wait
|
@@ -369,7 +369,7 @@ class Roster::HelperTest < Test::Unit::TestCase
|
|
369
369
|
}
|
370
370
|
|
371
371
|
query_waiter = Semaphore.new
|
372
|
-
h = Roster::Helper
|
372
|
+
h = Roster::Helper.new(@client)
|
373
373
|
h.add_query_callback { |iq| query_waiter.run }
|
374
374
|
wait_state
|
375
375
|
query_waiter.wait
|
@@ -512,4 +512,3 @@ class Roster::HelperTest < Test::Unit::TestCase
|
|
512
512
|
assert_nil(update_args[1])
|
513
513
|
end
|
514
514
|
end
|
515
|
-
|
@@ -11,7 +11,7 @@ include Jabber
|
|
11
11
|
|
12
12
|
class Roster::IqQueryRosterTest < Test::Unit::TestCase
|
13
13
|
def test_create
|
14
|
-
r = Roster::IqQueryRoster
|
14
|
+
r = Roster::IqQueryRoster.new
|
15
15
|
assert_equal('jabber:iq:roster', r.namespace)
|
16
16
|
assert_equal(r.to_a.size, 0)
|
17
17
|
assert_equal(r.to_a, [])
|
@@ -19,16 +19,16 @@ class Roster::IqQueryRosterTest < Test::Unit::TestCase
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def test_import
|
22
|
-
iq = Iq
|
23
|
-
q = REXML::Element
|
22
|
+
iq = Iq.new
|
23
|
+
q = REXML::Element.new('query')
|
24
24
|
q.add_namespace('jabber:iq:roster')
|
25
25
|
iq.add(q)
|
26
|
-
iq2 = Iq
|
26
|
+
iq2 = Iq.new.import(iq)
|
27
27
|
assert_equal(Roster::IqQueryRoster, iq2.query.class)
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_answer
|
31
|
-
iq = Iq
|
31
|
+
iq = Iq.new_rosterget
|
32
32
|
assert_equal(:get, iq.type)
|
33
33
|
assert_nil(iq.to)
|
34
34
|
assert_equal('jabber:client', iq.namespace)
|
@@ -59,7 +59,7 @@ class Roster::IqQueryRosterTest < Test::Unit::TestCase
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def test_items
|
62
|
-
r = Roster::IqQueryRoster
|
62
|
+
r = Roster::IqQueryRoster.new
|
63
63
|
r.add(Roster::RosterItem.new)
|
64
64
|
r.add(Roster::RosterItem.new(JID.new('a@b/d'), 'ABC', :none, :subscribe)).groups = ['a']
|
65
65
|
itemstr = "<item jid='astro@spaceboyz.net' name='Astro' subscribtion='both'>" \
|
@@ -88,10 +88,10 @@ class Roster::IqQueryRosterTest < Test::Unit::TestCase
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def test_dupitems
|
91
|
-
r = Roster::IqQueryRoster
|
92
|
-
jid = JID
|
93
|
-
jid2 = JID
|
94
|
-
ri = Roster::RosterItem
|
91
|
+
r = Roster::IqQueryRoster.new
|
92
|
+
jid = JID.new('a@b')
|
93
|
+
jid2 = JID.new('c@d')
|
94
|
+
ri = Roster::RosterItem.new(jid, 'ab')
|
95
95
|
r.add(ri)
|
96
96
|
assert_equal('ab', ri.iname)
|
97
97
|
assert_equal('ab', r[jid].iname)
|
@@ -121,13 +121,13 @@ end
|
|
121
121
|
|
122
122
|
class Roster::RosterItemTest < Test::Unit::TestCase
|
123
123
|
def test_create
|
124
|
-
ri = Roster::RosterItem
|
124
|
+
ri = Roster::RosterItem.new
|
125
125
|
assert_equal(JID.new, ri.jid)
|
126
126
|
assert_equal(nil, ri.iname)
|
127
127
|
assert_equal(nil, ri.subscription)
|
128
128
|
assert_equal(nil, ri.ask)
|
129
129
|
|
130
|
-
ri = Roster::RosterItem
|
130
|
+
ri = Roster::RosterItem.new(JID.new('a@b/c'), 'xyz', :both, nil)
|
131
131
|
assert_equal(JID.new('a@b/c'), ri.jid)
|
132
132
|
assert_equal('xyz', ri.iname)
|
133
133
|
assert_equal(:both, ri.subscription)
|
@@ -135,11 +135,11 @@ class Roster::RosterItemTest < Test::Unit::TestCase
|
|
135
135
|
end
|
136
136
|
|
137
137
|
def test_modify
|
138
|
-
ri = Roster::RosterItem
|
138
|
+
ri = Roster::RosterItem.new(JID.new('a@b/c'), 'xyz', :both, :subscribe)
|
139
139
|
|
140
140
|
assert_equal(JID.new('a@b/c'), ri.jid)
|
141
141
|
ri.jid = nil
|
142
|
-
assert_equal(JID
|
142
|
+
assert_equal(JID.new, ri.jid)
|
143
143
|
|
144
144
|
assert_equal('xyz', ri.iname)
|
145
145
|
ri.iname = nil
|
@@ -155,7 +155,7 @@ class Roster::RosterItemTest < Test::Unit::TestCase
|
|
155
155
|
end
|
156
156
|
|
157
157
|
def test_groupdeletion
|
158
|
-
ri = Roster::RosterItem
|
158
|
+
ri = Roster::RosterItem.new
|
159
159
|
g1 = ['a', 'b', 'c']
|
160
160
|
ri.groups = g1
|
161
161
|
assert_equal(g1, ri.groups.sort)
|
@@ -165,7 +165,7 @@ class Roster::RosterItemTest < Test::Unit::TestCase
|
|
165
165
|
end
|
166
166
|
|
167
167
|
def test_dupgroups
|
168
|
-
ri = Roster::RosterItem
|
168
|
+
ri = Roster::RosterItem.new
|
169
169
|
mygroups = ['a', 'a', 'b']
|
170
170
|
ri.groups = mygroups
|
171
171
|
assert_equal(mygroups.uniq, ri.groups)
|
data/test/roster/tc_xroster.rb
CHANGED
@@ -33,7 +33,7 @@ class Roster::XRosterTest < Test::Unit::TestCase
|
|
33
33
|
assert_kind_of(Roster::XRosterItem, r.first_element('item'))
|
34
34
|
assert_kind_of(Roster::XRosterItem, r.typed_add(REXML::Element.new('item')))
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
def test_items
|
38
38
|
j1 = Roster::XRosterItem.new
|
39
39
|
assert_equal(JID.new(nil), j1.jid)
|
data/test/rpc/tc_helper.rb
CHANGED
@@ -15,6 +15,7 @@ class RPC::HelperTest < Test::Unit::TestCase
|
|
15
15
|
|
16
16
|
def give_client_jid!
|
17
17
|
class << @client
|
18
|
+
remove_method(:jid) # avoids warning
|
18
19
|
def jid; Jabber::JID.new('client@test.com/clienttester'); end
|
19
20
|
end
|
20
21
|
end
|
@@ -28,14 +29,26 @@ class RPC::HelperTest < Test::Unit::TestCase
|
|
28
29
|
assert_kind_of(RPC::Server, sv)
|
29
30
|
end
|
30
31
|
|
32
|
+
def echo(msg = nil)
|
33
|
+
msg
|
34
|
+
end
|
35
|
+
|
31
36
|
def test_simple
|
32
37
|
give_client_jid!
|
33
38
|
|
34
39
|
sv = RPC::Server.new(@server)
|
35
|
-
sv.add_handler("echo")
|
40
|
+
sv.add_handler("echo", &method(:echo))
|
36
41
|
|
37
42
|
cl = RPC::Client.new(@client, 'a@b/c')
|
38
|
-
|
43
|
+
assert_nothing_raised do
|
44
|
+
assert_equal('Test string', cl.call("echo", 'Test string'))
|
45
|
+
end
|
46
|
+
|
47
|
+
# exception during serialisation bug identified on xmpp4r-devel
|
48
|
+
# https://mail.gna.org/public/xmpp4r-devel/2008-05/msg00010.html
|
49
|
+
assert_raise XMLRPC::FaultException do
|
50
|
+
cl.call("echo")
|
51
|
+
end
|
39
52
|
end
|
40
53
|
|
41
54
|
def test_introspection
|
@@ -81,4 +94,3 @@ class RPC::HelperTest < Test::Unit::TestCase
|
|
81
94
|
assert(correct)
|
82
95
|
end
|
83
96
|
end
|
84
|
-
|
data/test/tc_callbacks.rb
CHANGED
@@ -9,7 +9,7 @@ include Jabber
|
|
9
9
|
class CallbacksTest < Test::Unit::TestCase
|
10
10
|
def test_test1
|
11
11
|
called = 0
|
12
|
-
cb = Callback
|
12
|
+
cb = Callback.new(5, "toto", Proc.new { called += 1 })
|
13
13
|
assert_equal(5, cb.priority)
|
14
14
|
assert_equal("toto", cb.ref)
|
15
15
|
cb.block.call
|
@@ -19,7 +19,7 @@ class CallbacksTest < Test::Unit::TestCase
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def test_callbacklist1
|
22
|
-
cbl = CallbackList
|
22
|
+
cbl = CallbackList.new
|
23
23
|
called1 = false
|
24
24
|
called2 = false
|
25
25
|
called3 = false
|
@@ -37,7 +37,7 @@ class CallbacksTest < Test::Unit::TestCase
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_callbacklist2
|
40
|
-
cbl = CallbackList
|
40
|
+
cbl = CallbackList.new
|
41
41
|
assert(0, cbl.length)
|
42
42
|
cbl.add(5, "ref1") { called1 = true }
|
43
43
|
assert(1, cbl.length)
|
@@ -50,7 +50,7 @@ class CallbacksTest < Test::Unit::TestCase
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def test_callbacklist4
|
53
|
-
cbl = CallbackList
|
53
|
+
cbl = CallbackList.new
|
54
54
|
cbl.add(5, "ref1") { false }
|
55
55
|
cbl.add(7, "ref1") { false }
|
56
56
|
o = "o"
|
@@ -58,7 +58,7 @@ class CallbacksTest < Test::Unit::TestCase
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def test_callbacklist5
|
61
|
-
cbl = CallbackList
|
61
|
+
cbl = CallbackList.new
|
62
62
|
cbl.add(5, "ref1") { true }
|
63
63
|
cbl.add(7, "ref1") { false }
|
64
64
|
o = "o"
|
@@ -66,7 +66,7 @@ class CallbacksTest < Test::Unit::TestCase
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def test_callbacklist6
|
69
|
-
cbl = CallbackList
|
69
|
+
cbl = CallbackList.new
|
70
70
|
ok = false
|
71
71
|
c = 'a'
|
72
72
|
d = 'b'
|
@@ -81,7 +81,7 @@ class CallbacksTest < Test::Unit::TestCase
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def test_callbacklist7
|
84
|
-
cbl = CallbackList
|
84
|
+
cbl = CallbackList.new
|
85
85
|
called1 = false
|
86
86
|
called2 = false
|
87
87
|
called3 = false
|
data/test/tc_class_names.rb
CHANGED
@@ -9,12 +9,15 @@ require 'xmpp4r'
|
|
9
9
|
class JIDTest < Test::Unit::TestCase
|
10
10
|
def test_base
|
11
11
|
assert_kind_of(Module, Jabber)
|
12
|
-
assert_kind_of(Class, Jabber::
|
12
|
+
assert_kind_of(Class, Jabber::JabberError)
|
13
|
+
assert_kind_of(Class, Jabber::ErrorResponse)
|
14
|
+
assert_kind_of(Class, Jabber::ClientAuthenticationFailure)
|
15
|
+
assert_kind_of(Class, Jabber::ComponentAuthenticationFailure)
|
13
16
|
assert_kind_of(Class, Jabber::Client)
|
14
17
|
assert_kind_of(Class, Jabber::Component)
|
15
18
|
assert_kind_of(Class, Jabber::Connection)
|
16
|
-
assert_kind_of(Class, Jabber::
|
17
|
-
assert_kind_of(Class, Jabber::
|
19
|
+
assert_kind_of(Class, Jabber::ErrorResponse)
|
20
|
+
assert_kind_of(Class, Jabber::ServerError)
|
18
21
|
assert_kind_of(Class, Jabber::IdGenerator)
|
19
22
|
assert_kind_of(Class, Jabber::Iq)
|
20
23
|
assert_kind_of(Class, Jabber::IqQuery)
|
@@ -57,6 +60,7 @@ class JIDTest < Test::Unit::TestCase
|
|
57
60
|
|
58
61
|
def test_bytestreams
|
59
62
|
require 'xmpp4r/bytestreams'
|
63
|
+
assert_kind_of(Class, Jabber::SOCKS5Error)
|
60
64
|
assert_kind_of(Module, Jabber::FileTransfer)
|
61
65
|
assert_kind_of(Module, Jabber::FileTransfer::TransferSource)
|
62
66
|
assert_kind_of(Class, Jabber::FileTransfer::FileSource)
|
@@ -77,10 +81,9 @@ class JIDTest < Test::Unit::TestCase
|
|
77
81
|
assert_kind_of(Class, Jabber::Bytestreams::SOCKS5Bytestreams)
|
78
82
|
assert_kind_of(Class, Jabber::Bytestreams::SOCKS5BytestreamsInitiator)
|
79
83
|
assert_kind_of(Class, Jabber::Bytestreams::SOCKS5BytestreamsTarget)
|
80
|
-
assert_kind_of(Class, Jabber::Bytestreams::SOCKS5Error)
|
81
84
|
assert_kind_of(Class, Jabber::Bytestreams::SOCKS5Socket)
|
82
85
|
end
|
83
|
-
|
86
|
+
|
84
87
|
def test_dataforms
|
85
88
|
require 'xmpp4r/dataforms'
|
86
89
|
assert_kind_of(Module, Jabber::Dataforms)
|
@@ -90,7 +93,7 @@ class JIDTest < Test::Unit::TestCase
|
|
90
93
|
assert_kind_of(Class, Jabber::Dataforms::XDataField)
|
91
94
|
assert_kind_of(Class, Jabber::Dataforms::XDataReported)
|
92
95
|
end
|
93
|
-
|
96
|
+
|
94
97
|
def test_delay
|
95
98
|
require 'xmpp4r/delay'
|
96
99
|
assert_kind_of(Module, Jabber::Delay)
|
@@ -134,4 +137,10 @@ class JIDTest < Test::Unit::TestCase
|
|
134
137
|
assert_kind_of(Class, Jabber::RPC::Server)
|
135
138
|
assert_kind_of(Class, Jabber::RPC::Client)
|
136
139
|
end
|
140
|
+
|
141
|
+
def test_pubsub
|
142
|
+
require 'xmpp4r/pubsub'
|
143
|
+
assert_kind_of(Module, Jabber::PubSub)
|
144
|
+
assert_kind_of(Class, Jabber::PubSub::ServiceHelper)
|
145
|
+
end
|
137
146
|
end
|
data/test/tc_client.rb
CHANGED
@@ -9,7 +9,7 @@ include Jabber
|
|
9
9
|
class ClientTest < Test::Unit::TestCase
|
10
10
|
def test_client1
|
11
11
|
=begin
|
12
|
-
c = Client
|
12
|
+
c = Client.new(JID.new('client1@localhost/res'))
|
13
13
|
assert_nothing_raised("Couldn't connect") {
|
14
14
|
c.connect
|
15
15
|
}
|
@@ -20,10 +20,10 @@ class ClientTest < Test::Unit::TestCase
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def test_jid_is_jid
|
23
|
-
c1 = Client
|
23
|
+
c1 = Client.new(JID.new('user@host/resource'))
|
24
24
|
assert_kind_of(JID, c1.jid)
|
25
25
|
assert_equal('user@host/resource', c1.jid.to_s)
|
26
|
-
c2 = Client
|
26
|
+
c2 = Client.new('user@host/resource')
|
27
27
|
assert_kind_of(JID, c2.jid)
|
28
28
|
assert_equal('user@host/resource', c2.jid.to_s)
|
29
29
|
end
|
@@ -5,13 +5,55 @@ $:.unshift '../lib'
|
|
5
5
|
require 'test/unit'
|
6
6
|
require 'xmpp4r'
|
7
7
|
require 'xmpp4r/rexmladdons'
|
8
|
-
require 'xmpp4r/error'
|
9
8
|
require 'xmpp4r/message'
|
10
9
|
include Jabber
|
11
10
|
|
11
|
+
class ServerErrorTest < Test::Unit::TestCase
|
12
|
+
|
13
|
+
def test_create_with_empty_error
|
14
|
+
e = ErrorResponse.new()
|
15
|
+
ee = ServerError.new(e)
|
16
|
+
assert_equal(nil, e.error)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_create_with_error_code
|
20
|
+
e = ErrorResponse.new('payment-required')
|
21
|
+
ee = ServerError.new(e)
|
22
|
+
assert_equal("payment-required: ", ee.to_s)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_create_invalid
|
26
|
+
assert_raise(Jabber::ArgumentError) {
|
27
|
+
e = ErrorResponse.new('invalid error')
|
28
|
+
ee = ServerError.new(e)
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_to_s_with_error_code_but_no_text
|
33
|
+
e = ErrorResponse.new('payment-required')
|
34
|
+
ee = ServerError.new(e)
|
35
|
+
assert_equal("payment-required: ", ee.to_s)
|
36
|
+
assert_equal('payment-required', e.error)
|
37
|
+
assert_equal(402, ee.error.code)
|
38
|
+
assert_equal(:auth, ee.error.type)
|
39
|
+
assert_equal(nil, ee.error.text)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_to_s_with_error_code_and_text
|
43
|
+
e = ErrorResponse.new('payment-required', 'cuz you are a deadbeat.')
|
44
|
+
ee = ServerError.new(e)
|
45
|
+
assert_equal("payment-required: cuz you are a deadbeat.", ee.to_s)
|
46
|
+
assert_equal('payment-required', e.error)
|
47
|
+
assert_equal(402, ee.error.code)
|
48
|
+
assert_equal(:auth, ee.error.type)
|
49
|
+
assert_equal("cuz you are a deadbeat.", ee.error.text)
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
12
54
|
class ErrorTest < Test::Unit::TestCase
|
13
55
|
def test_create
|
14
|
-
e =
|
56
|
+
e = ErrorResponse.new
|
15
57
|
assert_equal(nil, e.error)
|
16
58
|
assert_equal(nil, e.code)
|
17
59
|
assert_equal(nil, e.type)
|
@@ -19,7 +61,7 @@ class ErrorTest < Test::Unit::TestCase
|
|
19
61
|
end
|
20
62
|
|
21
63
|
def test_create2
|
22
|
-
e =
|
64
|
+
e = ErrorResponse.new('payment-required')
|
23
65
|
assert_equal('payment-required', e.error)
|
24
66
|
assert_equal(402, e.code)
|
25
67
|
assert_equal(:auth, e.type)
|
@@ -27,7 +69,7 @@ class ErrorTest < Test::Unit::TestCase
|
|
27
69
|
end
|
28
70
|
|
29
71
|
def test_create3
|
30
|
-
e =
|
72
|
+
e = ErrorResponse.new('gone', 'User moved to afterlife.gov')
|
31
73
|
assert_equal('gone', e.error)
|
32
74
|
assert_equal(302, e.code)
|
33
75
|
assert_equal(:modify, e.type)
|
@@ -35,13 +77,13 @@ class ErrorTest < Test::Unit::TestCase
|
|
35
77
|
end
|
36
78
|
|
37
79
|
def test_create_invalid
|
38
|
-
assert_raise(
|
39
|
-
e =
|
80
|
+
assert_raise(Jabber::ArgumentError) {
|
81
|
+
e = ErrorResponse.new('invalid error')
|
40
82
|
}
|
41
83
|
end
|
42
84
|
|
43
85
|
def test_type
|
44
|
-
e =
|
86
|
+
e = ErrorResponse.new
|
45
87
|
assert_nil(e.type)
|
46
88
|
e.type = :auth
|
47
89
|
assert_equal(:auth, e.type)
|
@@ -58,7 +100,7 @@ class ErrorTest < Test::Unit::TestCase
|
|
58
100
|
end
|
59
101
|
|
60
102
|
def test_code
|
61
|
-
e =
|
103
|
+
e = ErrorResponse.new
|
62
104
|
assert_nil(e.code)
|
63
105
|
e.code = 404
|
64
106
|
assert_equal(404, e.code)
|
@@ -68,7 +110,7 @@ class ErrorTest < Test::Unit::TestCase
|
|
68
110
|
end
|
69
111
|
|
70
112
|
def test_error
|
71
|
-
e =
|
113
|
+
e = ErrorResponse.new
|
72
114
|
assert_nil(e.error)
|
73
115
|
e.error = 'gone'
|
74
116
|
assert_equal('gone', e.error)
|
@@ -80,13 +122,13 @@ class ErrorTest < Test::Unit::TestCase
|
|
80
122
|
def test_stanzas
|
81
123
|
m = Message.new
|
82
124
|
assert_equal(nil, m.error)
|
83
|
-
m.typed_add(
|
125
|
+
m.typed_add(ErrorResponse.new)
|
84
126
|
assert_equal('<error/>', m.error.to_s)
|
85
127
|
end
|
86
128
|
|
87
129
|
def test_sample_normal
|
88
130
|
src = '<error code="302" type="modify"><gone xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/><text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">...</text></error>'
|
89
|
-
e =
|
131
|
+
e = ErrorResponse.new.import(REXML::Document.new(src).root)
|
90
132
|
assert_equal(:modify, e.type)
|
91
133
|
assert_equal(302, e.code)
|
92
134
|
assert_equal('gone', e.error)
|
@@ -95,7 +137,7 @@ class ErrorTest < Test::Unit::TestCase
|
|
95
137
|
|
96
138
|
def test_sample_muc
|
97
139
|
src = '<error code="409">Please choose a different nickname.</error>'
|
98
|
-
e =
|
140
|
+
e = ErrorResponse.new.import(REXML::Document.new(src).root)
|
99
141
|
assert_equal(nil, e.type)
|
100
142
|
assert_equal(409, e.code)
|
101
143
|
assert_equal(nil, e.error)
|