Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

root/trunk/test/wsdl/oneway/test_oneway.rb

Revision 2006, 2.8 kB (checked in by nahi, 1 year ago)
  • update tests for the previous change ('in' -> :in)
Line 
1 require 'test/unit'
2 require 'soap/rpc/standaloneServer'
3 require 'wsdl/soap/wsdl2ruby'
4 require 'soap/wsdlDriver'
5 require File.join(File.dirname(File.expand_path(__FILE__)), '..', '..', 'testutil.rb')
6
7
8 module WSDL
9 module Oneway
10
11
12 class TestOneway < Test::Unit::TestCase
13   NS = 'http://www.example.com/oneway'
14   class Server < ::SOAP::RPC::StandaloneServer
15     Methods = [
16       [ "initiate",
17         "initiate",
18         [ [:in, "payload", ["::SOAP::SOAPElement", "http://www.example.com/oneway", "onewayProcessRequest"]] ],
19         { :request_style =>  :document, :request_use =>  :literal,
20           :response_style => :document, :response_use => nil,
21           :faults => {} }
22       ]
23     ]
24
25     def on_init
26       Methods.each do |definition|
27         add_document_operation(self, *definition)
28       end
29       self.mapping_registry = OnewayMappingRegistry::EncodedRegistry
30       self.literal_mapping_registry = OnewayMappingRegistry::LiteralRegistry
31     end
32  
33     def initiate(payload)
34       raise unless payload.msg
35     end
36   end
37
38   DIR = File.dirname(File.expand_path(__FILE__))
39
40   Port = 17171
41
42   def setup
43     setup_classdef
44     setup_server
45     @client = nil
46   end
47
48   def teardown
49     teardown_server if @server
50     unless $DEBUG
51       File.unlink(pathname('oneway.rb'))
52       File.unlink(pathname('onewayMappingRegistry.rb'))
53       File.unlink(pathname('onewayDriver.rb'))
54     end
55     @client.reset_stream if @client
56   end
57
58   def setup_server
59     @server = Server.new('Test', "http://www.example.com/oneway", '0.0.0.0', Port)
60     @server.level = Logger::Severity::ERROR
61     @server_thread = TestUtil.start_server_thread(@server)
62   end
63
64   def setup_classdef
65     gen = WSDL::SOAP::WSDL2Ruby.new
66     gen.location = pathname("oneway.wsdl")
67     gen.basedir = DIR
68     gen.logger.level = Logger::FATAL
69     gen.opt['classdef'] = nil
70     gen.opt['mapping_registry'] = nil
71     gen.opt['driver'] = nil
72     gen.opt['force'] = true
73     gen.opt['module_path'] = 'WSDL::Oneway'
74     gen.run
75     TestUtil.require(DIR, 'oneway.rb', 'onewayDriver.rb', 'onewayMappingRegistry.rb')
76   end
77
78   def teardown_server
79     @server.shutdown
80     @server_thread.kill
81     @server_thread.join
82   end
83
84   def pathname(filename)
85     File.join(DIR, filename)
86   end
87
88   def test_stub
89     @client = OnewayPort.new("http://localhost:#{Port}/")
90     @client.wiredump_dev = STDERR if $DEBUG
91     # not raised
92     @client.initiate(OnewayProcessRequest.new("msg"))
93     @client.initiate(OnewayProcessRequest.new(nil))
94   end
95
96   def test_wsdl
97     @client = ::SOAP::WSDLDriverFactory.new(pathname('oneway.wsdl')).create_rpc_driver
98     @client.endpoint_url = "http://localhost:#{Port}/"
99     @client.wiredump_dev = STDERR if $DEBUG
100     # not raised
101     @client.initiate(OnewayProcessRequest.new("msg"))
102     @client.initiate(OnewayProcessRequest.new(nil))
103   end
104 end
105
106
107 end
108 end
Note: See TracBrowser for help on using the browser.