Sha256: 9b7c4e6486718618b6d58e19fc05ea710d13c3ea6831b32cd24ac5c9369e8e67

Contents?: true

Size: 1.21 KB

Versions: 30

Compression:

Stored size: 1.21 KB

Contents

#!/usr/bin/ruby

$:.unshift '../lib'

require 'test/unit'
require 'socket'
require 'tempfile'
require 'io/wait'
require 'xmpp4r'
include Jabber

class StreamSendTest < Test::Unit::TestCase
  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

  def teardown
    @stream.close
    @server.close
    @servlisten.close
  end

  def mysend(s)
    @stream.send(s)
    @stream.send("\n") #needed for easy test writing
  end

  ##
  # Tries to send a basic message
  def test_sendbasic
    mysend(Message.new)
    assert_equal("<message/>\n", @server.gets)
  end

  def test_sendmessage
    mysend(Message.new('lucas@linux.ensimag.fr', 'coucou'))
    assert_equal("<message to='lucas@linux.ensimag.fr'><body>coucou</body></message>\n", @server.gets)
  end

  def test_sendpresence
    mysend(Presence.new)
    assert_equal("<presence/>\n", @server.gets)
  end

  def test_sendiq
    mysend(Iq.new)
    assert_equal("<iq/>\n", @server.gets)
  end

end

Version data entries

30 entries across 30 versions & 12 rubygems

Version Path
brontes3d-xmpp4r-0.4 test/tc_streamSend.rb
bryanl-xmpp4r-0.3.2 test/tc_streamSend.rb
edavey-xmpp4r-0.4.1 test/tc_streamSend.rb
edavey-xmpp4r-0.4.2 test/tc_streamSend.rb
edavey-xmpp4r-0.4 test/tc_streamSend.rb
heipei-xmpp4r-0.3.2 test/tc_streamSend.rb
ln-xmpp4r-0.5 test/tc_streamSend.rb
mojodna-xmpp4r-0.4.0.2 test/tc_streamSend.rb
mojodna-xmpp4r-0.4.0.3 test/tc_streamSend.rb
seanohalpin-xmpp4r-0.4.1 test/tc_streamSend.rb
xmpp4r-0.5.6 test/tc_streamSend.rb
xmpp4r-0.5.5 test/tc_streamSend.rb
mad-p-xmpp4r-0.6.3 test/tc_streamSend.rb
mad-p-xmpp4r-0.6.2 test/tc_streamSend.rb
mad-p-xmpp4r-0.6.1 test/tc_streamSend.rb
mad-p-xmpp4r-0.6.0 test/tc_streamSend.rb
cerberus-0.8.0 lib/vendor/xmpp4r/test/tc_streamSend.rb
cerberus-0.7.9 lib/vendor/xmpp4r/test/tc_streamSend.rb
edavis10-cerberus-0.7.8 lib/vendor/xmpp4r/test/tc_streamSend.rb
cerberus-0.7.8 lib/vendor/xmpp4r/test/tc_streamSend.rb