Sha256: 7f85930de03a3ea00b4aa79314b167ca9c0903792ad773033fae98df32f5c3ae

Contents?: true

Size: 1.95 KB

Versions: 15

Compression:

Stored size: 1.95 KB

Contents

# encoding: ASCII-8BIT
require 'helper'
require 'soap/rpc/standaloneServer'
require 'soap/rpc/driver'

if defined?(HTTPClient)

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 if @server
    if @t
      @t.kill
      @t.join
    end
    @client.reset_stream if @client
  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_xml_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_xml_equal(NO_INDENT_XML, parse_requestxml(str))
  end

  def parse_requestxml(str)
    str.split(/\r?\n\r?\n/)[3]
  end
end


end

end

Version data entries

15 entries across 15 versions & 9 rubygems

Version Path
malagant-soap4r-1.5.8.20141127181857 test/soap/test_no_indent.rb
rtiss_soap4r-1.6.1 test/soap/test_no_indent.rb
rtiss_soap4r-1.6.0 test/soap/test_no_indent.rb
eSpace_soap4r-1.5.8 test/soap/test_no_indent.rb
soap4r-ruby19-1.5.9 test/soap/test_no_indent.rb
tomdz-soap4r-1.5.8.20120202093209 test/soap/test_no_indent.rb
soap5r-2.0.3 test/soap/test_no_indent.rb
soap5r-2.0.2 test/soap/test_no_indent.rb
soap5r-2.0.1 test/soap/test_no_indent.rb
soap5r-2.0.0 test/soap/test_no_indent.rb
soap5r-2.0.0.20120130130121 test/soap/test_no_indent.rb
soap4r-sgonyea-1.5.9 test/soap/test_no_indent.rb
sunteya-soap4r-1.5.8.0 test/soap/test_no_indent.rb
tomdz-soap4r-1.5.8.20111103171510 test/soap/test_no_indent.rb
rubyjedi-soap4r-1.5.8.20100619003610 test/soap/test_no_indent.rb