5 use lib "$FindBin::Bin/../lib";
9 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
11 use Test::More tests => 34*$iters;
12 use Catalyst::Test 'TestApp';
14 if ( $ENV{CAT_BENCHMARK} ) {
16 Benchmark::timethis( $iters, \&run_tests );
26 ok( my $response = request('http://localhost/action/local/one'),
28 ok( $response->is_success, 'Response Successful 2xx' );
29 is( $response->content_type, 'text/plain', 'Response Content-Type' );
30 is( $response->header('X-Catalyst-Action'),
31 'action/local/one', 'Test Action' );
33 $response->header('X-Test-Class'),
34 'TestApp::Controller::Action::Local',
39 qr/^bless\( .* 'Catalyst::Request' \)$/s,
40 'Content is a serialized Catalyst::Request'
45 ok( my $response = request('http://localhost/action/local/two/1/2'),
47 ok( $response->is_success, 'Response Successful 2xx' );
48 is( $response->content_type, 'text/plain', 'Response Content-Type' );
49 is( $response->header('X-Catalyst-Action'),
50 'action/local/two', 'Test Action' );
52 $response->header('X-Test-Class'),
53 'TestApp::Controller::Action::Local',
58 qr/^bless\( .* 'Catalyst::Request' \)$/s,
59 'Content is a serialized Catalyst::Request'
64 ok( my $response = request('http://localhost/action/local/two'),
66 ok( !$response->is_success, 'Request with wrong number of args failed' );
70 ok( my $response = request('http://localhost/action/local/three'),
72 ok( $response->is_success, 'Response Successful 2xx' );
73 is( $response->content_type, 'text/plain', 'Response Content-Type' );
74 is( $response->header('X-Catalyst-Action'),
75 'action/local/three', 'Test Action' );
77 $response->header('X-Test-Class'),
78 'TestApp::Controller::Action::Local',
83 qr/^bless\( .* 'Catalyst::Request' \)$/s,
84 'Content is a serialized Catalyst::Request'
91 request('http://localhost/action/local/four/five/six'),
94 ok( $response->is_success, 'Response Successful 2xx' );
95 is( $response->content_type, 'text/plain', 'Response Content-Type' );
96 is( $response->header('X-Catalyst-Action'),
97 'action/local/four/five/six', 'Test Action' );
99 $response->header('X-Test-Class'),
100 'TestApp::Controller::Action::Local',
105 qr/^bless\( .* 'Catalyst::Request' \)$/s,
106 'Content is a serialized Catalyst::Request'
112 if ( $ENV{CATALYST_SERVER} ) {
113 skip "tests for %2F on remote server", 6;
118 request('http://localhost/action/local/one/foo%2Fbar'),
121 ok( $response->is_success, 'Response Successful 2xx' );
122 is( $response->content_type, 'text/plain', 'Response Content-Type' );
123 is( $response->header('X-Catalyst-Action'),
124 'action/local/one', 'Test Action' );
126 $response->header('X-Test-Class'),
127 'TestApp::Controller::Action::Local',
130 my $content = $response->content;
133 my $request = eval $content;
135 fail("Content cannot be unserialized: $@ $content");
138 is_deeply $request->arguments, ['foo/bar'], "Parameters don't split on %2F";
144 ok( my $content = get('http://locahost/action/local/five/foo%2Fbar%3B'),
145 'request with URI-encoded arg');
146 # this is the CURRENT behavior
147 like( $content, qr{'foo/bar;'}, 'args for Local actions URI-decoded' );