Class: StreamSendTest
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- StreamSendTest
- Defined in:
- lib/vendor/xmpp4r/test/tc_streamSend.rb
Instance Method Summary collapse
- #mysend(s) ⇒ Object
- #setup ⇒ Object
- #teardown ⇒ Object
-
#test_sendbasic ⇒ Object
Tries to send a basic message.
- #test_sendiq ⇒ Object
- #test_sendmessage ⇒ Object
- #test_sendpresence ⇒ Object
Instance Method Details
#mysend(s) ⇒ Object
32 33 34 35 |
# File 'lib/vendor/xmpp4r/test/tc_streamSend.rb', line 32 def mysend(s) @stream.send(s) @stream.send("\n") #needed for easy test writing end |
#setup ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/vendor/xmpp4r/test/tc_streamSend.rb', line 13 def setup @tmpfile = Tempfile.new("StreamSendTest") @tmpfilepath = @tmpfile.path() @tmpfile.unlink @servlisten = UNIXServer.new(@tmpfilepath) thServer = Thread.new { @server = @servlisten.accept } @iostream = UNIXSocket.new(@tmpfilepath) @stream = Stream.new @stream.start(@iostream) thServer.join end |
#teardown ⇒ Object
26 27 28 29 30 |
# File 'lib/vendor/xmpp4r/test/tc_streamSend.rb', line 26 def teardown @stream.close @server.close @servlisten.close end |
#test_sendbasic ⇒ Object
Tries to send a basic message
39 40 41 42 |
# File 'lib/vendor/xmpp4r/test/tc_streamSend.rb', line 39 def test_sendbasic mysend(Message.new) assert_equal("<message/>\n", @server.gets) end |
#test_sendiq ⇒ Object
54 55 56 57 |
# File 'lib/vendor/xmpp4r/test/tc_streamSend.rb', line 54 def test_sendiq mysend(Iq.new) assert_equal("<iq/>\n", @server.gets) end |
#test_sendmessage ⇒ Object
44 45 46 47 |
# File 'lib/vendor/xmpp4r/test/tc_streamSend.rb', line 44 def mysend(Message.new('[email protected]', 'coucou')) assert_equal("<message to='[email protected]'><body>coucou</body></message>\n", @server.gets) end |