File: WSDLParser.pm

package info (click to toggle)
libsoap-wsdl-perl 3.004-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,600 kB
  • sloc: perl: 8,433; xml: 1,769; java: 19; makefile: 15
file content (74 lines) | stat: -rw-r--r-- 2,566 bytes parent folder | download | duplicates (6)
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
#!perl
package Test::SOAP::WSDL::Expat::WSDLParser;
use strict;
use warnings;
use Test::More;
use Test::SOAP::WSDL::Tester;
use base qw(Test::SOAP::WSDL::Tester);

# It's a modulinho - it runs when executed...
if (! caller() ) {
    __PACKAGE__->runtests();
}

sub parse_t_uri {
    my $self = shift;
    my $parser = SOAP::WSDL::Expat::WSDLParser->new();
    return $parser->parse_uri($self->t_url() . '/'. shift);
}

sub parse_wsdl_schema :Test(1) {
    my $self = shift;
    ok my $wsdl = $self->parse_t_uri( "../imported/schema/wsdl11/wsdl.xsd");
}

sub parse_soap_binding :Test(1) {
    my $self = shift;
    ok my $wsdl = $self->parse_t_uri( "../imported/schema/wsdl11/soap_binding.xsd");
}

sub parse_http_binding :Test(1) {
    my $self = shift;
    ok my $wsdl = $self->parse_t_uri( "../imported/schema/wsdl11/http_binding.xsd");
}

sub parse_wsdl :Test(3) {
    my $self = shift;
    ok my $wsdl = $self->parse_t_uri( "acceptance/wsdl/WSDLParser.wsdl");
    my $schema = $wsdl->first_types()->get_schema()->[1];
    my $attr = $schema->get_element()->[0]->first_complexType->first_attribute();
    ok $attr->get_name('testAttribute');
    ok $attr->get_type('xs:string');

}

sub parse_wsdl_with_import :Test(8) {
    my $self = shift;
    ok my $wsdl = $self->parse_t_uri( "acceptance/wsdl/WSDLParser-import.wsdl");

    # Content checks
    is $wsdl->get_service()->[0]->get_name(),   'Service1',     'found service name';
    is $wsdl->get_portType->[0]->get_name(),    'Service1Soap', 'found portType name';
    is $wsdl->get_types()->[0]
        ->get_schema()->[1]
            ->get_element()->[0]->get_name(),   'sayHello',     'found element name';
    ok my $schema_from_ref = $wsdl->get_types()
        ->[0]->get_schema(), 'found schema';
    is @{ $schema_from_ref },                   2,              'got builtin and imported schema';
    ok @{ $schema_from_ref->[1]->get_element } > 0,             'found mi element in second schema';
    is $schema_from_ref->[1]
        ->get_element->[0]->get_name(),          'sayHello',     'found element name';
}

sub parse_wsdl_with_import_loop :Test(1) {
    my $self = shift;
    SKIP: {
        skip 'cannot test without Test::Warn', 1 if not $self->has_test_warn();
        my $wsdl;
        Test::Warn::warning_like
             { $wsdl = $self->parse_t_uri( "acceptance/wsdl/WSDLParser_import_loop.wsdl") }
            qr{file:///home/martin/workspace/SOAP-WSDL/t/acceptance/wsdl/import_loop.xsd \s already \s imported. \s Ignoring \s it}x,
            'warn about duplicate import';
    }
}
1;