import SOAP-WSDL 2.00_27 from CPAN
git-cpan-module: SOAP-WSDL git-cpan-version: 2.00_27 git-cpan-authorid: MKUTTER git-cpan-file: authors/id/M/MK/MKUTTER/SOAP-WSDL-2.00_27.tar.gz
This commit is contained in:
committed by
Michael G. Schwern
parent
3cfeebae54
commit
eb096ad88e
@@ -1,4 +1,4 @@
|
||||
use Test::More tests => 37;
|
||||
use Test::More tests => 38;
|
||||
use File::Basename qw(dirname);
|
||||
use File::Spec;
|
||||
use File::Path;
|
||||
@@ -11,6 +11,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(
|
||||
"$path/../../../acceptance/wsdl/generator_test.wsdl"
|
||||
#"$path/../../../acceptance/wsdl/elementAtomicComplexType.xml"
|
||||
@@ -34,6 +35,7 @@ $generator->generate_typelib();
|
||||
}
|
||||
# print $code;
|
||||
|
||||
|
||||
$generator->set_type_prefix('MyTypes');
|
||||
$generator->set_element_prefix('MyElements');
|
||||
$generator->set_typemap_prefix('MyTypemaps');
|
||||
@@ -43,7 +45,15 @@ $generator->set_output(undef);
|
||||
$generator->generate();
|
||||
#$generator->generate_typelib();
|
||||
#$generator->generate_typemap();
|
||||
$generator->generate_interface();
|
||||
|
||||
if (eval { require Test::Warn; }) {
|
||||
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 };
|
||||
}
|
||||
|
||||
$generator->generate_server();
|
||||
|
||||
|
||||
44
t/SOAP/WSDL/Part.t
Normal file
44
t/SOAP/WSDL/Part.t
Normal file
@@ -0,0 +1,44 @@
|
||||
package MyTypelib;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
|
||||
sub find_element {};
|
||||
sub find_type {};
|
||||
|
||||
package main;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 5;
|
||||
|
||||
use_ok qw(SOAP::WSDL::Part);
|
||||
|
||||
my $typelib = {};
|
||||
|
||||
eval { SOAP::WSDL::Part->serialize() };
|
||||
like $@, qr{No typelib};
|
||||
|
||||
my $opt = {
|
||||
typelib => 'MyTypelib',
|
||||
namespace => { foo => 'bar'}
|
||||
};
|
||||
|
||||
my $data = {};
|
||||
|
||||
my $part = SOAP::WSDL::Part->new();
|
||||
|
||||
eval { $part->serialize('name', $data, $opt ) };
|
||||
like $@, qr{Neither type nor element};
|
||||
|
||||
$part->set_type('foo:Foo');
|
||||
|
||||
eval { $part->serialize('name', $data, $opt ) };
|
||||
like $@, qr{type foo:Foo};
|
||||
|
||||
$part->set_type(undef);
|
||||
|
||||
$part->set_element('foo:Foo');
|
||||
|
||||
eval { $part->serialize('name', $data, $opt ) };
|
||||
like $@, qr{element foo:Foo};
|
||||
13
t/SOAP/WSDL/Serializer/XSD.t
Normal file
13
t/SOAP/WSDL/Serializer/XSD.t
Normal file
@@ -0,0 +1,13 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More qw(no_plan);
|
||||
|
||||
use_ok qw(SOAP::WSDL::Serializer::XSD);
|
||||
|
||||
my $serializer = SOAP::WSDL::Serializer::XSD->new();
|
||||
|
||||
like $serializer->serialize(), qr{<SOAP-ENV:Body></SOAP-ENV:Body>}, 'empty body';
|
||||
like $serializer->serialize({ body => {} }), qr{<SOAP-ENV:Body></SOAP-ENV:Body>}, 'empty body';
|
||||
like $serializer->serialize({ body => [] }), qr{<SOAP-ENV:Body></SOAP-ENV:Body>}, 'empty body';
|
||||
like $serializer->serialize({ header => {}, body => [] }),
|
||||
qr{<SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body></SOAP-ENV:Body>}, 'empty header and body';
|
||||
@@ -7,7 +7,11 @@ sub bar {
|
||||
return "Verdammte Axt";
|
||||
}
|
||||
package main;
|
||||
use Test::More tests => 4;
|
||||
use Test::More;
|
||||
eval "require IO::Scalar"
|
||||
or plan skip_all => 'IO::Scalar required for testing...';
|
||||
|
||||
plan tests => 8;
|
||||
|
||||
use_ok(SOAP::WSDL::Server);
|
||||
use_ok(SOAP::WSDL::Server::CGI);
|
||||
@@ -19,8 +23,6 @@ $server->set_action_map_ref({
|
||||
'testaction' => 'testmethod',
|
||||
});
|
||||
|
||||
eval "require IO::Scalar"
|
||||
or exit 0;
|
||||
{
|
||||
no warnings qw(once);
|
||||
*IO::Scalar::BINMODE = sub {};
|
||||
@@ -48,17 +50,31 @@ $server->set_action_map_ref({
|
||||
$server->set_dispatch_to( 'HandlerClass' );
|
||||
|
||||
$server->handle();
|
||||
like $output, qr{no \s element \s found}xms;
|
||||
$output = q{};
|
||||
|
||||
print "\n";
|
||||
|
||||
$ENV{HTTP_SOAPAction} = 'test';
|
||||
$ENV{REQUEST_METHOD} = 'POST';
|
||||
$ENV{HTTP_SOAPACTION} = 'test';
|
||||
$server->handle();
|
||||
like $output, qr{no \s element \s found}xms;
|
||||
$output = q{};
|
||||
|
||||
print "\n";
|
||||
delete $ENV{HTTP_SOAPACTION};
|
||||
|
||||
$ENV{EXPECT} = 'Foo';
|
||||
$ENV{HTTP_SOAPAction} = 'foo';
|
||||
$server->handle();
|
||||
|
||||
like $output, qr{no \s element \s found}xms;
|
||||
$output = q{};
|
||||
|
||||
$ENV{EXPECT} = '100-Continue';
|
||||
$ENV{HTTP_SOAPAction} = 'foo';
|
||||
$server->handle();
|
||||
like $output, qr{100 \s Continue}xms;
|
||||
$output = q{};
|
||||
|
||||
|
||||
*STDOUT = $stdout;
|
||||
|
||||
# print $output;
|
||||
11
t/SOAP/WSDL/XSD/ComplexType.t
Normal file
11
t/SOAP/WSDL/XSD/ComplexType.t
Normal file
@@ -0,0 +1,11 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 2; #qw(no_plan);
|
||||
|
||||
use_ok qw(SOAP::WSDL::XSD::ComplexType);
|
||||
|
||||
my $obj = SOAP::WSDL::XSD::ComplexType->new();
|
||||
$obj->set_flavor('extension');
|
||||
|
||||
eval { $obj->serialize('foo') };
|
||||
like $@, qr{sorry, \s we \s just}xsm;
|
||||
43
t/SOAP/WSDL/XSD/Element.t
Normal file
43
t/SOAP/WSDL/XSD/Element.t
Normal file
@@ -0,0 +1,43 @@
|
||||
package Foo;
|
||||
sub serialize {
|
||||
return "serialized $_[1] $_[2]";
|
||||
}
|
||||
package main;
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 12;
|
||||
|
||||
use_ok qw(SOAP::WSDL::XSD::Element);
|
||||
|
||||
my $element = SOAP::WSDL::XSD::Element->new();
|
||||
|
||||
is $element->first_simpleType(), undef;
|
||||
|
||||
$element->set_simpleType('Foo');
|
||||
is $element->first_simpleType(), 'Foo';
|
||||
|
||||
$element->set_simpleType( [ 'Foo', 'Bar' ]);
|
||||
is $element->first_simpleType(), 'Foo';
|
||||
|
||||
is $element->first_complexType(), undef;
|
||||
|
||||
$element->set_complexType('Foo');
|
||||
is $element->first_complexType(), 'Foo';
|
||||
|
||||
$element->set_complexType( [ 'Foo', 'Bar' ]);
|
||||
is $element->first_complexType(), 'Foo';
|
||||
|
||||
$element->set_default('Foo');
|
||||
is $element->serialize('Foobar', undef, { namespace => {} } ), 'serialized Foobar Foo';
|
||||
|
||||
$element->set_name('Bar');
|
||||
is $element->serialize(undef, undef, { namespace => {} } ), 'serialized Bar Foo';
|
||||
|
||||
$element->set_fixed('Foobar');
|
||||
is $element->serialize(undef, undef, { namespace => {} } ), 'serialized Bar Foobar';
|
||||
|
||||
$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;
|
||||
33
t/SOAP/WSDL/XSD/SimpleType.t
Normal file
33
t/SOAP/WSDL/XSD/SimpleType.t
Normal file
@@ -0,0 +1,33 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 11;
|
||||
|
||||
use_ok qw(SOAP::WSDL::XSD::SimpleType);
|
||||
|
||||
my $obj = SOAP::WSDL::XSD::SimpleType->new();
|
||||
|
||||
$obj->set_list({ LocalName => 'foo', Value => 'bar'},
|
||||
{ LocalName => 'itemType', Value => 'xsd:int'} );
|
||||
is $obj->get_flavor(), 'list';
|
||||
is $obj->get_itemType(), 'xsd:int';
|
||||
|
||||
is $obj->serialize('Foo', ['Foo', 'Bar']), '<Foo>Foo Bar</Foo>';
|
||||
|
||||
$obj->set_union({ LocalName => 'foo', Value => 'bar'},
|
||||
{ LocalName => 'memberTypes', Value => 'xsd:int'} );
|
||||
is $obj->get_flavor(), 'union';
|
||||
is $obj->get_base()->[0], 'xsd:int';
|
||||
|
||||
$obj->set_union({ LocalName => 'foo', Value => 'bar'},
|
||||
{ LocalName => 'memberTypes', Value => 'xsd:int xsd:string'} );
|
||||
is $obj->get_flavor(), 'union';
|
||||
is $obj->get_base()->[1], 'xsd:string';
|
||||
|
||||
is $obj->serialize('Foo', 'Foobar'), '<Foo>Foobar</Foo>';
|
||||
|
||||
$obj->set_flavor('enumeration');
|
||||
is $obj->serialize('Foo', 'Foobar'), '<Foo>Foobar</Foo>';
|
||||
|
||||
# TODO die on non-serializable content...
|
||||
$obj->set_flavor('');
|
||||
is $obj->serialize('Foo', 'Foobar'), '';
|
||||
@@ -1,6 +1,14 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
package MyEmptyType;
|
||||
use base qw(SOAP::WSDL::XSD::Typelib::ComplexType);
|
||||
__PACKAGE__->_factory([],{},{});
|
||||
|
||||
package MyEmptyType2;
|
||||
use base qw(SOAP::WSDL::XSD::Typelib::ComplexType);
|
||||
__PACKAGE__->_factory();
|
||||
|
||||
package MyType;
|
||||
|
||||
use base qw(SOAP::WSDL::XSD::Typelib::ComplexType);
|
||||
@@ -34,15 +42,34 @@ __PACKAGE__->_factory(
|
||||
);
|
||||
|
||||
package main;
|
||||
use Test::More tests => 89;
|
||||
use Data::Dumper;
|
||||
use Test::More tests => 100;
|
||||
use Storable;
|
||||
|
||||
my $have_warn = eval { use Test::Warn; 1; };
|
||||
|
||||
my $obj;
|
||||
|
||||
$obj = MyEmptyType->new();
|
||||
is $obj->serialize, '';
|
||||
is $obj->serialize({ name => 'test'}), '<test />';
|
||||
|
||||
$obj = MyEmptyType2->new();
|
||||
is $obj->serialize, '';
|
||||
is $obj->serialize({ name => 'test'}), '<test />';
|
||||
|
||||
|
||||
$obj = MyType->new({});
|
||||
isa_ok $obj, 'MyType';
|
||||
is $obj->get_test, undef, 'undefined element content';
|
||||
|
||||
my $hash_of_ref = $obj->as_hash_ref();
|
||||
is scalar keys %{ $hash_of_ref }, 0;
|
||||
|
||||
SKIP: {
|
||||
skip 'Cannot test warnings without Test::Warn', 1 if not $have_warn;
|
||||
warning_is { $obj->add_test() } 'attempting to add empty value to MyType';
|
||||
}
|
||||
|
||||
$obj = MyType->new({ test => 'Test1'});
|
||||
isa_ok $obj, 'MyType';
|
||||
isa_ok $obj->get_test, 'SOAP::WSDL::XSD::Typelib::Builtin::string';
|
||||
@@ -64,6 +91,9 @@ isa_ok $obj, 'MyType';
|
||||
isa_ok $obj->get_test, 'SOAP::WSDL::XSD::Typelib::Builtin::string';
|
||||
is $obj->get_test, 'Test2', 'element content';
|
||||
|
||||
$hash_of_ref = $obj->as_hash_ref();
|
||||
is $hash_of_ref->{ test }, 'Test2';
|
||||
|
||||
$obj = MyType->new({
|
||||
test => [
|
||||
SOAP::WSDL::XSD::Typelib::Builtin::string->new({
|
||||
@@ -80,6 +110,10 @@ isa_ok $obj->get_test, 'ARRAY';
|
||||
is $obj->get_test()->[0], 'Test', 'element content (list content [0])';
|
||||
is $obj->get_test()->[1], 'Test2', 'element content (list content [1])';
|
||||
|
||||
$hash_of_ref = $obj->as_hash_ref();
|
||||
is $hash_of_ref->{ test }->[0], 'Test';
|
||||
is $hash_of_ref->{ test }->[1], 'Test2';
|
||||
|
||||
my $nested = MyType2->new({
|
||||
test => $obj,
|
||||
});
|
||||
@@ -106,6 +140,10 @@ $nested = MyType2->new({
|
||||
});
|
||||
|
||||
|
||||
$hash_of_ref = $nested->as_hash_ref();
|
||||
is $hash_of_ref->{ test }->{ test }->[1], 'Test2';
|
||||
|
||||
|
||||
# isnt $nested->get_test->[0], $obj, 'element identity';
|
||||
|
||||
$obj = MyType->new();
|
||||
@@ -203,6 +241,14 @@ eval {
|
||||
like $@, qr{cannot \s use \s CODE}xms;
|
||||
|
||||
|
||||
eval {
|
||||
$obj = MyType->new({
|
||||
foobar => 'fubar'
|
||||
});
|
||||
};
|
||||
like $@, qr{unknown \s field \s foobar \s in \s MyType }xms;
|
||||
|
||||
|
||||
eval { $obj->set_FOO(42) };
|
||||
like $@, qr{Can't \s locate \s object \s method}x;
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@
|
||||
(Inclusive constraints) </xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:all>
|
||||
<xsd:element name="test1" type="xsd:int"/>
|
||||
<xsd:element name="test1" type="int"/>
|
||||
<xsd:element name="test2" type="xsd:string"/>
|
||||
</xsd:all>
|
||||
</xsd:complexType>
|
||||
@@ -204,6 +204,10 @@
|
||||
<message name="testResponse">
|
||||
<part name="testAll" element="tns:testElementString"/>
|
||||
</message>
|
||||
<message name="testMultiPartWarning">
|
||||
<part name="testAll" element="tns:testElementString"/>
|
||||
<part name="parameters" element="tns:testChoice"/>
|
||||
</message>
|
||||
<message name="testHeaderRequest">
|
||||
<part name="testBody" element="tns:testHeader"/>
|
||||
<part name="testHeader" element="tns:Header"/>
|
||||
@@ -233,6 +237,14 @@
|
||||
<input message="tns:testChoice"/>
|
||||
<output message="tns:testChoice"/>
|
||||
</operation>
|
||||
<operation name="testMultiPartWarning">
|
||||
<documentation>
|
||||
Test-Methode
|
||||
</documentation>
|
||||
<input message="tns:testMultiPartWarning"/>
|
||||
<output message="tns:testMultiPartWarning"/>
|
||||
</operation>
|
||||
|
||||
</portType>
|
||||
|
||||
<binding type="tns:testPort" name="testBinding">
|
||||
@@ -257,15 +269,25 @@
|
||||
</output>
|
||||
</operation>
|
||||
<operation name="testHeader">
|
||||
<soap:operation soapAction="testHeader"/>
|
||||
<soap:operation soapAction="testHeader"/>
|
||||
<input>
|
||||
<soap:body use="literal" parts="tns:testBody"/>
|
||||
<soap:header use="literal" part="tns:testHeader" message="tns:testHeaderRequest"/>
|
||||
</input>
|
||||
<output>
|
||||
<soap:body use="literal"/>
|
||||
</output>
|
||||
</operation>
|
||||
</input>
|
||||
<output>
|
||||
<soap:body use="literal"/>
|
||||
</output>
|
||||
</operation>
|
||||
<operation name="testMultiPartWarning">
|
||||
<soap:operation soapAction="testHeader"/>
|
||||
<input>
|
||||
<soap:body use="literal"/>
|
||||
</input>
|
||||
<output>
|
||||
<soap:body use="literal"/>
|
||||
</output>
|
||||
</operation>
|
||||
|
||||
</binding>
|
||||
<service name="testService">
|
||||
<port name="testPort" binding="tns:testBinding">
|
||||
|
||||
Reference in New Issue
Block a user