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