import SOAP-WSDL 2.00.07 from CPAN

git-cpan-module:   SOAP-WSDL
git-cpan-version:  2.00.07
git-cpan-authorid: MKUTTER
git-cpan-file:     authors/id/M/MK/MKUTTER/SOAP-WSDL-2.00.07.tar.gz
This commit is contained in:
Martin Kutter
2009-12-12 19:48:57 -08:00
committed by Michael G. Schwern
parent 3de318be40
commit bfc3247583
229 changed files with 16685 additions and 2064 deletions
+18 -3
View File
@@ -30,12 +30,27 @@ ok( $soap = SOAP::WSDL->new(
# which requires SOAP::Lite
$soap->outputxml(1);
ok ($xml = $soap->call('test',
ok ($xml = $soap->call('test',
testAll => {
Test2 => 'Test2',
TestElement => 'TestRef'
}
), 'Serialized complexType' );
like $xml, qr{<SOAP-ENV:Body><testAll><TestElement>TestRef</TestElement><Test2>Test2</Test2></testAll></SOAP-ENV:Body>}
, 'element ref="" serialization';
my $HAVE_TEST_XML = eval {
require Test::XML;
import Test::XML;
1;
};
SKIP: {
skip "Can't test XML without Test::XML", 1 if not $HAVE_TEST_XML;
is_xml( q{<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" >
<SOAP-ENV:Body >
<testAll><TestElement>TestRef</TestElement>
<Test2>Test2</Test2>
</testAll>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>}, $xml);
};
+7 -1
View File
@@ -1,5 +1,5 @@
use strict; use warnings;
use Test::More tests => 6;
use Test::More tests => 8;
use_ok qw(SOAP::WSDL::Base);
@@ -11,3 +11,9 @@ ok $obj->push_annotation('foo');
ok $obj->set_namespace('foo');
ok $obj->push_namespace('foo');
eval { $obj->find_namespace('uri:example','foo') };
like $@, qr{get_targetNamespace};
eval { $obj->find_namespace(['uri:example','foo']) };
like $@, qr{get_targetNamespace};
+30 -1
View File
@@ -1,8 +1,17 @@
use strict;
use warnings;
use Test::More tests => 9; #qw(no_plan);
use Test::More tests => 15;
use_ok qw(SOAP::WSDL::Client);
{
no warnings qw(redefine once);
*SOAP::WSDL::Factory::Transport::get_transport = sub {
my ($self, $url , %args_of) = @_;
if (%args_of) {
is $args_of{foo}, 'bar';
}
};
}
ok my $client = SOAP::WSDL::Client->new();
ok $client = SOAP::WSDL::Client->new({
@@ -13,6 +22,23 @@ is $client->get_content_type(), 'text/xml; charset=utf-8';
is $client->get_endpoint(), 'http://localhost';
$client->set_proxy('http://localhost',
foo => 'bar',
);
#TODO is this behaviour still required? declare as deprecated and remove...
$client->set_proxy(
[ 'http://localhost',
foo => 'bar',
]
);
is $client->get_proxy(), $client->get_transport(), 'get_proxy returns same as get_transport';
ok $client->set_soap_version('1.1');
is $client->get_soap_version(), '1.1';
$client->no_dispatch(1);
$client->set_serializer('main');
my $serialize = $client->call({
@@ -35,3 +61,6 @@ sub serialize {
my $self = shift;
return shift;
}
$client->set_deserializer_args({ strict => 0 });
is $client->get_deserializer_args()->{ strict }, 0;
+12 -3
View File
@@ -2,9 +2,9 @@ use strict;
use warnings;
package TestResolver;
sub get_typemap { {} };
sub get_class {};
package main;
use Test::More tests => 9;
use Test::More tests => 11;
use SOAP::WSDL::Deserializer::XSD;
@@ -27,4 +27,13 @@ isa_ok $obj->deserialize('<zumsel></zumsel>'), 'SOAP::WSDL::SOAP::Typelib::Fault
isa_ok $obj->deserialize('<Envelope xmlns="huchmampf"></Envelope>'), 'SOAP::WSDL::SOAP::Typelib::Fault11';
is $obj->deserialize('<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" >
<SOAP-ENV:Body ></SOAP-ENV:Body></SOAP-ENV:Envelope>'), undef, 'Deserialize empty envelope';
<SOAP-ENV:Body ></SOAP-ENV:Body></SOAP-ENV:Envelope>'), undef, 'Deserialize empty envelope';
is $obj->get_strict(), 1;
$obj->set_strict(0);
is $obj->deserialize('<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" >
<SOAP-ENV:Body ><foo></foo></SOAP-ENV:Body></SOAP-ENV:Envelope>'),
undef,
'Deserialize envelope with unknown element with strict disabled';
+15 -1
View File
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
use strict;
use warnings;
use Test::More tests => 5;
use Test::More tests => 6;
use lib '../../../../lib';
use lib '../../../../t/lib';
use lib 't/lib';
@@ -28,6 +28,8 @@ my $parser = SOAP::WSDL::Expat::MessageParser->new({
test_nil($parser);
test_simple_element($parser);
$parser->parse( $xml );
@@ -72,6 +74,7 @@ BEGIN {
'MyElementAttrs' => 'MyElementAttrs',
'MyElementAttrs/test' => 'MyTestElement',
'MyElementAttrs/test2' => 'MyTestElement2',
'MySimpleElement' => 'MySimpleElement',
);
sub new { return bless {}, 'FakeResolver' };
@@ -98,3 +101,14 @@ sub test_nil {
my $result = $parser->parse($xml_nil_attr);
is $result->get_test2->serialize({ name => 'test2'}), '<test2 xsi:nil="true"/>';
}
sub test_simple_element {
my $parser = shift;
my $body = $parser->parse(
q{<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" >
<SOAP-ENV:Body><MySimpleElement xmlns="urn:Test">3</MySimpleElement></SOAP-ENV:Body></SOAP-ENV:Envelope>});
is $body->get_value(), 3;
}
+7 -1
View File
@@ -1,6 +1,6 @@
use strict;
use warnings;
use Test::More tests => 16; #qw(no_plan);
use Test::More tests => 17; #qw(no_plan);
use File::Spec;
use File::Basename;
@@ -38,6 +38,10 @@ else {
);
}
$parser = SOAP::WSDL::Expat::WSDLParser->new();
$definitions = $parser->parse_uri(
"file://$path/../../../acceptance/wsdl/WSDLParser-import.wsdl"
);
ok my $service = $definitions->first_service();
is $service->get_name(), 'Service1', 'wsdl:import service name';
is $definitions->first_binding()->get_name(), 'Service1Soap', 'wsdl:import binding name';
@@ -47,6 +51,8 @@ is @{ $schema_from_ref }, 2, 'got builtin and imported schema';
ok @{ $schema_from_ref->[1]->get_element } > 0;
is $schema_from_ref->[1]->get_element->[0]->get_name(), 'sayHello';
is $schema_from_ref->[1]->get_xmlns()->{ foo }, 'urn:Bar1', 'namespace prefix not overridden by import';
{
my $warn_parser = SOAP::WSDL::Expat::WSDLParser->new();
my $warning;
+8 -2
View File
@@ -4,7 +4,12 @@ use File::Basename qw(dirname);
use File::Spec;
use File::Path;
use diagnostics;
my $path = File::Spec->rel2abs( dirname __FILE__ );
my ($volume, $dir) = File::Spec->splitpath($path, 1);
my @dir_from = File::Spec->splitdir($dir);
unshift @dir_from, $volume if $volume;
my $url = join '/', @dir_from;
my $HAVE_TEST_WARN =eval { require Test::Warn; };
@@ -20,7 +25,7 @@ my $definitions;
if ($HAVE_TEST_WARN) {
Test::Warn::warning_like(sub {
$definitions = $parser->parse_uri(
"file://$path/../../../../../acceptance/wsdl/WSDLParser-import.wsdl"
"file://$url/../../../../../acceptance/wsdl/WSDLParser-import.wsdl"
);
}
, qr{already \s imported}x
@@ -30,7 +35,7 @@ else {
local $SIG{__WARN__} = sub {};
SKIP: { skip 'Cannot test warning without Test::Warn', 1; }
$definitions = $parser->parse_uri(
"file://$path/../../../../../acceptance/wsdl/WSDLParser-import.wsdl"
"file://$url/../../../../../acceptance/wsdl/WSDLParser-import.wsdl"
);
}
my $generator = SOAP::WSDL::Generator::Template::XSD->new({
@@ -39,6 +44,7 @@ my $generator = SOAP::WSDL::Generator::Template::XSD->new({
element_prefix => 'Foo',
typemap_prefix => 'Foo',
OUTPUT_PATH => "$path/testlib",
silent => 1,
});
my $code = "";
@@ -0,0 +1,56 @@
use strict;
use Test::More tests => 4;
use File::Basename qw(dirname);
use File::Spec;
use File::Path;
use diagnostics;
my $path;
$path = File::Spec->rel2abs( dirname __FILE__ );
my ( $volume, $dir ) = File::Spec->splitpath( $path, 1 );
my @dir_from = File::Spec->splitdir($dir);
unshift @dir_from, $volume if $volume;
$path = join '/', @dir_from;
my $HAVE_TEST_XML = eval {
require Test::XML;
import Test::XML;
1;
};
use_ok qw(SOAP::WSDL::Generator::Visitor::Typelib);
use_ok qw(SOAP::WSDL::Generator::Template::XSD);
use SOAP::WSDL::Expat::WSDLParser;
my $parser = SOAP::WSDL::Expat::WSDLParser->new();
my $definitions = $parser->parse_uri(
"file://$path/../../../../../acceptance/wsdl/006_sax_client.wsdl" );
my $generator = SOAP::WSDL::Generator::Template::XSD->new( {
definitions => $definitions,
OUTPUT_PATH => "$path/testlib",
silent => 1,
} );
my $code = "";
$generator->generate_typelib();
eval qq{use lib "$path/testlib";};
ok eval("require MyElements::EnqueueMessage;"), "require generated class";
my $obj =
MyElements::EnqueueMessage->new( {MMessage => {MSubject => 'test'}} );
my $xml = q{<EnqueueMessage xmlns="http://www.example.org/Test/">
<MMessage xmlns=""><MSubject>test</MSubject></MMessage>
</EnqueueMessage>
};
SKIP: {
skip( "Cannot test XML content without Test::XML", 1 )
if not $HAVE_TEST_XML;
is_xml( "$obj", $xml, "XML content" );
}
rmtree "$path/testlib";
+1
View File
@@ -47,6 +47,7 @@ my $generator = SOAP::WSDL::Generator::Template::XSD->new({
element_prefix => 'Foo',
typemap_prefix => 'Foo',
OUTPUT_PATH => "$path/testlib",
silent => 1
});
my $code = "";
@@ -45,6 +45,7 @@ my $generator = SOAP::WSDL::Generator::Template::XSD->new({
typemap_prefix => 'Foo',
OUTPUT_PATH => "$path/testlib",
prefix_resolver_class => 'TestResolver',
silent => 1,
});
my $code = "";
+1
View File
@@ -23,6 +23,7 @@ my $generator = SOAP::WSDL::Generator::Template::XSD->new({
element_prefix => 'Foo',
typemap_prefix => 'Foo',
OUTPUT_PATH => "$path/testlib",
silent => 1,
});
my $code = "";
@@ -32,6 +32,7 @@ my $generator = SOAP::WSDL::Generator::Template::XSD->new({
element_prefix => 'BarElem',
typemap_prefix => 'Bar',
OUTPUT_PATH => "$path/testlib",
silent => 1,
});
+1
View File
@@ -16,6 +16,7 @@ my $definitions = $parser->parse_file(
my $generator = SOAP::WSDL::Generator::Template::XSD->new({
definitions => $definitions,
silent => 1,
});
{
+15 -1
View File
@@ -2,11 +2,19 @@ package FOO;
use strict; use warnings;
use Class::Std::Fast;
sub serialize_qualified { 'FOO' };
sub get_xmlns { 'urn:foo' };
{
my $name = 'Foo';
sub __set_name { $name = $_[1]};
sub __get_name{ $name };
sub serialize { "<$name/>" };
}
package main;
use strict;
use warnings;
use Test::More qw(no_plan);
use Test::More tests => 10;
use_ok qw(SOAP::WSDL::Serializer::XSD);
@@ -34,3 +42,9 @@ like $serializer->serialize({ header => {}, body => [ undef ] }),
qr{<SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body></SOAP-ENV:Body>}, 'empty header and body';
like $serializer->serialize({ header => {}, body => [ undef, FOO->new() ] }),
qr{<SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body>FOO</SOAP-ENV:Body>}, 'empty header and body';
like $serializer->serialize({ header => FOO->new(), body => FOO->new()}),
qr{<SOAP-ENV:Body>FOO</SOAP-ENV:Body>}, 'prefixed body element';
like $serializer->serialize({ header => FOO->new(), body => FOO->new() , options => { prefix => 'foo'}}),
qr{<SOAP-ENV:Body><foo:Foo/></SOAP-ENV:Body>}, 'prefixed body element';
+127
View File
@@ -0,0 +1,127 @@
package MyTypemap;
sub get_typemap { return {} }
package main;
use Test::More;
use CGI;
plan tests => 8;
use_ok(SOAP::WSDL::Server);
use_ok(SOAP::WSDL::Server::Simple);
my $server = SOAP::WSDL::Server::Simple->new( {class_resolver => 'MyTypemap',} );
$server->set_action_map_ref( {'testaction' => 'testmethod',} );
test_fault_output();
test_deserializer_fault();
test_simple_fault();
test_success();
#
# test _output by forcing a fault (passing a empty CGI object)
# IO::Scalar required
#
sub test_fault_output {
no warnings qw(once);
SKIP: {
eval "require IO::Scalar"
or skip 'IO::Scalar required for testing...', 1;
# set up a IO::Scalar handle as STDOUT
local *IO::Scalar::BINMODE = sub { };
my $output = q{};
my $fh = IO::Scalar->new( \$output );
{
local *STDOUT = $fh;
# don't try to print() anything from here on - it gehts caught in $output,
#and does not make it to STDOUT...
$server->handle( CGI->new() );
}
like $output, qr{no \s element \s found}xms;
}
}
sub test_deserializer_fault {
*SOAP::WSDL::Server::Simple::_output = sub {
like $_[1]->content(), qr{Error \s deserializing \s message}xms,
'Fault on (wrong) content';
};
local $ENV{REQUEST_METHOD} = 'POST';
local $ENV{HTTP_SOAPACTION} = 'testaction';
$server->handle(
CGI->new( {
POSTDATA => q{<SOAP-ENV:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
><SOAP-ENV:Body>
<TestOperation xmlns="http://www.example.org/example/">
<Name>Kutter</Name>
<Vorname>Martin</Vorname>
<Anrede>Herr</Anrede>
</TestOperation>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>}
} ) );
}
sub test_simple_fault {
*SOAP::WSDL::Server::Simple::_output = sub {
is $_[1]->code, 500;
like $_[1]->content(), qr{Something \s is \s rotten}xms,
'Fault on (wrong) content';
};
local $ENV{REQUEST_METHOD} = 'POST';
local $ENV{HTTP_SOAPAction} = 'testaction';
local *SOAP::WSDL::Server::handle = sub { die 'Something is rotten' };
$server->handle(
CGI->new( {
POSTDATA => q{<SOAP-ENV:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
><SOAP-ENV:Body>
<TestOperation xmlns="http://www.example.org/example/">
<Name>Kutter</Name>
<Vorname>Martin</Vorname>
<Anrede>Herr</Anrede>
</TestOperation>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>}
} ) );
}
sub test_success {
*SOAP::WSDL::Server::Simple::_output = sub {
is $_[1]->code(), 200;
like $_[1]->content(), qr{Everything \s OK}xms,
'Status 200 on OK content';
};
local $ENV{REQUEST_METHOD} = 'POST';
local $ENV{HTTP_SOAPAction} = 'testaction';
local *SOAP::WSDL::Server::handle = sub { 'Everything OK' };
$server->handle(
CGI->new( {
POSTDATA => q{<SOAP-ENV:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
><SOAP-ENV:Body>
<TestOperation xmlns="http://www.example.org/example/">
<Name>Kutter</Name>
<Vorname>Martin</Vorname>
<Anrede>Herr</Anrede>
</TestOperation>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>}
} ) );
}
+3 -3
View File
@@ -30,9 +30,9 @@ ok ! $transport->is_success();
my $self = shift;
my $request = shift;
is $request->header('Content-Type'), 'text/xml; charset=utf-8';
return HTTP::Response->new();
return HTTP::Response->new( 200 );
};
$transport->send_receive(envelope => 'Test', action => 'foo');
$result = $transport->send_receive(envelope => 'Test', action => 'foo');
*LWP::UserAgent::request = $request_sub;
}
}
+2 -1
View File
@@ -8,7 +8,8 @@ use SOAP::WSDL::Expat::WSDLParser;
my $parser = SOAP::WSDL::Expat::WSDLParser->new();
my $xml = q{<s:schema elementFormDefault="qualified"
targetNamespace="urn:HelloWorld" xmlns:s="http://www.w3.org/2001/XMLSchema">
targetNamespace="urn:HelloWorld"
xmlns="urn:HelloWorld" xmlns:s="http://www.w3.org/2001/XMLSchema">
<s:element name="sayHello">
<s:complexType>
<s:sequence>
+2 -1
View File
@@ -1,5 +1,6 @@
package Foo;
sub serialize {
$_[2] = q{} if not defined $_[2];
return "serialized $_[1] $_[2]" . join ' ', @{$_[3]->{ attributes } || [] } if $_[3];
}
package main;
@@ -50,4 +51,4 @@ $element->set_abstract('1');
is $element->serialize('Bar', undef, { namespace => {} } ), 'serialized Bar Foobar';
eval { $element->serialize(undef, undef, { namespace => {} } ) };
like $@, qr{cannot \s serialize \s abstract}xms;
like $@, qr{cannot \s serialize \s abstract}xms;
+2 -1
View File
@@ -8,7 +8,8 @@ use SOAP::WSDL::Expat::WSDLParser;
my $parser = SOAP::WSDL::Expat::WSDLParser->new();
my $xml = q{<s:schema elementFormDefault="qualified"
targetNamespace="urn:HelloWorld" xmlns:s="http://www.w3.org/2001/XMLSchema">
targetNamespace="urn:HelloWorld" xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns="urn:HelloWorld">
<s:simpleType name="test">
<s:restriction base="s:string">
<s:enumeration value="foo"/>
+3 -1
View File
@@ -9,15 +9,17 @@ my $obj = SOAP::WSDL::XSD::Schema->new({
element => [
SOAP::WSDL::XSD::Element->new({
name => 'foo',
targetNamespace => 'bar',
xmlns => { '#default' => 'bar' },
}),
SOAP::WSDL::XSD::Element->new({
name => 'foo',
targetNamespace => 'baz',
xmlns => { '#default' => 'baz' },
}),
SOAP::WSDL::XSD::Element->new({
name => 'foobar',
targetNamespace => 'bar',
xmlns => { '#default' => 'bar' },
}),
]
});
+4 -2
View File
@@ -1,6 +1,6 @@
use strict;
use warnings;
use Test::More tests => 11;
use Test::More tests => 12;
use_ok qw(SOAP::WSDL::XSD::SimpleType);
@@ -30,4 +30,6 @@ is $obj->serialize('Foo', 'Foobar'), '<Foo>Foobar</Foo>';
# TODO die on non-serializable content...
$obj->set_flavor('');
is $obj->serialize('Foo', 'Foobar'), '';
is $obj->serialize('Foo', 'Foobar'), '';
ok eval { $obj->set_restriction({ LocalName => 'bar'}, { LocalName => 'base', Value => 'string' }); 1; };
+10 -8
View File
@@ -1,4 +1,4 @@
use Test::More tests => 30;
use Test::More tests => 31;
use strict;
use warnings;
#use Carp qw(cluck);
@@ -19,7 +19,7 @@ sub timezone {
}
my %dates = (
'2007/12/31' => '2007-12-31',
'2007/12/31' => '2007-12-31',
'2007:08:31' => '2007-08-31',
'30 Aug 2007' => '2007-08-30',
);
@@ -36,8 +36,8 @@ my %localized_date_of = (
'2007-12-31T00:00:00.0000000+0800' => '2007-12-31+08:00',
'2007-12-31T00:00:00.0000000+0900' => '2007-12-31+09:00',
'2007-12-31T00:00:00.0000000+1000' => '2007-12-31+10:00',
'2007-12-31T00:00:00.0000000+1100' => '2007-12-31+11:00',
'2007-12-31T00:00:00.0000000+1200' => '2007-12-31+12:00',
'2007-12-31T00:00:00.0000000+1100' => '2007-12-31+11:00',
'2007-12-31T00:00:00.0000000+1200' => '2007-12-31+12:00',
'2007-12-31T00:00:00.0000000-0100' => '2007-12-31-01:00',
'2007-12-31T00:00:00.0000000-0200' => '2007-12-31-02:00',
'2007-12-31T00:00:00.0000000-0300' => '2007-12-31-03:00',
@@ -48,8 +48,8 @@ my %localized_date_of = (
'2007-12-31T00:00:00.0000000-0800' => '2007-12-31-08:00',
'2007-12-31T00:00:00.0000000-0900' => '2007-12-31-09:00',
'2007-12-31T00:00:00.0000000-1000' => '2007-12-31-10:00',
'2007-12-31T00:00:00.0000000-1100' => '2007-12-31-11:00',
'2007-12-31T00:00:00.0000000-1200' => '2007-12-31-12:00',
'2007-12-31T00:00:00.0000000-1100' => '2007-12-31-11:00',
'2007-12-31T00:00:00.0000000-1200' => '2007-12-31-12:00',
);
@@ -64,7 +64,7 @@ while (my ($date, $converted) = each %localized_date_of ) {
$obj = SOAP::WSDL::XSD::Typelib::Builtin::date->new();
$obj->set_value( $date );
is $obj->get_value() , $converted , 'conversion';
}
@@ -72,10 +72,12 @@ while (my ($date, $converted) = each %dates ) {
$obj = SOAP::WSDL::XSD::Typelib::Builtin::date->new();
$obj->set_value( $date );
is $obj->get_value() , $converted . timezone($date), 'conversion';
}
$obj->set_value( '2037-12-31+12:00' );
is $obj->get_value() , '2037-12-31+12:00', 'no conversion on match';
$obj->set_value('2007-12-31+01:00');
is $obj->get_value(), '2007-12-31+01:00';
+10 -5
View File
@@ -1,7 +1,7 @@
use strict;
use warnings;
use lib '../lib';
use Test::More tests => 7;
use Test::More tests => 9;
use Date::Parse;
use Date::Format;
@@ -17,7 +17,7 @@ use_ok('SOAP::WSDL::XSD::Typelib::Builtin::dateTime');
print "# timezone is " . timezone( scalar localtime(time) ) . "\n";
my $obj;
my %dates = (
'2007-12-31 12:32' => '2007-12-31T12:32:00',
'2007-12-31 12:32' => '2007-12-31T12:32:00',
'2007-08-31 00:32' => '2007-08-31T00:32:00',
'30 Aug 2007' => '2007-08-30T00:00:00',
);
@@ -30,7 +30,8 @@ while (my ($date, $converted) = each %dates ) {
$obj = SOAP::WSDL::XSD::Typelib::Builtin::dateTime->new();
$obj->set_value( $date );
local $^W; # really turn off warnings for the next line
is $obj->get_value() , $converted . timezone($date), 'conversion with timezone';
}
$obj->set_value('2007-12-31T00:00:00.0000000+01:00');
@@ -38,5 +39,9 @@ is $obj->get_value(), '2007-12-31T00:00:00.0000000+01:00';
$obj->set_value(undef);
is $obj->get_value(), undef;
eval { $obj->set_value(1) };
ok $@, 'Die on illegal datetime';
eval { print $obj->set_value(0) };
ok $@, 'Die on illegal datetime ' . $@;
eval { print $obj->set_value('A') };
ok $@, 'Die on illegal datetime';
eval { print $obj->set_value('8') };
ok $@, 'Die on illegal datetime';
+39 -5
View File
@@ -22,7 +22,8 @@ use base qw(SOAP::WSDL::XSD::Typelib::ComplexType);
__PACKAGE__->_factory(
[ 'test' ],
{ test => \%test_of, },
{ test => 'SOAP::WSDL::XSD::Typelib::Builtin::string', }
{ test => 'SOAP::WSDL::XSD::Typelib::Builtin::string', },
);
}
@@ -50,7 +51,8 @@ use base qw(SOAP::WSDL::XSD::Typelib::AttributeSet);
{
test => 'SOAP::WSDL::XSD::Typelib::Builtin::string',
test2 => 'MyAttribute',
}
},
{ test => 'test' }
);
}
@@ -82,7 +84,7 @@ __PACKAGE__->__set_name( 'MyElementSimpleContent' );
sub __get_attr_class { 'MyElement::_ATTR' };
package main;
use Test::More tests => 115;
use Test::More tests => 127;
use Storable;
my $have_warn = eval { require Test::Warn; import Test::Warn; 1; };
@@ -236,6 +238,22 @@ is $obj->serialize(),
q{<MyElement test="TestAttribute" test2="test"/>},
'Serialization with attributes';
#
# cloning attributes...
#
ok exists $obj->as_hash_ref()->{ xmlattr }, 'as_hash_ref attributes';
is $obj->as_hash_ref()->{ xmlattr }->{ test }, 'TestAttribute', 'as_hash_ref attribute value';
is $obj->as_hash_ref()->{ xmlattr }->{ test2 }, 'test', 'as_hash_ref attribute value';
my $clone = ref($obj)->new($obj->as_hash_ref());
isnt $$clone, $$obj, 'clone is new object';
isnt ${ $clone->attr() }, ${ $obj->attr() }, 'cloned attrs are a new object';
is $clone->attr()->get_test(), 'TestAttribute';
#
# end cloning attributes
#
$obj = MyType->new();
isa_ok $obj, 'MyType';
@@ -283,8 +301,10 @@ for my $count (1..5) {
}
my $clone = Storable::thaw( Storable::freeze( $obj ));
is $clone->get_test()->[0], 'TestString0', 'clone via freeze/thaw';
{
my $clone = Storable::thaw( Storable::freeze( $obj ));
is $clone->get_test()->[0], 'TestString0', 'clone via freeze/thaw';
}
## failure tests
@@ -359,3 +379,17 @@ like $@, qr{ Can't \s locate \s HopeItDoesntExistOnYourSystem.pm }xms;
$obj = MyElementSimpleContent->new({ value => 'foo' });
$obj->attr({ test => 'foo', test2 => 'bar' });
is $obj->serialize_qualified(), '<MyElementSimpleContent xmlns="http://www.w3.org/2001/XMLSchema" test="foo" test2="bar">foo</MyElementSimpleContent>';
$clone = ref($obj)->new($obj->as_hash_ref());
isnt $$clone, $$obj, 'clone is new object';
isnt ${ $clone->attr() }, ${ $obj->attr() }, 'cloned attrs are a new object';
is $clone->get_value(), 'foo';
ok ! exists $obj->as_hash_ref(1)->{ xmlattr };
{
local $SOAP::WSDL::XSD::Typelib::ComplexType::AS_HASH_REF_WITHOUT_ATTRIBUTES = 1;
ok ! exists $obj->as_hash_ref()->{ xmlattr };
ok ! exists $obj->as_hash_ref(1)->{ xmlattr };
}
+16 -2
View File
@@ -10,7 +10,7 @@ __PACKAGE__->__set_name('MyElement');
__PACKAGE__->__set_nillable(1);
package main;
use Test::More tests => 13;
use Test::More tests => 18;
my $obj;
@@ -34,15 +34,29 @@ is $obj->__get_nillable(), 1;
$obj->__set_nillable(0);
is $obj->__get_nillable(), 0;
eval { SOAP::WSDL::XSD::Typelib::Element::__get_nillable() };
like $@, qr{Cannot \s call}xms;
eval { SOAP::WSDL::XSD::Typelib::Element::__set_nillable() };
like $@, qr{Cannot \s call}xms;
# useless test for increasing coverage...
# Stores a value under the key "0" of the element class' private nillable
# hash.
#
# Don't you ever abuse the element's this method for such bad stuff !
is SOAP::WSDL::XSD::Typelib::Element::__set_nillable(0,0), 0;
is SOAP::WSDL::XSD::Typelib::Element::__get_nillable(0), 0;
is $obj->start_tag({ name => 'foo'}), '<foo>';
is $obj->start_tag({empty => 1}), '<MyElement/>';
is $obj->start_tag({nil => 1}), '', 'empty string with nil option and NILLABLE false';
is $obj->end_tag(), '</MyElement>';
is $obj->end_tag({ name => 'foo'}), '</foo>';
$obj->set_value('Test');
eval { is @{ $obj }, 1, 'ARRAYIFY' };
fail 'ARRAYIFY' if ($@);
fail 'ARRAYIFY' if ($@);