import SOAP-WSDL 2.00_05 from CPAN

git-cpan-module:   SOAP-WSDL
git-cpan-version:  2.00_05
git-cpan-authorid: MKUTTER
git-cpan-file:     authors/id/M/MK/MKUTTER/SOAP-WSDL-2.00_05.tar.gz
This commit is contained in:
Martin Kutter
2009-12-12 19:47:43 -08:00
committed by Michael G. Schwern
parent 5c42b1d8f6
commit a78d6d15b5
32 changed files with 565 additions and 360 deletions
+4
View File
@@ -0,0 +1,4 @@
use Test::More tests => 2;
use lib '../lib';
use_ok(qw/SOAP::WSDL/);
ok( SOAP::WSDL->new(), 'Instantiated object' );
+47
View File
@@ -0,0 +1,47 @@
use Test::More tests => 10;
use strict;
use warnings;
use diagnostics;
use Cwd;
use File::Basename;
use Data::Dumper;
use lib '../lib';
use_ok(qw/SOAP::WSDL/);
# chdir to my location
my $cwd = cwd;
my $path = dirname( $0 );
my $soap = undef;
my $name = basename( $0 );
$name =~s/\.(t|pl)$//;
chdir $path;
$path = cwd;
$path =~s{/SOAP/WSDL}{}xms;
#2
ok( $soap = SOAP::WSDL->new(
wsdl => 'file:///' . $path . '/acceptance/wsdl/' . $name . '.wsdl'
), 'Instantiated object' );
ok( $soap->wsdlinit(), 'parsed WSDL' );
ok( ($soap->servicename('testService') ), 'set service' );
ok( ($soap->portname('testPort') ) ,'set portname');
ok( ($soap->portname() eq 'testPort' ),
"Found first port definition" );
ok( ($soap->portname('testPort2') ),
"Found second port definition (based on URL)" );
ok( ($soap->portname('testPort3') ),
"Found third port definition (based on Name)" );
ok( $soap->wsdlinit( servicename => 'testService', portname => 'testPort'), 'parsed WSDL' );
$soap->_wsdl_init_methods();
ok( ($soap->portname() eq 'testPort' ), 'found port passed to wsdlinit');
+87
View File
@@ -0,0 +1,87 @@
use Test::More tests => 7;
use strict;
use warnings;
use lib '../lib';
use lib 't/lib';
use lib 'lib';
use Cwd;
use File::Basename;
our $SKIP;
eval "use Test::SOAPMessage";
if ($@)
{
$SKIP = "Test::Differences required for testing. ";
}
my $path = cwd();
my $name = basename $0;
$name =~s/\.t$//;
$name =~s/^t\///;
$path =~s{(/t)?/SOAP/WSDL}{}xms;
use_ok(qw/SOAP::WSDL/);
print "# SOAP::WSDL Version: $SOAP::WSDL::VERSION\n";
my $xml;
my $soap;
#2
ok( $soap = SOAP::WSDL->new(
wsdl => 'file://' . $path . '/t/acceptance/wsdl/' . $name . '.wsdl',
readable =>1,
), 'Instantiated object' );
#3
ok $soap->wsdlinit(
checkoccurs => 1,
servicename => 'testService',
), 'parse WSDL';
ok $soap->no_dispatch(1), 'set no dispatch';
ok ($xml = $soap->call('test',
testAll => {
Test1 => 'Test 1',
Test2 => [ 'Test 2', 'Test 3' ]
}
), 'Serialized complexType' );
# print $xml;
# $soap->wsdl_checkoccurs(1);
TODO: {
local $TODO = "not implemented yet";
eval
{
$xml = $soap->serializer->method(
$soap->call('test',
testAll => {
Test1 => 'Test 1',
Test2 => [ 'Test 2', 'Test 3' ]
}
)
);
};
ok( ($@ =~m/illegal\snumber\sof\selements/),
"Died on illegal number of elements (too many)"
);
eval {
$xml = $soap->serializer->method(
$soap->call('test',
testAll => {
Test1 => 'Test 1',
}
)
)
};
ok($@, 'Died on illegal number of elements (not enough)');
}
+22
View File
@@ -0,0 +1,22 @@
use Test::More tests => 2;
use lib '../lib';
use lib 't/lib';
use lib 'lib';
use Cwd;
use File::Basename;
our $SKIP;
eval "use Test::SOAPMessage";
if ($@) {
$SKIP = "Test::Differences required for testing. $@";
}
use_ok qw/SOAP::WSDL/;
my $soap = SOAP::WSDL->new();
TODO: {
local $TODO="implement <choice> support";
fail "serialize choice element";
}
@@ -0,0 +1,22 @@
use Test::More tests => 2;
use lib '../lib';
use lib 't/lib';
use lib 'lib';
use Cwd;
use File::Basename;
our $SKIP;
eval "use Test::SOAPMessage";
if ($@) {
$SKIP = "Test::Differences required for testing. $@";
}
use_ok qw/SOAP::WSDL/;
my $soap = SOAP::WSDL->new();
TODO: {
local $TODO="implement <complexContent> support";
fail "serialize complexContent element";
}
+22
View File
@@ -0,0 +1,22 @@
use Test::More tests => 2;
use lib '../lib';
use lib 't/lib';
use lib 'lib';
use Cwd;
use File::Basename;
our $SKIP;
eval "use Test::SOAPMessage";
if ($@) {
$SKIP = "Test::Differences required for testing. $@";
}
use_ok qw/SOAP::WSDL/;
my $soap = SOAP::WSDL->new();
TODO: {
local $TODO="implement <group> support";
fail "serialize group element";
}
+78
View File
@@ -0,0 +1,78 @@
BEGIN {
use Test::More tests => 6;
use lib '../lib';
use lib 't/lib';
use lib 'lib';
use Cwd;
use File::Basename;
our $SKIP;
eval "use Test::SOAPMessage";
if ($@)
{
$SKIP = "Test::Differences required for testing. $@";
}
}
use_ok(qw/SOAP::WSDL/);
my $xml;
my $path = cwd();
my $name = basename $0;
$name =~s/\.t$//;
$path=~s{(/t)?/SOAP/WSDL}{}xms;
#2
ok( $soap = SOAP::WSDL->new(
wsdl => 'file://' . $path . '/t/acceptance/wsdl/' . $name . '.wsdl'
), 'Instantiated object' );
#3
ok( $soap->wsdlinit(
checkoccurs => 1,
servicename => 'testService',
), 'parsed WSDL' );
$soap->no_dispatch(1);
$soap->serializer()->envprefix('SOAP-ENV');
$soap->serializer()->encprefix('SOAP-ENC');
#4
ok $xml = $soap->call('test',
testSequence => {
Test1 => 'Test 1',
Test2 => 'Test 2',
}
), 'Serialized complexType';
#5
eval
{
$xml = $soap->serializer->method(
$soap->call('test',
testSequence => {
Test1 => 'Test 1',
}
)
);
};
ok( ($@),
"Died on illegal number of elements"
);
#6
eval
{
$xml = $soap->serializer->method(
$soap->call('test',
testSequence => {
Test1 => 'Test 1',
Test2 => [ 1, 2, 3, ]
}
)
);
};
ok( ($@),
"Died on illegal number of elements"
);
@@ -0,0 +1,22 @@
use Test::More tests => 2;
use lib '../lib';
use lib 't/lib';
use lib 'lib';
use Cwd;
use File::Basename;
our $SKIP;
eval "use Test::SOAPMessage";
if ($@) {
$SKIP = "Test::Differences required for testing. $@";
}
use_ok qw/SOAP::WSDL/;
my $soap = SOAP::WSDL->new();
TODO: {
local $TODO="implement <simpleContent> support";
fail "serialize simpleContent element";
}
+4
View File
@@ -0,0 +1,4 @@
use Test::More skip_all => 'TODO: implement tests';
use lib '../lib';
+50
View File
@@ -0,0 +1,50 @@
use Test::More tests => 6;
use strict;
use warnings;
use lib '../lib';
use lib 't/lib';
use lib 'lib';
use Cwd;
use File::Basename;
use_ok(qw/SOAP::WSDL/);
my $xml;
my $soap = undef;
my $name = basename $0;
$name =~s/\.(t|pl)$//;
my $path = cwd;
$path =~s{(/t)?/SOAP/WSDL}{}xms;
#2
ok( $soap = SOAP::WSDL->new(
wsdl => 'file:///' . $path . '/t/acceptance/wsdl/' . $name . '.wsdl'
), 'Instantiated object' );
#3
$soap->readable(1);
ok( $soap->wsdlinit(
servicename => 'testService',
), 'parsed WSDL' );
$soap->no_dispatch(1);
ok ( $xml = $soap->call('test', testElement1 => 1 ) ,
'Serialized (simpler) element' );
# print $xml, "\n";
TODO: {
local $TODO="implement min/maxOccurs checks";
eval { $soap->call('test', testAll => [ 2, 3 ] ); };
like $@, qr{illegal\snumber\sof\selements}, "Died on illegal number of elements (too many)";
eval { $soap->call('test', testAll => undef ) };
ok $@, 'Died on illegal number of elements (not enough)';
}
+60
View File
@@ -0,0 +1,60 @@
use Test::More tests => 6;
use strict;
use warnings;
use lib '../lib';
use lib 't/lib';
use lib 'lib';
use Cwd;
use File::Basename;
our $SKIP;
eval "use Test::SOAPMessage";
if ($@) {
$SKIP = "Test::Differences required for testing.";
}
use_ok(qw/SOAP::WSDL/);
my $soap;
my $xml;
my $path = cwd();
my $name = basename $0;
$name =~s/\.t$//;
$path =~s{(/t)?/SOAP/WSDL}{}xsm;
#2
ok( $soap = SOAP::WSDL->new(
wsdl => 'file://' . $path . '/t/acceptance/wsdl/' . $name . '.wsdl'
), 'Instantiated object' );
#3
$soap->readable(1);
ok( $soap->wsdlinit(
servicename => 'testService',
), 'parsed WSDL' );
$soap->no_dispatch(1);
ok ($xml = $soap->call('test',
testElement1 => 'Test'
), 'Serialized (simple) element' );
TODO: {
local $TODO="implement min/maxOccurs checks";
eval {
$xml = $soap->call('test',
testAll => [ 'Test 2', 'Test 3' ]
);
};
ok( ($@ =~m/illegal\snumber\sof\selements/),
"Died on illegal number of elements (too many)"
);
eval {
$xml = $soap->call('test', testAll => undef );
};
ok($@, 'Died on illegal number of elements (not enough)');
}
+53
View File
@@ -0,0 +1,53 @@
use Test::More tests => 8;
use strict;
use lib '../lib';
use lib 'lib';
use lib 't/lib';
use Cwd;
use File::Basename;
use_ok(qw/SOAP::WSDL/);
my ($soap, $xml, $xml2);
# chdir to my location
my $name = basename( $0 );
$name =~s/\.(t|pl)$//;
my $path = cwd;
$path =~s{(/t)/SOAP/WSDL}{}xms;
#2
ok( $soap = SOAP::WSDL->new(
wsdl => 'file:///' . $path . '/t/acceptance/wsdl/' . $name . '.wsdl'
), 'Instantiated object' );
$soap->readable(1);
#3
ok( $soap->wsdlinit(
servicename => 'testService',
), 'parsed WSDL' );
$soap->no_dispatch(1);
#4
ok $xml = $soap->call('test', testAll => [ 1, 2 ] ), 'Serialize list call';
#5
ok ( $xml2 = $soap->call('test', testAll => "1 2" ) , 'Serialized scalar call' );
#6
ok( $xml eq $xml2, 'Got expected result');
#7
TODO: {
local $TODO = "implement minLength check";
eval { $xml = $soap->call('test', testAll => undef ) };
ok($@, 'Died on illegal number of elements (not enough)');
}
#8
TODO: {
local $TODO = "maxLength test not implemented";
eval { $xml = $soap->call('test', testAll => [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 ] ) };
ok($@, 'Died on illegal number of elements (more than maxLength)');
}
+59
View File
@@ -0,0 +1,59 @@
use Test::More tests => 8;
use strict;
use warnings;
use diagnostics;
use Cwd;
use File::Basename;
use lib '../lib';
use lib 'lib';
use lib 't/lib';
use_ok(qw/SOAP::WSDL/);
my $xml;
my $name = basename $0;
$name =~s/\.(t|pl)$//;
my $path = cwd;
$path =~s{(/t)/SOAP/WSDL}{}xms;
my $soap;
#2
ok( $soap = SOAP::WSDL->new(
wsdl => 'file:///' . $path . '/t/acceptance/wsdl/' . $name . '.wsdl'
), 'Instantiated object' );
#3
$soap->readable(1);
ok( $soap->wsdlinit(
servicename => 'testService',
), 'parsed WSDL' );
$soap->no_dispatch(1);
$soap->autotype(0);
#4
ok $xml = $soap->call('test', testAll => [ 1, 2 ] ) , 'Serialize list call';
# print $xml, "\n";
TODO: {
local $TODO = "implement minLength/maxLength checks";
eval { $soap->call('test', testAll => [ 1, 2, 3 ] ) };
ok($@, 'Died on illegal number of elements (too many)');
eval { $soap->call('test', testAll => [] ) };
ok($@, 'Died on illegal number of elements (not enough)');
}
TODO: {
local $TODO = "minValue check not implemented ";
eval { $xml = $soap->call('test', testAll => 0 ) };
ok($@, 'Died on illegal value');
}
TODO: {
local $TODO = "maxValue check not implemented ";
eval { $xml = $soap->call('test', testAll => 100 ) };
ok($@, 'Died on illegal value');
}
+66
View File
@@ -0,0 +1,66 @@
use Test::More skip_all => 'Not supported yet';
use strict;
use warnings;
use Cwd;
use File::Basename;
use lib '../lib';
use_ok qw/SOAP::WSDL/;
my $xml;
my $soap = undef;
my $name = basename( $0 );
$name =~s/\.(t|pl)$//;
my $path = cwd;
$path =~s{(/t)?/SOAP/WSDL}{}xms;
#2
ok $soap = SOAP::WSDL->new(
wsdl => 'file:///' . $path . '/t/acceptance/wsdl/' . $name . '.wsdl'
), 'Instantiated object';
#3
$soap->readable(1);
ok $soap->wsdlinit(), 'parsed WSDL';
$soap->no_dispatch(1);
#4
ok $xml = $soap->call('test', testAll => 1 ) , 'Serialized call';
# 6
eval {
$xml = $soap->serializer->method(
$soap->call('test',
testAll => [ 1 , 'union']
)
)
};
ok($@, 'Died on illegal number of elements (not enough)');
eval {
$xml = $soap->serializer->method(
$soap->call('test',
testAll => undef
)
)
};
ok($@, 'Died on illegal number of elements (not enough)');
#8
ok ( $xml = $soap->serializer->method( $soap->call('test2',
testAll => 1 )
),
'Serialized (simple) call (list)' );
#9
eval {
$xml = $soap->serializer->method(
$soap->call('test',
testAll => [ 1 , 'union']
)
)
};
ok($@, 'Died on illegal number of elements (not enough)');
+83
View File
@@ -0,0 +1,83 @@
#!/usr/bin/perl -w
use strict;
use Test::More tests=> 5;
use Time::HiRes qw( gettimeofday tv_interval );
use lib '../..';
use Data::Dumper;
use Cwd;
use File::Basename;
use_ok qw/ SOAP::WSDL /;
use Benchmark;
print "# Testing SOAP::WSDL ". $SOAP::WSDL::VERSION."\n";
print "# Performance test with simple WSDL file\n";
my $soap;
my $data = {
sayHello => {
name => 'Mein Name',
givenName => 'Vorname',
}
};
my $name = basename( $0 );
$name =~s/\.(t|pl)$//;
my $path = cwd;
$path=~s{(/t)?/SOAP/WSDL}{}xms;
my $cacheDir;
if ($^O =~ m/Win/)
{
$cacheDir = 'C:/Temp/WSDL';
}
else
{
$cacheDir = '/tmp/';
}
my $t0 = [gettimeofday];
ok(
$soap=SOAP::WSDL->new(
wsdl => "file://$path/t/acceptance/wsdl/10_helloworld.asmx.xml",
no_dispatch => 1
),
"Create SOAP::WSDL object (".tv_interval ( $t0, [gettimeofday]) ."ms)" );
$soap->proxy('http://helloworld/helloworld.asmx');
$t0 = [gettimeofday];
eval{
$soap->wsdlinit(
caching => 1,
cache_directory => $cacheDir,
servicename => 'Service1' ) };
unless ($@) {
pass("wsdl file init (".tv_interval ( $t0, [gettimeofday]) ."s)");
} else {
fail( $@ );
}
$soap->readable(1);
$t0 = [gettimeofday];
ok( $soap->call("sayHello" , %{ $data }),
"1 x call pre-work (".tv_interval ( $t0, [gettimeofday]) ."s)") ;
$t0 = [gettimeofday];
ok($soap->call(sayHello => %{ $data }),
"1 x call pre-work (".tv_interval ( $t0, [gettimeofday]) ."s)" );
timethis 1000, sub { $soap->call(sayHello => %{ $data }) };
__END__
$t0 = [gettimeofday];
for (my $i=1; $i<100; $i++)
{
$soap->call(sayHello => %{ $data });
}
ok(1, "100 x call pre-work (".tv_interval ( $t0, [gettimeofday]) ."s)");
chdir $cwd;
+56
View File
@@ -0,0 +1,56 @@
#!/usr/bin/perl -w
#######################################################################################
#
# 2_helloworld.t
#
# Acceptance test for message encoding, based on .NET wsdl and example code.
# SOAP::WSDL's encoding doesn't I<exactly> match the .NET example, because
# .NET doesn't always specify types (SOAP::WSDL does), and the namespace
# prefixes chosen are different (maybe the encoding style, too ? this would be a bug !)
#
########################################################################################
use strict;
use Test::More tests => 4;
use lib '../..';
use Cwd;
use File::Basename;
use_ok q/SOAP::WSDL/;
### test vars END
print "# Testing SOAP::WSDL ". $SOAP::WSDL::VERSION."\n";
print "# Acceptance test against sample output with simple WSDL\n";
my $data = {
name => 'test',
givenName => 'test',
};
my $soap = undef;
my $name = basename( $0 );
$name =~s/\.(t|pl)$//;
my $path = cwd;
$path =~s{(/t)?/SOAP/WSDL}{}xms;
ok $soap = SOAP::WSDL->new(
wsdl => 'file:///'.$path.'/t/acceptance/wsdl/11_helloworld.wsdl',
no_dispatch => 1
), 'Create SOAP::WSDL object';
$soap->serializer()->namespace('SOAP-ENV');
$soap->serializer()->encodingspace('SOAP-ENC');
$soap->proxy('http://helloworld/helloworld.asmx');
ok $soap->wsdlinit(
servicename => 'Service1',
), 'wsdlinit';
ok $soap->call('sayHello', 'sayHello' => $data), 'soap call';
+46
View File
@@ -0,0 +1,46 @@
use strict;
use lib '../lib';
use Test::More tests => 4;
use SOAP::WSDL;
use Cwd;
use Data::Dumper;
use File::Basename;
print "# Using SOAP::WSDL Version $SOAP::WSDL::VERSION\n";
my $name = '02_port';
# chdir to my location
my $soap = undef;
my $path = cwd;
$path =~s{(/t)?/SOAP/WSDL}{}xms;
my $url = 'http://127.0.0.1/testPort';
ok( $soap = SOAP::WSDL->new(
wsdl => 'file:///' . $path . '/t/acceptance/wsdl/' . $name . '.wsdl'
) );
ok $soap->wsdlinit( url => $url );
ok $soap->servicename('testService');
ok $soap->portname('testPort');
__END__
my $xpath = $soap->_wsdl_xpath( );
my @ports = $xpath->findnodes( '/definitions/service[@name="' . $soap->servicename() . '"]/port/soap:address[@location="' . $url .'"]');
if (@ports)
{
print "# found testPort URL\n";
my $address = shift @ports;
my $port = $address->getParentNode();
print $port->getAttribute('binding'), "\n";
print $port->getAttribute('name'), "\n";
}
+27
View File
@@ -0,0 +1,27 @@
use Test::More;
eval "use Test::Pod 1.00";
plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
use Cwd;
my $dir = cwd;
if ( $dir =~ /t$/ )
{
@directories = ('../lib/');
}
else
{
@directories = ();
}
my @files = all_pod_files(
@directories
);
plan tests => scalar(@files);
foreach my $module (@files)
{
pod_file_ok( $module )
}
@@ -0,0 +1,20 @@
use Test::More tests => 4;
use strict;
use warnings;
use diagnostics;
use lib '../lib';
use Benchmark;
use_ok('SOAP::WSDL::XSD::Typelib::Builtin::string');
my $obj;
ok $obj = SOAP::WSDL::XSD::Typelib::Builtin::string->new(
{ value => '& "Aber" <test>'})
, "Object creation";
is $obj, '&amp; &qout;Aber&qout; &lt;test&gt;'
, 'escape text on serialization';
is $obj->serialize({ name => 'test'})
, '<test >&amp; &qout;Aber&qout; &lt;test&gt;</test >'
, 'Serialization with name';