summaryrefslogtreecommitdiff
path: root/ruby_1_8_5/test/wsdl/map/test_map.rb
blob: 68f7d76e05c78a2a6298985c5b724d41f7b6f642 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
require 'test/unit'
require 'soap/rpc/httpserver'
require 'soap/wsdlDriver'


module WSDL


class TestMap < Test::Unit::TestCase
  Port = 17171
  DIR = File.dirname(File.expand_path(__FILE__))

  class Server < ::SOAP::RPC::HTTPServer
    def on_init
      add_method(self, 'map')
      add_method(self, 'map2', 'arg')
    end

    def map
      {1 => "a", 2 => "b"}
    end

    def map2(arg)
      arg
    end
  end

  def setup
    setup_server
    setup_client
  end

  def setup_server
    @server = Server.new(
      :BindAddress => "0.0.0.0",
      :Port => Port,
      :AccessLog => [],
      :SOAPDefaultNamespace => "urn:map"
    )
    @server.level = Logger::Severity::ERROR
    @t = Thread.new {
      Thread.current.abort_on_exception = true
      @server.start
    }
  end

  def setup_client
    wsdl = File.join(DIR, 'map.wsdl')
    @client = ::SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
    @client.endpoint_url = "http://localhost:#{Port}/"
    @client.generate_explicit_type = true
    @client.wiredump_dev = STDOUT if $DEBUG
  end

  def teardown
    teardown_server
    teardown_client
  end

  def teardown_server
    @server.shutdown
    @t.kill
    @t.join
  end

  def teardown_client
    @client.reset_stream
  end

  def test_by_wsdl
    dir = File.dirname(File.expand_path(__FILE__))
    wsdlfile = File.join(dir, 'map.wsdl')
    xml = File.open(File.join(dir, 'map.xml')) { |f| f.read }
    wsdl = WSDL::Importer.import(wsdlfile)
    service = wsdl.services[0]
    port = service.ports[0]
    wsdl_types = wsdl.collect_complextypes
    rpc_decode_typemap = wsdl_types + wsdl.soap_rpc_complextypes(port.find_binding)
    opt = {}
    opt[:default_encodingstyle] = ::SOAP::EncodingNamespace
    opt[:decode_typemap] = rpc_decode_typemap
    header, body = ::SOAP::Processor.unmarshal(xml, opt)
    map = ::SOAP::Mapping.soap2obj(body.response)
    assert_equal(["a1"], map["a"]["a1"])
    assert_equal(["a2"], map["a"]["a2"])
    assert_equal(["b1"], map["b"]["b1"])
    assert_equal(["b2"], map["b"]["b2"])
  end

  def test_wsdldriver
    assert_equal({1 => "a", 2 => "b"}, @client.map)
    assert_equal({1 => 2}, @client.map2({1 => 2}))
    assert_equal({1 => {2 => 3}}, @client.map2({1 => {2 => 3}}))
    assert_equal({["a", 2] => {2 => 3}}, @client.map2({["a", 2] => {2 => 3}}))
  end
end


end
id=44cb6eaef9b189a48d78a0090da78d48e2196fb5'> * vm_dump.c (rb_vmdebug_debug_print_pre): Bugfix. Get PC directly.tarui 2013-11-18vm_core.h: extract VM_STACK_OVERFLOWED_Pnobu 2013-07-26vm_exec.h: fix CHECK_VM_STACK_OVERFLOW_FOR_INSNnobu 2013-07-26* vm_exec.h, tool/instruction.rb: not an error, but a BUG if stackko1 2013-04-22fix minor code comment typostmm1 2013-03-18* vm_exec.h (END_INSN): revert r39517 because the segv seems fixed bynaruse 2013-02-27* vm_exec.h (END_INSN): llvm-gcc may optimize out reg_cfp and causenaruse 2013-02-10vm_exec.h: fix typonobu 2013-02-10* vm_exec.h (DISPATCH_ARCH_DEPEND_WAY): use __asm__ __vilatile__kosaki 2012-12-29adjust stylenobu 2012-11-15* vm_exec.h (GENTRY): GENTRY should be pointer size.ko1 2012-10-04* insns.def (getlocal, setlocal): remove old getlocal/setlocalko1 2012-10-04* vm.c (VM_COLLECT_USAGE_DETAILS): make new VM usage analysisko1 2012-07-25Suppress warnings.naruse 2012-06-11* vm_core.h: remove lfp (local frame pointer) and renameko1 2011-01-23* vm_exec.h: parenthesize macro arguments.akr 2010-10-12* configure.in (RUBY_CHECK_PRINTF_PREFIX): check for printf formatnobu 2010-07-27* class.c, compile.c, dir.c, file.c, iseq.c, parse.y, random.c:naruse 2010-01-05removes the dtrace support. reverts r26239, r26238 and r26235.yugui 2010-01-03* trace.h: new file. wraps tracing mechanisms.yugui 2009-01-19* vm_dump.c: add a prefix "rb_vmdebug_" toko1 2008-11-19* vm_exec.h (RUBY_VM_EXEC_H): fixed include guard.nobu 2008-09-23* common.mk: clean upko1