Class: RPC::HelperTest
- Includes:
- ClientTester
- Defined in:
- lib/gems/xmpp4r-0.4/test/rpc/tc_helper.rb
Instance Method Summary collapse
- #echo(msg = nil) ⇒ Object
- #give_client_jid! ⇒ Object
- #test_100calls ⇒ Object
- #test_create ⇒ Object
- #test_introspection ⇒ Object
- #test_multicall ⇒ Object
- #test_simple ⇒ Object
Instance Method Details
#echo(msg = nil) ⇒ Object
32 33 34 |
# File 'lib/gems/xmpp4r-0.4/test/rpc/tc_helper.rb', line 32 def echo(msg = nil) msg end |
#give_client_jid! ⇒ Object
16 17 18 19 20 21 |
# File 'lib/gems/xmpp4r-0.4/test/rpc/tc_helper.rb', line 16 def give_client_jid! class << @client remove_method(:jid) # avoids warning def jid; Jabber::JID.new('[email protected]/clienttester'); end end end |
#test_100calls ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/gems/xmpp4r-0.4/test/rpc/tc_helper.rb', line 81 def test_100calls give_client_jid! sv = RPC::Server.new(@server) sv.add_handler("add") do |a,b| a+b end cl = RPC::Client.new(@client, 'a@b/c') correct = true 100.times { a, b = rand(1000), rand(1000) correct &&= (cl.call('add', a, b) == a + b) } assert(correct) end |
#test_create ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/gems/xmpp4r-0.4/test/rpc/tc_helper.rb', line 23 def test_create give_client_jid! cl = RPC::Client.new(@client, 'a@b/c') assert_kind_of(RPC::Client, cl) sv = RPC::Server.new(@server) assert_kind_of(RPC::Server, sv) end |
#test_introspection ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/gems/xmpp4r-0.4/test/rpc/tc_helper.rb', line 54 def test_introspection give_client_jid! sv = RPC::Server.new(@server) sv.add_introspection cl = RPC::Client.new(@client, 'a@b/c') cl_methods = cl.call("system.listMethods") assert(cl_methods.size > 0) cl_methods.each { |method| assert_kind_of(String, method) assert(method =~ /^system\./) } end |
#test_multicall ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/gems/xmpp4r-0.4/test/rpc/tc_helper.rb', line 69 def test_multicall give_client_jid! sv = RPC::Server.new(@server) sv.add_multicall sv.add_handler("reverse") do |s| s.reverse end sv.add_handler("upcase") do |s| s.upcase end cl = RPC::Client.new(@client, 'a@b/c') assert_equal(['tseT', 'TEST'], cl.multicall(['reverse', 'Test'], ['upcase', 'Test'])) end |
#test_simple ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/gems/xmpp4r-0.4/test/rpc/tc_helper.rb', line 36 def test_simple give_client_jid! sv = RPC::Server.new(@server) sv.add_handler("echo", &method(:echo)) cl = RPC::Client.new(@client, 'a@b/c') assert_nothing_raised do assert_equal('Test string', cl.call("echo", 'Test string')) end # exception during serialisation bug identified on xmpp4r-devel # https://mail.gna.org/public/xmpp4r-devel/2008-05/msg00010.html assert_raise XMLRPC::FaultException do cl.call("echo") end end |