import SOAP-WSDL 2.00_31 from CPAN

git-cpan-module:   SOAP-WSDL
git-cpan-version:  2.00_31
git-cpan-authorid: MKUTTER
git-cpan-file:     authors/id/M/MK/MKUTTER/SOAP-WSDL-2.00_31.tar.gz
This commit is contained in:
Martin Kutter authored and Michael G. Schwern committed 2009-12-12 19:48:21 -08:00
1 parent 874251225f
commit f0b3bdc201
54 files changed
+1094 -450

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
use strict;
use warnings;
use Test::More tests => 2; #qw(no_plan);
use_ok qw(SOAP::WSDL::XSD::Attribute);
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">
<s:element name="sayHello">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="name"
type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="givenName"
type="s:string" nillable="1" />
</s:sequence>
<s:attribute name="testAttr" type="s:string" use="optional"></s:attribute>
</s:complexType>
</s:element>
<s:element name="sayHelloResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1"
name="sayHelloResult" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
};
my $schema = $parser->parse($xml);
is $schema->find_element('urn:HelloWorld', 'sayHello')
->first_complexType()
->first_attribute()->get_name(),
'testAttr', 'found attribute';
+12 -2
View File
@@ -1,11 +1,11 @@
package Foo;
sub serialize {
return "serialized $_[1] $_[2]";
return "serialized $_[1] $_[2]" . join ' ', @{$_[3]->{ attributes } || [] } if $_[3];
}
package main;
use strict;
use warnings;
use Test::More tests => 12;
use Test::More tests => 16;
use_ok qw(SOAP::WSDL::XSD::Element);
@@ -16,6 +16,9 @@ is $element->first_simpleType(), undef;
$element->set_simpleType('Foo');
is $element->first_simpleType(), 'Foo';
is $element->serialize('Foobar', 'Bar', { namespace => {} } ), 'serialized Foobar Bar';
is $element->serialize('Foobar', undef, { namespace => {} } ), 'serialized Foobar ';
$element->set_simpleType( [ 'Foo', 'Bar' ]);
is $element->first_simpleType(), 'Foo';
@@ -30,6 +33,13 @@ is $element->first_complexType(), 'Foo';
$element->set_default('Foo');
is $element->serialize('Foobar', undef, { namespace => {} } ), 'serialized Foobar Foo';
$element->set_targetNamespace('urn:foobar');
is $element->serialize('Foobar', undef, { namespace => {}, qualify => 1 } ), 'serialized Foobar Foo xmlns="urn:foobar"';
$element->set_targetNamespace('urn:foobar');
is $element->serialize('Foobar', 'Bar', { namespace => {}, qualify => 1 } ), 'serialized Foobar Bar xmlns="urn:foobar"';
$element->set_name('Bar');
is $element->serialize(undef, undef, { namespace => {} } ), 'serialized Bar Foo';
+32
View File
@@ -0,0 +1,32 @@
use strict;
use warnings;
use Test::More tests => 4;
use SOAP::WSDL::XSD::Element;
use_ok qw(SOAP::WSDL::XSD::Schema);
my $obj = SOAP::WSDL::XSD::Schema->new({
element => [
SOAP::WSDL::XSD::Element->new({
name => 'foo',
targetNamespace => 'bar',
}),
SOAP::WSDL::XSD::Element->new({
name => 'foo',
targetNamespace => 'baz',
}),
SOAP::WSDL::XSD::Element->new({
name => 'foobar',
targetNamespace => 'bar',
}),
]
});
my $found= $obj->find_element('bar', 'foobar');
is $found->get_name(), 'foobar', 'found Element';
$found = $obj->find_element('baz', 'foo');
is $found->get_name(), 'foo', 'found Element';
$found = $obj->find_element('baz', 'foobar');
is $found, undef, 'find_Element returns undef on unknown Element';
+47 -36
View File
@@ -18,7 +18,7 @@ package MyType;
use base qw(SOAP::WSDL::XSD::Typelib::ComplexType);
{
my %test_of :ATTR(:get<test>);
__PACKAGE__->_factory(
[ 'test' ],
{ test => \%test_of, },
@@ -41,11 +41,11 @@ use base qw(SOAP::WSDL::XSD::Typelib::AttributeSet);
my %test2_of :ATTR(:get<test2>);
__PACKAGE__->_factory(
[ 'test', 'test2' ],
{
{
test => \%test_of,
test2 => \%test2_of,
},
{
{
test => 'SOAP::WSDL::XSD::Typelib::Builtin::string',
test2 => 'MyAttribute',
}
@@ -68,21 +68,18 @@ __PACKAGE__->_factory(
);
package main;
use Test::More tests => 106;
use Test::More tests => 109;
use Storable;
my $have_warn = eval { require Test::Warn; import 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/>';
for my $class (qw{MyEmptyType MyEmptyType2}) {
$obj = $class->new();
is $obj->serialize, '', "$class object serializes to q{}";
is $obj->serialize({ name => 'test'}), '<test/>', "$class object serializes to <test/> with name=test";
}
$obj = MyType->new({});
isa_ok $obj, 'MyType';
@@ -101,16 +98,17 @@ isa_ok $obj, 'MyType';
isa_ok $obj->get_test, 'SOAP::WSDL::XSD::Typelib::Builtin::string';
is $obj->get_test, 'Test1', 'element content';
$obj = MyType->new({
test => SOAP::WSDL::XSD::Typelib::Builtin::string->new({
$obj = MyType->new({
test => SOAP::WSDL::XSD::Typelib::Builtin::string->new({
value => 'Test2'
})
});
isa_ok $obj, 'MyType';
isa_ok $obj->get_test, 'SOAP::WSDL::XSD::Typelib::Builtin::string';
is $obj->get_test, 'Test2', 'element content';
$obj = MyType->new({
$obj = MyType->new({
test => { value => 'Test2' } # just a trick - pass it unaltered to new...
});
isa_ok $obj, 'MyType';
@@ -120,17 +118,18 @@ is $obj->get_test, 'Test2', 'element content';
$hash_of_ref = $obj->as_hash_ref();
is $hash_of_ref->{ test }, 'Test2';
$obj = MyType->new({
$obj = MyType->new({
test => [
SOAP::WSDL::XSD::Typelib::Builtin::string->new({
SOAP::WSDL::XSD::Typelib::Builtin::string->new({
value => 'Test'
}),
SOAP::WSDL::XSD::Typelib::Builtin::string->new({
SOAP::WSDL::XSD::Typelib::Builtin::string->new({
value => 'Test2'
})
],
});
isa_ok $obj, 'MyType';
isa_ok $obj->get_test, 'ARRAY';
is $obj->get_test()->[0], 'Test', 'element content (list content [0])';
@@ -154,24 +153,21 @@ is $nested->get_test->[0], $obj;
$nested = MyType2->new({
test => {
test => [
SOAP::WSDL::XSD::Typelib::Builtin::string->new({
SOAP::WSDL::XSD::Typelib::Builtin::string->new({
value => 'Test'
}),
SOAP::WSDL::XSD::Typelib::Builtin::string->new({
SOAP::WSDL::XSD::Typelib::Builtin::string->new({
value => 'Test2'
})
],
},
},
});
$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();
isa_ok $obj, 'MyType';
is $obj->get_test, undef, 'undefined element content';
@@ -197,6 +193,11 @@ for my $count (1..5) {
$obj->set_test();
is $obj->get_test, (), 'removed element content';
$obj = MyEmptyType->new();
eval {
isa_ok $obj->attr() , 'SOAP::WSDL::XSD::Typelib::AttributeSet';
};
like $@, qr{\s has \s no \s attributes}x;
$obj = MyElement->new();
isa_ok $obj->attr() , 'SOAP::WSDL::XSD::Typelib::AttributeSet';
@@ -212,7 +213,7 @@ is $obj->serialize(),
'Serialization with attributes';
$obj->attr()->set_test2('test');
is $obj->serialize(),
is $obj->serialize(),
q{<MyElement test="TestAttribute" test2="test"/>},
'Serialization with attributes';
@@ -227,7 +228,7 @@ is $obj->get_test, undef;
eval { $foo = @{ $obj->get_test() } };
if (! $@) {
is $foo, undef;
}
}
else {
like $@ , qr{Can't \s use \s an \s undefined}x, 'get_ELEMENT still undef on ARRAYIFY';
}
@@ -260,13 +261,18 @@ for my $count (1..5) {
is $obj->get_test->[$index], "TestString$index";
}
is $obj->serialize(), $serialized[$count -1];
}
my $clone = Storable::thaw( Storable::freeze( $obj ));
is $clone->get_test()->[0], 'TestString0';
## failure tests
eval {
$obj = MyType->new({
$obj = MyType->new({
test => [
SOAP::WSDL::XSD::Typelib::Builtin::string->new({
SOAP::WSDL::XSD::Typelib::Builtin::string->new({
value => 'Test'
}),
@@ -277,14 +283,22 @@ eval {
like $@, qr{cannot \s use \s CODE}xms;
eval {
$obj = MyType->new({
$obj = MyType->new({
test => \&CORE::die,
});
};
like $@, qr{cannot \s use \s CODE}xms;
# TODO ignore XMLNS (for now)
$obj = MyType->new({ xmlns => 'fubar'});
ok defined $obj;
TODO: {
local $TODO = "Support XML namespaces";
is $obj->get_xmlns(), 'fubar';
}
eval {
$obj = MyType->new({
$obj = MyType->new({
foobar => 'fubar'
});
};
@@ -300,16 +314,13 @@ like $@, qr{Can't \s locate \s object \s method}x;
eval { MyType->new({ FOO => 42 }) };
like $@, qr{unknown \s field \s}xm;
my $clone = Storable::thaw( Storable::freeze( $obj ));
is $clone->get_test()->[0], 'TestString0';
eval { SOAP::WSDL::XSD::Typelib::ComplexType::AUTOMETHOD() };
like $@, qr{Cannot \s call}xm;
eval { SOAP::WSDL::XSD::Typelib::ComplexType->_factory([], { test => {} }, {}) };
like $@, qr{ No \s class \s given \s for \s }xms;
eval { SOAP::WSDL::XSD::Typelib::ComplexType->_factory([], { test => {} }, { test => 'HopeItDoesntExistOnYourSystem'}) };
like $@, qr{ Can't \s locate \s HopeItDoesntExistOnYourSystem.pm }xms;
# print Dumper