/[cwmp]/google/trunk/t/20-methods.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /google/trunk/t/20-methods.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

google/t/20-response.t revision 50 by dpavlin, Tue Jun 19 21:29:04 2007 UTC google/trunk/t/20-response.t revision 172 by dpavlin, Sun Oct 28 15:43:07 2007 UTC
# Line 4  use warnings; Line 4  use warnings;
4    
5  my $debug = shift @ARGV;  my $debug = shift @ARGV;
6    
7  use Test::More tests => 7;  use Test::More tests => 14;
8  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
9    use Cwd qw/abs_path/;
10    use File::Slurp;
11  use blib;  use blib;
12    
13  BEGIN {  BEGIN {
14          use_ok('CWMP::Response');          use_ok('CWMP::Response');
15  }  }
16    
17  #ok( my $xml = join("",<DATA>), 'xml' );  ok(my $abs_path = abs_path($0), "abs_path");
18  #diag $xml if $debug;  $abs_path =~ s!/[^/]*$!/!;      #!fix-vim
19    
20  ok( my $response = CWMP::Response->new({ debug => $debug }), 'new' );  ok( my $response = CWMP::Response->new({ debug => $debug }), 'new' );
21  isa_ok( $response, 'CWMP::Response' );  isa_ok( $response, 'CWMP::Response' );
22    
23  sub is_like {  sub check_response {
24          my ( $command, $template_xml ) = @_;          my $command = shift || die "no command?";
25    
26          ok( my $xml = $response->$command({ ID => 42 }), $command );          my $state = {
27          diag $xml if $debug;                  ID => 42,
28          chomp( $xml );          };
29          chomp( $template_xml );  
30          like( $xml, qr{^\Q$template_xml\E$}, $command . ' xml' );          diag "check_response $command",dump( 'state', @_ ) if $debug;
31            ok( my $xml = $response->$command( $state, @_ ), "generate response $command" . dump(@_) );
32    
33            my $file = "$abs_path/response/$command.xml";
34    
35            if ( ! -e $file ) {
36                    diag "creating $file";
37                    write_file( $file, $xml );
38            }
39    
40            my $template_xml = read_file( $file ) || die "can't read template xml $file: $!";
41    
42            is( $xml, $template_xml, "compare $command" );
43  }  }
44    
45  is_like( 'Inform', <<__SOAP__  check_response( 'InformResponse' );
46  <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/">  check_response( 'GetRPCMethods' );
47    <soap:Header>  check_response( 'Reboot' );
48      <cwmp:ID mustUnderstand="1">42</cwmp:ID>  check_response( 'GetParameterNames', 'InternetGatewayDevice.DeviceInfo.SerialNumber' );
49      <cwmp:NoMoreRequests>0</cwmp:NoMoreRequests>  check_response( 'GetParameterValues', 'InternetGatewayDevice.DeviceInfo.SerialNumber', 'InternetGatewayDevice.DeviceInfo.VendorConfigFile.' );
   </soap:Header>  
   <soap:Body>  
     <cwmp:InformResponse>  
       <cwmp:MaxEnvelopes>1</cwmp:MaxEnvelopes>  
     </cwmp:InformResponse>  
   </soap:Body>  
 </soap:Envelope>  
 __SOAP__  
 );  
   
 is_like( 'GetRPCMethods', <<__SOAP__  
 <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/">  
   <soap:Header>  
     <cwmp:ID mustUnderstand="1">42</cwmp:ID>  
     <cwmp:NoMoreRequests>0</cwmp:NoMoreRequests>  
   </soap:Header>  
   <soap:Body>  
     <GetRPCMethods />  
   </soap:Body>  
 </soap:Envelope>  
 __SOAP__  
 );  

Legend:
Removed from v.50  
changed lines
  Added in v.172

  ViewVC Help
Powered by ViewVC 1.1.26