import SOAP-WSDL 2.00_33 from CPAN

git-cpan-module:   SOAP-WSDL
git-cpan-version:  2.00_33
git-cpan-authorid: MKUTTER
git-cpan-file:     authors/id/M/MK/MKUTTER/SOAP-WSDL-2.00_33.tar.gz
This commit is contained in:
Martin Kutter
2009-12-12 19:48:28 -08:00
committed by Michael G. Schwern
parent 51db446428
commit 0cbf981665
146 changed files with 3364 additions and 1280 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
use strict;
use warnings;
use Test::More qw(no_plan);
use Test::More tests => 2;
use Template;
use File::Basename;
use File::Spec;
+28 -7
View File
@@ -4,11 +4,23 @@ use Test::More tests => 5;
use File::Basename;
use File::Spec;
my $path = File::Spec->rel2abs( dirname __FILE__ );
use SOAP::WSDL::Generator::Template::Plugin::XSD;
use SOAP::WSDL::Generator::Iterator::WSDL11;
use SOAP::WSDL::Generator::PrefixResolver;
use_ok qw(SOAP::WSDL::Generator::Visitor::Typemap);
my $visitor;
ok $visitor = SOAP::WSDL::Generator::Visitor::Typemap->new(), 'constructor';
ok $visitor = SOAP::WSDL::Generator::Visitor::Typemap->new({
resolver => SOAP::WSDL::Generator::Template::Plugin::XSD->new({
prefix_resolver=> SOAP::WSDL::Generator::PrefixResolver->new({
prefix => {
type => 'TestTypes',
element => 'TestElements',
typemap => 'TestTypemap',
}
}),
})
}), 'constructor';
use SOAP::WSDL::Expat::WSDLParser;
@@ -24,12 +36,21 @@ $parser->parse_file(
my $definitions = $parser->get_data();
$definitions->_accept( $visitor );
my $iter = SOAP::WSDL::Generator::Iterator::WSDL11->new({
definitions => $definitions
});
$visitor->set_definitions($definitions);
$iter->init();
while (my $node = $iter->get_next()) {
$node->_accept( $visitor );
};
my $typemap = $visitor->get_typemap();
is $typemap->{'EnqueueMessage/MMessage/MKeepalive'}, 'MyTypes::TKeepalive', 'content';
is $typemap->{'EnqueueMessageResponse'}, 'MyElements::EnqueueMessageResponse', 'content';
is $typemap->{'KeepaliveMessageResponse'}, 'MyElements::KeepaliveMessageResponse', 'content';
is $typemap->{'EnqueueMessage/MMessage/MKeepalive'}, 'TestTypes::TKeepalive', 'content';
is $typemap->{'EnqueueMessageResponse'}, 'TestElements::EnqueueMessageResponse', 'content';
is $typemap->{'KeepaliveMessageResponse'}, 'TestElements::KeepaliveMessageResponse', 'content';
use Data::Dumper;
print Dumper $typemap;
sub wsdl {
q{<?xml version="1.0" encoding="UTF-8"?>
@@ -137,4 +158,4 @@ xmlns="http://schemas.xmlsoap.org/wsdl/">
</service>
</definitions>
}
}
}
-27
View File
@@ -1,27 +0,0 @@
use strict;
use warnings;
use Test::More;
use File::Spec;
use File::Basename;
eval { require XML::Compile::WSDL11 }
or plan skip_all => 'Cannot test without XML::Compile::WSDL11';
eval { require XML::LibXML }
or plan skip_all => 'Cannot test without XML::LibXML';
plan skip_all => 'XML::Compile::WSDL11 is not functional yet';
plan qw(no_plan);
my $path = File::Spec->rel2abs( dirname __FILE__ );
my $libxml = XML::LibXML->new();
my $xml = $libxml->parse_file("$path/../../../acceptance/wsdl/generator_test.wsdl");
my $wsdl = XML::Compile::WSDL11->new($xml);
my $schemas = $wsdl->schemas;
ok my $operation = $wsdl->operation('testHeader');
#die Dumper $operation;
#
#my $client = $operation->prepareClient();
+33 -2
View File
@@ -1,4 +1,4 @@
use Test::More tests => 42;
use Test::More tests => 49;
use File::Basename qw(dirname);
use File::Spec;
use File::Path;
@@ -156,9 +156,40 @@ ok my $empty = MyElements::testElementCompletelyEmptyComplex->new();
is $empty->serialize_qualified(), '<testElementCompletelyEmptyComplex xmlns="urn:Test"/>'
, 'serialize empty';
ok eval { require MyTypes::testComplexTypeSimpleRestriction; }
, 'load MyTypes::testComplexTypeSimpleRestriction';
ok eval { require MyTypes::testComplexTypeSequenceWithAttribute; }
, 'load MyTypes::testComplexTypeSequenceWithAttribute';
use_ok qw(MyElements::testElementComplexTypeSequenceWithAttribute);
my $obj = MyElements::testElementComplexTypeSequenceWithAttribute->new({
Test1 => 'foo',
Test2 => 'bar',
});
$obj->attr({ testAttr => 'foobar' });
is $obj, q{<testElementComplexTypeSequenceWithAttribute xmlns="urn:Test" }
. q{testAttr="foobar"><Test1>foo</Test1><Test2>bar</Test2>}
. q{</testElementComplexTypeSequenceWithAttribute>}
, 'seralize complexType sequence with attribute';
use_ok qw(MyTypes::testSimpleContentExtension);
ok $obj = MyTypes::testSimpleContentExtension->new({ value => 'foo' });
$obj->attr({ testAttr => 'bar' });
is $obj->serialize({ name => 'baz'}), q{<baz testAttr="bar">foo</baz>};
SKIP: {
eval { require Test::Pod::Content; }
or skip 'Cannot test pod content without Test::Pod::Content', 1;
Test::Pod::Content::pod_section_like(
'MyTypes::testComplexTypeSequenceWithAttribute',
'attr',
qr{Test \s Attribute \s good \s for \s nothing}x,
'Attribute POD');
}
rmtree "$path/testlib";
+19 -17
View File
@@ -1,4 +1,4 @@
use Test::More tests => 12;
use Test::More tests => 14;
use File::Basename qw(dirname);
use File::Spec;
use File::Path;
@@ -12,7 +12,7 @@ use SOAP::WSDL::Expat::WSDLParser;
my $parser = SOAP::WSDL::Expat::WSDLParser->new();
my $definitions = $parser->parse_file(
my $definitions = $parser->parse_file(
"$path/../../../acceptance/wsdl/generator_test_dot_names.wsdl"
#"$path/../../../acceptance/wsdl/elementAtomicComplexType.xml"
);
@@ -26,7 +26,7 @@ my $generator = SOAP::WSDL::Generator::Template::XSD->new({
});
my $code = "";
$generator->set_output(\$code);
$generator->set_output(\$code);
$generator->generate_typelib();
{
eval $code;
@@ -47,9 +47,9 @@ $generator->generate();
#$generator->generate_typemap();
if (eval { require Test::Warn; }) {
Test::Warn::warning_like( sub { $generator->generate_interface() },
Test::Warn::warning_like( sub { $generator->generate_interface() },
qr{\A Multiple \s parts \s detected \s in \s message \s testMultiPartWarning}xms);
}
}
else {
$generator->generate_interface();
SKIP: { skip 'Cannot test warnings without Test::Warn', 1 };
@@ -61,38 +61,40 @@ eval "use lib '$path/testlib'";
use_ok qw(MyInterfaces::My::SOAP::testService::testPort);
use_ok qw(MyServer::My::SOAP::testService::testPort);
use_ok qw(MyTypes::testComplexTypeRestriction);
use_ok qw(MyTypes::testComplexTypeAll);
SKIP: {
eval { require Test::Pod::Content; }
or skip 'Cannot test pod content without Test::Pod::Content', 6;
Test::Pod::Content::pod_section_like(
'MyInterfaces::My::SOAP::testService::testPort',
'NAME',
'MyInterfaces::My::SOAP::testService::testPort',
'NAME',
qr{^MyInterfaces::My::SOAP::testService::testPort \s - \s}xms,
'Pod NAME section');
Test::Pod::Content::pod_section_like(
'MyInterfaces::My::SOAP::testService::testPort',
'SYNOPSIS',
'MyInterfaces::My::SOAP::testService::testPort',
'SYNOPSIS',
qr{use \s MyInterfaces::My::SOAP::testService::testPort}xms,
'Pod SYNOPSIS section');
Test::Pod::Content::pod_section_like(
'MyInterfaces::My::SOAP::testService::testPort',
'SYNOPSIS',
'MyInterfaces::My::SOAP::testService::testPort',
'SYNOPSIS',
qr{\s MyInterfaces::My::SOAP::testService::testPort->new\(}xms,
'Pod SYNOPSIS section');
Test::Pod::Content::pod_section_like(
'MyServer::My::SOAP::testService::testPort',
'NAME',
'MyServer::My::SOAP::testService::testPort',
'NAME',
qr{^MyServer::My::SOAP::testService::testPort \s - \s}xms,
'Pod NAME section');
Test::Pod::Content::pod_section_like(
'MyServer::My::SOAP::testService::testPort',
'SYNOPSIS',
'MyServer::My::SOAP::testService::testPort',
'SYNOPSIS',
qr{use \s MyServer::My::SOAP::testService::testPort}xms,
'Pod SYNOPSIS section');
Test::Pod::Content::pod_section_like(
'MyServer::My::SOAP::testService::testPort',
'SYNOPSIS',
'MyServer::My::SOAP::testService::testPort',
'SYNOPSIS',
qr{\s MyServer::My::SOAP::testService::testPort->new\(}xms,
'Pod SYNOPSIS section');
}
@@ -0,0 +1,117 @@
use Test::More tests => 14;
use File::Basename qw(dirname);
use File::Spec;
use File::Path;
my $path = File::Spec->rel2abs( dirname __FILE__ );
use SOAP::WSDL::Expat::MessageParser;
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_file(
"$path/../../../acceptance/wsdl/nested_complextype.wsdl"
);
ok my $element = $definitions->get_types()->[0]->find_element("urn:HelloWorld", "sayHello")
, 'got element';
ok my $sub_element = $element->get_complexType->[0]->find_element("urn:HelloWorld", "givenName"),
, 'atomic type element';
ok $sub_element->get_complexType->[0]->find_element("urn:HelloWorld", "givenName"),
'element in subtype';
my $generator = SOAP::WSDL::Generator::Template::XSD->new({
definitions => $definitions,
type_prefix => 'Bar',
element_prefix => 'BarElem',
typemap_prefix => 'Bar',
OUTPUT_PATH => "$path/testlib",
});
my $code = "";
$generator->set_output(\$code);
$generator->generate_typelib();
{
eval $code;
ok !$@, 'eval generated code';
print $@ if $@;
}
# print $code;
my %prefix_of = (
type => 'FooType',
element => 'FooElement',
typemap => 'FooMap',
);
while (my ($name, $value) = each %prefix_of ) {
$generator->can("set_$name\_prefix")->($generator, $value);
}
$generator->set_output(undef);
$generator->generate();
#$generator->generate_typelib();
$generator->generate_typemap();
$generator->generate_server();
eval "use lib '$path/testlib'";
use_ok qw(FooElement::sayHello);
eval {
FooElement::sayHello::_givenName->new({
givenName => 'Foo',
middleInitial => 'Bar',
});
};
ok !$@, 'instantiate subpackage FooElement::sayHello::_givenName';
eval {
FooElement::sayHello::_givenName::XmlAttr->new({
testAttr => 'Bar'
});
};
ok !$@, 'instantiate subpackage attribute class FooElement::sayHello::_givenName::XmlAttr';
SKIP: {
eval { require Test::Pod::Content; }
or skip 'Cannot test pod content without Test::Pod::Content', 1;
Test::Pod::Content::pod_section_is(
'FooElement::sayHello',
'NAME',
'FooElement::sayHello',
'Pod NAME section');
}
#rmtree "$path/testlib";
require FooMap::Service1;
my $message_parser = SOAP::WSDL::Expat::MessageParser->new({
class_resolver => 'FooMap::Service1',
});
my $result = $message_parser->parse_string( xml() );
is $result->get_name(), 'Kutter', 'content';
is $result->get_givenName()->get_givenName, 'Martin', 'nested complexType content';
is $result->get_givenName()->get_givenName, 'Martin', 'nested complexType content';
is $result->get_givenName()->attr()->get_testAttr, 'Bar', 'nested complexType attr';
sub xml {
return q{<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" >
<SOAP-ENV:Body >
<sayHello xmlns="urn:HelloWorld" testAttr="Foo">
<name>Kutter</name>
<givenName testAttr="Bar">
<givenName>Martin</givenName>
<middleInitial>A.</middleInitial>
</givenName>
</sayHello>
</SOAP-ENV:Body></SOAP-ENV:Envelope>};
}
+2 -2
View File
@@ -10,7 +10,7 @@ use_ok qw(SOAP::WSDL::Generator::Template::XSD);
use SOAP::WSDL::Expat::WSDLParser;
my $parser = SOAP::WSDL::Expat::WSDLParser->new();
my $definitions = $parser->parse_file(
my $definitions = $parser->parse_file(
"$path/../../../acceptance/wsdl/generator_unsupported_test.wsdl"
);
@@ -21,4 +21,4 @@ my $generator = SOAP::WSDL::Generator::Template::XSD->new({
{
eval { $generator->generate_typelib() };
}
ok $@;
ok $@, $@;
+23
View File
@@ -0,0 +1,23 @@
use Test::More qw(no_plan);
use lib 'testlib';
#ok eval { require MyTypes::testComplexTypeSequenceWithAttribute; }
# , 'load MyTypes::testComplexTypeSequenceWithAttribute';
#
#my $obj = MyTypes::testComplexTypeSequenceWithAttribute->new({
# Test1 => 'foo',
# Test2 => 'bar',
#});
#$obj->attr({ testAttr => 'foobar' });
#
#print $obj->attr();
#
use_ok qw(MyElements::testElementComplexTypeSequenceWithAttribute);
my $obj = MyElements::testElementComplexTypeSequenceWithAttribute->new({
Test1 => 'foo',
Test2 => 'bar',
});
$obj->attr({ testAttr => 'foobar' });
print $obj;