~ubuntu-branches/ubuntu/hardy/ruby1.8/hardy-updates

« back to all changes in this revision

Viewing changes to test/soap/wsdlDriver/test_document.rb

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2007-03-13 22:11:58 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070313221158-h3oql37brlaf2go2
Tags: 1.8.6-1
* new upstream version, 1.8.6.
* libruby1.8 conflicts with libopenssl-ruby1.8 (< 1.8.6) (closes: #410018)
* changed packaging style to cdbs from dbs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require 'test/unit'
 
2
require 'soap/rpc/standaloneServer'
 
3
require 'soap/wsdlDriver'
 
4
 
 
5
 
 
6
module SOAP
 
7
 
 
8
 
 
9
class TestDocument < Test::Unit::TestCase
 
10
  Namespace = 'urn:example.com:document'
 
11
 
 
12
  class Server < ::SOAP::RPC::StandaloneServer
 
13
    def on_init
 
14
      add_document_method(self, 'urn:example.com:document#submit', 'submit', XSD::QName.new(Namespace, 'ruby'), XSD::QName.new(Namespace, 'ruby'))
 
15
    end
 
16
  
 
17
    def submit(ruby)
 
18
      ruby
 
19
    end
 
20
  end
 
21
 
 
22
  DIR = File.dirname(File.expand_path(__FILE__))
 
23
 
 
24
  Port = 17171
 
25
 
 
26
  def setup
 
27
    setup_server
 
28
    setup_client
 
29
  end
 
30
 
 
31
  def setup_server
 
32
    @server = Server.new('Test', Namespace, '0.0.0.0', Port)
 
33
    @server.level = Logger::Severity::ERROR
 
34
    @server_thread = start_server_thread(@server)
 
35
  end
 
36
 
 
37
  def setup_client
 
38
    wsdl = File.join(DIR, 'document.wsdl')
 
39
    @client = ::SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
 
40
    @client.endpoint_url = "http://localhost:#{Port}/"
 
41
    @client.wiredump_dev = STDOUT if $DEBUG
 
42
  end
 
43
 
 
44
  def teardown
 
45
    teardown_server
 
46
    teardown_client
 
47
  end
 
48
 
 
49
  def teardown_server
 
50
    @server.shutdown
 
51
    @server_thread.kill
 
52
    @server_thread.join
 
53
  end
 
54
 
 
55
  def teardown_client
 
56
    @client.reset_stream
 
57
  end
 
58
 
 
59
  def start_server_thread(server)
 
60
    t = Thread.new {
 
61
      Thread.current.abort_on_exception = true
 
62
      server.start
 
63
    }
 
64
    t
 
65
  end
 
66
 
 
67
  def test_document
 
68
    msg = {'myversion' => "1.9", 'date' => "2004-01-01T00:00:00Z"}
 
69
    reply_msg = @client.submit(msg)
 
70
    assert_equal('1.9', reply_msg.myversion)
 
71
    assert_equal('1.9', reply_msg['myversion'])
 
72
    assert_equal('2004-01-01T00:00:00Z', reply_msg.date)
 
73
    assert_equal('2004-01-01T00:00:00Z', reply_msg['date'])
 
74
  end
 
75
end
 
76
 
 
77
 
 
78
end