Class: IqTest
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- IqTest
- Defined in:
- lib/vendor/xmpp4r/test/tc_iq.rb
Instance Method Summary collapse
- #test_browseget ⇒ Object
- #test_create ⇒ Object
- #test_error ⇒ Object
- #test_iqauth ⇒ Object
- #test_iqauth_digest ⇒ Object
- #test_new_query ⇒ Object
- #test_query ⇒ Object
- #test_register ⇒ Object
- #test_rosterget ⇒ Object
- #test_rosterset ⇒ Object
- #test_types ⇒ Object
- #test_vcard ⇒ Object
Instance Method Details
#test_browseget ⇒ Object
51 52 53 54 |
# File 'lib/vendor/xmpp4r/test/tc_iq.rb', line 51 def test_browseget x = Iq.new_browseget assert_equal_xml("<iq type='get' xmlns='jabber:client'><query xmlns='jabber:iq:browse'/></iq>", x) end |
#test_create ⇒ Object
15 16 17 18 19 20 |
# File 'lib/vendor/xmpp4r/test/tc_iq.rb', line 15 def test_create x = Iq.new() assert_equal("iq", x.name) assert_equal("jabber:client", x.namespace) assert_equal_xml("<iq xmlns='jabber:client'/>", x) end |
#test_error ⇒ Object
95 96 97 98 99 100 101 102 103 |
# File 'lib/vendor/xmpp4r/test/tc_iq.rb', line 95 def test_error x = Iq.new(:set) e = REXML::Element.new('error') x.add(e) # test if, after an import, the error element is successfully changed # into an ErrorResponse object. x2 = Iq.new.import(x) assert_equal(ErrorResponse, x2.first_element('error').class) end |
#test_iqauth ⇒ Object
22 23 24 25 |
# File 'lib/vendor/xmpp4r/test/tc_iq.rb', line 22 def test_iqauth x = Iq.new_authset(JID.new('node@domain/resource'), 'password') 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) end |
#test_iqauth_digest ⇒ Object
27 28 29 30 |
# File 'lib/vendor/xmpp4r/test/tc_iq.rb', line 27 def test_iqauth_digest x = Iq.new_authset_digest(JID.new('node@domain/resource'), '', 'password') 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) end |
#test_new_query ⇒ Object
105 106 107 108 109 110 111 112 |
# File 'lib/vendor/xmpp4r/test/tc_iq.rb', line 105 def test_new_query x = Iq.new_query(:get, JID.new('a@b/c')) assert_equal(:get, x.type) assert_equal(nil, x.from) assert_equal(JID.new('a@b/c'), x.to) assert_kind_of(IqQuery, x.query) assert_equal('jabber:client', x.queryns) end |
#test_query ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/vendor/xmpp4r/test/tc_iq.rb', line 71 def test_query x = Iq.new(:set) assert_equal(nil, x.queryns) query = REXML::Element.new('query') x.add(query) assert_equal('jabber:client', x.queryns) query.add_namespace('jabber:iq:auth') assert_equal(query.to_s, x.query.to_s) assert_equal('jabber:iq:auth', x.queryns) query2 = REXML::Element.new('query') x.query = query2 assert_equal('jabber:client', x.queryns) query2.add_namespace('jabber:iq:register') assert_equal('jabber:iq:register', x.queryns) end |
#test_register ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/vendor/xmpp4r/test/tc_iq.rb', line 32 def test_register x1 = Iq.new_register assert_equal_xml("<iq type='set' xmlns='jabber:client'><query xmlns='jabber:iq:register'/></iq>", x1) x2 = Iq.new_register('node') assert_equal_xml("<iq type='set' xmlns='jabber:client'><query xmlns='jabber:iq:register'><username>node</username></query></iq>", x2) x3 = Iq.new_register('node', 'password') assert_equal_xml("<iq type='set' xmlns='jabber:client'><query xmlns='jabber:iq:register'><username>node</username><password>password</password></query></iq>", x3) end |
#test_rosterget ⇒ Object
41 42 43 44 |
# File 'lib/vendor/xmpp4r/test/tc_iq.rb', line 41 def test_rosterget x = Iq.new_rosterget assert_equal_xml("<iq type='get' xmlns='jabber:client'><query xmlns='jabber:iq:roster'/></iq>", x) end |
#test_rosterset ⇒ Object
46 47 48 49 |
# File 'lib/vendor/xmpp4r/test/tc_iq.rb', line 46 def test_rosterset x = Iq.new_rosterset assert_equal_xml("<iq type='set' xmlns='jabber:client'><query xmlns='jabber:iq:roster'/></iq>", x) end |
#test_types ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/vendor/xmpp4r/test/tc_iq.rb', line 56 def test_types iq = Iq.new assert_equal(nil, iq.type) iq.type = :get assert_equal(:get, iq.type) iq.type = :set assert_equal(:set, iq.type) iq.type = :result assert_equal(:result, iq.type) iq.type = :error assert_equal(:error, iq.type) iq.type = :invalid assert_equal(nil, iq.type) end |