1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
use Test::More tests => 11;
use lib '../lib';
use File::Basename qw(dirname);
use Cwd;
my $path = dirname __FILE__;
use_ok(qw/SOAP::WSDL::Expat::WSDLParser/);
my $filter;
my $parser;
ok($parser = SOAP::WSDL::Expat::WSDLParser->new() );
eval { $parser->parse_file( "$path/test.wsdl" ) };
if ($@)
{
fail("parsing WSDL: $@");
die "Can't test without parsed WSDL";
}
else
{
pass("parsing XML");
}
my $wsdl;
ok( $wsdl = $parser->get_data() , "get object tree");
my $schema = $wsdl->first_types();
my $opt = {
readable => 0,
autotype => 1,
namespace => $wsdl->get_xmlns(),
indent => "\t",
typelib => $schema,
};
is( $schema->find_type( 'urn:myNamespace', 'testSimpleType1' )->serialize(
'test', 1 , $opt ),
q{<test type="tns:testSimpleType1">1</test>} , "serialize simple type");
is( $schema->find_type( 'urn:myNamespace', 'testSimpleList' )->serialize(
'testList', [ 1, 2, 3 ] , $opt),
q{<testList type="tns:testSimpleList">1 2 3</testList>},
"serialize simple list type"
);
is( $schema->find_element( 'urn:myNamespace', 'TestElement' )->serialize(
undef, 1 , $opt),
q{<TestElement type="xsd:int">1</TestElement>}, "Serialize element"
);
$opt->{ readable } = 0;
is( $schema->find_type( 'urn:myNamespace', 'length3')->serialize(
'TestComplex', { size => -13, unit => 'BLA' } ,
$opt ),
q{<TestComplex type="tns:length3" >}
. q{<size type="xsd:nonPositiveInteger">-13</size>}
. q{<unit type="xsd:NMTOKEN">BLA</unit></TestComplex>}
, "serialize complex type" );
is( $schema->find_element( 'urn:myNamespace', 'TestElementComplexType')->serialize(
undef, { size => -13, unit => 'BLA' } ,
$opt ),
q{<TestElementComplexType type="tns:length3" >}
. q{<size type="xsd:nonPositiveInteger">-13</size>}
. q{<unit type="xsd:NMTOKEN">BLA</unit></TestElementComplexType>},
"element with complex type"
);
is( $schema->find_type( 'urn:myNamespace', 'complex')->serialize(
'complexComplex',
{ 'length' => { size => -13, unit => 'BLA' }, 'int' => 1 },
$opt ),
q{<complexComplex type="tns:complex" >}
. q{<length type="tns:length3" >}
. q{<size type="xsd:nonPositiveInteger">-13</size>}
. q{<unit type="xsd:NMTOKEN">BLA</unit></length>}
. q{<int type="xsd:int">1</int></complexComplex>},
"nested complex type"
);
is( $wsdl->find_message('urn:myNamespace', 'testRequest')->first_part()->serialize(
undef, { test => { length => { size => -13, unit => 'BLA' } , int => 3 } },
$opt ),
q{<test type="tns:complex" >}
. q{<length type="tns:length3" >}
. q{<size type="xsd:nonPositiveInteger">-13</size>}
. q{<unit type="xsd:NMTOKEN">BLA</unit>}
. q{</length><int type="xsd:int">3</int></test>}
, "Message part"
);
|