diff options
Diffstat (limited to 'test/wsdl/datetime')
-rw-r--r-- | test/wsdl/datetime/DatetimeService.rb | 38 | ||||
-rw-r--r-- | test/wsdl/datetime/datetime.rb | 0 | ||||
-rw-r--r-- | test/wsdl/datetime/datetime.wsdl | 45 | ||||
-rw-r--r-- | test/wsdl/datetime/datetimeServant.rb | 21 | ||||
-rw-r--r-- | test/wsdl/datetime/test_datetime.rb | 81 |
5 files changed, 185 insertions, 0 deletions
diff --git a/test/wsdl/datetime/DatetimeService.rb b/test/wsdl/datetime/DatetimeService.rb new file mode 100644 index 0000000000..91c006005d --- /dev/null +++ b/test/wsdl/datetime/DatetimeService.rb @@ -0,0 +1,38 @@ +#!/usr/bin/env ruby +require 'datetimeServant.rb' + +require 'soap/rpc/standaloneServer' + +class DatetimePortType + MappingRegistry = SOAP::Mapping::Registry.new + + # No mapping definition + + Methods = [ + ["now", "now", [ + ["in", "now", + [SOAP::SOAPDateTime]], + ["retval", "now", + [SOAP::SOAPDateTime]]], "", "urn:jp.gr.jin.rrr.example.datetime"] + ] +end + +class DatetimePortTypeApp < SOAP::RPC::StandaloneServer + def initialize(*arg) + super + + servant = DatetimePortType.new + DatetimePortType::Methods.each do |name_as, name, params, soapaction, namespace| + qname = XSD::QName.new(namespace, name_as) + @soaplet.app_scope_router.add_method(servant, qname, soapaction, + name, params) + end + + self.mapping_registry = DatetimePortType::MappingRegistry + end +end + +# Change listen port. +if $0 == __FILE__ + DatetimePortTypeApp.new('app', nil, '0.0.0.0', 10080).start +end diff --git a/test/wsdl/datetime/datetime.rb b/test/wsdl/datetime/datetime.rb new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/wsdl/datetime/datetime.rb diff --git a/test/wsdl/datetime/datetime.wsdl b/test/wsdl/datetime/datetime.wsdl new file mode 100644 index 0000000000..4998dc48d6 --- /dev/null +++ b/test/wsdl/datetime/datetime.wsdl @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8"?> +<wsdl:definitions name = "datetime" + targetNamespace="urn:jp.gr.jin.rrr.example.datetime" + xmlns:tns="urn:jp.gr.jin.rrr.example.datetime" + xmlns="http://schemas.xmlsoap.org/wsdl/" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" + xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + + <wsdl:message name="nowRequest"> + <wsdl:part name="now" type="xsd:dateTime"/> + </wsdl:message> + + <wsdl:message name="nowResponse"> + <wsdl:part name="now" type="xsd:dateTime"/> + </wsdl:message> + + <wsdl:portType name="DatetimePortType"> + <wsdl:operation name="now"> + <wsdl:input message="tns:nowRequest" name="nowRequest"/> + <wsdl:output message="tns:nowResponse" name="nowResponse"/> + </wsdl:operation> + </wsdl:portType> + + <wsdl:binding name="DatetimeBinding" type="tns:DatetimePortType"> + <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> + <wsdl:operation name="now"> + <soap:operation soapAction=""/> + <wsdl:input name="nowRequest"> + <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" + namespace="urn:jp.gr.jin.rrr.example.datetime" use="encoded"/> + </wsdl:input> + <wsdl:output name="nowResponse"> + <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" + namespace="urn:jp.gr.jin.rrr.example.datetime" use="encoded"/> + </wsdl:output> + </wsdl:operation> + </wsdl:binding> + + <wsdl:service name="DatetimeService"> + <wsdl:port binding="tns:DatetimeBinding" name="DatetimePort"> + <soap:address location="http://localhost:10080/"/> + </wsdl:port> + </wsdl:service> +</wsdl:definitions> diff --git a/test/wsdl/datetime/datetimeServant.rb b/test/wsdl/datetime/datetimeServant.rb new file mode 100644 index 0000000000..14145c42e5 --- /dev/null +++ b/test/wsdl/datetime/datetimeServant.rb @@ -0,0 +1,21 @@ +require 'datetime.rb' + +class DatetimePortType + # SYNOPSIS + # now(now) + # + # ARGS + # now - {http://www.w3.org/2001/XMLSchema}dateTime + # + # RETURNS + # now - {http://www.w3.org/2001/XMLSchema}dateTime + # + # RAISES + # (undefined) + # + def now(now) + #raise NotImplementedError.new + now + 1 + end +end + diff --git a/test/wsdl/datetime/test_datetime.rb b/test/wsdl/datetime/test_datetime.rb new file mode 100644 index 0000000000..a60d9b70a0 --- /dev/null +++ b/test/wsdl/datetime/test_datetime.rb @@ -0,0 +1,81 @@ +require 'test/unit' +require 'soap/wsdlDriver' + + +module WSDL +module Datetime + + +class TestDatetime < Test::Unit::TestCase + DIR = File.dirname(File.expand_path(__FILE__)) + + Port = 17171 + + def setup + setup_server + setup_client + end + + def setup_server + $:.push(DIR) + require File.join(DIR, 'DatetimeService.rb') + $:.delete(DIR) + @server = DatetimePortTypeApp.new('Datetime server', nil, '0.0.0.0', Port) + @server.level = Logger::Severity::ERROR + @t = Thread.new { + Thread.current.abort_on_exception = true + @server.start + } + while @server.server.nil? or @server.server.status != :Running + sleep 0.1 + unless @t.alive? + @t.join + raise + end + end + end + + def setup_client + wsdl = File.join(DIR, 'datetime.wsdl') + @client = ::SOAP::WSDLDriverFactory.new(wsdl).create_driver + @client.endpoint_url = "http://localhost:#{Port}/" + @client.generate_explicit_type = true + end + + def teardown + teardown_server + teardown_client + end + + def teardown_server + @server.server.shutdown + @t.kill + @t.join + end + + def teardown_client + @client.reset_stream + end + + def test_datetime + d = DateTime.now + assert_equal(d + 1, @client.now(d)) + end + + def test_time + d = DateTime.now + t = Time.gm(d.year, d.month, d.day, d.hour, d.min, d.sec) + d2 = d + 1 + t2 = @client.now(t) + assert_equal(d2.year, t2.year) + assert_equal(d2.month, t2.month) + assert_equal(d2.day, t2.day) + assert_equal(d2.hour, t2.hour) + assert_equal(d2.min, t2.min) + assert_equal(d2.sec, t2.sec) + end +end + + +end +end |