line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Plack::Handler::Stomp::FakeStomp; |
2
|
|
|
|
|
|
|
$Test::Plack::Handler::Stomp::FakeStomp::VERSION = '1.14'; |
3
|
|
|
|
|
|
|
{ |
4
|
|
|
|
|
|
|
$Test::Plack::Handler::Stomp::FakeStomp::DIST = 'Plack-Handler-Stomp'; |
5
|
|
|
|
|
|
|
} |
6
|
11
|
|
|
11
|
|
68
|
use strict; |
|
11
|
|
|
|
|
24
|
|
|
11
|
|
|
|
|
318
|
|
7
|
11
|
|
|
11
|
|
60
|
use warnings; |
|
11
|
|
|
|
|
20
|
|
|
11
|
|
|
|
|
341
|
|
8
|
11
|
|
|
11
|
|
61
|
use parent 'Net::Stomp'; |
|
11
|
|
|
|
|
23
|
|
|
11
|
|
|
|
|
87
|
|
9
|
11
|
|
|
11
|
|
71786
|
use Net::Stomp::Frame; |
|
11
|
|
|
|
|
25
|
|
|
11
|
|
|
|
|
59
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# ABSTRACT: subclass of L<Net::Stomp>, half-mocked for testing |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub _get_connection { |
15
|
14
|
|
|
14
|
|
2266
|
return 1; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub current_host { |
19
|
56
|
|
|
56
|
1
|
6577
|
return 0; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new { |
24
|
14
|
|
|
14
|
1
|
42
|
my $class = shift; |
25
|
14
|
|
|
|
|
38
|
my $callbacks = shift; |
26
|
14
|
|
|
|
|
74
|
$callbacks->{new}->(@_); |
27
|
14
|
|
|
|
|
151
|
my $self = $class->SUPER::new(@_); |
28
|
14
|
|
|
|
|
103
|
$self->{__fakestomp__callbacks} = $callbacks; |
29
|
14
|
|
|
|
|
437
|
return $self; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub connect { |
34
|
14
|
|
|
14
|
1
|
30135
|
my ( $self, $conf ) = @_; |
35
|
|
|
|
|
|
|
|
36
|
14
|
|
|
|
|
70
|
$self->{__fakestomp__callbacks}{connect}->($conf); |
37
|
13
|
|
|
|
|
134
|
return Net::Stomp::Frame->new({ |
38
|
|
|
|
|
|
|
command => 'CONNECTED', |
39
|
|
|
|
|
|
|
headers => { |
40
|
|
|
|
|
|
|
session => 'ID:foo', |
41
|
|
|
|
|
|
|
}, |
42
|
|
|
|
|
|
|
body => '', |
43
|
|
|
|
|
|
|
}); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub disconnect { |
48
|
0
|
|
|
0
|
1
|
0
|
my ( $self ) = @_; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
0
|
$self->{__fakestomp__callbacks}{disconnect}->(); |
51
|
0
|
|
|
|
|
0
|
return 1; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
0
|
1
|
0
|
sub can_read { return 1 } |
56
|
0
|
|
|
0
|
|
0
|
sub _connected { return 1 } |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub subscribe { |
61
|
19
|
|
|
19
|
1
|
2559
|
my ( $self, $conf ) = @_; |
62
|
|
|
|
|
|
|
|
63
|
19
|
|
|
|
|
84
|
$self->{__fakestomp__callbacks}{subscribe}->($conf); |
64
|
18
|
|
|
|
|
45
|
return 1; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub unsubscribe { |
69
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $conf ) = @_; |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
0
|
$self->{__fakestomp__callbacks}{unsubscribe}->($conf); |
72
|
0
|
|
|
|
|
0
|
return 1; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub send_frame { |
77
|
11
|
|
|
11
|
1
|
624
|
my ( $self, $frame ) = @_; |
78
|
|
|
|
|
|
|
|
79
|
11
|
|
|
|
|
41
|
$self->{__fakestomp__callbacks}{send_frame}->($frame); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub receive_frame { |
84
|
18
|
|
|
18
|
1
|
180
|
my ( $self, $conf ) = @_; |
85
|
|
|
|
|
|
|
|
86
|
18
|
|
|
|
|
84
|
return $self->{__fakestomp__callbacks}{receive_frame}->($conf); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
__END__ |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=pod |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=encoding UTF-8 |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 NAME |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Test::Plack::Handler::Stomp::FakeStomp - subclass of L<Net::Stomp>, half-mocked for testing |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 VERSION |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
version 1.14 |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 DESCRIPTION |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This class is designed to be used in conjuction with |
108
|
|
|
|
|
|
|
L<Test::Plack::Handler::Stomp>. It expects a set of callbacks that |
109
|
|
|
|
|
|
|
will be invoked whenever a method is called. It also does not talk to |
110
|
|
|
|
|
|
|
the network at all. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 METHODS |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 C<new> |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
my $stomp = Test::Plack::Handler::Stomp::FakeStomp->new({ |
117
|
|
|
|
|
|
|
new => sub { $self->queue_constructor_call(shift) }, |
118
|
|
|
|
|
|
|
connect => sub { $self->queue_connection_call(shift) }, |
119
|
|
|
|
|
|
|
disconnect => sub { $self->queue_disconnection_call(shift) }, |
120
|
|
|
|
|
|
|
subscribe => sub { $self->queue_subscription_call(shift) }, |
121
|
|
|
|
|
|
|
unsubscribe => sub { $self->queue_unsubscription_call(shift) }, |
122
|
|
|
|
|
|
|
send_frame => sub { $self->queue_sent_frame(shift) }, |
123
|
|
|
|
|
|
|
receive_frame => sub { $self->next_frame_to_receive() }, |
124
|
|
|
|
|
|
|
},$params); |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
The first parameter must be a hashref with all those keys pointing to |
127
|
|
|
|
|
|
|
coderefs. Each coderef will be invoked when the corresponding method |
128
|
|
|
|
|
|
|
is called, and will receive all the parameters of that call (minus the |
129
|
|
|
|
|
|
|
invocant). |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
The parameters (to this C<new>) after the first will be passed to |
132
|
|
|
|
|
|
|
L<Net::Stomp>'s C<new>. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
The C<new> callback I<is> called by this method, just before |
135
|
|
|
|
|
|
|
delegating to the inherited constructor. This callback does not |
136
|
|
|
|
|
|
|
receive the callback hashref (i.e. it receives C<< @_[2..*] >>. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 C<connect> |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Calls the C<connect> callback, and returns 1. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head2 C<disconnect> |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Calls the C<disconnect> callback, and returns 1. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head2 C<can_read> |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Returns 1. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head2 C<subscribe> |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Calls the C<subscribe> callback, and returns 1. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head2 C<unsubscribe> |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Calls the C<unsubscribe> callback, and returns 1. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head2 C<send_frame> |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Calls the C<send_frame> callback. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head2 C<receive_frame> |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Calls the C<receive_frame> callback, and returns whatever that |
165
|
|
|
|
|
|
|
returned. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 AUTHOR |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Gianni Ceccarelli <gianni.ceccarelli@net-a-porter.com> |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
This software is copyright (c) 2012 by Net-a-porter.com. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
176
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=cut |