~ubuntu-branches/ubuntu/utopic/libdbus-ruby/utopic

« back to all changes in this revision

Viewing changes to test/server_robustness_test.rb

  • Committer: Bazaar Package Importer
  • Author(s): Paul van Tilburg, Gunnar Wolf, Paul van Tilburg
  • Date: 2010-02-14 21:12:08 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100214211208-zb8wnxcq9izet9hf
Tags: 0.2.12-1
[ Gunnar Wolf ]
* Changed section to Ruby as per ftp-masters' request

[ Paul van Tilburg ]
* New upstream release.
* debian/control:
  - Bumped standards version to 3.8.4.
  - Added missing ${misc:Depends} to libdbus-ruby and libdbus-ruby1.8.
* debian/watch:
  - Updated the URL to the new location on github (closes: #558602).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env ruby
 
2
# Test that a server survives various error cases
 
3
require "test/unit"
 
4
require "dbus"
 
5
 
 
6
class ServerRobustnessTest < Test::Unit::TestCase
 
7
  def setup
 
8
    @bus = DBus::SessionBus.instance
 
9
    @svc = @bus.service("org.ruby.service")
 
10
  end
 
11
 
 
12
  # https://trac.luon.net/ruby-dbus/ticket/31
 
13
  # the server should not crash
 
14
  def test_no_such_path_with_introspection
 
15
    obj = @svc.object "/org/ruby/NotMyInstance"
 
16
    obj.introspect
 
17
    assert false, "should have raised"
 
18
  rescue DBus::Error => e
 
19
    assert_no_match(/timeout/, e)
 
20
  end
 
21
 
 
22
  def test_no_such_path_without_introspection
 
23
    obj = @svc.object "/org/ruby/NotMyInstance"
 
24
    ifc = DBus::ProxyObjectInterface.new(obj, "org.ruby.SampleInterface")
 
25
    ifc.define_method("the_answer", "out n:i")
 
26
    ifc.the_answer
 
27
    assert false, "should have raised"
 
28
  rescue DBus::Error => e
 
29
    assert_no_match(/timeout/, e)
 
30
  end
 
31
 
 
32
  def test_a_method_that_raises
 
33
    obj = @svc.object "/org/ruby/MyInstance"
 
34
    obj.introspect
 
35
    obj.default_iface = "org.ruby.SampleInterface"
 
36
    obj.will_raise
 
37
    assert false, "should have raised"
 
38
  rescue DBus::Error => e
 
39
    assert_no_match(/timeout/, e)
 
40
  end
 
41
end