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

« back to all changes in this revision

Viewing changes to test/soap/calc/test_calc2.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 'server2.rb'
4
 
 
5
 
 
6
 
module SOAP
7
 
module Calc
8
 
 
9
 
 
10
 
class TestCalc2 < Test::Unit::TestCase
11
 
  Port = 17171
12
 
 
13
 
  def setup
14
 
    @server = CalcServer2.new('CalcServer', 'http://tempuri.org/calcService', '0.0.0.0', Port)
15
 
    @server.level = Logger::Severity::ERROR
16
 
    @t = Thread.new {
17
 
      Thread.current.abort_on_exception = true
18
 
      @server.start
19
 
    }
20
 
    @endpoint = "http://localhost:#{Port}/"
21
 
    @var = SOAP::RPC::Driver.new(@endpoint, 'http://tempuri.org/calcService')
22
 
    @var.wiredump_dev = STDERR if $DEBUG
23
 
    @var.add_method('set_value', 'newValue')
24
 
    @var.add_method('get_value')
25
 
    @var.add_method_as('+', 'add', 'rhs')
26
 
    @var.add_method_as('-', 'sub', 'rhs')
27
 
    @var.add_method_as('*', 'multi', 'rhs')
28
 
    @var.add_method_as('/', 'div', 'rhs')
29
 
  end
30
 
 
31
 
  def teardown
32
 
    @server.shutdown
33
 
    @t.kill
34
 
    @t.join
35
 
    @var.reset_stream
36
 
  end
37
 
 
38
 
  def test_calc2
39
 
    assert_equal(1, @var.set_value(1))
40
 
    assert_equal(3, @var + 2)
41
 
    assert_equal(-1.2, @var - 2.2)
42
 
    assert_equal(2.2, @var * 2.2)
43
 
    assert_equal(0, @var / 2)
44
 
    assert_equal(0.5, @var / 2.0)
45
 
    assert_raises(ZeroDivisionError) do
46
 
      @var / 0
47
 
    end
48
 
  end
49
 
end
50
 
 
51
 
 
52
 
end
53
 
end