/[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 71 by dpavlin, Wed Jun 20 23:35:04 2007 UTC google/trunk/t/20-methods.t revision 178 by dpavlin, Sun Oct 28 19:47:30 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 => 11;  use Test::More tests => 16;
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::Methods');
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 $method = CWMP::Methods->new({ debug => $debug }), 'new' );
21  isa_ok( $response, 'CWMP::Response' );  isa_ok( $method, 'CWMP::Methods' );
22    
23  sub is_like {  sub check_method {
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 );          };
         chomp( $template_xml );  
         like( $xml, qr{^\Q$template_xml\E$}, $command . ' xml' );  
 }  
29    
30  is_like( 'InformResponse', <<__SOAP__          diag "check_method $command",dump( 'state', @_ ) if $debug;
31  <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/">          ok( my $xml = $method->$command( $state, @_ ), "generate method $command" . dump(@_) );
   <soap:Header>  
     <cwmp:ID mustUnderstand="1">42</cwmp:ID>  
     <cwmp:NoMoreRequests>0</cwmp:NoMoreRequests>  
   </soap:Header>  
   <soap:Body>  
     <cwmp:InformResponse>  
       <cwmp:MaxEnvelopes>1</cwmp:MaxEnvelopes>  
     </cwmp:InformResponse>  
   </soap:Body>  
 </soap:Envelope>  
 __SOAP__  
 );  
32    
33  is_like( 'GetRPCMethods', <<__SOAP__          my $file = "$abs_path/methods/$command.xml";
 <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__  
 );  
34    
35  is_like( 'Reboot', <<__SOAP__          if ( ! -e $file ) {
36  <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/">                  diag "creating $file";
37    <soap:Header>                  write_file( $file, $xml );
38      <cwmp:ID mustUnderstand="1">42</cwmp:ID>          }
     <cwmp:NoMoreRequests>0</cwmp:NoMoreRequests>  
   </soap:Header>  
   <soap:Body>  
     <Reboot />  
   </soap:Body>  
 </soap:Envelope>  
 __SOAP__  
 );  
39    
40  is_like( 'GetParameterNames', <<__SOAP__          my $template_xml = read_file( $file ) || die "can't read template xml $file: $!";
41  <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/">  
42    <soap:Header>          is( $xml, $template_xml, "compare $file" );
43      <cwmp:ID mustUnderstand="1">42</cwmp:ID>  }
44      <cwmp:NoMoreRequests>0</cwmp:NoMoreRequests>  
45    </soap:Header>  check_method( 'InformResponse' );
46    <soap:Body>  check_method( 'GetRPCMethods' );
47      <cwmp:GetParameterNames>  check_method( 'Reboot' );
48        <cwmp:ParameterPath></cwmp:ParameterPath>  check_method( 'SetParameterValues',
49        <cwmp:NextLevel>0</cwmp:NextLevel>          'InternetGatewayDevice.DeviceInfo.ProvisioningCode' => 'test provision',
50      </cwmp:GetParameterNames>          'InternetGatewayDevice.DeviceInfo.X_000E50_Country' => 42,
51    </soap:Body>  );
52  </soap:Envelope>  check_method( 'GetParameterNames', 'InternetGatewayDevice.DeviceInfo.SerialNumber' );
53  __SOAP__  check_method( 'GetParameterValues',
54            'InternetGatewayDevice.DeviceInfo.SerialNumber',
55            'InternetGatewayDevice.DeviceInfo.VendorConfigFile.',
56  );  );

Legend:
Removed from v.71  
changed lines
  Added in v.178

  ViewVC Help
Powered by ViewVC 1.1.26