Sha256: a1afdf26b7516aa13b5fa6c460dad0d18a06ce27c8ac3b81c3d7d7241364d6c9

Contents?: true

Size: 1.57 KB

Versions: 15

Compression:

Stored size: 1.57 KB

Contents

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


module SOAP
module SWA


class TestFile < Test::Unit::TestCase
  Port = 17171
  THIS_FILE = File.expand_path(__FILE__)

  class SwAService
    def get_file
      return {
     	'name' => $0,
	'file' => SOAP::Attachment.new(File.open(THIS_FILE)) # closed when GCed.
      }
    end
  
    def put_file(name, file)
      "File '#{name}' was received ok."
    end
  end

  def setup
    @server = SOAP::RPC::StandaloneServer.new('SwAServer',
      'http://www.acmetron.com/soap', '0.0.0.0', Port)
    @server.add_servant(SwAService.new)
    @server.level = Logger::Severity::ERROR
    @t = Thread.new {
      @server.start
    }
    @endpoint = "http://localhost:#{Port}/"
    @client = SOAP::RPC::Driver.new(@endpoint, 'http://www.acmetron.com/soap')
    @client.add_method('get_file')
    @client.add_method('put_file', 'name', 'file')
    @client.wiredump_dev = STDERR if $DEBUG
  end

  def teardown
    @server.shutdown if @server
    if @t
      @t.kill
      @t.join
    end
    @client.reset_stream if @client
  end

  def test_get_file
    assert_equal(
      File.open(THIS_FILE) { |f| f.read },
      @client.get_file['file'].content
    )
  end

  def test_put_file
    assert_equal(
      "File 'foo' was received ok.",
      @client.put_file('foo',
	SOAP::Attachment.new(File.open(THIS_FILE)))
    )
    assert_equal(
      "File 'bar' was received ok.",
      @client.put_file('bar',
	SOAP::Attachment.new(File.open(THIS_FILE) { |f| f.read }))
    )
  end
end


end
end

Version data entries

15 entries across 15 versions & 9 rubygems

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