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
data/test/tc_xmppstanza.rb
CHANGED
@@ -9,6 +9,7 @@ require 'xmpp4r/xmppstanza'
|
|
9
9
|
require 'xmpp4r/iq'
|
10
10
|
require 'xmpp4r/feature_negotiation'
|
11
11
|
require 'xmpp4r/dataforms'
|
12
|
+
require 'xmpp4r/errors'
|
12
13
|
include Jabber
|
13
14
|
|
14
15
|
class XMPPStanzaTest < Test::Unit::TestCase
|
@@ -24,7 +25,7 @@ class XMPPStanzaTest < Test::Unit::TestCase
|
|
24
25
|
end
|
25
26
|
|
26
27
|
def test_from
|
27
|
-
x = MyXMPPStanza
|
28
|
+
x = MyXMPPStanza.new
|
28
29
|
assert_equal(nil, x.from)
|
29
30
|
assert_equal(x, x.set_from("blop"))
|
30
31
|
assert_equal("blop", x.from.to_s)
|
@@ -33,7 +34,7 @@ class XMPPStanzaTest < Test::Unit::TestCase
|
|
33
34
|
end
|
34
35
|
|
35
36
|
def test_to
|
36
|
-
x = MyXMPPStanza
|
37
|
+
x = MyXMPPStanza.new
|
37
38
|
assert_equal(nil, x.to)
|
38
39
|
assert_equal(x, x.set_to("blop"))
|
39
40
|
assert_equal("blop", x.to.to_s)
|
@@ -42,7 +43,7 @@ class XMPPStanzaTest < Test::Unit::TestCase
|
|
42
43
|
end
|
43
44
|
|
44
45
|
def test_id
|
45
|
-
x = MyXMPPStanza
|
46
|
+
x = MyXMPPStanza.new
|
46
47
|
assert_equal(nil, x.id)
|
47
48
|
assert_equal(x, x.set_id("blop"))
|
48
49
|
assert_equal("blop", x.id)
|
@@ -51,7 +52,7 @@ class XMPPStanzaTest < Test::Unit::TestCase
|
|
51
52
|
end
|
52
53
|
|
53
54
|
def test_type
|
54
|
-
x = MyXMPPStanza
|
55
|
+
x = MyXMPPStanza.new
|
55
56
|
assert_equal(nil, x.type)
|
56
57
|
assert_equal(x, x.set_type("blop"))
|
57
58
|
assert_equal("blop", x.type)
|
@@ -60,7 +61,7 @@ class XMPPStanzaTest < Test::Unit::TestCase
|
|
60
61
|
end
|
61
62
|
|
62
63
|
def test_import
|
63
|
-
x = MyXMPPStanza
|
64
|
+
x = MyXMPPStanza.new
|
64
65
|
x.id = "heya"
|
65
66
|
q = x.add_element("query")
|
66
67
|
q.add_namespace("about:blank")
|
@@ -73,7 +74,7 @@ class XMPPStanzaTest < Test::Unit::TestCase
|
|
73
74
|
assert_raise(RuntimeError) { iq = Iq.import(x) }
|
74
75
|
x.name = 'iq'
|
75
76
|
iq = Iq.import(x)
|
76
|
-
|
77
|
+
|
77
78
|
assert_equal(x.id, iq.id)
|
78
79
|
assert_equal(q.to_s, iq.query.to_s)
|
79
80
|
assert_equal(x.to_s, iq.to_s)
|
@@ -90,16 +91,25 @@ class XMPPStanzaTest < Test::Unit::TestCase
|
|
90
91
|
assert_equal(field.type, feature2.x.fields.first.type)
|
91
92
|
end
|
92
93
|
|
94
|
+
def test_import_xml_entities
|
95
|
+
e = REXML::Element.new('e')
|
96
|
+
e.text = '&'
|
97
|
+
assert_equal('<e>&</e>', e.to_s)
|
98
|
+
|
99
|
+
e2 = REXML::Element.new('e').import(e)
|
100
|
+
assert_equal('<e>&</e>', e2.to_s)
|
101
|
+
end
|
102
|
+
|
93
103
|
def test_error
|
94
|
-
x = MyXMPPStanza
|
104
|
+
x = MyXMPPStanza.new
|
95
105
|
assert_equal(nil, x.error)
|
96
106
|
x.typed_add(REXML::Element.new('error'))
|
97
107
|
assert_equal('<error/>', x.error.to_s)
|
98
|
-
assert_equal(
|
108
|
+
assert_equal(ErrorResponse, x.error.class)
|
99
109
|
end
|
100
110
|
|
101
111
|
def test_clone_and_dup
|
102
|
-
x = MyXMPPStanza
|
112
|
+
x = MyXMPPStanza.new
|
103
113
|
x.attributes['xyz'] = '123'
|
104
114
|
x.text = 'abc'
|
105
115
|
|
data/test/ts_xmpp4r.rb
CHANGED
@@ -28,11 +28,20 @@ Find.find(File.dirname(__FILE__)) do |f|
|
|
28
28
|
elsif File::basename(f) =~ /^tc.*\.rb$/
|
29
29
|
tc_files << f
|
30
30
|
end
|
31
|
-
end
|
31
|
+
end
|
32
32
|
|
33
33
|
tc_subdirs.each do |dir|
|
34
34
|
Find.find(dir) do |f|
|
35
35
|
if File::file?(f) and File::basename(f) =~ /^tc.*\.rb$/
|
36
|
+
|
37
|
+
if (RUBY_VERSION.split('.').collect {|n| n.to_i} <=> [1,9,0]) >= 0
|
38
|
+
# TODO: at the moment, these two test cases have timing dependencies
|
39
|
+
# on threaded code. While they may pass with the green thread
|
40
|
+
# implementation in Ruby 1.8, they often fail with real threads.
|
41
|
+
next if f =~ /tc_helper.rb/
|
42
|
+
next if f =~ /tc_stream.rb/
|
43
|
+
end
|
44
|
+
|
36
45
|
tc_files << f
|
37
46
|
end
|
38
47
|
end
|
@@ -0,0 +1,84 @@
|
|
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/tune/helper/helper'
|
10
|
+
require 'xmpp4r/tune/tune'
|
11
|
+
include Jabber
|
12
|
+
|
13
|
+
#Jabber::debug=true
|
14
|
+
|
15
|
+
class UserTune::HelperTest < Test::Unit::TestCase
|
16
|
+
include ClientTester
|
17
|
+
|
18
|
+
##
|
19
|
+
# Test receiving 'now playing' notifications
|
20
|
+
#
|
21
|
+
# See http://www.xmpp.org/extensions/xep-0118.html#protocol-transport,
|
22
|
+
# example 1
|
23
|
+
def test_recv_now_playing
|
24
|
+
state { |presence|
|
25
|
+
send(deliver_usertune)
|
26
|
+
}
|
27
|
+
|
28
|
+
query_waiter = Semaphore.new
|
29
|
+
|
30
|
+
h = UserTune::Helper.new(@client, 'stpeter@jabber.org')
|
31
|
+
h.add_usertune_callback do |tune|
|
32
|
+
assert_kind_of Jabber::UserTune::Tune, tune
|
33
|
+
assert_equal true, tune.playing?
|
34
|
+
assert_equal 'Yes', tune.artist
|
35
|
+
assert_equal 686, tune.length
|
36
|
+
assert_equal 'Yessongs', tune.source
|
37
|
+
assert_equal 'Heart of the Sunrise', tune.title
|
38
|
+
assert_equal '3', tune.track
|
39
|
+
assert_equal 'http://www.yesworld.com/lyrics/Fragile.html#9',tune.uri
|
40
|
+
end
|
41
|
+
@client.add_message_callback do |m|
|
42
|
+
query_waiter.run
|
43
|
+
end
|
44
|
+
@client.send Jabber::Presence.new
|
45
|
+
wait_state
|
46
|
+
|
47
|
+
query_waiter.wait
|
48
|
+
end
|
49
|
+
|
50
|
+
# see example 2 from http://www.xmpp.org/extensions/xep-0118.html#protocol-transport
|
51
|
+
def deliver_usertune
|
52
|
+
"<message
|
53
|
+
from='stpeter@jabber.org'
|
54
|
+
to='maineboy@jabber.org'>
|
55
|
+
<event xmlns='http://jabber.org/protocol/pubsub#event'>
|
56
|
+
<items node='http://jabber.org/protocol/tune'>
|
57
|
+
<item id='bffe6584-0f9c-11dc-84ba-001143d5d5db'>
|
58
|
+
<tune xmlns='http://jabber.org/protocol/tune'>
|
59
|
+
<artist>Yes</artist>
|
60
|
+
<length>686</length>
|
61
|
+
<source>Yessongs</source>
|
62
|
+
<title>Heart of the Sunrise</title>
|
63
|
+
<track>3</track>
|
64
|
+
<uri>http://www.yesworld.com/lyrics/Fragile.html#9</uri>
|
65
|
+
</tune>
|
66
|
+
</item>
|
67
|
+
</items>
|
68
|
+
</event>
|
69
|
+
</message>"
|
70
|
+
end
|
71
|
+
|
72
|
+
# an example from the Wild
|
73
|
+
def psi_usertune
|
74
|
+
"<message from='admin@new-big-computer.local' to='matt@new-big-computer.local/trackbot' xmlns='jabber:client'><event xmlns='http://jabber.org/protocol/pubsub#event'><items node='http://jabber.org/protocol/tune'><item id='current'>
|
75
|
+
|
76
|
+
<tune xmlns='http://jabber.org/protocol/tune'>
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
<artist>Wes Montgomery</artist><title>Jingles</title><source>Bags Meets Wes</source><track>8</track><length>410</length></tune></item></items></event></message>"
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,74 @@
|
|
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/tune/helper/helper'
|
10
|
+
require 'xmpp4r/tune/tune'
|
11
|
+
include Jabber
|
12
|
+
|
13
|
+
#Jabber::debug=true
|
14
|
+
|
15
|
+
class UserTune::HelperTest < Test::Unit::TestCase
|
16
|
+
include ClientTester
|
17
|
+
|
18
|
+
##
|
19
|
+
# Test sending 'now playing' notifications
|
20
|
+
#
|
21
|
+
# See http://www.xmpp.org/extensions/xep-0118.html#protocol-transport,
|
22
|
+
# example 1
|
23
|
+
def test_send_now_playing
|
24
|
+
artist = 'Mike Flowers Pops'
|
25
|
+
title = 'Light My Fire'
|
26
|
+
tune_to_send = UserTune::Tune.new(artist, title)
|
27
|
+
|
28
|
+
h = UserTune::Helper.new(@client, nil)
|
29
|
+
assert_kind_of(UserTune::Helper, h)
|
30
|
+
|
31
|
+
state { |now_playing|
|
32
|
+
assert_kind_of(Jabber::Iq, now_playing)
|
33
|
+
assert_equal :set, now_playing.type
|
34
|
+
|
35
|
+
assert_kind_of(Jabber::PubSub::IqPubSub,now_playing.first_element('pubsub'))
|
36
|
+
assert_equal(Jabber::UserTune::NS_USERTUNE,now_playing.first_element('pubsub').first_element('publish').node)
|
37
|
+
|
38
|
+
tune=now_playing.first_element('pubsub').first_element('publish').first_element('item').first_element('tune')
|
39
|
+
assert_kind_of Jabber::UserTune::Tune,tune
|
40
|
+
assert_equal true, tune.playing?
|
41
|
+
assert_equal artist,tune.artist
|
42
|
+
assert_equal title,tune.title
|
43
|
+
assert_equal nil,tune.length
|
44
|
+
assert_equal nil,tune.track
|
45
|
+
assert_equal nil,tune.source
|
46
|
+
assert_equal nil,tune.uri
|
47
|
+
|
48
|
+
send("<iq type='result' id='#{now_playing.id}'/>")
|
49
|
+
}
|
50
|
+
h.now_playing(tune_to_send)
|
51
|
+
wait_state
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_send_stop_playing
|
55
|
+
h = UserTune::Helper.new(@client, nil)
|
56
|
+
|
57
|
+
state { |now_playing|
|
58
|
+
tune = now_playing.first_element('pubsub').first_element('publish').first_element('item').first_element('tune')
|
59
|
+
|
60
|
+
assert_kind_of Jabber::UserTune::Tune, tune
|
61
|
+
assert_equal false, tune.playing?
|
62
|
+
assert_equal nil, tune.artist
|
63
|
+
assert_equal nil, tune.title
|
64
|
+
assert_equal nil,tune.length
|
65
|
+
assert_equal nil,tune.track
|
66
|
+
assert_equal nil,tune.source
|
67
|
+
assert_equal nil,tune.uri
|
68
|
+
|
69
|
+
send("<iq type='result' id='#{now_playing.id}'/>")
|
70
|
+
}
|
71
|
+
h.stop_playing
|
72
|
+
wait_state
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift '../lib'
|
4
|
+
|
5
|
+
require 'test/unit'
|
6
|
+
require 'xmpp4r/tune/tune.rb'
|
7
|
+
|
8
|
+
class Jabber::UserTune::TuneTest < Test::Unit::TestCase
|
9
|
+
def test_create
|
10
|
+
artist='Mike Flowers Pops'
|
11
|
+
title='Light My Fire'
|
12
|
+
length=175
|
13
|
+
track='4'
|
14
|
+
source='A Groovy Place'
|
15
|
+
uri='http://musicbrainz.org/track/d44110e6-4b20-4d16-9e69-74bf0e4f7106.html'
|
16
|
+
rating=10
|
17
|
+
|
18
|
+
t=Jabber::UserTune::Tune.new(artist,title,length,track,source,uri,rating)
|
19
|
+
|
20
|
+
assert_kind_of Jabber::UserTune::Tune,t
|
21
|
+
assert_equal 7,t.elements.size
|
22
|
+
assert_equal true,t.playing?
|
23
|
+
assert_equal artist,t.artist
|
24
|
+
assert_equal track,t.track
|
25
|
+
assert_equal length,t.length
|
26
|
+
assert_equal track,t.track
|
27
|
+
assert_equal source,t.source
|
28
|
+
assert_equal uri,t.uri
|
29
|
+
assert_equal rating,t.rating
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_stop_playing
|
33
|
+
t=Jabber::UserTune::Tune.new
|
34
|
+
|
35
|
+
assert_kind_of Jabber::UserTune::Tune,t
|
36
|
+
assert_equal 0,t.elements.size
|
37
|
+
assert_equal false, t.playing?
|
38
|
+
assert_equal nil,t.artist
|
39
|
+
assert_equal nil,t.track
|
40
|
+
assert_equal nil,t.length
|
41
|
+
assert_equal nil,t.track
|
42
|
+
assert_equal nil,t.source
|
43
|
+
assert_equal nil,t.uri
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_rating_edgecases
|
47
|
+
assert_equal(0, Jabber::UserTune::Tune.new(artist,title,length,track,source,uri,-1.5).rating)
|
48
|
+
assert_equal(10, Jabber::UserTune::Tune.new(artist,title,length,track,source,uri,11.5).rating)
|
49
|
+
assert_equal(nil, Jabber::UserTune::Tune.new(artist,title,length,track,source,uri,'fantastic').rating)
|
50
|
+
end
|
51
|
+
|
52
|
+
def artist
|
53
|
+
'Mike Flowers Pops'
|
54
|
+
end
|
55
|
+
|
56
|
+
def title
|
57
|
+
'Light My Fire'
|
58
|
+
end
|
59
|
+
|
60
|
+
def length
|
61
|
+
175
|
62
|
+
end
|
63
|
+
|
64
|
+
def track
|
65
|
+
'4'
|
66
|
+
end
|
67
|
+
|
68
|
+
def source
|
69
|
+
'A Groovy Place'
|
70
|
+
end
|
71
|
+
|
72
|
+
def uri
|
73
|
+
'http://musicbrainz.org/track/d44110e6-4b20-4d16-9e69-74bf0e4f7106.html'
|
74
|
+
end
|
75
|
+
|
76
|
+
def rating
|
77
|
+
10
|
78
|
+
end
|
79
|
+
end
|
data/test/vcard/tc_helper.rb
CHANGED
@@ -13,13 +13,14 @@ class Vcard::HelperTest < Test::Unit::TestCase
|
|
13
13
|
include ClientTester
|
14
14
|
|
15
15
|
def test_create
|
16
|
-
h = Vcard::Helper
|
16
|
+
h = Vcard::Helper.new(@client)
|
17
17
|
assert_kind_of(Vcard::Helper, h)
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_callback
|
21
21
|
@server.on_exception{|*e| p e}
|
22
22
|
class << @client
|
23
|
+
remove_method(:jid)
|
23
24
|
def jid
|
24
25
|
JID.new('b@b.com/b')
|
25
26
|
end
|
@@ -46,4 +47,3 @@ class Vcard::HelperTest < Test::Unit::TestCase
|
|
46
47
|
assert_equal('====', res['PHOTO/BINVAL'])
|
47
48
|
end
|
48
49
|
end
|
49
|
-
|
data/test/vcard/tc_iqvcard.rb
CHANGED
@@ -27,9 +27,9 @@ class IqVcardTest < Test::Unit::TestCase
|
|
27
27
|
f.each { |s|
|
28
28
|
v[s.downcase] = s.upcase
|
29
29
|
}
|
30
|
-
|
30
|
+
|
31
31
|
assert_equal(f, v.fields.sort)
|
32
|
-
|
32
|
+
|
33
33
|
f.each { |s|
|
34
34
|
assert_equal(s.upcase, v[s.downcase])
|
35
35
|
assert_equal(nil, v[s.upcase])
|
@@ -41,7 +41,7 @@ class IqVcardTest < Test::Unit::TestCase
|
|
41
41
|
'FN' => 'John D. Random',
|
42
42
|
'PHOTO/TYPE' => 'image/png',
|
43
43
|
'PHOTO/BINVAL' => '===='})
|
44
|
-
|
44
|
+
|
45
45
|
assert_equal(['FN', 'PHOTO/BINVAL', 'PHOTO/TYPE'], v.fields.sort)
|
46
46
|
assert_equal('John D. Random', v['FN'])
|
47
47
|
assert_equal('image/png', v['PHOTO/TYPE'])
|
@@ -49,4 +49,14 @@ class IqVcardTest < Test::Unit::TestCase
|
|
49
49
|
assert_equal(nil, v['PHOTO'])
|
50
50
|
assert_equal(nil, v['NICKNAME'])
|
51
51
|
end
|
52
|
+
|
53
|
+
def test_photo_binval
|
54
|
+
v = Vcard::IqVcard.new({'PHOTO/BINVAL'=>"SGVsbG8gd29ybGQ=\n"})
|
55
|
+
assert_equal('Hello world', v.photo_binval)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_photo_binval_nil
|
59
|
+
v = Vcard::IqVcard.new({})
|
60
|
+
assert_nil(v.photo_binval)
|
61
|
+
end
|
52
62
|
end
|
data/test/version/tc_helper.rb
CHANGED
@@ -14,14 +14,14 @@ class Version::HelperTest < Test::Unit::TestCase
|
|
14
14
|
include ClientTester
|
15
15
|
|
16
16
|
def test_create
|
17
|
-
h = Version::Responder
|
17
|
+
h = Version::Responder.new(@client)
|
18
18
|
assert_kind_of(Version::Responder, h)
|
19
19
|
assert_respond_to(h, :add_version_callback)
|
20
20
|
end
|
21
21
|
|
22
22
|
def test_callback
|
23
23
|
# Prepare helper
|
24
|
-
h = Version::Responder
|
24
|
+
h = Version::Responder.new(@client)
|
25
25
|
|
26
26
|
calls = 0
|
27
27
|
h.add_version_callback { |iq,responder|
|
@@ -10,7 +10,7 @@ include Jabber
|
|
10
10
|
|
11
11
|
class Version::IqQueryVersionTest < Test::Unit::TestCase
|
12
12
|
def test_create_empty
|
13
|
-
x = Version::IqQueryVersion
|
13
|
+
x = Version::IqQueryVersion.new
|
14
14
|
assert_equal('jabber:iq:version', x.namespace)
|
15
15
|
assert_nil(x.iname)
|
16
16
|
assert_nil(x.version)
|
@@ -18,7 +18,7 @@ class Version::IqQueryVersionTest < Test::Unit::TestCase
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_create
|
21
|
-
x = Version::IqQueryVersion
|
21
|
+
x = Version::IqQueryVersion.new('my test', 'XP')
|
22
22
|
assert_equal('jabber:iq:version', x.namespace)
|
23
23
|
assert_equal('my test', x.iname)
|
24
24
|
assert_equal('XP', x.version)
|
@@ -26,7 +26,7 @@ class Version::IqQueryVersionTest < Test::Unit::TestCase
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_create_with_os
|
29
|
-
x = Version::IqQueryVersion
|
29
|
+
x = Version::IqQueryVersion.new('superbot', '1.0-final', 'FreeBSD 5.4-RELEASE-p4')
|
30
30
|
assert_equal('jabber:iq:version', x.namespace)
|
31
31
|
assert_equal('superbot', x.iname)
|
32
32
|
assert_equal('1.0-final', x.version)
|
@@ -34,23 +34,23 @@ class Version::IqQueryVersionTest < Test::Unit::TestCase
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_import1
|
37
|
-
iq = Iq
|
38
|
-
q = REXML::Element
|
37
|
+
iq = Iq.new
|
38
|
+
q = REXML::Element.new('query')
|
39
39
|
q.add_namespace('jabber:iq:version')
|
40
40
|
iq.add(q)
|
41
|
-
iq2 = Iq
|
41
|
+
iq2 = Iq.new.import(iq)
|
42
42
|
assert_equal(Version::IqQueryVersion, iq2.query.class)
|
43
43
|
end
|
44
44
|
|
45
45
|
def test_import2
|
46
|
-
iq = Iq
|
47
|
-
q = REXML::Element
|
46
|
+
iq = Iq.new
|
47
|
+
q = REXML::Element.new('query')
|
48
48
|
q.add_namespace('jabber:iq:version')
|
49
49
|
q.add_element('name').text = 'AstroBot'
|
50
50
|
q.add_element('version').text = 'XP'
|
51
51
|
q.add_element('os').text = 'FreeDOS'
|
52
52
|
iq.add(q)
|
53
|
-
iq = Iq
|
53
|
+
iq = Iq.new.import(iq)
|
54
54
|
assert_equal(Version::IqQueryVersion, iq.query.class)
|
55
55
|
assert_equal('AstroBot', iq.query.iname)
|
56
56
|
assert_equal('XP', iq.query.version)
|
@@ -58,7 +58,7 @@ class Version::IqQueryVersionTest < Test::Unit::TestCase
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def test_replace
|
61
|
-
x = Version::IqQueryVersion
|
61
|
+
x = Version::IqQueryVersion.new('name', 'version', 'os')
|
62
62
|
|
63
63
|
num = 0
|
64
64
|
x.each_element('name') { |e| num += 1 }
|