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

« back to all changes in this revision

Viewing changes to test/soap/test_no_indent.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/standaloneServer'
3
 
require 'soap/rpc/driver'
4
 
 
5
 
if defined?(HTTPAccess2)
6
 
 
7
 
module SOAP
8
 
 
9
 
 
10
 
class TestNoIndent < Test::Unit::TestCase
11
 
  Port = 17171
12
 
 
13
 
  class NopServer < SOAP::RPC::StandaloneServer
14
 
    def initialize(*arg)
15
 
      super
16
 
      add_rpc_method(self, 'nop')
17
 
    end
18
 
 
19
 
    def nop
20
 
      SOAP::RPC::SOAPVoid.new
21
 
    end
22
 
  end
23
 
 
24
 
  def setup
25
 
    @server = NopServer.new(self.class.name, nil, '0.0.0.0', Port)
26
 
    @server.level = Logger::Severity::ERROR
27
 
    @t = Thread.new {
28
 
      @server.start
29
 
    }
30
 
    @endpoint = "http://localhost:#{Port}/"
31
 
    @client = SOAP::RPC::Driver.new(@endpoint)
32
 
    @client.add_rpc_method('nop')
33
 
  end
34
 
 
35
 
  def teardown
36
 
    @server.shutdown
37
 
    @t.kill
38
 
    @t.join
39
 
    @client.reset_stream
40
 
  end
41
 
 
42
 
  INDENT_XML =
43
 
%q[<?xml version="1.0" encoding="utf-8" ?>
44
 
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
45
 
    xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
46
 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
47
 
  <env:Body>
48
 
    <nop env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
49
 
    </nop>
50
 
  </env:Body>
51
 
</env:Envelope>]
52
 
 
53
 
  NO_INDENT_XML =
54
 
%q[<?xml version="1.0" encoding="utf-8" ?>
55
 
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
56
 
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
57
 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
58
 
<env:Body>
59
 
<nop env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
60
 
</nop>
61
 
</env:Body>
62
 
</env:Envelope>]
63
 
 
64
 
  def test_indent
65
 
    @client.wiredump_dev = str = ''
66
 
    @client.options["soap.envelope.no_indent"] = false
67
 
    @client.nop
68
 
    assert_equal(INDENT_XML, parse_requestxml(str))
69
 
  end
70
 
 
71
 
  def test_no_indent
72
 
    @client.wiredump_dev = str = ''
73
 
    @client.options["soap.envelope.no_indent"] = true
74
 
    @client.nop
75
 
    assert_equal(NO_INDENT_XML, parse_requestxml(str))
76
 
  end
77
 
 
78
 
  def parse_requestxml(str)
79
 
    str.split(/\r?\n\r?\n/)[3]
80
 
  end
81
 
end
82
 
 
83
 
 
84
 
end
85
 
 
86
 
end