xmpp4r 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +12 -0
- data/Rakefile +2 -4
- data/data/doc/xmpp4r/examples/advanced/adventure/adventuremuc.rb +6 -6
- data/data/doc/xmpp4r/examples/advanced/adventure/world.rb +3 -3
- data/data/doc/xmpp4r/examples/advanced/minimuc.rb +5 -5
- data/data/doc/xmpp4r/examples/advanced/xmpping.rb +17 -4
- data/data/doc/xmpp4r/examples/advanced/xmppingrc.sample +5 -0
- data/data/doc/xmpp4r/examples/basic/echo_threaded.rb +6 -2
- data/data/doc/xmpp4r/examples/basic/muc_owner_config.rb +13 -0
- data/lib/xmpp4r.rb +0 -6
- data/lib/xmpp4r/bytestreams/helper/filetransfer.rb +6 -7
- data/lib/xmpp4r/bytestreams/helper/ibb/base.rb +5 -6
- data/lib/xmpp4r/bytestreams/helper/ibb/target.rb +3 -5
- data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb +1 -1
- data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/server.rb +10 -8
- data/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb +3 -5
- data/lib/xmpp4r/bytestreams/iq/bytestreams.rb +11 -17
- data/lib/xmpp4r/bytestreams/iq/si.rb +13 -32
- data/lib/xmpp4r/callbacks.rb +124 -0
- data/lib/xmpp4r/client.rb +2 -5
- data/lib/xmpp4r/command/helper/responder.rb +53 -0
- data/lib/xmpp4r/command/iq/command.rb +154 -0
- data/lib/xmpp4r/connection.rb +49 -12
- data/lib/xmpp4r/dataforms/x/data.rb +66 -29
- data/lib/xmpp4r/delay/x/delay.rb +2 -3
- data/lib/xmpp4r/discovery/iq/discoinfo.rb +20 -33
- data/lib/xmpp4r/discovery/iq/discoitems.rb +5 -28
- data/lib/xmpp4r/error.rb +5 -10
- data/lib/xmpp4r/feature_negotiation/iq/feature.rb +2 -20
- data/lib/xmpp4r/httpbinding.rb +5 -0
- data/lib/xmpp4r/httpbinding/client.rb +285 -0
- data/lib/xmpp4r/iq.rb +22 -41
- data/lib/xmpp4r/message.rb +8 -38
- data/lib/xmpp4r/muc.rb +2 -0
- data/lib/xmpp4r/muc/helper/mucclient.rb +50 -1
- data/lib/xmpp4r/muc/helper/simplemucclient.rb +2 -2
- data/lib/xmpp4r/muc/iq/mucowner.rb +11 -0
- data/lib/xmpp4r/muc/x/muc.rb +2 -30
- data/lib/xmpp4r/muc/x/mucuserinvite.rb +4 -2
- data/lib/xmpp4r/muc/x/mucuseritem.rb +4 -2
- data/lib/xmpp4r/presence.rb +7 -35
- data/lib/xmpp4r/pubsub.rb +1 -0
- data/lib/xmpp4r/pubsub/helper/nodebrowser.rb +174 -0
- data/lib/xmpp4r/pubsub/helper/nodehelper.rb +153 -0
- data/lib/xmpp4r/pubsub/helper/servicehelper.rb +326 -0
- data/lib/xmpp4r/pubsub/iq/pubsub.rb +19 -0
- data/lib/xmpp4r/pubsub/stanzas/event.rb +49 -0
- data/lib/xmpp4r/pubsub/stanzas/item.rb +27 -0
- data/lib/xmpp4r/pubsub/stanzas/items.rb +35 -0
- data/lib/xmpp4r/pubsub/stanzas/subscription.rb +58 -0
- data/lib/xmpp4r/query.rb +4 -32
- data/lib/xmpp4r/rexmladdons.rb +7 -772
- data/lib/xmpp4r/roster/helper/roster.rb +29 -50
- data/lib/xmpp4r/roster/iq/roster.rb +6 -35
- data/lib/xmpp4r/roster/x/roster.rb +13 -30
- data/lib/xmpp4r/rpc.rb +2 -0
- data/lib/xmpp4r/rpc/helper/client.rb +114 -0
- data/lib/xmpp4r/rpc/helper/server.rb +75 -0
- data/lib/xmpp4r/rpc/helper/xmlrpcaddons.rb +57 -0
- data/lib/xmpp4r/rpc/iq/rpc.rb +24 -0
- data/lib/xmpp4r/sasl.rb +1 -1
- data/lib/xmpp4r/semaphore.rb +38 -0
- data/lib/xmpp4r/stream.rb +104 -165
- data/lib/xmpp4r/streamparser.rb +2 -2
- data/lib/xmpp4r/vcard/iq/vcard.rb +5 -12
- data/lib/xmpp4r/version/helper/responder.rb +2 -1
- data/lib/xmpp4r/version/iq/version.rb +6 -18
- data/lib/xmpp4r/x.rb +20 -26
- data/lib/xmpp4r/xmpp4r.rb +1 -1
- data/lib/xmpp4r/xmppelement.rb +152 -0
- data/lib/xmpp4r/{xmlstanza.rb → xmppstanza.rb} +17 -29
- data/setup.rb +1 -0
- data/test/bytestreams/tc_ibb.rb +8 -8
- data/test/dataforms/tc_data.rb +81 -0
- data/test/lib/clienttester.rb +20 -17
- data/test/muc/tc_muc_mucclient.rb +48 -23
- data/test/muc/tc_muc_simplemucclient.rb +7 -4
- data/test/muc/tc_mucowner.rb +50 -0
- data/test/pubsub/tc_helper.rb +227 -0
- data/test/roster/tc_helper.rb +181 -55
- data/test/roster/tc_iqqueryroster.rb +33 -0
- data/test/roster/tc_xroster.rb +6 -3
- data/test/rpc/tc_helper.rb +84 -0
- data/test/tc_callbacks.rb +2 -1
- data/test/tc_class_names.rb +9 -1
- data/test/tc_error.rb +1 -0
- data/test/tc_iq.rb +13 -12
- data/test/tc_message.rb +1 -0
- data/test/tc_presence.rb +1 -0
- data/test/tc_rexml.rb +1 -1
- data/test/tc_stream.rb +147 -102
- data/test/tc_streamComponent.rb +94 -0
- data/test/tc_streamError.rb +67 -29
- data/test/tc_streamSend.rb +1 -1
- data/test/tc_xmppstanza.rb +125 -0
- data/test/ts_xmpp4r.rb +37 -28
- data/test/version/tc_helper.rb +14 -0
- data/test/version/tc_iqqueryversion.rb +4 -3
- metadata +163 -123
- data/data/doc/xmpp4r/examples/basic/echo_nonthreaded.rb +0 -32
- data/lib/callbacks.rb +0 -122
- data/test/tc_streamThreaded.rb +0 -168
- data/test/tc_xmlstanza.rb +0 -76
@@ -0,0 +1,94 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift '../lib'
|
4
|
+
|
5
|
+
require 'tempfile'
|
6
|
+
require 'test/unit'
|
7
|
+
require 'socket'
|
8
|
+
require 'xmpp4r/component'
|
9
|
+
require 'xmpp4r/bytestreams'
|
10
|
+
require 'xmpp4r/semaphore'
|
11
|
+
require 'xmpp4r'
|
12
|
+
include Jabber
|
13
|
+
|
14
|
+
class StreamComponentTest < Test::Unit::TestCase
|
15
|
+
@@SOCKET_PORT = 65224
|
16
|
+
|
17
|
+
def setup
|
18
|
+
servlisten = TCPServer.new(@@SOCKET_PORT)
|
19
|
+
serverwait = Semaphore.new
|
20
|
+
Thread.new do
|
21
|
+
Thread.current.abort_on_exception = true
|
22
|
+
serversock = servlisten.accept
|
23
|
+
servlisten.close
|
24
|
+
serversock.sync = true
|
25
|
+
@server = Stream.new(true)
|
26
|
+
@server.add_xml_callback do |xml|
|
27
|
+
if xml.prefix == 'stream' and xml.name == 'stream'
|
28
|
+
@server.send('<stream:stream xmlns="jabber:component:accept">')
|
29
|
+
true
|
30
|
+
else
|
31
|
+
false
|
32
|
+
end
|
33
|
+
end
|
34
|
+
@server.start(serversock)
|
35
|
+
|
36
|
+
serverwait.run
|
37
|
+
end
|
38
|
+
|
39
|
+
@stream = Component::new('test')
|
40
|
+
@stream.connect('localhost', @@SOCKET_PORT)
|
41
|
+
|
42
|
+
serverwait.wait
|
43
|
+
end
|
44
|
+
|
45
|
+
def teardown
|
46
|
+
@stream.close
|
47
|
+
@server.close
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_process
|
51
|
+
stanzas = 0
|
52
|
+
message_lock = Semaphore.new
|
53
|
+
iq_lock = Semaphore.new
|
54
|
+
presence_lock = Semaphore.new
|
55
|
+
|
56
|
+
@stream.add_message_callback { |msg|
|
57
|
+
assert_kind_of(Message, msg)
|
58
|
+
stanzas += 1
|
59
|
+
message_lock.run
|
60
|
+
}
|
61
|
+
@stream.add_iq_callback { |iq|
|
62
|
+
assert_kind_of(Iq, iq)
|
63
|
+
stanzas += 1
|
64
|
+
iq_lock.run
|
65
|
+
}
|
66
|
+
@stream.add_presence_callback { |pres|
|
67
|
+
assert_kind_of(Presence, pres)
|
68
|
+
stanzas += 1
|
69
|
+
presence_lock.run
|
70
|
+
}
|
71
|
+
|
72
|
+
@server.send('<message/>')
|
73
|
+
@server.send('<iq/>')
|
74
|
+
@server.send('<presence/>')
|
75
|
+
|
76
|
+
message_lock.wait
|
77
|
+
iq_lock.wait
|
78
|
+
presence_lock.wait
|
79
|
+
|
80
|
+
assert_equal(3, stanzas)
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_outgoing
|
84
|
+
received_wait = Semaphore.new
|
85
|
+
|
86
|
+
@server.add_message_callback { |msg|
|
87
|
+
assert_kind_of(Message, msg)
|
88
|
+
received_wait.run
|
89
|
+
}
|
90
|
+
|
91
|
+
@stream.send(Message.new)
|
92
|
+
received_wait.wait
|
93
|
+
end
|
94
|
+
end
|
data/test/tc_streamError.rb
CHANGED
@@ -8,18 +8,48 @@ require 'xmpp4r/client'
|
|
8
8
|
include Jabber
|
9
9
|
|
10
10
|
class ConnectionErrorTest < Test::Unit::TestCase
|
11
|
+
@@SOCKET_PORT = 65225
|
12
|
+
|
13
|
+
def setup
|
14
|
+
servlisten = TCPServer.new(@@SOCKET_PORT)
|
15
|
+
serverwait = Semaphore.new
|
16
|
+
@server = nil
|
17
|
+
Thread.new do
|
18
|
+
Thread.current.abort_on_exception = true
|
19
|
+
@server = servlisten.accept
|
20
|
+
servlisten.close
|
21
|
+
@server.sync = true
|
22
|
+
|
23
|
+
serverwait.run
|
24
|
+
end
|
25
|
+
|
26
|
+
@conn = TCPSocket::new('localhost', @@SOCKET_PORT)
|
27
|
+
|
28
|
+
serverwait.wait
|
29
|
+
end
|
30
|
+
|
31
|
+
def teardown
|
32
|
+
@conn.close if not @conn.closed?
|
33
|
+
@server.close if not @conn.closed?
|
34
|
+
end
|
35
|
+
|
11
36
|
def test_connectionError_start_withexcblock
|
12
|
-
@
|
13
|
-
@stream = Stream::new(false)
|
37
|
+
@stream = Stream::new
|
14
38
|
error = false
|
15
39
|
@stream.on_exception do |e, o, w|
|
16
|
-
|
40
|
+
# strange exception, it's caused by REXML, actually
|
41
|
+
assert_equal(NameError, e.class)
|
17
42
|
assert_equal(Jabber::Stream, o.class)
|
18
43
|
assert_equal(:start, w)
|
19
44
|
error = true
|
20
45
|
end
|
21
46
|
assert(!error)
|
22
|
-
|
47
|
+
begin
|
48
|
+
# wrong port on purpose
|
49
|
+
conn = TCPSocket::new('localhost', 1)
|
50
|
+
rescue
|
51
|
+
end
|
52
|
+
@stream.start(conn)
|
23
53
|
sleep 0.2
|
24
54
|
assert(error)
|
25
55
|
@server.close
|
@@ -27,8 +57,7 @@ class ConnectionErrorTest < Test::Unit::TestCase
|
|
27
57
|
end
|
28
58
|
|
29
59
|
def test_connectionError_parse_withexcblock
|
30
|
-
@
|
31
|
-
@stream = Stream::new(false)
|
60
|
+
@stream = Stream::new
|
32
61
|
error = false
|
33
62
|
@stream.start(@conn)
|
34
63
|
@stream.on_exception do |e, o, w|
|
@@ -40,9 +69,7 @@ class ConnectionErrorTest < Test::Unit::TestCase
|
|
40
69
|
@server.puts('<stream:stream>')
|
41
70
|
@server.flush
|
42
71
|
assert(!error)
|
43
|
-
|
44
|
-
@server.puts('</blop>')
|
45
|
-
}
|
72
|
+
@server.puts('</blop>')
|
46
73
|
@server.flush
|
47
74
|
sleep 0.2
|
48
75
|
assert(error)
|
@@ -51,37 +78,48 @@ class ConnectionErrorTest < Test::Unit::TestCase
|
|
51
78
|
end
|
52
79
|
|
53
80
|
def test_connectionError_send_withexcblock
|
54
|
-
@
|
55
|
-
|
56
|
-
error = false
|
81
|
+
@stream = Stream::new
|
82
|
+
error = 0
|
57
83
|
@stream.start(@conn)
|
58
|
-
@stream.on_exception do |
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
84
|
+
@stream.on_exception do |exc, o, w|
|
85
|
+
case w
|
86
|
+
when :sending
|
87
|
+
assert_equal(IOError, exc.class)
|
88
|
+
assert_equal(Jabber::Stream, o.class)
|
89
|
+
when :disconnected
|
90
|
+
assert_equal(nil, exc)
|
91
|
+
assert_equal(Jabber::Stream, o.class)
|
92
|
+
else
|
93
|
+
assert(false)
|
94
|
+
end
|
95
|
+
error += 1
|
63
96
|
end
|
64
97
|
@server.puts('<stream:stream>')
|
65
98
|
@server.flush
|
66
|
-
|
67
|
-
@stream.send('</test>')
|
68
|
-
sleep 0.2
|
69
|
-
assert(error)
|
99
|
+
assert_equal(0, error)
|
70
100
|
@server.close
|
101
|
+
sleep 0.1
|
102
|
+
assert_equal(1, error)
|
103
|
+
@stream.send('</test>')
|
104
|
+
sleep 0.1
|
105
|
+
@stream.send('</test>')
|
106
|
+
sleep 0.1
|
107
|
+
assert_equal(3, error)
|
71
108
|
@stream.close
|
72
109
|
end
|
73
110
|
|
74
111
|
def test_connectionError_send_withoutexcblock
|
75
|
-
@
|
76
|
-
@stream = Stream::new(false)
|
112
|
+
@stream = Stream::new
|
77
113
|
@stream.start(@conn)
|
78
114
|
@server.puts('<stream:stream>')
|
79
115
|
@server.flush
|
80
|
-
assert_raise(
|
81
|
-
|
82
|
-
|
116
|
+
assert_raise(Errno::EPIPE) do
|
117
|
+
@server.close
|
118
|
+
sleep 0.1
|
119
|
+
@stream.send('</test>')
|
120
|
+
sleep 0.1
|
121
|
+
@stream.send('</test>')
|
122
|
+
sleep 0.1
|
123
|
+
end
|
83
124
|
end
|
84
|
-
|
85
|
-
|
86
|
-
|
87
125
|
end
|
data/test/tc_streamSend.rb
CHANGED
@@ -17,7 +17,7 @@ class StreamSendTest < Test::Unit::TestCase
|
|
17
17
|
@servlisten = UNIXServer::new(@tmpfilepath)
|
18
18
|
thServer = Thread.new { @server = @servlisten.accept }
|
19
19
|
@iostream = UNIXSocket::new(@tmpfilepath)
|
20
|
-
@stream = Stream::new
|
20
|
+
@stream = Stream::new
|
21
21
|
@stream.start(@iostream)
|
22
22
|
|
23
23
|
thServer.join
|
@@ -0,0 +1,125 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift '../lib'
|
4
|
+
|
5
|
+
require 'test/unit'
|
6
|
+
require 'socket'
|
7
|
+
require 'xmpp4r/rexmladdons'
|
8
|
+
require 'xmpp4r/xmppstanza'
|
9
|
+
require 'xmpp4r/iq'
|
10
|
+
require 'xmpp4r/feature_negotiation'
|
11
|
+
require 'xmpp4r/dataforms'
|
12
|
+
include Jabber
|
13
|
+
|
14
|
+
class XMPPStanzaTest < Test::Unit::TestCase
|
15
|
+
|
16
|
+
##
|
17
|
+
# Hack: XMPPStanza derives from XMPPElement
|
18
|
+
# which enforces element classes to be named at declaration time
|
19
|
+
class MyXMPPStanza < XMPPStanza
|
20
|
+
name_xmlns 'stanza', 'http://home.gna.org/xmpp4r'
|
21
|
+
end
|
22
|
+
|
23
|
+
class MyStanza < XMPPStanza
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_from
|
27
|
+
x = MyXMPPStanza::new
|
28
|
+
assert_equal(nil, x.from)
|
29
|
+
assert_equal(x, x.set_from("blop"))
|
30
|
+
assert_equal("blop", x.from.to_s)
|
31
|
+
x.from = "tada"
|
32
|
+
assert_equal("tada", x.from.to_s)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_to
|
36
|
+
x = MyXMPPStanza::new
|
37
|
+
assert_equal(nil, x.to)
|
38
|
+
assert_equal(x, x.set_to("blop"))
|
39
|
+
assert_equal("blop", x.to.to_s)
|
40
|
+
x.to = "tada"
|
41
|
+
assert_equal("tada", x.to.to_s)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_id
|
45
|
+
x = MyXMPPStanza::new
|
46
|
+
assert_equal(nil, x.id)
|
47
|
+
assert_equal(x, x.set_id("blop"))
|
48
|
+
assert_equal("blop", x.id)
|
49
|
+
x.id = "tada"
|
50
|
+
assert_equal("tada", x.id)
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_type
|
54
|
+
x = MyXMPPStanza::new
|
55
|
+
assert_equal(nil, x.type)
|
56
|
+
assert_equal(x, x.set_type("blop"))
|
57
|
+
assert_equal("blop", x.type)
|
58
|
+
x.type = "tada"
|
59
|
+
assert_equal("tada", x.type)
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_import
|
63
|
+
x = MyXMPPStanza::new
|
64
|
+
x.id = "heya"
|
65
|
+
q = x.add_element("query")
|
66
|
+
q.add_namespace("about:blank")
|
67
|
+
q.add_element("b").text = "I am b"
|
68
|
+
q.add_text("I am text")
|
69
|
+
q.add_element("a").add_attribute("href", "http://home.gna.org/xmpp4r/")
|
70
|
+
x.add_text("yow")
|
71
|
+
x.add_element("query")
|
72
|
+
|
73
|
+
assert_raise(RuntimeError) { iq = Iq.import(x) }
|
74
|
+
x.name = 'iq'
|
75
|
+
iq = Iq.import(x)
|
76
|
+
|
77
|
+
assert_equal(x.id, iq.id)
|
78
|
+
assert_equal(q.to_s, iq.query.to_s)
|
79
|
+
assert_equal(x.to_s, iq.to_s)
|
80
|
+
assert_equal(q.namespace, iq.queryns)
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_import2
|
84
|
+
feature = FeatureNegotiation::IqFeature.new
|
85
|
+
xdata = feature.add(Dataforms::XData.new(:form))
|
86
|
+
field = xdata.add(Dataforms::XDataField.new('stream-method', :list_single))
|
87
|
+
|
88
|
+
feature2 = FeatureNegotiation::IqFeature.new.import(feature)
|
89
|
+
assert_equal(field.var, feature2.x.fields.first.var)
|
90
|
+
assert_equal(field.type, feature2.x.fields.first.type)
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_error
|
94
|
+
x = MyXMPPStanza::new
|
95
|
+
assert_equal(nil, x.error)
|
96
|
+
x.typed_add(REXML::Element.new('error'))
|
97
|
+
assert_equal('<error/>', x.error.to_s)
|
98
|
+
assert_equal(Error, x.error.class)
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_clone_and_dup
|
102
|
+
x = MyXMPPStanza::new
|
103
|
+
x.attributes['xyz'] = '123'
|
104
|
+
x.text = 'abc'
|
105
|
+
|
106
|
+
assert_equal(x.attributes['xyz'], '123')
|
107
|
+
assert_equal(x.text, 'abc')
|
108
|
+
|
109
|
+
x2 = x.clone
|
110
|
+
assert_kind_of(MyXMPPStanza, x2)
|
111
|
+
assert_equal('123', x2.attributes['xyz'])
|
112
|
+
assert_nil(x2.text)
|
113
|
+
|
114
|
+
x3 = x.dup
|
115
|
+
assert_kind_of(MyXMPPStanza, x3)
|
116
|
+
assert_equal('123', x3.attributes['xyz'])
|
117
|
+
assert_equal('abc', x3.text)
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_raise
|
121
|
+
assert_raises(NoNameXmlnsRegistered) {
|
122
|
+
XMPPStanza.name_xmlns_for_class(MyStanza)
|
123
|
+
}
|
124
|
+
end
|
125
|
+
end
|
data/test/ts_xmpp4r.rb
CHANGED
@@ -1,35 +1,44 @@
|
|
1
1
|
#!/usr/bin/ruby -w
|
2
2
|
|
3
|
-
|
4
3
|
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
5
4
|
$:.unshift File.join(File.dirname(__FILE__), '..', 'test')
|
6
5
|
$:.unshift File.join(File.dirname(__FILE__), 'lib')
|
7
6
|
$:.unshift File.join(File.dirname(__FILE__), 'test')
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
require '
|
13
|
-
require '
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
#
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
8
|
+
# This is allowed here, to make sure it's enabled in all test.
|
9
|
+
Thread::abort_on_exception = true
|
10
|
+
|
11
|
+
require 'xmpp4r'
|
12
|
+
require 'find'
|
13
|
+
|
14
|
+
# List files' basenames, not full path!
|
15
|
+
# EXCLUDED_FILES = [ 'tc_muc_simplemucclient.rb' ]
|
16
|
+
EXCLUDED_FILES = []
|
17
|
+
|
18
|
+
tc_files = []
|
19
|
+
tc_subdirs = []
|
20
|
+
Find.find(File.dirname(__FILE__)) do |f|
|
21
|
+
if File::directory?(f)
|
22
|
+
if f == '.'
|
23
|
+
# do nothing
|
24
|
+
elsif File::basename(f) != '.svn'
|
25
|
+
tc_subdirs << f
|
26
|
+
Find.prune
|
27
|
+
end
|
28
|
+
elsif File::basename(f) =~ /^tc.*\.rb$/
|
29
|
+
tc_files << f
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
tc_subdirs.each do |dir|
|
34
|
+
Find.find(dir) do |f|
|
35
|
+
if File::file?(f) and File::basename(f) =~ /^tc.*\.rb$/
|
36
|
+
tc_files << f
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
tc_files.each do |f|
|
42
|
+
next if EXCLUDED_FILES.include?(File::basename(f))
|
43
|
+
require f
|
44
|
+
end
|
data/test/version/tc_helper.rb
CHANGED
@@ -7,6 +7,7 @@ require File::dirname(__FILE__) + '/../lib/clienttester'
|
|
7
7
|
|
8
8
|
require 'xmpp4r'
|
9
9
|
require 'xmpp4r/version/helper/responder'
|
10
|
+
require 'xmpp4r/version/helper/simpleresponder'
|
10
11
|
include Jabber
|
11
12
|
|
12
13
|
class Version::HelperTest < Test::Unit::TestCase
|
@@ -43,4 +44,17 @@ class Version::HelperTest < Test::Unit::TestCase
|
|
43
44
|
}
|
44
45
|
assert_equal(1, calls)
|
45
46
|
end
|
47
|
+
|
48
|
+
def test_simple
|
49
|
+
h = Version::SimpleResponder.new(@client, 'Test program', '1.0', 'Ruby Test::Unit')
|
50
|
+
|
51
|
+
# Send a query
|
52
|
+
@server.send("<iq type='get'><query xmlns='jabber:iq:version'/></iq>") { |reply|
|
53
|
+
assert_equal('Test program', reply.query.iname)
|
54
|
+
assert_equal('1.0', reply.query.version)
|
55
|
+
assert_equal('Ruby Test::Unit', reply.query.os)
|
56
|
+
true
|
57
|
+
}
|
58
|
+
|
59
|
+
end
|
46
60
|
end
|