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

Changeset 1933

Show
Ignore:
Timestamp:
09/02/07 01:09:30 (10 months ago)
Author:
nahi
Message:
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/test/wsdl/raa/RAAService.rb

    r1694 r1933  
    11#!/usr/bin/env ruby 
    2 require 'RAAServant.rb
     2require 'soap/rpc/standaloneServer
    33 
    4 require 'soap/rpc/standaloneServer' 
    5 require 'soap/mapping/registry' 
     4module WSDL; module RAA 
    65 
    7 class RAABaseServicePortType 
    8   MappingRegistry = ::SOAP::Mapping::Registry.new 
     6class RAABaseServicePortTypeServer 
     7  def getAllListings 
     8    ["ruby", "soap4r"] 
     9  end 
    910 
    10   MappingRegistry.set( 
    11     StringArray, 
    12     ::SOAP::SOAPArray, 
    13     ::SOAP::Mapping::Registry::TypedArrayFactory, 
    14     { :type => XSD::QName.new("http://www.w3.org/2001/XMLSchema", "string") } 
    15   ) 
    16   MappingRegistry.set( 
    17     Category, 
    18     ::SOAP::SOAPStruct, 
    19     ::SOAP::Mapping::Registry::TypedStructFactory, 
    20     { :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Category") } 
    21   ) 
    22   MappingRegistry.set( 
    23     InfoArray, 
    24     ::SOAP::SOAPArray, 
    25     ::SOAP::Mapping::Registry::TypedArrayFactory, 
    26     { :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info") } 
    27   ) 
    28   MappingRegistry.set( 
    29     Info, 
    30     ::SOAP::SOAPStruct, 
    31     ::SOAP::Mapping::Registry::TypedStructFactory, 
    32     { :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info") } 
    33   ) 
    34   MappingRegistry.set( 
    35     Product, 
    36     ::SOAP::SOAPStruct, 
    37     ::SOAP::Mapping::Registry::TypedStructFactory, 
    38     { :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Product") } 
    39   ) 
    40   MappingRegistry.set( 
    41     Owner, 
    42     ::SOAP::SOAPStruct, 
    43     ::SOAP::Mapping::Registry::TypedStructFactory, 
    44     { :type => XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Owner") } 
    45   ) 
     11  def getProductTree 
     12    raise NotImplementedError.new 
     13  end 
     14   
     15  def getInfoFromCategory(category) 
     16    raise NotImplementedError.new 
     17  end 
     18   
     19  def getModifiedInfoSince(timeInstant) 
     20    raise NotImplementedError.new 
     21  end 
     22   
     23  def getInfoFromName(productName) 
     24    Info.new( 
     25      Category.new("major", "minor"),  
     26      Product.new(123, productName, "short description", "version", "status", 
     27        URI.parse("http://example.com/homepage"), 
     28        URI.parse("http://example.com/download"), 
     29        "license", "description"), 
     30      Owner.new(456, URI.parse("mailto:email@example.com"), "name"), 
     31      Time.now, 
     32      Time.now) 
     33  end 
     34   
     35  def getInfoFromOwnerId(ownerId) 
     36    raise NotImplementedError.new 
     37  end 
    4638 
    4739  Methods = [ 
     
    4941      "", 
    5042      "getAllListings", 
    51       [ ["retval", "return", ["String[]", "http://www.w3.org/2001/XMLSchema", "string"]] ], 
     43      [ ["retval", "return", ["WSDL::RAA::C_String[]", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "StringArray"]] ], 
    5244      { :request_style =>  :rpc, :request_use =>  :encoded, 
    53         :response_style => :rpc, :response_use => :encoded } 
     45        :response_style => :rpc, :response_use => :encoded, 
     46        :faults => {} } 
    5447    ], 
    5548    [ XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "getProductTree"), 
     
    5851      [ ["retval", "return", ["Hash", "http://xml.apache.org/xml-soap", "Map"]] ], 
    5952      { :request_style =>  :rpc, :request_use =>  :encoded, 
    60         :response_style => :rpc, :response_use => :encoded } 
     53        :response_style => :rpc, :response_use => :encoded, 
     54        :faults => {} } 
    6155    ], 
    6256    [ XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "getInfoFromCategory"), 
    6357      "", 
    6458      "getInfoFromCategory", 
    65       [ ["in", "category", ["Category", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Category"]], 
    66         ["retval", "return", ["Info[]", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info"]] ], 
     59      [ ["in", "category", ["WSDL::RAA::Category", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Category"]], 
     60        ["retval", "return", ["WSDL::RAA::Info[]", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "InfoArray"]] ], 
    6761      { :request_style =>  :rpc, :request_use =>  :encoded, 
    68         :response_style => :rpc, :response_use => :encoded } 
     62        :response_style => :rpc, :response_use => :encoded, 
     63        :faults => {} } 
    6964    ], 
    7065    [ XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "getModifiedInfoSince"), 
     
    7267      "getModifiedInfoSince", 
    7368      [ ["in", "timeInstant", ["::SOAP::SOAPDateTime"]], 
    74         ["retval", "return", ["Info[]", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info"]] ], 
     69        ["retval", "return", ["WSDL::RAA::Info[]", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "InfoArray"]] ], 
    7570      { :request_style =>  :rpc, :request_use =>  :encoded, 
    76         :response_style => :rpc, :response_use => :encoded } 
     71        :response_style => :rpc, :response_use => :encoded, 
     72        :faults => {} } 
    7773    ], 
    7874    [ XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "getInfoFromName"), 
     
    8076      "getInfoFromName", 
    8177      [ ["in", "productName", ["::SOAP::SOAPString"]], 
    82         ["retval", "return", ["Info", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info"]] ], 
     78        ["retval", "return", ["WSDL::RAA::Info", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info"]] ], 
    8379      { :request_style =>  :rpc, :request_use =>  :encoded, 
    84         :response_style => :rpc, :response_use => :encoded } 
     80        :response_style => :rpc, :response_use => :encoded, 
     81        :faults => {} } 
    8582    ], 
    8683    [ XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "getInfoFromOwnerId"), 
     
    8885      "getInfoFromOwnerId", 
    8986      [ ["in", "ownerId", ["::SOAP::SOAPInt"]], 
    90         ["retval", "return", ["Info[]", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "Info"]] ], 
     87        ["retval", "return", ["WSDL::RAA::Info[]", "http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "InfoArray"]] ], 
    9188      { :request_style =>  :rpc, :request_use =>  :encoded, 
    92         :response_style => :rpc, :response_use => :encoded } 
     89        :response_style => :rpc, :response_use => :encoded, 
     90        :faults => {} } 
    9391    ] 
    9492  ] 
    9593end 
    9694 
     95end; end 
     96 
     97module WSDL; module RAA 
     98 
    9799class RAABaseServicePortTypeApp < ::SOAP::RPC::StandaloneServer 
    98100  def initialize(*arg) 
    99101    super(*arg) 
    100     servant = RAABaseServicePortType.new 
    101     RAABaseServicePortType::Methods.each do |definitions| 
     102    servant = WSDL::RAA::RAABaseServicePortTypeServer.new 
     103    WSDL::RAA::RAABaseServicePortType::Methods.each do |definitions| 
    102104      opt = definitions.last 
    103105      if opt[:request_style] == :document 
     
    107109      end 
    108110    end 
    109     self.mapping_registry = RAABaseServicePortType::MappingRegistry 
     111    self.mapping_registry = RAAMappingRegistry::EncodedRegistry 
     112    self.literal_mapping_registry = RAAMappingRegistry::LiteralRegistry 
    110113  end 
    111114end 
    112115 
     116end; end 
     117 
    113118if $0 == __FILE__ 
    114119  # Change listen port. 
    115   server = RAABaseServicePortTypeApp.new('app', nil, '0.0.0.0', 10080) 
     120  server = WSDL::RAA::RAABaseServicePortTypeApp.new('app', nil, '0.0.0.0', 10080) 
    116121  trap(:INT) do 
    117122    server.shutdown 
  • trunk/test/wsdl/raa/test_raa.rb

    r1694 r1933  
    11require 'test/unit' 
    22require 'soap/wsdlDriver' 
    3 require 'RAA.rb' 
    4 require 'RAAServant.rb' 
    5 require 'RAAService.rb' 
     3require 'wsdl/soap/wsdl2ruby' 
     4require File.join(File.dirname(File.expand_path(__FILE__)), '..', '..', 'testutil.rb') 
    65 
    76 
     
    1615 
    1716  def setup 
     17    setup_stub 
    1818    setup_server 
    1919    setup_client 
    2020  end 
    2121 
     22  def setup_stub 
     23    gen = WSDL::SOAP::WSDL2Ruby.new 
     24    gen.location = pathname("raa.wsdl") 
     25    gen.basedir = DIR 
     26    gen.logger.level = Logger::FATAL 
     27    gen.opt['module_path'] = self.class.to_s.sub(/::[^:]+$/, '') 
     28    gen.opt['classdef'] = nil 
     29    gen.opt['mapping_registry'] = nil 
     30    gen.opt['driver'] = nil 
     31    gen.opt['force'] = true 
     32    gen.run 
     33    TestUtil.require(DIR, 'RAADriver.rb', 'RAAMappingRegistry.rb', 'RAA.rb') 
     34  end 
     35 
    2236  def setup_server 
     37    require pathname('RAAService.rb') 
    2338    @server = RAABaseServicePortTypeApp.new('RAA server', nil, '0.0.0.0', Port) 
    2439    @server.level = Logger::Severity::ERROR 
     
    3348    @raa = ::SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver 
    3449    @raa.endpoint_url = "http://localhost:#{Port}/" 
     50    @raa.wiredump_dev = STDOUT if $DEBUG 
     51    @raa.mapping_registry = RAAMappingRegistry::EncodedRegistry 
     52    @raa.literal_mapping_registry = RAAMappingRegistry::LiteralRegistry 
    3553  end 
    3654 
     
    3856    teardown_server 
    3957    teardown_client 
     58    unless $DEBUG 
     59      File.unlink(pathname('RAA.rb')) 
     60      File.unlink(pathname('RAAMappingRegistry.rb')) 
     61      File.unlink(pathname('RAADriver.rb')) 
     62    end 
    4063  end 
    4164 
     
    5073  end 
    5174 
     75  def test_stubgeneration 
     76    compare("expectedClassDef.rb", "RAA.rb") 
     77    compare("expectedMappingRegistry.rb", "RAAMappingRegistry.rb") 
     78    compare("expectedDriver.rb", "RAADriver.rb") 
     79  end 
     80 
    5281  def test_raa 
    53     assert_equal(["ruby", "soap4r"], @raa.getAllListings) 
     82    do_test_raa(@raa) 
     83  end 
    5484 
    55     info = @raa.getInfoFromName("SOAP4R") 
    56     assert_equal(::Info, info.class) 
    57     assert_equal(::Category, info.category.class) 
    58     assert_equal(::Product, info.product.class) 
    59     assert_equal(::Owner, info.owner.class) 
     85  def test_stub 
     86    client = RAABaseServicePortType.new("http://localhost:#{Port}/") 
     87    do_test_raa(client) 
     88  end 
     89 
     90  def do_test_raa(client) 
     91    assert_equal(["ruby", "soap4r"], client.getAllListings) 
     92    info = client.getInfoFromName("SOAP4R") 
     93    assert_equal(Info, info.class) 
     94    assert_equal(Category, info.category.class) 
     95    assert_equal(Product, info.product.class) 
     96    assert_equal(Owner, info.owner.class) 
    6097    assert_equal("major", info.category.major) 
    6198    assert_equal("minor", info.category.minor) 
     
    76113  end 
    77114 
    78   def foo 
    79     p @raa.getInfoFromCategory(Category.new("Library", "XML")) 
    80     t = Time.at(Time.now.to_i - 24 * 3600) 
    81     p @raa.getModifiedInfoSince(t) 
    82     p @raa.getModifiedInfoSince(DateTime.new(t.year, t.mon, t.mday, t.hour, t.min, t.sec)) 
    83     p o.type 
    84     p o.owner.name 
    85     p o 
     115  def compare(expected, actual) 
     116    TestUtil.filecompare(pathname(expected), pathname(actual)) 
     117  end 
     118 
     119  def pathname(filename) 
     120    File.join(DIR, filename) 
    86121  end 
    87122end