/[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-methods.t revision 227 by dpavlin, Sun Nov 25 18:51:26 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 => 18;
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    use Devel::LeakTrace::Fast;
14    
15  BEGIN {  BEGIN {
16          use_ok('CWMP::Response');          use_ok('CWMP::Methods');
17  }  }
18    
19  #ok( my $xml = join("",<DATA>), 'xml' );  ok(my $abs_path = abs_path($0), "abs_path");
20  #diag $xml if $debug;  $abs_path =~ s!/[^/]*$!/!;      #!fix-vim
21    
22    ok( my $method = CWMP::Methods->new({ debug => $debug }), 'new' );
23    isa_ok( $method, 'CWMP::Methods' );
24    
25    sub check_method {
26            my $command = shift || die "no command?";
27    
28            my $state = {
29                    ID => 42,
30            };
31    
32            diag "check_method $command",dump( 'state', @_ ) if $debug;
33            ok( my $xml = $method->$command( $state, shift ), "generate method $command" . dump(@_) );
34    
35            my $file = "$abs_path/methods/$command.xml";
36    
37  ok( my $response = CWMP::Response->new({ debug => $debug }), 'new' );          if ( ! -e $file ) {
38  isa_ok( $response, 'CWMP::Response' );                  diag "creating $file";
39                    write_file( $file, $xml );
40            }
41    
42  sub is_like {          my $template_xml = read_file( $file ) || die "can't read template xml $file: $!";
         my ( $command, $template_xml ) = @_;  
43    
44          ok( my $xml = $response->$command({ ID => 42 }), $command );          is( $xml, $template_xml, "compare $file" );
         diag $xml if $debug;  
         chomp( $xml );  
         chomp( $template_xml );  
         like( $xml, qr{^\Q$template_xml\E$}, $command . ' xml' );  
45  }  }
46    
47  is_like( 'Inform', <<__SOAP__  check_method( 'InformResponse' );
48  <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_method( 'GetRPCMethods' );
49    <soap:Header>  check_method( 'Reboot' );
50      <cwmp:ID mustUnderstand="1">42</cwmp:ID>  check_method( 'SetParameterValues', {
51      <cwmp:NoMoreRequests>0</cwmp:NoMoreRequests>          'InternetGatewayDevice.DeviceInfo.ProvisioningCode' => 'test provision',
52    </soap:Header>          'InternetGatewayDevice.DeviceInfo.X_000E50_Country' => 42,
53    <soap:Body>  });
54      <cwmp:InformResponse>  check_method( 'GetParameterNames', [ 'InternetGatewayDevice.DeviceInfo.SerialNumber' ] );
55        <cwmp:MaxEnvelopes>1</cwmp:MaxEnvelopes>  check_method( 'GetParameterValues', [
56      </cwmp:InformResponse>          'InternetGatewayDevice.DeviceInfo.SerialNumber',
57    </soap:Body>          'InternetGatewayDevice.DeviceInfo.VendorConfigFile.',
58  </soap:Envelope>  ]);
59  __SOAP__  check_method( 'GetParameterAttributes', [
60  );          'InternetGatewayDevice.DeviceInfo.SerialNumber'
61    ]);
 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.227

  ViewVC Help
Powered by ViewVC 1.1.26