http-webtest-commits Mailing List for HTTP-WebTest (Page 9)
Brought to you by:
m_ilya,
richardanderson
You can subscribe to this list here.
| 2002 |
Jan
(38) |
Feb
(83) |
Mar
(10) |
Apr
(28) |
May
(42) |
Jun
(61) |
Jul
(43) |
Aug
(42) |
Sep
(14) |
Oct
(27) |
Nov
(16) |
Dec
(81) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(81) |
Feb
(29) |
Mar
(32) |
Apr
(42) |
May
(3) |
Jun
|
Jul
(11) |
Aug
|
Sep
(33) |
Oct
(6) |
Nov
(4) |
Dec
|
| 2004 |
Jan
|
Feb
|
Mar
(10) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Ilya M. <m_...@us...> - 2003-01-25 14:49:54
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder In directory sc8-pr-cvs1:/tmp/cvs-serv23794/lib/HTTP/WebTest/Recorder Log Message: Directory /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder added to the repository |
|
From: Ilya M. <m_...@us...> - 2003-01-24 09:38:11
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/t
In directory sc8-pr-cvs1:/tmp/cvs-serv23790/t
Modified Files:
02-controller.t
Log Message:
Tests for redirects
Index: 02-controller.t
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/t/02-controller.t,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** 02-controller.t 3 Jan 2003 23:01:17 -0000 1.1.1.1
--- 02-controller.t 24 Jan 2003 09:38:07 -0000 1.2
***************
*** 6,10 ****
use HTTP::Status;
! use Test::More tests => 28;
# get test template files directory included in search path
--- 6,11 ----
use HTTP::Status;
! use Test::More tests => 34;
! use Test::Exception;
# get test template files directory included in search path
***************
*** 73,76 ****
--- 74,79 ----
like($response->content, qr/REQUEST = HTTP::Request/,
'Request object should be passed to template');
+ is($response->header('Pragma'), 'No-Cache',
+ 'Make sure that proxy web interface is not cached');
}
***************
*** 96,98 ****
--- 99,134 ----
like($response->content, qr/parse error.*unexpected token \(ME\)/,
'Verify text of error message');
+ }
+
+ # test redirect()
+ {
+ dies_ok { $CONTROLLER->redirect('xxx') } 'Expecting redirect exception';
+ isa_ok($@, 'HTTP::WebTest::Exception::Redirect',
+ 'Verify exception class');
+ is($@->url, 'xxx', 'Test url property of exception');
+ }
+
+ # try to access page that generates a redirect
+ {
+ local %HTTP::WebTest::Controller::DISPATCH =
+ ( redirect => 'TestRedirect' );
+ # just to disable used only once warning
+ () = %HTTP::WebTest::Controller::DISPATCH;
+ {
+ package TestRedirect;
+ use base qw(HTTP::WebTest::Action);
+
+ sub execute {
+ my $self = shift;
+ my $controller = shift;
+
+ return $controller->redirect('xxx');
+ }
+ }
+ my $request = GET 'http://localhost/webtest/redirect';
+ my $response = $CONTROLLER->execute(action => 'redirect',
+ request => $request);
+ is($response->code, RC_FOUND, 'Expect redirect message');
+ is($response->header('Location'), 'xxx',
+ 'Check if we got correct Location header');
}
|
|
From: Ilya M. <m_...@us...> - 2003-01-24 09:37:47
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/template
In directory sc8-pr-cvs1:/tmp/cvs-serv23439/lib/HTTP/WebTest/template
Modified Files:
page.inc
Log Message:
Add recorder turn on/off switch to all pages
Index: page.inc
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/template/page.inc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** page.inc 3 Jan 2003 23:01:24 -0000 1.1.1.1
--- page.inc 24 Jan 2003 09:37:44 -0000 1.2
***************
*** 2,5 ****
--- 2,6 ----
[% USE HTML %]
+ [% USE enable_url = URL('enable') %]
<html>
***************
*** 8,13 ****
--- 9,22 ----
</head>
<body>
+
+ [% IF controller.recorder.is_recording %]
+ <p><a href="[% enable_url(enable => 0) %]">Turn off</a> recording</p>
+ [% ELSE %]
+ <p><a href="[% enable_url(enable => 1) %]">Turn on</a> recording</p>
+ [% END %]
+
<h1>[% HTML.escape(title) %]</h1>
[% content %]
+
</body>
</html>
|
|
From: Ilya M. <m_...@us...> - 2003-01-24 09:36:52
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest
In directory sc8-pr-cvs1:/tmp/cvs-serv22742/lib/HTTP/WebTest
Modified Files:
Controller.pm
Log Message:
Support redirects
Index: Controller.pm
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Controller.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Controller.pm 18 Jan 2003 18:51:13 -0000 1.3
--- Controller.pm 24 Jan 2003 09:36:49 -0000 1.4
***************
*** 9,12 ****
--- 9,13 ----
use HTTP::Status;
use HTTP::WebTest::Utils qw(make_access_method);
+ use HTTP::WebTest::Exceptions;
use Template;
***************
*** 29,36 ****
*request = make_access_method('REQUEST');
! my %DISPATCH = (list => 'HTTP::WebTest::Action::List',
! request => 'HTTP::WebTest::Action::Request',
! wtscript => 'HTTP::WebTest::Action::WTScript',
! default => 'HTTP::WebTest::Action');
# serves requests for web interface of the proxy
--- 30,40 ----
*request = make_access_method('REQUEST');
! use vars qw(%DISPATCH);
!
! %DISPATCH = (list => 'HTTP::WebTest::Action::List',
! request => 'HTTP::WebTest::Action::Request',
! wtscript => 'HTTP::WebTest::Action::WTScript',
! enable => 'HTTP::WebTest::Action::Enable',
! default => 'HTTP::WebTest::Action');
# serves requests for web interface of the proxy
***************
*** 49,53 ****
my $action = $action_package->new;
! return $self->process_template($action->execute($self));
}
--- 53,70 ----
my $action = $action_package->new;
! my $response;
! eval {
! $response = $self->process_template($action->execute($self));
! };
! if($@) {
! if($@->isa('HTTP::WebTest::Exception::Redirect')) {
! $response = HTTP::Response->new(RC_FOUND);
! $response->header(Location => $@->url);
! } else {
! $@->rethrow;
! }
! };
! $response->header(Pragma => 'No-Cache');
! return $response;
}
***************
*** 75,78 ****
--- 92,104 ----
return $response;
}
+ }
+
+ # generates redirect exception
+ sub redirect {
+ my $self = shift;
+ my $url = shift;
+
+ HTTP::WebTest::Exception::Redirect->throw(message => 'Redirect',
+ url => $url);
}
|
|
From: Ilya M. <m_...@us...> - 2003-01-24 09:26:44
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder
In directory sc8-pr-cvs1:/tmp/cvs-serv14884
Modified Files:
Makefile.PL
Log Message:
Updated requirements
Index: Makefile.PL
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/Makefile.PL,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Makefile.PL 3 Jan 2003 23:01:12 -0000 1.1.1.1
--- Makefile.PL 24 Jan 2003 09:26:41 -0000 1.2
***************
*** 14,19 ****
WriteMakefile( NAME => 'HTTP::WebTest::Recorder',
VERSION_FROM => $VERSION_FROM,
! PREREQ_PM => { 'HTTP::WebTest' => 2.01,
! 'Template' => 2.00 },
AUTHOR => $AUTHOR,
ABSTRACT => $ABSTRACT,
--- 14,21 ----
WriteMakefile( NAME => 'HTTP::WebTest::Recorder',
VERSION_FROM => $VERSION_FROM,
! PREREQ_PM => { 'Exception::Class' => 0.99,
! 'HTTP::WebTest' => 2.01,
! 'Template' => 2.00,
! 'Test::Exception' => 0.03},
AUTHOR => $AUTHOR,
ABSTRACT => $ABSTRACT,
|
|
From: Ilya M. <m_...@us...> - 2003-01-24 09:21:55
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Action
In directory sc8-pr-cvs1:/tmp/cvs-serv11556/lib/HTTP/WebTest/Action
Added Files:
Enable.pm
Log Message:
Added
--- NEW FILE: Enable.pm ---
package HTTP::WebTest::Action::Enable;
# $Id: Enable.pm,v 1.1 2003/01/24 09:21:44 m_ilya Exp $
use strict;
use base qw(HTTP::WebTest::Action);
sub execute {
my $self = shift;
my $controller = shift;
my $enable = $controller->cgi->param('enable');
$controller->recorder->is_recording($enable);
$controller->redirect('list');
}
1;
|
|
From: Ilya M. <m_...@us...> - 2003-01-24 09:21:55
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest
In directory sc8-pr-cvs1:/tmp/cvs-serv11556/lib/HTTP/WebTest
Added Files:
Exceptions.pm
Log Message:
Added
--- NEW FILE: Exceptions.pm ---
package HTTP::WebTest::Exceptions;
use strict;
my %EXC;
BEGIN {
%EXC = ( HTTP::WebTest::Exception =>
{ description =>
'Generic base class for all Investion exceptions' },
HTTP::WebTest::Exception::Redirect =>
{ isa => 'HTTP::WebTest::Exception',
fields => [ 'url' ],
description => 'Redirect message' },
);
}
use Exception::Class %EXC;
{
package HTTP::WebTest::Exception;
# have nice stack trace output
sub as_string {
my $self = shift;
my $str = $self->full_message;
chomp $str;
if(exists $self->{show_trace} ? $self->{show_trace} : $self->Trace) {
$str .= "\n\n\n" . $self->_stack_trace . "\n\n";
}
return $str;
}
sub _stack_trace {
my $self = shift;
my $str = '';
while(my $frame = $self->trace->next_frame) {
next if $frame->subroutine eq 'Exception::Class::Base::throw';
next if $frame->subroutine =~ /^Investop::Exceptions::.*error$/;
my $args = join ', ', map defined $_ ? "'$_'" : 'undef', $frame->args;
$str .= ' [' . $frame->filename . ':' . $frame->line . '] ';
$str .= $frame->subroutine . "($args)\n";
}
return $str;
}
}
1;
|
|
From: Ilya M. <m_...@us...> - 2003-01-24 09:21:55
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/t
In directory sc8-pr-cvs1:/tmp/cvs-serv11556/t
Added Files:
07-action-enable.t
Log Message:
Added
--- NEW FILE: 07-action-enable.t ---
#!/usr/bin/perl -w
use strict;
use HTTP::Request::Common;
use HTTP::Status;
use HTTP::WebTest::Test;
use Test::More tests => 18;
use Test::Exception;
require_ok('HTTP::WebTest::Action::Enable');
require_ok('HTTP::WebTest::Controller');
require_ok('HTTP::WebTest::Recorder');
# test constructors
my $ACTION = new HTTP::WebTest::Action::Enable;
isa_ok($ACTION, 'HTTP::WebTest::Action::Enable');
my $CONTROLLER = new HTTP::WebTest::Controller;
isa_ok($CONTROLLER, 'HTTP::WebTest::Controller');
my $RECORDER = new HTTP::WebTest::Recorder;
isa_ok($RECORDER, 'HTTP::WebTest::Recorder');
$CONTROLLER->recorder($RECORDER);
# test if we can turn on recording
{
$CONTROLLER->cgi(CGI->new({ enable => 1 }));
dies_ok { $ACTION->execute($CONTROLLER) } 'Expect redirect';
isa_ok($@, 'HTTP::WebTest::Exception::Redirect',
'Verify exception class');
is($@->url, 'list', 'Test url property of exception');
ok($CONTROLLER->recorder->is_recording, 'Recording');
}
# test if we can turn off recording
{
$CONTROLLER->cgi(CGI->new({ enable => 0 }));
dies_ok { $ACTION->execute($CONTROLLER) } 'Expect redirect';
isa_ok($@, 'HTTP::WebTest::Exception::Redirect',
'Verify exception class');
is($@->url, 'list', 'Test url property of exception');
ok(not($CONTROLLER->recorder->is_recording), 'Not recording');
}
# test if we can turn on recording once again
{
$CONTROLLER->cgi(CGI->new({ enable => 1 }));
dies_ok { $ACTION->execute($CONTROLLER) } 'Expect redirect';
isa_ok($@, 'HTTP::WebTest::Exception::Redirect',
'Verify exception class');
is($@->url, 'list', 'Test url property of exception');
ok($CONTROLLER->recorder->is_recording, 'Recording');
}
|
|
From: Ilya M. <m_...@us...> - 2003-01-18 18:52:25
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/t
In directory sc8-pr-cvs1:/tmp/cvs-serv5228/t
Modified Files:
06-action-wtscript.t 05-action-request.t 04-action-list.t
03-action.t
Log Message:
Updated
Index: 06-action-wtscript.t
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/t/06-action-wtscript.t,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** 06-action-wtscript.t 7 Jan 2003 21:03:55 -0000 1.1
--- 06-action-wtscript.t 18 Jan 2003 18:52:18 -0000 1.2
***************
*** 43,49 ****
}
! # check if template_data returns draft of wtscript
{
! my %data = $ACTION->template_data($CONTROLLER);
is($data{wtscript}, <<'WTSCRIPT',
test_name = N/A
--- 43,49 ----
}
! # check if execute returns draft of wtscript
{
! my %data = $ACTION->execute($CONTROLLER);
is($data{wtscript}, <<'WTSCRIPT',
test_name = N/A
Index: 05-action-request.t
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/t/05-action-request.t,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** 05-action-request.t 7 Jan 2003 21:10:04 -0000 1.2
--- 05-action-request.t 18 Jan 2003 18:52:18 -0000 1.3
***************
*** 38,55 ****
}
! # check if template_data returns request object by number
{
$CONTROLLER->cgi(CGI->new({num => 0}));
! my %data = $ACTION->template_data($CONTROLLER);
is($data{test}, $RECORDER->tests->[0],
'Check if "test" variable is defined');
$CONTROLLER->cgi(CGI->new({num => 1}));
! %data = $ACTION->template_data($CONTROLLER);
is($data{test}, $RECORDER->tests->[1],
'Check if "test" variable is defined');
$CONTROLLER->cgi(CGI->new({num => 2}));
! %data = $ACTION->template_data($CONTROLLER);
is($data{test}, undef,
'Check if "test" variable is not defined');
--- 38,55 ----
}
! # check if execute returns request object by number
{
$CONTROLLER->cgi(CGI->new({num => 0}));
! my %data = $ACTION->execute($CONTROLLER);
is($data{test}, $RECORDER->tests->[0],
'Check if "test" variable is defined');
$CONTROLLER->cgi(CGI->new({num => 1}));
! %data = $ACTION->execute($CONTROLLER);
is($data{test}, $RECORDER->tests->[1],
'Check if "test" variable is defined');
$CONTROLLER->cgi(CGI->new({num => 2}));
! %data = $ACTION->execute($CONTROLLER);
is($data{test}, undef,
'Check if "test" variable is not defined');
Index: 04-action-list.t
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/t/04-action-list.t,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** 04-action-list.t 3 Jan 2003 23:01:15 -0000 1.1.1.1
--- 04-action-list.t 18 Jan 2003 18:52:18 -0000 1.2
***************
*** 24,28 ****
# test template_data to return recorder object
{
! my %data = $ACTION->template_data($CONTROLLER);
is($data{tests}, $RECORDER->tests,
'Check if "tests" variable is defined');
--- 24,28 ----
# test template_data to return recorder object
{
! my %data = $ACTION->execute($CONTROLLER);
is($data{tests}, $RECORDER->tests,
'Check if "tests" variable is defined');
Index: 03-action.t
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/t/03-action.t,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** 03-action.t 3 Jan 2003 23:01:15 -0000 1.1.1.1
--- 03-action.t 18 Jan 2003 18:52:19 -0000 1.2
***************
*** 6,10 ****
use HTTP::Status;
! use Test::More tests => 15;
# get test template files directory included in search path
--- 6,10 ----
use HTTP::Status;
! use Test::More tests => 5;
# get test template files directory included in search path
***************
*** 20,61 ****
isa_ok($CONTROLLER, 'HTTP::WebTest::Controller');
! # test template_data()
{
! is_deeply([$ACTION->template_data($CONTROLLER)],
[action => $ACTION, controller => $CONTROLLER],
'Test template_data()');
- }
-
- # try to access recorder's web interface
- {
- $CONTROLLER->view('testdump');
- my $response = $ACTION->execute($CONTROLLER);
- is($response->header('Content-Type'), 'text/html',
- 'Response is in HTML');
- is($response->code, RC_OK, 'Expect success code');
- like($response->content, qr/ACTION = HTTP::WebTest::Action/,
- 'Action object should be passed to template');
- like($response->content, qr/CONTROLLER = HTTP::WebTest::Controller/,
- 'Request object should be passed to template');
- }
-
- # try to access part of recorder's web interface which doesn't exist
- {
- $CONTROLLER->view('testmissing');
- my $response = $ACTION->execute($CONTROLLER);
- is($response->code, RC_NOT_FOUND, 'Expect not found error');
- is($response->header('Content-Type'), 'text/plain',
- 'Response is a plain text');
- is($response->content, 'Not Found', 'Check text of error message');
- }
-
- # try to access faulty part of recorder's web interface
- {
- $CONTROLLER->view('testcrash');
- my $response = $ACTION->execute($CONTROLLER);
- is($response->code, RC_INTERNAL_SERVER_ERROR, 'Expect internal error');
- is($response->header('Content-Type'), 'text/plain',
- 'Response is a plain text');
- like($response->content, qr/parse error.*unexpected token \(ME\)/,
- 'Verify text of error message');
}
--- 20,27 ----
isa_ok($CONTROLLER, 'HTTP::WebTest::Controller');
! # test execute()
{
! is_deeply([$ACTION->execute($CONTROLLER)],
[action => $ACTION, controller => $CONTROLLER],
'Test template_data()');
}
|
|
From: Ilya M. <m_...@us...> - 2003-01-18 18:51:35
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Action
In directory sc8-pr-cvs1:/tmp/cvs-serv4715/lib/HTTP/WebTest/Action
Modified Files:
WTScript.pm Request.pm List.pm
Log Message:
Rename method template_data() to execute()
Index: WTScript.pm
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Action/WTScript.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** WTScript.pm 7 Jan 2003 21:04:11 -0000 1.1
--- WTScript.pm 18 Jan 2003 18:51:31 -0000 1.2
***************
*** 9,14 ****
use CGI;
! # returns data to fill in template
! sub template_data {
my $self = shift;
my $controller = shift;
--- 9,13 ----
use CGI;
! sub execute {
my $self = shift;
my $controller = shift;
***************
*** 18,22 ****
my $wtscript = join "\n", map $self->test2wtscript($_), @tests;
! return($self->SUPER::template_data($controller),
wtscript => $wtscript);
}
--- 17,21 ----
my $wtscript = join "\n", map $self->test2wtscript($_), @tests;
! return($self->SUPER::execute($controller),
wtscript => $wtscript);
}
Index: Request.pm
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Action/Request.pm,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Request.pm 3 Jan 2003 23:01:22 -0000 1.1.1.1
--- Request.pm 18 Jan 2003 18:51:31 -0000 1.2
***************
*** 7,12 ****
use base qw(HTTP::WebTest::Action);
! # returns data to fill in template
! sub template_data {
my $self = shift;
my $controller = shift;
--- 7,11 ----
use base qw(HTTP::WebTest::Action);
! sub execute {
my $self = shift;
my $controller = shift;
***************
*** 15,19 ****
my $test = $controller->recorder->tests->[$num];
! return($self->SUPER::template_data($controller),
test => $test);
}
--- 14,18 ----
my $test = $controller->recorder->tests->[$num];
! return($self->SUPER::execute($controller),
test => $test);
}
Index: List.pm
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Action/List.pm,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** List.pm 3 Jan 2003 23:01:22 -0000 1.1.1.1
--- List.pm 18 Jan 2003 18:51:31 -0000 1.2
***************
*** 7,16 ****
use base qw(HTTP::WebTest::Action);
! # returns data to fill in template
! sub template_data {
my $self = shift;
my $controller = shift;
! return($self->SUPER::template_data($controller),
tests => $controller->recorder->tests);
}
--- 7,15 ----
use base qw(HTTP::WebTest::Action);
! sub execute {
my $self = shift;
my $controller = shift;
! return($self->SUPER::execute($controller),
tests => $controller->recorder->tests);
}
|
|
From: Ilya M. <m_...@us...> - 2003-01-18 18:51:19
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest
In directory sc8-pr-cvs1:/tmp/cvs-serv4361/lib/HTTP/WebTest
Modified Files:
Controller.pm Action.pm
Log Message:
Move responsibility of processing templates from action to controller;
Rename action's method template_data() to execute()
Index: Controller.pm
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Controller.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Controller.pm 7 Jan 2003 21:07:22 -0000 1.2
--- Controller.pm 18 Jan 2003 18:51:13 -0000 1.3
***************
*** 7,10 ****
--- 7,11 ----
use CGI;
use File::Spec;
+ use HTTP::Status;
use HTTP::WebTest::Utils qw(make_access_method);
use Template;
***************
*** 44,51 ****
$self->view($param{action});
! my $dispatch = $DISPATCH{$param{action}} || $DISPATCH{default};
! eval "require $dispatch";
! $dispatch = $dispatch->new;
! return $dispatch->execute($self);
}
--- 45,78 ----
$self->view($param{action});
! my $action_package = $DISPATCH{$param{action}} || $DISPATCH{default};
! eval "require $action_package";
! my $action = $action_package->new;
!
! return $self->process_template($action->execute($self));
! }
!
! # populates template with data returned by action object and generates
! # response based on template output
! sub process_template {
! my $self = shift;
! my %data = @_;
!
! my $content = '';
! if($self->template->process($self->view, \%data, \$content)) {
! my $response = HTTP::Response->new(RC_OK);
! $response->header(Content_Type => 'text/html');
! $response->content($content);
! return $response;
! } elsif($self->template->error =~ /file error - .*: not found/) {
! my $response = HTTP::Response->new(RC_NOT_FOUND);
! $response->header(Content_Type => 'text/plain');
! $response->content('Not Found');
! return $response;
! } else {
! my $response = HTTP::Response->new(RC_INTERNAL_SERVER_ERROR);
! $response->header(Content_Type => 'text/plain');
! $response->content($self->template->error);
! return $response;
! }
}
Index: Action.pm
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Action.pm,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Action.pm 3 Jan 2003 23:01:22 -0000 1.1.1.1
--- Action.pm 18 Jan 2003 18:51:13 -0000 1.2
***************
*** 5,10 ****
use strict;
- use HTTP::Status;
-
# constructor
sub new {
--- 5,8 ----
***************
*** 16,45 ****
# serves requests
sub execute {
- my $self = shift;
- my $controller = shift;
-
- my $content = '';
- my %data = $self->template_data($controller);
-
- if($controller->template->process($controller->view, \%data, \$content)) {
- my $response = HTTP::Response->new(RC_OK);
- $response->header(Content_Type => 'text/html');
- $response->content($content);
- return $response;
- } elsif($controller->template->error =~ /file error - .*: not found/) {
- my $response = HTTP::Response->new(RC_NOT_FOUND);
- $response->header(Content_Type => 'text/plain');
- $response->content('Not Found');
- return $response;
- } else {
- my $response = HTTP::Response->new(RC_INTERNAL_SERVER_ERROR);
- $response->header(Content_Type => 'text/plain');
- $response->content($controller->template->error);
- return $response;
- }
- }
-
- # returns data to fill in template
- sub template_data {
my $self = shift;
my $controller = shift;
--- 14,17 ----
|
|
From: Ilya M. <m_...@us...> - 2003-01-18 17:04:49
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/t
In directory sc8-pr-cvs1:/tmp/cvs-serv16206
Modified Files:
01-recorder.t
Log Message:
Tests for is_recording()
Index: 01-recorder.t
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/t/01-recorder.t,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** 01-recorder.t 18 Jan 2003 16:34:03 -0000 1.3
--- 01-recorder.t 18 Jan 2003 17:04:45 -0000 1.4
***************
*** 8,12 ****
use HTTP::WebTest::SelfTest;
! use Test::More tests => 31;
# get test template files directory included in search path
--- 8,12 ----
use HTTP::WebTest::SelfTest;
! use Test::More tests => 40;
# get test template files directory included in search path
***************
*** 21,29 ****
isa_ok($RECORDER, 'HTTP::WebTest::Recorder');
! # pass a couple of requests and see outcome
{
my $request1 = GET abs_url($URL, '/test-file1');
my $request2 = POST abs_url($URL, '/unknown');
my $response1 = $RECORDER->handle($request1);
my $response2 = $RECORDER->handle($request2);
--- 21,50 ----
isa_ok($RECORDER, 'HTTP::WebTest::Recorder');
! # test that recorder is empty and doesn't record anything while being
! # turned off
! {
! is(@{$RECORDER->tests}, 0,
! 'Check if recorder is empty');
! ok(not($RECORDER->is_recording),
! 'And it is turned off');
!
! my $request = GET abs_url($URL, '/test-file1');
! my $response = $RECORDER->handle($request);
! isa_ok($response, 'HTTP::Response');
! is($response->code, RC_OK,
! 'First response should be successful');
! like($response->content, qr/This is a test text file.*#1/s,
! 'Check response content');
!
! is(@{$RECORDER->tests}, 0,
! 'Check if recorder is still empty');
! }
!
! # turn on record, pass a couple of requests and see outcome
{
my $request1 = GET abs_url($URL, '/test-file1');
my $request2 = POST abs_url($URL, '/unknown');
+ $RECORDER->is_recording(1);
my $response1 = $RECORDER->handle($request1);
my $response2 = $RECORDER->handle($request2);
***************
*** 48,54 ****
--- 69,89 ----
}
+ # turn off recorder again and check that it doesn't record anything
+ {
+ $RECORDER->is_recording(0);
+ my $request = GET abs_url($URL, '/unknown');
+ my $response = $RECORDER->handle($request);
+ isa_ok($response, 'HTTP::Response');
+ is($response->code, RC_NOT_FOUND,
+ 'Expect not found for second response');
+
+ is(@{$RECORDER->tests}, 2,
+ 'Check if number of recorded test cases have not change');
+ }
+
# make sure that redirects are *not* handled automatically by LWP and
# actually get recorded as it is
{
+ $RECORDER->is_recording(1);
my $request = GET abs_url($URL, '/redirect');
my $response = $RECORDER->handle($request);
|
|
From: Ilya M. <m_...@us...> - 2003-01-18 17:04:07
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest
In directory sc8-pr-cvs1:/tmp/cvs-serv15939
Modified Files:
Recorder.pm
Log Message:
Add is_recording() method to disable/enable recording
Index: Recorder.pm
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Recorder.pm 15 Jan 2003 21:15:58 -0000 1.2
--- Recorder.pm 18 Jan 2003 17:03:59 -0000 1.3
***************
*** 49,52 ****
--- 49,54 ----
# stores all test cases
*tests = make_access_method('TESTS', sub { [] });
+ # if recording is enabled
+ *is_recording = make_access_method('IS_RECORDING', sub { 0 });
# serve web interface and do recording/proxying
***************
*** 65,72 ****
# proxy request
my $response = $self->user_agent->simple_request($request);
! my $test = HTTP::WebTest::Test->new;
! $test->request($request);
! $test->response($response);
! push @{$self->tests}, $test;
return $response;
}
--- 67,76 ----
# proxy request
my $response = $self->user_agent->simple_request($request);
! if($self->is_recording) {
! my $test = HTTP::WebTest::Test->new;
! $test->request($request);
! $test->response($response);
! push @{$self->tests}, $test;
! }
return $response;
}
|
|
From: Ilya M. <m_...@us...> - 2003-01-18 16:34:10
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/t In directory sc8-pr-cvs1:/tmp/cvs-serv6585/t Modified Files: 01-recorder.t Log Message: Don't rely on deprecated API Index: 01-recorder.t =================================================================== RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/t/01-recorder.t,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** 01-recorder.t 15 Jan 2003 21:15:28 -0000 1.2 --- 01-recorder.t 18 Jan 2003 16:34:03 -0000 1.3 *************** *** 5,8 **** --- 5,9 ---- use HTTP::Request::Common; use HTTP::Status; + use HTTP::WebTest::Utils qw(start_webserver stop_webserver); use HTTP::WebTest::SelfTest; |
|
From: Ilya M. <m_...@us...> - 2003-01-18 10:15:00
|
Update of /cvsroot/http-webtest/HTTP-WebTest/lib/HTTP
In directory sc8-pr-cvs1:/tmp/cvs-serv12489/lib/HTTP
Modified Files:
WebTest.pm
Log Message:
HTTP::WebTest::Plugin::HarnessReport produced report output on STDERR
what was adding noise in 'make test' output when being used in
Test::Harness-style test suites.
Index: WebTest.pm
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest/lib/HTTP/WebTest.pm,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** WebTest.pm 13 Dec 2002 01:36:39 -0000 1.32
--- WebTest.pm 18 Jan 2003 10:14:55 -0000 1.33
***************
*** 264,271 ****
brackets are used to denote Perl code inside wtscript files.
C<HTTP::WebTest> compiles this Perl code as anonymous subroutines
! which are called when values of corresponding test
! parameters are required. These subroutines are called in an object-oriented
! fashion, so the
! C<HTTP::WebTest> object is passed to them as the first argument.
Some examples of syntax:
--- 264,270 ----
brackets are used to denote Perl code inside wtscript files.
C<HTTP::WebTest> compiles this Perl code as anonymous subroutines
! which are called when values of corresponding test parameters are
! required. When these subroutines are called C<HTTP::WebTest> object
! is passed to them as the first argument.
Some examples of syntax:
***************
*** 277,281 ****
name = (
'first value'
! { "first " . "value" }
)
--- 276,280 ----
name = (
'first value'
! { "second " . "value" }
)
***************
*** 384,392 ****
=head2 Core plugin modules
! C<HTTP::WebTest> is implemented in a modular structure that allows programmers
! to easily add modules to run additional tests or define additional simple
! tests without writing a module.
! C<HTTP::WebTest> provides a number of core plugin modules which are
! loaded by default:
=over 4
--- 383,390 ----
=head2 Core plugin modules
! C<HTTP::WebTest> is implemented in a modular structure that allows
! programmers to easily add modules to run additional tests or define
! additional simple tests without writing a module. C<HTTP::WebTest>
! provides a number of core plugin modules which are loaded by default:
=over 4
***************
*** 473,476 ****
--- 471,482 ----
This plugin supports testing web files using a local instance of Apache.
+
+ =item L<HTTP::WebTest::Plugin::DateTest|HTTP::WebTest::Plugin::DateTest>
+
+ Evaluate the "age" of embedded date strings in response body.
+
+ =item L<HTTP::WebTest::Plugin::XMLReport|HTTP::WebTest::Plugin::XMLReport>
+
+ Report plugin for HTTP::WebTest, generates output in XML format.
=back
|
|
From: Ilya M. <m_...@us...> - 2003-01-18 10:15:00
|
Update of /cvsroot/http-webtest/HTTP-WebTest/t
In directory sc8-pr-cvs1:/tmp/cvs-serv12489/t
Modified Files:
13-harness.t
Log Message:
HTTP::WebTest::Plugin::HarnessReport produced report output on STDERR
what was adding noise in 'make test' output when being used in
Test::Harness-style test suites.
Index: 13-harness.t
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest/t/13-harness.t,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** 13-harness.t 22 Dec 2002 20:35:38 -0000 1.2
--- 13-harness.t 18 Jan 2003 10:14:55 -0000 1.3
***************
*** 33,54 ****
default_report => 'no' };
! test_diag('-' x 60,
! 'URL: ' . abs_url($URL, '/test-file1'),
! 'STATUS CODE CHECK',
! ' Expected \'200\' and got: 200 OK: SUCCEED',
! 'REQUIRED TEXT',
! ' 987654: SUCCEED');
test_out('ok 1');
! test_diag('-' x 60,
! 'URL: ' . abs_url($URL, '/non-existent'),
! 'STATUS CODE CHECK',
! ' Expected \'200\' and got: 404 Not Found: FAIL');
test_out('not ok 2');
! test_fail(9);
! test_diag('-' x 60,
! 'URL: ' . abs_url($URL, '/non-existent'),
! 'Test Name: BlaBla',
! 'STATUS CODE CHECK',
! ' Expected \'200\' and got: 404 Not Found: FAIL');
test_out('not ok 3');
test_fail(2);
--- 33,57 ----
default_report => 'no' };
! test_out(map "# $_",
! '-' x 60,
! 'URL: ' . abs_url($URL, '/test-file1'),
! 'STATUS CODE CHECK',
! ' Expected \'200\' and got: 200 OK: SUCCEED',
! 'REQUIRED TEXT',
! ' 987654: SUCCEED');
test_out('ok 1');
! test_out(map "# $_",
! '-' x 60,
! 'URL: ' . abs_url($URL, '/non-existent'),
! 'STATUS CODE CHECK',
! ' Expected \'200\' and got: 404 Not Found: FAIL');
test_out('not ok 2');
! test_fail(10);
! test_out(map "# $_",
! '-' x 60,
! 'URL: ' . abs_url($URL, '/non-existent'),
! 'Test Name: BlaBla',
! 'STATUS CODE CHECK',
! ' Expected \'200\' and got: 404 Not Found: FAIL');
test_out('not ok 3');
test_fail(2);
***************
*** 66,82 ****
default_report => 'no' };
! test_diag('-' x 60,
! 'URL: ' . abs_url($URL, '/test-file1'),
! 'STATUS CODE CHECK',
! ' Expected \'200\' and got: 200 OK: SUCCEED',
! 'REQUIRED TEXT',
! ' 987654: SUCCEED');
test_out('ok 1');
! test_diag('-' x 60,
! 'URL: ' . abs_url($URL, '/test-file1'),
! 'STATUS CODE CHECK',
! ' Expected \'200\' and got: 200 OK: SUCCEED',
! 'REQUIRED TEXT',
! ' 987654: SUCCEED');
test_out('ok 2');
--- 69,87 ----
default_report => 'no' };
! test_out(map "# $_",
! '-' x 60,
! 'URL: ' . abs_url($URL, '/test-file1'),
! 'STATUS CODE CHECK',
! ' Expected \'200\' and got: 200 OK: SUCCEED',
! 'REQUIRED TEXT',
! ' 987654: SUCCEED');
test_out('ok 1');
! test_out(map "# $_",
! '-' x 60,
! 'URL: ' . abs_url($URL, '/test-file1'),
! 'STATUS CODE CHECK',
! ' Expected \'200\' and got: 200 OK: SUCCEED',
! 'REQUIRED TEXT',
! ' 987654: SUCCEED');
test_out('ok 2');
|
|
From: Ilya M. <m_...@us...> - 2003-01-18 10:15:00
|
Update of /cvsroot/http-webtest/HTTP-WebTest/lib/HTTP/WebTest/Plugin
In directory sc8-pr-cvs1:/tmp/cvs-serv12489/lib/HTTP/WebTest/Plugin
Modified Files:
HarnessReport.pm
Log Message:
HTTP::WebTest::Plugin::HarnessReport produced report output on STDERR
what was adding noise in 'make test' output when being used in
Test::Harness-style test suites.
Index: HarnessReport.pm
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest/lib/HTTP/WebTest/Plugin/HarnessReport.pm,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** HarnessReport.pm 13 Dec 2002 01:23:11 -0000 1.10
--- HarnessReport.pm 18 Jan 2003 10:14:55 -0000 1.11
***************
*** 68,71 ****
--- 68,75 ----
}
+ # fool Test::Builder to generate diag output on STDOUT
+ my $failure_output = $TEST->failure_output;
+ $TEST->failure_output($TEST->output);
+
$TEST->diag('-' x 60);
$TEST->diag("URL: $url");
***************
*** 90,93 ****
--- 94,100 ----
}
}
+
+ # restore failure_output
+ $TEST->failure_output($failure_output);
local $Test::Builder::Level = 3;
|
|
From: Ilya M. <m_...@us...> - 2003-01-18 10:15:00
|
Update of /cvsroot/http-webtest/HTTP-WebTest In directory sc8-pr-cvs1:/tmp/cvs-serv12489 Modified Files: Changes Log Message: HTTP::WebTest::Plugin::HarnessReport produced report output on STDERR what was adding noise in 'make test' output when being used in Test::Harness-style test suites. Index: Changes =================================================================== RCS file: /cvsroot/http-webtest/HTTP-WebTest/Changes,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** Changes 3 Jan 2003 22:22:14 -0000 1.69 --- Changes 18 Jan 2003 10:14:55 -0000 1.70 *************** *** 27,30 **** --- 27,34 ---- report. + * HTTP::WebTest::Plugin::HarnessReport produced report output on + STDERR what was adding noise in 'make test' output when being used in + Test::Harness-style test suites. + 2.00 Sat Dec 14 2002 |
|
From: Ilya M. <m_...@us...> - 2003-01-15 21:16:01
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest
In directory sc8-pr-cvs1:/tmp/cvs-serv13258/lib/HTTP/WebTest
Modified Files:
Recorder.pm
Log Message:
Added optional constructor parameter 'ui_path'
Index: Recorder.pm
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/lib/HTTP/WebTest/Recorder.pm,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Recorder.pm 3 Jan 2003 23:01:22 -0000 1.1.1.1
--- Recorder.pm 15 Jan 2003 21:15:58 -0000 1.2
***************
*** 30,36 ****
--- 30,45 ----
my $class = shift;
my $self = bless {}, $class;
+ my %param = @_;
+
+ my $ui_path = $param{ui_path} || 'webtest';
+ # strip leading and ending slashes
+ $ui_path =~ s|^ / (.*?) / $|$1|x;
+ $self->ui_path($ui_path);
+
return $self;
}
+ # path to web interface
+ *ui_path = make_access_method('UI_PATH');
# controller object
*controller = make_access_method('CONTROLLER',
***************
*** 46,50 ****
my $request = shift;
! if($request->uri->path =~ m|^ /webtest/(\w+) |x) {
# request for recorder web interface
return $self->controller->execute(recorder => $self,
--- 55,61 ----
my $request = shift;
! my $ui_path = $self->ui_path;
!
! if($request->uri->path =~ m|^ /\Q$ui_path\E/(\w+) |x) {
# request for recorder web interface
return $self->controller->execute(recorder => $self,
***************
*** 79,83 ****
=head1 COPYRIGHT
! Copyright (c) 2002 Ilya Martynov. All rights reserved.
This program is free software; you can redistribute it and/or modify
--- 90,94 ----
=head1 COPYRIGHT
! Copyright (c) 2003 Ilya Martynov. All rights reserved.
This program is free software; you can redistribute it and/or modify
|
|
From: Ilya M. <m_...@us...> - 2003-01-15 21:15:31
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/t
In directory sc8-pr-cvs1:/tmp/cvs-serv13166/t
Modified Files:
01-recorder.t
Log Message:
Tests for ui_path
Index: 01-recorder.t
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/t/01-recorder.t,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** 01-recorder.t 3 Jan 2003 23:01:15 -0000 1.1.1.1
--- 01-recorder.t 15 Jan 2003 21:15:28 -0000 1.2
***************
*** 7,11 ****
use HTTP::WebTest::SelfTest;
! use Test::More tests => 21;
# get test template files directory included in search path
--- 7,11 ----
use HTTP::WebTest::SelfTest;
! use Test::More tests => 31;
# get test template files directory included in search path
***************
*** 79,82 ****
--- 79,96 ----
like($response->content, qr/This is a test file/,
'Check content of response');
+ }
+
+ # test constructor with parameter 'path'
+ {
+ for my $ui_path (qw(xxx [yyy] /zzz/ /a b/)) {
+ my $ui_path = $ui_path;
+ $ui_path =~ s|^ / (.*?) / $|$1|x;
+ my $recorder = new HTTP::WebTest::Recorder(ui_path => $ui_path);
+ my $request = GET "http://localhost/$ui_path/testme";
+ my $response = $recorder->handle($request);
+ is($response->code, RC_OK, 'Expect success code');
+ like($response->content, qr/This is a test file/,
+ 'Check content of response');
+ }
}
|
|
From: Ilya M. <m_...@us...> - 2003-01-15 21:15:05
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/bin
In directory sc8-pr-cvs1:/tmp/cvs-serv13069/bin
Modified Files:
rec-proxy
Log Message:
Added more documentation; Added parameters port and path
Index: rec-proxy
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/bin/rec-proxy,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** rec-proxy 3 Jan 2003 23:01:24 -0000 1.1.1.1
--- rec-proxy 15 Jan 2003 21:15:00 -0000 1.2
***************
*** 3,11 ****
--- 3,104 ----
# $Id$
+ =head1 NAME
+
+ rec-proxy - recording proxy (frontend to HTTP::WebTest::Recorder)
+
+ =head1 SYNOPSIS
+
+ rec-proxy [options]
+
+ Options:
+ -p, --port=PORT port to listen on
+ -P, --path=PATH path to access web interface of the proxy
+ -?, --help brief help message
+ --man full documentation
+ -V, --version version number
+
+ =head1 OPTIONS
+
+ =over 4
+
+ =item B<-p> PORT
+
+ =item B<--port>=PORT
+
+ Sets a port on which C<rec-proxy> listens. By default C<rec-proxy>
+ listens on 8000.
+
+ =item B<-P> PATH
+
+ =item B<--path>=PATH
+
+ By default web interface of the proxy is accessible via URL
+ C<http://localhost:PORT/webtest/PAGE>. This parameter configures the
+ proxy to give access to its web interface via
+ C<http://localhost:PORT/PATH/PAGE>.
+
+ =item B<-?>
+
+ =item B<--help>
+
+ Print a brief help message and exits.
+
+ =item B<--man>
+
+ Prints the manual page and exits.
+
+ =item B<-V>
+
+ =item B<--version>
+
+ Prints version number of
+ L<HTTP::WebTest::Recorder|HTTP::WebTest::Recorder> and exits.
+
+ =back
+
+ =head1 DESCRIPTION
+
+ This program starts recording proxy.
+
+ =head1 COPYRIGHT
+
+ Copyright (c) 2003 Ilya Martynov. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the same terms as Perl itself.
+
+ =head1 SEE ALSO
+
+ L<HTTP::WebTest::Recorder|HTTP::WebTest::Recorder>
+
+ =cut
+
use strict;
+ use Pod::Usage;
+ use Getopt::Long qw(:config gnu_getopt);
use HTTP::WebTest::Utils qw(start_webserver);
use HTTP::WebTest::Recorder;
+ my %OPTIONS = ();
+ GetOptions(\%OPTIONS,
+ qw(port|p=i path|P=s help|? version|V man)) or pod2usage(2);
+ pod2usage(1) if $OPTIONS{help};
+ pod2usage(-verbose => 2) if $OPTIONS{man};
+ if($OPTIONS{version}) {
+ my $version = HTTP::WebTest::Recorder->VERSION;
+ print <<TEXT;
+ wt - recording proxy (frontend to HTTP::WebTest::Recorder)
+
+ This program uses HTTP::WebTest::Recorder version $version.
+
+ Copyright (c) 2003 Ilya Martynov. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the same terms as Perl itself.
+ TEXT
+ exit 0;
+ }
+
main();
***************
*** 16,20 ****
my %param = @_;
! $recorder ||= HTTP::WebTest::Recorder->new;
my $response = $recorder->handle($param{request});
--- 109,113 ----
my %param = @_;
! $recorder ||= HTTP::WebTest::Recorder->new(ui_path => $OPTIONS{path});
my $response = $recorder->handle($param{request});
***************
*** 22,26 ****
};
! start_webserver(port => 8000,
server_sub => $server_sub);
}
--- 115,119 ----
};
! start_webserver(port => $OPTIONS{port} || 8000,
server_sub => $server_sub);
}
|
|
From: Johannes la P. <joe...@us...> - 2003-01-08 21:27:43
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Plugin-XMLReport In directory sc8-pr-cvs1:/tmp/cvs-serv23528 Modified Files: Changes Log Message: Added example script for using the XMLReport output Index: Changes =================================================================== RCS file: /cvsroot/http-webtest/HTTP-WebTest-Plugin-XMLReport/Changes,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Changes 6 Jan 2003 12:25:02 -0000 1.3 --- Changes 8 Jan 2003 21:27:40 -0000 1.4 *************** *** 1,8 **** Revision history for Perl extension XMLReport. ! 1.01 Mon Jan 6 13:18:47 CET 2003 - use Test instead of Test::More - fixes spurious fails with SelfTest - date string conforms RFC822 (with Time Zone offset) 1.00 Thu Jan 2 17:44:33 CET 2003 --- 1,9 ---- Revision history for Perl extension XMLReport. ! 1.01 Wed Jan 8 22:27:20 CET 2003 - use Test instead of Test::More - fixes spurious fails with SelfTest - date string conforms RFC822 (with Time Zone offset) + - added example scripts and XSL stylesheets 1.00 Thu Jan 2 17:44:33 CET 2003 |
|
From: Johannes la P. <joe...@us...> - 2003-01-08 21:23:06
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Plugin-XMLReport In directory sc8-pr-cvs1:/tmp/cvs-serv20952 Modified Files: MANIFEST Log Message: Added example script for using the XMLReport output Index: MANIFEST =================================================================== RCS file: /cvsroot/http-webtest/HTTP-WebTest-Plugin-XMLReport/MANIFEST,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MANIFEST 2 Jan 2003 16:52:16 -0000 1.2 --- MANIFEST 8 Jan 2003 21:23:01 -0000 1.3 *************** *** 5,8 **** --- 5,19 ---- README TODO + example/README + example/testdefs.xml + example/transform/content.xsl + example/transform/email.xsl + example/transform/extract-failed.xsl + example/transform/listtests-html.xsl + example/transform/listtests.xsl + example/transform/merge-results.xsl + example/transform/sidebar.xsl + example/webtest + example/webtest.sh lib/HTTP/WebTest/Plugin/XMLReport.pm t/01_basic.t |
Update of /cvsroot/http-webtest/HTTP-WebTest-Plugin-XMLReport/example/transform In directory sc8-pr-cvs1:/tmp/cvs-serv19392/example/transform Added Files: content.xsl email.xsl extract-failed.xsl listtests-html.xsl listtests.xsl merge-results.xsl sidebar.xsl Log Message: Added example script for using the XMLReport output --- NEW FILE: content.xsl --- <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" omit-xml-declaration="yes" indent="yes" encoding="utf-8"/> <xsl:template match="/"> <html> <head> <meta http-equiv="Refresh" content="600; url=content.html"/> <meta http-equiv="Pragma" content="no-cache"/> <title> <xsl:value-of select="testresults/title"/> <xsl:text> - </xsl:text> <xsl:value-of select="testresults/@date"/> </title> <xsl:call-template name="style"/> <xsl:call-template name="script"/> </head> <body> <a name="top"><xsl:comment>top</xsl:comment></a> <h2> <xsl:value-of select="testresults/title"/> <xsl:text> - </xsl:text> <xsl:value-of select="testresults/@date"/> </h2> <h3>WebTest results</h3> <ul> <xsl:apply-templates select="testresults/group" mode="toc"/> </ul> <p> <a href="javascript:addNetscapePanel('{testresults/title}'); void(0);">Add this to Mozilla Sidepanel</a> </p> <xsl:apply-templates select="testresults/group" mode="body"/> </body> </html> </xsl:template> <xsl:template match="group" mode="toc"> <li> <span class="{@status}"> <xsl:value-of select="@status"/> </span> <xsl:text>: </xsl:text> <a href="#group{position()}"> <xsl:value-of select="string(@name)"/> </a> </li> </xsl:template> <xsl:template match="group" mode="body"> <a name="group{position()}"> <xsl:comment> This space for rent </xsl:comment> </a> <div class="group"> <div style="float: right; padding-right: 5px;"> <a href="#top">TOP</a> </div> <a href="{@url}" onclick="return warn(this, '{@method}');" title="Link: request url for {@name}"> <xsl:value-of select="@name"/> </a> <xsl:if test="@method"> <xsl:text> (method = </xsl:text> <xsl:value-of select="@method"/> <xsl:text>)</xsl:text> </xsl:if> <xsl:apply-templates select="test"/> </div> </xsl:template> <xsl:template match="test"> <div class="test"> <span title="{@name}"> <xsl:value-of select="string(@name)"/> </span> <xsl:apply-templates select="result"/> </div> </xsl:template> <xsl:template match="result"> <xsl:element name="div"> <xsl:attribute name="class"> <xsl:text>result </xsl:text> <xsl:value-of select="@status"/> </xsl:attribute> <xsl:attribute name="title"> <xsl:value-of select="."/> </xsl:attribute> <div class="status"> <xsl:value-of select="string(@status)"/> </div> <xsl:value-of select="string(.)"/> </xsl:element> </xsl:template> <!-- Utilities --> <xsl:template name="script"> <script language="JavaScript"> <xsl:text disable-output-escaping="yes"><![CDATA[ //<![CDATA[ function warn(oLink, strMethod) { var strWarn = oLink.href; if (strWarn.length > 53) { strWarn = strWarn.substring(0,50) + "..."; } strWarn += '\n \n'; if (strMethod == 'POST') { strWarn += 'This link does not match the test condition\n'; strWarn += 'because POST data is missing.\n \n'; } else { strWarn += 'This link may not fully match the test conditions.\n'; strWarn += 'Cookies or adapted http-headers may exist.\n \n' } strWarn += 'Continue?'; return window.confirm(strWarn); } function addNetscapePanel(strTitle) { if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) { if (!strTitle) strTitle = "WebTest"; var url = document.location.protocol + '//' + document.location.host + document.location.pathname; url = url.substring(0,url.indexOf('content.html')) + 'sidebar.html'; window.sidebar.addPanel (strTitle, url, ""); } else { var rv = window.confirm ("This page is enhanced for use with Netscape 6. " + "Would you like to upgrade now?"); if (rv) document.location.href = "http://home.netscape.com/download/index.html"; } } ]]>// ]]></xsl:text> </script> </xsl:template> <xsl:template name="style"> <style type="text/css"> <xsl:text disable-output-escaping="yes"><![CDATA[ body { background-color: white; font-family: arial,helvetica,sans-serif; font-size: 10pt; } a { text-decoration: none; color: darkblue; } a:hover { text-decoration: underline; color: blue; } div.group { margin: 16px 0px; padding: 0px 3px; background-color: white; border: 1px solid black; font-weight: bold; } div.test { margin: 4px 0px; padding: 1px 4px; background-color: white; border: 1px solid #999; font-weight: normal; } div.result { margin: 1px 0px; padding: 1px 8px; font-family: courier,monospace; } .PASS { background-color: #1d1; } .FAIL { background-color: #e00; } div.status { font-family: arial,helvetica,sans-serif; font-weight: bold; font-size: 9pt; width: 50px; float: left; color: white; } ]]></xsl:text> </style> </xsl:template> </xsl:stylesheet> --- NEW FILE: email.xsl --- <?xml version="1.0"?> <!-- define a DOS type line ending as entity --> <!DOCTYPE stylesheet [ <!ENTITY crlf " "> ]> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" omit-xml-declaration="yes" indent="no" encoding="iso-8859-1"/> <xsl:strip-space elements="*"/> <!-- read the test definition document into variable "$testdef" --> <xsl:param name="testdoc"/> <xsl:variable name="testdef" select="document($testdoc)"/> <xsl:template match="/"> <!-- count number of failed tests --> <xsl:variable name="failed"> <xsl:value-of select="count(//group[test/result/@status = 'FAIL'])"/> </xsl:variable> <!-- list failed test numbers --> <xsl:variable name="testnums"> <xsl:for-each select="//group[test/result/@status = 'FAIL']"> <xsl:text> </xsl:text> <xsl:apply-templates select="$testdef/WebTest/testgroup" method="testnumber"> <xsl:with-param name="testname" select="@name"/> </xsl:apply-templates> </xsl:for-each> </xsl:variable> <xsl:choose> <xsl:when test="$failed = 0"> <!-- <xsl:message terminate="yes"> <xsl:text>All tests passed.</xsl:text> </xsl:message> --> </xsl:when> <xsl:otherwise> <xsl:call-template name="email-headers"> <xsl:with-param name="num" select="$failed"/> <xsl:with-param name="list" select="$testnums"/> </xsl:call-template> <xsl:text>Output of </xsl:text> <xsl:value-of select="concat($testdef/WebTest/@title,' (',$failed,' failed) at ')"/> <xsl:value-of select="testresults/@date"/> <xsl:text>&crlf;&crlf;</xsl:text> <xsl:apply-templates select="testresults"/> <xsl:call-template name="email-footer"/> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="testresults"> <xsl:apply-templates mode="list-tests" select="group[count(test/result[normalize-space(@status) = 'FAIL']) > 0]"/> <xsl:text>&crlf;Test links:&crlf;</xsl:text> <xsl:apply-templates mode="list-links" select="group[count(test/result[normalize-space(@status) = 'FAIL']) > 0]"/> </xsl:template> <xsl:template match="group" mode="list-tests"> <!-- we only have nodes with failed subtests --> <xsl:variable name="failed"> <xsl:value-of select="count(test/result[normalize-space(@status) = 'FAIL'])"/> </xsl:variable> <xsl:variable name="testname"> <xsl:value-of select="@name"/> </xsl:variable> <xsl:variable name="testnumber"> <!-- test number in original test specification --> <xsl:apply-templates select="$testdef/WebTest/testgroup" method="testnumber"> <xsl:with-param name="testname" select="$testname"/> </xsl:apply-templates> </xsl:variable> <xsl:value-of disable-output-escaping="yes" select="concat('[',position(),'] test #',$testnumber,': ',normalize-space(@name),'&crlf;')"/> <xsl:value-of select="concat('Failed: ',$failed,' of ',count(test/result),' subtest')"/> <xsl:if test="count(test/result) > 1"> <xsl:text>s</xsl:text> </xsl:if> <xsl:if test="$testdef/WebTest/testgroup[@test_name=$testname]/@method"> <xsl:text> (method=</xsl:text> <xsl:value-of select="$testdef/WebTest/testgroup[@test_name=$testname]/@method"/> <xsl:text>)</xsl:text> </xsl:if> <xsl:text>&crlf;</xsl:text> <xsl:for-each select="test/result[normalize-space(@status) = 'FAIL']"> <xsl:value-of disable-output-escaping="yes" select="concat(' ',../@name,': "',normalize-space(.),'"&crlf;')"/> </xsl:for-each> <xsl:text>&crlf;</xsl:text> </xsl:template> <xsl:template match="testgroup" method="testnumber"> <xsl:param name="testname"/> <xsl:if test="@test_name=$testname"> <xsl:value-of select="position()"/> </xsl:if> </xsl:template> <xsl:template match="group" mode="list-links"> <xsl:variable name="num"> <xsl:value-of select="position()"/> </xsl:variable> <xsl:variable name="testname"> <xsl:value-of select="@name"/> </xsl:variable> <xsl:if test="$num < 100"> <xsl:text> </xsl:text> </xsl:if> <xsl:if test="$num < 10"> <xsl:text> </xsl:text> </xsl:if> <xsl:number value="$num" format="1. "/> <xsl:value-of select="@url"/> <xsl:if test="$testdef/WebTest/testgroup[@test_name=$testname]/@method"> <xsl:text> (method=</xsl:text> <xsl:value-of select="$testdef/WebTest/testgroup[@test_name=$testname]/@method"/> <xsl:text>)</xsl:text> </xsl:if> <xsl:text>&crlf;</xsl:text> </xsl:template> <xsl:template name="email-headers"> <xsl:param name="num"/> <xsl:param name="list"/> <xsl:text>From: </xsl:text> <xsl:value-of disable-output-escaping="yes" select="$testdef/WebTest/param/mail_from"/> <xsl:text>&crlf;To: </xsl:text> <xsl:for-each select="$testdef/WebTest/param/mail_addresses"> <xsl:value-of disable-output-escaping="yes" select="concat(text(), ', ')"/> </xsl:for-each> <xsl:choose> <xsl:when test="normalize-space($testdef/WebTest/param/mail_method)='SMS'"> <xsl:text>&crlf;Subject: Webtest:</xsl:text> <xsl:value-of select="$list"/> </xsl:when> <xsl:otherwise> <xsl:text>&crlf;Subject: [webtest] </xsl:text> <xsl:value-of select="$num"/> <xsl:choose> <xsl:when test="$num > 1"> <xsl:text> tests</xsl:text> </xsl:when> <xsl:when test="$num = 1"> <xsl:text> test</xsl:text> </xsl:when> </xsl:choose> <xsl:text> failed for "</xsl:text> <xsl:value-of select="$testdef/WebTest/@title"/> <xsl:text>".</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:text>&crlf;&crlf;</xsl:text> </xsl:template> <xsl:template name="email-footer"> <xsl:text> -- NOTE: the test links will not properly work if the original test contained POST data, cookie headers or other http-headers which affect the application's behaviour. </xsl:text> </xsl:template> </xsl:stylesheet> --- NEW FILE: extract-failed.xsl --- <?xml version="1.0"?> <!-- Usage: xsltproc -param testdoc "'Input.xml'" extract-failed.xsl Output.xml Where: Input.xml = original webtest specification Output.xml = output of webtest, based on Input.xml Returns: WebTest specification with only tests that failed in Output.xml Purpose: Use the resulting document to run previously failed webtest groups again --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" omit-xml-declaration="no" indent="yes" encoding="utf-8"/> <xsl:param name="testdoc"/> <xsl:variable name="testtree" select="document($testdoc)"/> <xsl:key name="testNameKey" match="/WebTest/testgroup" use="@test_name"/> <xsl:template match="/testresults"> <WebTest title="{$testtree/WebTest/@title}"> <xsl:comment> <xsl:text>Failed tests from Webtest run at </xsl:text> <xsl:value-of select="@date"/> </xsl:comment> <!-- copy global test parameter block --> <xsl:apply-templates select="$testtree/WebTest/param" /> <!-- find testgroups with failed subtests --> <xsl:for-each select="group"> <xsl:variable name="name" select="@name"/> <xsl:if test="test/result[@status='FAIL']"> <!-- breaks when test-text contains 'dash-dash' sequence... <xsl:comment> <xsl:text>First failed test: </xsl:text> <xsl:value-of select="test[result/@status='FAIL']/@name"/> <xsl:text> = </xsl:text> <xsl:value-of select="test/result[@status='FAIL']"/> </xsl:comment> --> <xsl:apply-templates select="$testtree/WebTest/testgroup[@test_name=$name]"/> </xsl:if> </xsl:for-each> </WebTest> </xsl:template> <xsl:template match="testgroup"> <!-- first copy previous testgroup if there is no url attribute --> <xsl:if test="not(@url)"> <xsl:apply-templates select="preceding-sibling::*[position()=1]"/> </xsl:if> <!-- then the current testgroup element --> <xsl:element name="testgroup"> <xsl:apply-templates select="@*|node()|comment"/> </xsl:element> </xsl:template> <xsl:template match="@*|node()|comment"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> --- NEW FILE: listtests-html.xsl --- <?xml version="1.0"?> <!-- Stylesheet to list names of testgroups --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" omit-xml-declaration="no" indent="yes" encoding="utf-8"/> <xsl:template match="/"> <html> <head> <title>WebTest: <xsl:value-of select="/WebTest/@title"/></title> </head> <body> <h2>WebTest: <xsl:value-of select="/WebTest/@title"/></h2> <table border="1"> <tr> <th>#</th> <th>Test</th> <th>Comment</th> </tr> <xsl:apply-templates select="//testgroup"/> </table> </body> </html> </xsl:template> <xsl:template match="testgroup"> <tr> <td><xsl:value-of select="position()"/></td> <td><xsl:value-of select="@test_name"/></td> <td><xsl:value-of select="comment"/></td> </tr> </xsl:template> </xsl:stylesheet> --- NEW FILE: listtests.xsl --- <?xml version="1.0"?> <!-- Stylesheet to list names of testgroups --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" omit-xml-declaration="no" indent="yes" encoding="utf-8"/> <xsl:template match="/"> <xsl:apply-templates select="//testgroup"/> </xsl:template> <xsl:template match="testgroup"> <xsl:value-of select="position()"/> <xsl:text>	</xsl:text> <xsl:value-of select="/WebTest/@title"/> <xsl:text>	</xsl:text> <xsl:value-of select="@test_name"/> <xsl:text>	</xsl:text> <xsl:value-of select="comment"/> <xsl:text> </xsl:text> </xsl:template> </xsl:stylesheet> --- NEW FILE: merge-results.xsl --- <?xml version="1.0"?> <!-- Stylesheet to merge results of two test-runs Set "status" attribute of "group" element according to one failing subtest Copy a few values from test definition --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" omit-xml-declaration="no" indent="yes" encoding="utf-8"/> <!-- read the results of the second pass into variable "$retried" --> <xsl:param name="merge"/> <xsl:variable name="retried" select="document($merge)"/> <!-- read the test definition document into variable "$testdef" --> <xsl:param name="testdoc"/> <xsl:variable name="testdef" select="document($testdoc)"/> <xsl:template match="/"> <xsl:apply-templates select="*|@*"/> </xsl:template> <xsl:template match="testresults"> <xsl:element name="testresults"> <xsl:apply-templates select="@*"/> <!-- insert title based on test-def. attribute --> <title> <xsl:value-of select="$testdef/WebTest/@title"/> </title> <xsl:apply-templates select="*"/> </xsl:element> </xsl:template> <xsl:template match="group"> <xsl:variable name="localname" select="@name"/> <xsl:element name="group"> <!-- insert attribute status based on subtests --> <xsl:attribute name="status"> <xsl:choose> <!-- check only for second testrun result --> <xsl:when test="$retried/testresults/group[@name=$localname]/test/result[@status='FAIL']"> <xsl:text>FAIL</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>PASS</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:attribute> <xsl:if test="$testdef/WebTest/testgroup[@test_name=$localname]/@method='POST'"> <xsl:attribute name="method">POST</xsl:attribute> </xsl:if> <!-- copy remaining attributes --> <xsl:apply-templates select="@*"/> <!-- select results from latest testrun --> <xsl:choose> <xsl:when test="$retried/testresults/group[@name=$localname]"> <xsl:apply-templates select="$retried/testresults/group[@name=$localname]/test"/> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="test"/> </xsl:otherwise> </xsl:choose> </xsl:element> </xsl:template> <!-- Utilities --> <!-- ## default elements: just copy ## --> <xsl:template match="*"> <xsl:element name="{name()}"> <xsl:apply-templates select="@*"/> <!--xsl:apply-templates select="node()"/--> <xsl:apply-templates select="*|processing-instruction()|comment()|text()"/> </xsl:element> </xsl:template> <!-- ## attributes: just copy ## --> <xsl:template match="@*"> <xsl:attribute name="{name()}"> <xsl:value-of select="."/> </xsl:attribute> </xsl:template> <!-- ## PI: just copy ## --> <xsl:template match="processing-instruction()"> <xsl:processing-instruction name="{name()}"> <xsl:value-of select="."/> </xsl:processing-instruction> </xsl:template> <!-- ## Comment: just copy ## --> <xsl:template match="comment()"> <xsl:comment> <xsl:value-of select="."/> </xsl:comment> </xsl:template> </xsl:stylesheet> --- NEW FILE: sidebar.xsl --- <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" omit-xml-declaration="yes" indent="yes" encoding="utf-8"/> <!-- establish a "random" variable to force reload of target url --> <xsl:variable name="rnd" select="translate(/testresults/@date,' :','--')"/> <xsl:template match="/"> <html> <head> <meta http-equiv="Refresh" content="600; url=sidebar.html"/> <meta http-equiv="Pragma" content="no-cache"/> <title> <xsl:text>WebTest Output</xsl:text> </title> <xsl:call-template name="style"/> </head> <body> <p> <xsl:value-of select="testresults/@date"/> <br/> <a href="content.html?{$rnd}#top" target="_content"> <xsl:text>-> test results</xsl:text> </a> </p> <xsl:apply-templates select="testresults/group"/> </body> </html> </xsl:template> <xsl:template match="group"> <xsl:element name="div"> <xsl:attribute name="title"> <xsl:value-of select="@name"/> </xsl:attribute> <xsl:attribute name="class"> <xsl:text>group</xsl:text> <xsl:if test="@status = 'FAIL'"> <xsl:text> failed</xsl:text> </xsl:if> </xsl:attribute> <a href="content.html?{$rnd}#group{position()}" title="{@name}" target="_content"> <xsl:value-of select="string(@name)"/> </a> </xsl:element> </xsl:template> <xsl:template name="style"> <style type="text/css"> <xsl:text disable-output-escaping="yes"><![CDATA[ body { background-color: white; font-family: arial,helvetica,sans-serif; font-size: 8pt; } a { text-decoration: none; color: black; } a:hover { text-decoration: underline; color: blue; } div.group a:hover { text-decoration: underline; color: white; } div.group { margin: 2px 0px; padding-left: 3px; background-color: #1d1; } div.failed { background-color: #e00; } ]]></xsl:text> </style> </xsl:template> </xsl:stylesheet> |
|
From: Johannes la P. <joe...@us...> - 2003-01-08 21:18:00
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Plugin-XMLReport/example
In directory sc8-pr-cvs1:/tmp/cvs-serv19123/example
Added Files:
README testdefs.xml webtest webtest.sh
Log Message:
Added example script for using the XMLReport output
--- NEW FILE: README ---
README XMLReport example script
The scripts and documents in this directory are meant as a demonstration
of how the XMLReport can be used to automate web tests and to enhance
the output of HTTP::WebTest.
For a short demonstration, just run the shellscript 'webtest.sh'
from *this* directory. You need to have Gnome's LibXML installed
and the 'xsltproc' tool somewhere in your PATH.
A short description of the files in this directory:
o webtest - Perl wrapper, parse XML input and call HTTP::WebTest
run 'webtest --help' for a short explanation
o testdefs.xml - Test definitions in XML format, just a bunch of
rather contrieved but nicely annotated examples
o transform/ - a bunch of XSLT stylesheets to convert XMLReport output
o webtest.sha - shell wrapper around 'webtest' and 'xsltproc'
The following files are generated by running webtest.sh:
o out1.xml - output of first test run, XMLReport format
o failed1.xml - test definitions of tests that failed during the
first test run
o out2.xml - otput of second test run
o result.xml - merged result from 1st and 2nd test runs, enhanced
from the XMLReport format (more attributes)
o sidebar.html - summary of test results in html format, suitable for
the Mozilla sidebar
o content.html - detailed report in html format
email.txt - failed test results formatted as email including
headers (suitable to send with sendmail).
Of course this is just a rough example, use your imagination to expand
on this concept!
Feedback and comments are welcome via the HTTP::WebTest site on Sourceforge:
http://sourceforge.net/projects/http-webtest
--- NEW FILE: testdefs.xml ---
<?xml version="1.0" ?>
<!-- root element WebTest
title: describe the purpose of this test suite
-->
<WebTest title="Content tests">
<!-- param element
contains global parameters for HTTP::WebTest and plugins
-->
<param>
<!-- suppress generation of default report -->
<default_report>no</default_report>
<!-- use the following plugins (default prefix is HTTP::WebTest::Plugin) -->
<!-- output results in xml format -->
<plugins>::XMLReport</plugins>
<!-- follow named links from previous html page -->
<plugins>::Click</plugins>
<user_agent>Mozilla/5.0 (HTTP-WebTest)</user_agent>
<!-- send to these mail addresses (element may be repeated) -->
<mail_addresses>NOC <no...@is...></mail_addresses>
<mail_from>WebTest <we...@is...></mail_from>
<!-- do not specify the email element for now; this will break the XML report -->
<!-- basic auth. credentials, used if requested by http server -->
<auth>user</auth>
<auth>secretpass</auth>
</param>
<!-- test groups specify tests to apply to a html page
test_name: a distinctive name for the report
url: location of the page to test
method: get, post (default get)
-->
<testgroup test_name="Yahoo Home" url="http://www.yahoo.com/">
<comment>Test yahoo homepage</comment>
<text_require><![CDATA[</html>]]></text_require>
<text_require>Yahoo!</text_require>
<text_forbid>Internal Server Error</text_forbid>
</testgroup>
<testgroup test_name="Slashdot - Front page" url="http://slashdot.org/">
<comment>Front page of Slashdot site</comment>
<!-- no explicit tests (response will always be checked) -->
<!-- use result page for next testgroup: follow named link -->
</testgroup>
<testgroup test_name="Slashdot 1st article">
<comment>Topmost Slashdot story</comment>
<!-- parameter for Click plugin: request url targeted by this link -->
<!-- NOTE: this is interpreted as Perl regex, so be careful with special chars -->
<click_link><![CDATA[.*Read More\.\.\..*]]></click_link>
<!-- contrieved example: check if view modifier form is available -->
<text_require>Threshold:</text_require>
</testgroup>
<testgroup test_name="This should fail" url="http://www.yahoo.com/thisshouldnotexist">
<comment>Test non-existing document</comment>
<text_require><![CDATA[</html>]]></text_require>
<text_require>Yahoo!</text_require>
<text_require>Sorry, the page you requested was not found</text_require>
<text_forbid>Internal Server Error</text_forbid>
</testgroup>
</WebTest>
--- NEW FILE: webtest ---
#!/usr/bin/perl -w
use HTTP::WebTest;
use XML::Simple;
use Getopt::Long;
my %opt;
GetOptions(\%opt, qw(config=s help verbose dump debug name=s) );
&usage() if ((! -f $opt{config}) || $opt{help});
## read and parse configuration from xml file
my $cfg = XMLin($opt{config},
suppressempty => '',
forcecontent => 0,
forcearray => &ARRYPARAMS,
);
if ($opt{debug}) {
$cfg->{param}->{default_report} = 'yes';
$cfg->{param}->{plugins} = [];
$cfg->{param}->{show_headers} = 'yes';
$cfg->{param}->{show_html} = 'yes';
}
# delete locally invented <comment/> elements from tests
# in order to avoid possible name clashes
foreach my $t (@{$cfg->{testgroup}}) {
delete $t->{comment};
}
# same for mail_method parameter
delete $cfg->{param}->{mail_method};
if ($opt{name}) {
my @tests;
foreach my $t (@{$cfg->{testgroup}}) {
push @tests, $t if ($t->{test_name} =~ /\Q$opt{name}\E/i);
}
$cfg->{testgroup} = \@tests;
}
if ($opt{dump}) {
eval { use Data::Dumper; };
print Dumper($cfg);
exit;
}
my $wt = HTTP::WebTest->new;
$wt->run_tests( $cfg->{testgroup}, $cfg->{param});
### UTIL ###
sub usage {
print <<" EU";
webtest --config=<xmlfile> [options]
--config=file - read webtests from xml file "file"
--verbose - be verbose
--dump - dump parsed configuration, exit
--debug - output full http-headers and html content
in plain text representation
--name=string - run only test group(s) containing "string"
in the name, case-insensitive
--help - this
EU
exit;
}
## ARRAYPARAMS
## all xml elements which need to be expanded to array refs
## even if they contain only one element:
sub ARRYPARAMS { return [ qw(
testgroup
plugins
cookie
text_require text_forbid
regex_require regex_forbid
date_maxage date_start date_end
mail_addresses
) ];
}
--- NEW FILE: webtest.sh ---
#!/bin/sh
#
# script to demonstrate some possibilities of XMLReport plugin
#
# Prerequisites:
XSLT=xsltproc # part of Gnome/LibXML
WEBTEST="./webtest" # perl wrapper
SENDMAIL="/bin/true" # replace by Sendmail, e.g.
# SENDMAIL="/usr/sbin/sendmail -t"
$WEBTEST --config="testdefs.xml" >out1.xml
if [ ! -s out1.xml ]
then
echo "Empty test output 'out1.xml', further processing stopped."
exit 1
fi
# generate testscript for failed tests only
$XSLT --param testdoc "'../testdefs.xml'" transform/extract-failed.xsl out1.xml >failed1.xml
# wait before retrying failed tests
sleep 5
# 2nd iteration: run only tests that failed in 1st round
$WEBTEST --config="failed1.xml" >out2.xml
# merge results into enhanced test report
$XSLT --param merge "'../out2.xml'" --param testdoc "'../testdefs.xml'" \
transform/merge-results.xsl out1.xml >result.xml
# generate sidebar HTML
$XSLT transform/sidebar.xsl result.xml >"sidebar.html"
# generate main report HTML
$XSLT transform/content.xsl result.xml >"content.html"
# generate email; will be empty if all tests passed
$XSLT --param testdoc "'../testdefs.xml'" transform/email.xsl out2.xml >email.txt
if [ -s email.txt ]; then $SENDMAIL <email.txt ; fi
|