reorg source code tree to make trunk
[perl-cwmp.git] / t / 20-response.t
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4
5 my $debug = shift @ARGV;
6
7 use Test::More tests => 11;
8 use Data::Dump qw/dump/;
9 use blib;
10
11 BEGIN {
12         use_ok('CWMP::Response');
13 }
14
15 #ok( my $xml = join("",<DATA>), 'xml' );
16 #diag $xml if $debug;
17
18 ok( my $response = CWMP::Response->new({ debug => $debug }), 'new' );
19 isa_ok( $response, 'CWMP::Response' );
20
21 sub is_like {
22         my ( $command, $template_xml ) = @_;
23
24         ok( my $xml = $response->$command({ ID => 42 }), $command );
25         diag $xml if $debug;
26         chomp( $xml );
27         chomp( $template_xml );
28         like( $xml, qr{^\Q$template_xml\E$}, $command . ' xml' );
29 }
30
31 is_like( 'InformResponse', <<__SOAP__
32 <soap:Envelope xmlns:cwmp="urn:dslforum-org:cwmp-1-0" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
33   <soap:Header>
34     <cwmp:ID mustUnderstand="1">42</cwmp:ID>
35     <cwmp:NoMoreRequests>0</cwmp:NoMoreRequests>
36   </soap:Header>
37   <soap:Body>
38     <cwmp:InformResponse>
39       <cwmp:MaxEnvelopes>1</cwmp:MaxEnvelopes>
40     </cwmp:InformResponse>
41   </soap:Body>
42 </soap:Envelope>
43 __SOAP__
44 );
45
46 is_like( 'GetRPCMethods', <<__SOAP__
47 <soap:Envelope xmlns:cwmp="urn:dslforum-org:cwmp-1-0" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
48   <soap:Header>
49     <cwmp:ID mustUnderstand="1">42</cwmp:ID>
50     <cwmp:NoMoreRequests>0</cwmp:NoMoreRequests>
51   </soap:Header>
52   <soap:Body>
53     <GetRPCMethods />
54   </soap:Body>
55 </soap:Envelope>
56 __SOAP__
57 );
58
59 is_like( 'Reboot', <<__SOAP__
60 <soap:Envelope xmlns:cwmp="urn:dslforum-org:cwmp-1-0" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
61   <soap:Header>
62     <cwmp:ID mustUnderstand="1">42</cwmp:ID>
63     <cwmp:NoMoreRequests>0</cwmp:NoMoreRequests>
64   </soap:Header>
65   <soap:Body>
66     <Reboot />
67   </soap:Body>
68 </soap:Envelope>
69 __SOAP__
70 );
71
72 is_like( 'GetParameterNames', <<__SOAP__
73 <soap:Envelope xmlns:cwmp="urn:dslforum-org:cwmp-1-0" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
74   <soap:Header>
75     <cwmp:ID mustUnderstand="1">42</cwmp:ID>
76     <cwmp:NoMoreRequests>0</cwmp:NoMoreRequests>
77   </soap:Header>
78   <soap:Body>
79     <cwmp:GetParameterNames>
80       <cwmp:ParameterPath></cwmp:ParameterPath>
81       <cwmp:NextLevel>0</cwmp:NextLevel>
82     </cwmp:GetParameterNames>
83   </soap:Body>
84 </soap:Envelope>
85 __SOAP__
86 );