line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::STF::MockServer; |
2
|
1
|
|
|
1
|
|
37076
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
43
|
|
3
|
1
|
|
|
1
|
|
958
|
use Test::TCP; |
|
1
|
|
|
|
|
98908
|
|
|
1
|
|
|
|
|
74
|
|
4
|
1
|
|
|
1
|
|
1089
|
use URI; |
|
1
|
|
|
|
|
8473
|
|
|
1
|
|
|
|
|
58
|
|
5
|
|
|
|
|
|
|
use Class::Accessor::Lite |
6
|
1
|
|
|
|
|
8
|
ro => [ qw(impl) ] |
7
|
1
|
|
|
1
|
|
1424
|
; |
|
1
|
|
|
|
|
1313
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
1
|
|
|
1
|
1
|
19
|
my $class = shift; |
13
|
1
|
|
|
|
|
5
|
my %args = @_; |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
|
|
3
|
my $impl = $args{impl}; |
16
|
1
|
|
|
|
|
3
|
my $plack_args = $args{plack_args}; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $server = Test::TCP->new(code => sub { |
19
|
0
|
|
|
0
|
|
0
|
my $port = shift; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# require is in this scope because it would be used |
22
|
|
|
|
|
|
|
# in the child process. |
23
|
0
|
0
|
|
|
|
0
|
if (! $impl) { |
24
|
0
|
|
|
|
|
0
|
require STF::Dispatcher::Impl::Hash; |
25
|
0
|
|
|
|
|
0
|
$impl = STF::Dispatcher::Impl::Hash->new; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
0
|
require STF::Dispatcher::PSGI; |
29
|
0
|
|
|
|
|
0
|
my $dispatcher = STF::Dispatcher::PSGI->new( |
30
|
|
|
|
|
|
|
impl => $impl |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
0
|
require Plack::Runner; |
34
|
0
|
|
|
|
|
0
|
my $runner = Plack::Runner->new; |
35
|
0
|
0
|
|
|
|
0
|
$runner->parse_options('--port' => $port, $plack_args ? @$plack_args : ()); |
36
|
0
|
|
|
|
|
0
|
$runner->run($dispatcher->to_app); |
37
|
1
|
|
|
|
|
19
|
}); |
38
|
|
|
|
|
|
|
|
39
|
1
|
|
|
|
|
271765
|
my $url = URI->new("http://127.0.0.1"); |
40
|
1
|
|
|
|
|
9441
|
$url->port( $server->port ); |
41
|
1
|
|
|
|
|
290
|
bless [ $server, $url ], $class; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub url { |
45
|
2
|
|
|
2
|
1
|
15
|
return $_[0]->[1]->clone; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub url_for { |
49
|
2
|
|
|
2
|
1
|
17
|
my $self = shift; |
50
|
2
|
|
|
|
|
7
|
my $url = $self->url; |
51
|
2
|
|
|
|
|
29
|
$url->path("@_"); |
52
|
2
|
|
|
|
|
69
|
return $url; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |