~ubuntu-branches/ubuntu/trusty/ruby1.9/trusty

« back to all changes in this revision

Viewing changes to test/soap/fault/test_customfault.rb

  • Committer: Bazaar Package Importer
  • Author(s): Stephan Hermann
  • Date: 2008-01-24 11:42:29 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20080124114229-jw2f87rdxlq6gp11
Tags: 1.9.0.0-2ubuntu1
* Merge from debian unstable, remaining changes:
  - Robustify check for target_os, fixing build failure on lpia.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
require 'test/unit'
2
 
require 'soap/rpc/driver'
3
 
require 'soap/rpc/standaloneServer'
4
 
 
5
 
 
6
 
module SOAP
7
 
module Fault
8
 
 
9
 
 
10
 
class TestCustomFault < Test::Unit::TestCase
11
 
  Port = 17171
12
 
 
13
 
  class CustomFaultServer < SOAP::RPC::StandaloneServer
14
 
    def on_init
15
 
      add_method(self, 'fault', 'msg')
16
 
    end
17
 
 
18
 
    def fault(msg)
19
 
      SOAPFault.new(SOAPString.new("mycustom"),
20
 
        SOAPString.new("error: #{msg}"),
21
 
        SOAPString.new(self.class.name))
22
 
    end
23
 
  end
24
 
 
25
 
  def setup
26
 
    @server = CustomFaultServer.new('customfault', 'urn:customfault', '0.0.0.0', Port)
27
 
    @server.level = Logger::Severity::ERROR
28
 
    @t = Thread.new {
29
 
      Thread.current.abort_on_exception = true
30
 
      @server.start
31
 
    }
32
 
    @endpoint = "http://localhost:#{Port}/"
33
 
    @client = SOAP::RPC::Driver.new(@endpoint, 'urn:customfault')
34
 
    @client.wiredump_dev = STDERR if $DEBUG
35
 
    @client.add_method("fault", "msg")
36
 
  end
37
 
 
38
 
  def teardown
39
 
    @server.shutdown
40
 
    @t.kill
41
 
    @t.join
42
 
    @client.reset_stream
43
 
  end
44
 
 
45
 
  def test_custom_fault
46
 
    begin
47
 
      @client.fault("message")
48
 
      assert(false, 'exception not raised')
49
 
    rescue SOAP::FaultError => e
50
 
      assert(true, 'exception raised')
51
 
      assert_equal('error: message', e.message)
52
 
    end
53
 
  end
54
 
end
55
 
 
56
 
 
57
 
end
58
 
end