Changeset 1933
- Timestamp:
- 09/02/07 01:09:30 (10 months ago)
- Files:
-
- trunk/test/wsdl/raa/RAAServant.rb (deleted)
- trunk/test/wsdl/raa/RAAService.rb (modified) (7 diffs)
- trunk/test/wsdl/raa/expectedClassDef.rb (added)
- trunk/test/wsdl/raa/expectedDriver.rb (added)
- trunk/test/wsdl/raa/expectedMappingRegistry.rb (added)
- trunk/test/wsdl/raa/server.rb (deleted)
- trunk/test/wsdl/raa/test_raa.rb (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/test/wsdl/raa/RAAService.rb
r1694 r1933 1 1 #!/usr/bin/env ruby 2 require ' RAAServant.rb'2 require 'soap/rpc/standaloneServer' 3 3 4 require 'soap/rpc/standaloneServer' 5 require 'soap/mapping/registry' 4 module WSDL; module RAA 6 5 7 class RAABaseServicePortType 8 MappingRegistry = ::SOAP::Mapping::Registry.new 6 class RAABaseServicePortTypeServer 7 def getAllListings 8 ["ruby", "soap4r"] 9 end 9 10 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 46 38 47 39 Methods = [ … … 49 41 "", 50 42 "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"]] ], 52 44 { :request_style => :rpc, :request_use => :encoded, 53 :response_style => :rpc, :response_use => :encoded } 45 :response_style => :rpc, :response_use => :encoded, 46 :faults => {} } 54 47 ], 55 48 [ XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "getProductTree"), … … 58 51 [ ["retval", "return", ["Hash", "http://xml.apache.org/xml-soap", "Map"]] ], 59 52 { :request_style => :rpc, :request_use => :encoded, 60 :response_style => :rpc, :response_use => :encoded } 53 :response_style => :rpc, :response_use => :encoded, 54 :faults => {} } 61 55 ], 62 56 [ XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "getInfoFromCategory"), 63 57 "", 64 58 "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"]] ], 67 61 { :request_style => :rpc, :request_use => :encoded, 68 :response_style => :rpc, :response_use => :encoded } 62 :response_style => :rpc, :response_use => :encoded, 63 :faults => {} } 69 64 ], 70 65 [ XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "getModifiedInfoSince"), … … 72 67 "getModifiedInfoSince", 73 68 [ ["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"]] ], 75 70 { :request_style => :rpc, :request_use => :encoded, 76 :response_style => :rpc, :response_use => :encoded } 71 :response_style => :rpc, :response_use => :encoded, 72 :faults => {} } 77 73 ], 78 74 [ XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "getInfoFromName"), … … 80 76 "getInfoFromName", 81 77 [ ["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"]] ], 83 79 { :request_style => :rpc, :request_use => :encoded, 84 :response_style => :rpc, :response_use => :encoded } 80 :response_style => :rpc, :response_use => :encoded, 81 :faults => {} } 85 82 ], 86 83 [ XSD::QName.new("http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/", "getInfoFromOwnerId"), … … 88 85 "getInfoFromOwnerId", 89 86 [ ["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"]] ], 91 88 { :request_style => :rpc, :request_use => :encoded, 92 :response_style => :rpc, :response_use => :encoded } 89 :response_style => :rpc, :response_use => :encoded, 90 :faults => {} } 93 91 ] 94 92 ] 95 93 end 96 94 95 end; end 96 97 module WSDL; module RAA 98 97 99 class RAABaseServicePortTypeApp < ::SOAP::RPC::StandaloneServer 98 100 def initialize(*arg) 99 101 super(*arg) 100 servant = RAABaseServicePortType.new101 RAABaseServicePortType::Methods.each do |definitions|102 servant = WSDL::RAA::RAABaseServicePortTypeServer.new 103 WSDL::RAA::RAABaseServicePortType::Methods.each do |definitions| 102 104 opt = definitions.last 103 105 if opt[:request_style] == :document … … 107 109 end 108 110 end 109 self.mapping_registry = RAABaseServicePortType::MappingRegistry 111 self.mapping_registry = RAAMappingRegistry::EncodedRegistry 112 self.literal_mapping_registry = RAAMappingRegistry::LiteralRegistry 110 113 end 111 114 end 112 115 116 end; end 117 113 118 if $0 == __FILE__ 114 119 # 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) 116 121 trap(:INT) do 117 122 server.shutdown trunk/test/wsdl/raa/test_raa.rb
r1694 r1933 1 1 require 'test/unit' 2 2 require 'soap/wsdlDriver' 3 require 'RAA.rb' 4 require 'RAAServant.rb' 5 require 'RAAService.rb' 3 require 'wsdl/soap/wsdl2ruby' 4 require File.join(File.dirname(File.expand_path(__FILE__)), '..', '..', 'testutil.rb') 6 5 7 6 … … 16 15 17 16 def setup 17 setup_stub 18 18 setup_server 19 19 setup_client 20 20 end 21 21 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 22 36 def setup_server 37 require pathname('RAAService.rb') 23 38 @server = RAABaseServicePortTypeApp.new('RAA server', nil, '0.0.0.0', Port) 24 39 @server.level = Logger::Severity::ERROR … … 33 48 @raa = ::SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver 34 49 @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 35 53 end 36 54 … … 38 56 teardown_server 39 57 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 40 63 end 41 64 … … 50 73 end 51 74 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 52 81 def test_raa 53 assert_equal(["ruby", "soap4r"], @raa.getAllListings) 82 do_test_raa(@raa) 83 end 54 84 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) 60 97 assert_equal("major", info.category.major) 61 98 assert_equal("minor", info.category.minor) … … 76 113 end 77 114 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) 86 121 end 87 122 end