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

« back to all changes in this revision

Viewing changes to test/wsdl/document/test_nosoapaction.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 'wsdl/parser'
3
 
require 'wsdl/soap/wsdl2ruby'
4
 
require 'soap/rpc/standaloneServer'
5
 
require 'soap/wsdlDriver'
6
 
require 'soap/rpc/driver'
7
 
 
8
 
 
9
 
module WSDL; module Document
10
 
 
11
 
 
12
 
class TestNoSOAPAction < Test::Unit::TestCase
13
 
  class Server < ::SOAP::RPC::StandaloneServer
14
 
    Namespace = 'http://xmlsoap.org/Ping'
15
 
 
16
 
    def on_init
17
 
      add_document_method(
18
 
        self,
19
 
        Namespace + '/ping',
20
 
        'ping_with_soapaction',
21
 
        XSD::QName.new(Namespace, 'Ping'),
22
 
        XSD::QName.new(Namespace, 'PingResponse')
23
 
      )
24
 
 
25
 
      add_document_method(
26
 
        self,
27
 
        nil,
28
 
        'ping',
29
 
        XSD::QName.new(Namespace, 'Ping'),
30
 
        XSD::QName.new(Namespace, 'PingResponse')
31
 
      )
32
 
 
33
 
      # When no SOAPAction given, latter method(ping) is called.
34
 
    end
35
 
  
36
 
    def ping(arg)
37
 
      arg.text = 'ping'
38
 
      arg
39
 
    end
40
 
  
41
 
    def ping_with_soapaction(arg)
42
 
      arg.text = 'ping_with_soapaction'
43
 
      arg
44
 
    end
45
 
  end
46
 
 
47
 
  DIR = File.dirname(File.expand_path(__FILE__))
48
 
 
49
 
  Port = 17171
50
 
 
51
 
  def setup
52
 
    setup_server
53
 
    @client = nil
54
 
  end
55
 
 
56
 
  def teardown
57
 
    teardown_server
58
 
    @client.reset_stream if @client
59
 
  end
60
 
 
61
 
  def setup_server
62
 
    @server = Server.new('Test', Server::Namespace, '0.0.0.0', Port)
63
 
    @server.level = Logger::Severity::ERROR
64
 
    @server_thread = start_server_thread(@server)
65
 
  end
66
 
 
67
 
  def teardown_server
68
 
    @server.shutdown
69
 
    @server_thread.kill
70
 
    @server_thread.join
71
 
  end
72
 
 
73
 
  def start_server_thread(server)
74
 
    t = Thread.new {
75
 
      Thread.current.abort_on_exception = true
76
 
      server.start
77
 
    }
78
 
    t
79
 
  end
80
 
 
81
 
  def test_with_soapaction
82
 
    wsdl = File.join(DIR, 'ping_nosoapaction.wsdl')
83
 
    @client = ::SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
84
 
    @client.endpoint_url = "http://localhost:#{Port}/"
85
 
    @client.wiredump_dev = STDOUT if $DEBUG
86
 
    rv = @client.ping(:scenario => 'scenario', :origin => 'origin',
87
 
      :text => 'text')
88
 
    assert_equal('scenario', rv.scenario)
89
 
    assert_equal('origin', rv.origin)
90
 
    assert_equal('ping', rv.text)
91
 
  end
92
 
 
93
 
  def test_without_soapaction
94
 
    @client = ::SOAP::RPC::Driver.new("http://localhost:#{Port}/",
95
 
      Server::Namespace)
96
 
    @client.add_document_method('ping', Server::Namespace + '/ping',
97
 
      XSD::QName.new(Server::Namespace, 'Ping'),
98
 
      XSD::QName.new(Server::Namespace, 'PingResponse'))
99
 
    @client.wiredump_dev = STDOUT if $DEBUG
100
 
    rv = @client.ping(:scenario => 'scenario', :origin => 'origin',
101
 
      :text => 'text')
102
 
    assert_equal('scenario', rv.scenario)
103
 
    assert_equal('origin', rv.origin)
104
 
    assert_equal('ping_with_soapaction', rv.text)
105
 
  end
106
 
end
107
 
 
108
 
 
109
 
end; end