blob: f49fb7389fa5075253fa01c22d3a23a0efb2ff53 (
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
|
require 'test/unit'
require 'soap/rpc/standaloneServer'
require 'soap/rpc/driver'
if defined?(HTTPAccess2)
module SOAP
class TestNoIndent < Test::Unit::TestCase
Port = 17171
class NopServer < SOAP::RPC::StandaloneServer
def initialize(*arg)
super
add_rpc_method(self, 'nop')
end
def nop
SOAP::RPC::SOAPVoid.new
end
end
def setup
@server = NopServer.new(self.class.name, nil, '0.0.0.0', Port)
@server.level = Logger::Severity::ERROR
@t = Thread.new {
@server.start
}
@endpoint = "http://localhost:#{Port}/"
@client = SOAP::RPC::Driver.new(@endpoint)
@client.add_rpc_method('nop')
end
def teardown
@server.shutdown
@t.kill
@t.join
@client.reset_stream
end
INDENT_XML =
%q[<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Body>
<nop env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
</nop>
</env:Body>
</env:Envelope>]
NO_INDENT_XML =
%q[<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Body>
<nop env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
</nop>
</env:Body>
</env:Envelope>]
def test_indent
@client.wiredump_dev = str = ''
@client.options["soap.envelope.no_indent"] = false
@client.nop
assert_equal(INDENT_XML, parse_requestxml(str))
end
def test_no_indent
@client.wiredump_dev = str = ''
@client.options["soap.envelope.no_indent"] = true
@client.nop
assert_equal(NO_INDENT_XML, parse_requestxml(str))
end
def parse_requestxml(str)
str.split(/\r?\n\r?\n/)[3]
end
end
end
end
|