Commit | Line | Data |
50cc3183 |
1 | #!perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use FindBin; |
42da66a9 |
7 | use lib "$FindBin::Bin/../lib"; |
50cc3183 |
8 | |
9 | our $iters; |
10 | |
6b25e555 |
11 | BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; } |
50cc3183 |
12 | |
fa649eb7 |
13 | use Test::More tests => 42*$iters; |
50cc3183 |
14 | use Catalyst::Test 'TestApp'; |
15 | |
16 | if ( $ENV{CAT_BENCHMARK} ) { |
17 | require Benchmark; |
18 | Benchmark::timethis( $iters, \&run_tests ); |
19 | } |
20 | else { |
21 | for ( 1 .. $iters ) { |
22 | run_tests(); |
23 | } |
24 | } |
25 | |
26 | sub run_tests { |
27 | { |
28 | ok( |
29 | my $response = |
595f3872 |
30 | request('http://localhost/action/path/a%20path%20with%20spaces'), |
50cc3183 |
31 | 'Request' |
32 | ); |
33 | ok( $response->is_success, 'Response Successful 2xx' ); |
34 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); |
35 | is( |
36 | $response->header('X-Catalyst-Action'), |
595f3872 |
37 | 'action/path/a%20path%20with%20spaces', |
50cc3183 |
38 | 'Test Action' |
39 | ); |
40 | is( |
41 | $response->header('X-Test-Class'), |
42 | 'TestApp::Controller::Action::Path', |
43 | 'Test Class' |
44 | ); |
45 | like( |
46 | $response->content, |
47 | qr/^bless\( .* 'Catalyst::Request' \)$/s, |
48 | 'Content is a serialized Catalyst::Request' |
49 | ); |
50 | } |
51 | |
52 | { |
53 | ok( my $response = request('http://localhost/action/path/åäö'), |
54 | 'Request' ); |
55 | ok( $response->is_success, 'Response Successful 2xx' ); |
56 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); |
57 | is( $response->header('X-Catalyst-Action'), |
595f3872 |
58 | 'action/path/%C3%A5%C3%A4%C3%B6', 'Test Action' ); |
50cc3183 |
59 | is( |
60 | $response->header('X-Test-Class'), |
61 | 'TestApp::Controller::Action::Path', |
62 | 'Test Class' |
63 | ); |
64 | like( |
65 | $response->content, |
66 | qr/^bless\( .* 'Catalyst::Request' \)$/s, |
67 | 'Content is a serialized Catalyst::Request' |
68 | ); |
69 | } |
70 | |
71 | { |
72 | ok( my $response = request('http://localhost/action/path/'), |
73 | 'Request' ); |
74 | ok( $response->is_success, 'Response Successful 2xx' ); |
75 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); |
76 | is( $response->header('X-Catalyst-Action'), |
77 | 'action/path', 'Test Action' ); |
78 | is( |
79 | $response->header('X-Test-Class'), |
80 | 'TestApp::Controller::Action::Path', |
81 | 'Test Class' |
82 | ); |
83 | like( |
84 | $response->content, |
85 | qr/^bless\( .* 'Catalyst::Request' \)$/s, |
86 | 'Content is a serialized Catalyst::Request' |
87 | ); |
88 | } |
89 | |
90 | { |
91 | ok( my $response = request('http://localhost/action/path/spaces_near_parens_singleq'), |
92 | 'Request' ); |
93 | ok( $response->is_success, 'Response Successful 2xx' ); |
94 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); |
95 | is( $response->header('X-Catalyst-Action'), |
96 | 'action/path/spaces_near_parens_singleq', 'Test Action' ); |
97 | is( |
98 | $response->header('X-Test-Class'), |
99 | 'TestApp::Controller::Action::Path', |
100 | 'Test Class' |
101 | ); |
102 | like( |
103 | $response->content, |
104 | qr/^bless\( .* 'Catalyst::Request' \)$/s, |
105 | 'Content is a serialized Catalyst::Request' |
106 | ); |
107 | } |
108 | |
109 | { |
110 | ok( my $response = request('http://localhost/action/path/spaces_near_parens_doubleq'), |
111 | 'Request' ); |
112 | ok( $response->is_success, 'Response Successful 2xx' ); |
113 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); |
114 | is( $response->header('X-Catalyst-Action'), |
115 | 'action/path/spaces_near_parens_doubleq', 'Test Action' ); |
116 | is( |
117 | $response->header('X-Test-Class'), |
118 | 'TestApp::Controller::Action::Path', |
119 | 'Test Class' |
120 | ); |
121 | like( |
122 | $response->content, |
123 | qr/^bless\( .* 'Catalyst::Request' \)$/s, |
124 | 'Content is a serialized Catalyst::Request' |
125 | ); |
126 | } |
2f381252 |
127 | |
128 | { |
129 | ok( my $response = request('http://localhost/0'), 'Request' ); |
130 | ok( $response->is_success, 'Response Successful 2xx' ); |
131 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); |
132 | is( $response->header('X-Catalyst-Action'), |
133 | '0', 'Test Action' ); |
134 | is( |
135 | $response->header('X-Test-Class'), |
136 | 'TestApp::Controller::Root', |
137 | 'Test Class' |
138 | ); |
139 | like( |
140 | $response->content, |
141 | qr/^bless\( .* 'Catalyst::Request' \)$/s, |
142 | 'Content is a serialized Catalyst::Request' |
143 | ); |
144 | } |
fa649eb7 |
145 | |
146 | { |
147 | ok( my $response = request('http://localhost/action/path/six'), 'Request' ); |
148 | ok( $response->is_success, 'Response Successful 2xx' ); |
149 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); |
150 | is( $response->header('X-Catalyst-Action'), |
151 | 'action/path/six', 'Test Action' ); |
152 | is( |
153 | $response->header('X-Test-Class'), |
154 | 'TestApp::Controller::Action::Path', |
155 | 'Test Class' |
156 | ); |
157 | like( |
158 | $response->content, |
159 | qr/^bless\( .* 'Catalyst::Request' \)$/s, |
160 | 'Content is a serialized Catalyst::Request' |
161 | ); |
162 | } |
50cc3183 |
163 | } |