morgand     01/08/17 13:11:17

  Added:       latka/doc processWatchdogJSP.pl
  Log:
  perl script for converting Watchdog gtests to a Latka suite
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/latka/doc/processWatchdogJSP.pl
  
  Index: processWatchdogJSP.pl
  ===================================================================
  while (<STDIN>) {
    $doc .= $_;
  }
  
  print qq'<?xml version="1.0" standalone="no"?>\n';
  print qq'<!DOCTYPE suite SYSTEM "../conf/suite.dtd">\n';
  print qq'<suite default_host="localhost" default_port="8080" label="Watchdog JSP 
tests">';
  
  # remove junk
  $doc =~ s#<property .*?/>##sg;
  $doc =~ s#<taskdef .*?/>##sg;
  $doc =~ s#</?target.*?>##sg;
  $doc =~ s#</?project.*?>##sg;
  
  # fix me - create sessions for each test category
  $doc =~ s#testName=\".*?\"##sg;
  
  # this is never relevant - latka has other ways to handle this
  $doc =~ s#debug="0" host="\${host}" port ?="\${port}"##sg;
  
  # make every gtest into a request
  $doc =~ s#<gtest request="GET (.*?) 
HTTP/1.0"(.*?)assertion="(.*?)"\s*?testStrategy="(.*?)"\s*?/>#<request path="$1" 
label="$3">\n<validate>\n<TEMPLABLE>$4</TEMPLABLE>\n$2</validate>\n</request>#sg;
  
  $doc =~ s#returncode="200"#<status_code/>#sgi;
  $doc =~ s#returncode="HTTP/1.0 200 OK"#<status_code/>#sgi;
  $doc =~ s#returncode="500"#<status_code code="500"/>#sgi;
  $doc =~ s#goldenFile="(.*?)"#<golden_file file_name="$1" 
ignore_whitespace="true"/>#sg;
  $doc =~ s#responseMatch="(.*?)"#<regexp pattern="$1"/>#sg;
  
  # apply the label to the first test
  $doc =~ s#<validate>\s*<TEMPLABLE>(.*?)</TEMPLABLE>\s*?(<[^>]*?)/>#<validate>\n$2 
label="$1"/>#sg;
  
  
  
  print $doc;
  
  print "\n</suite>";
  
  #now someone beautify me and we're done
  
  
  

Reply via email to