Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nginx-push-stream-module
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
nginx-push-stream-module
Commits
ac1a4e5a
Commit
ac1a4e5a
authored
Apr 03, 2011
by
Wandenberg Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding test to publish messages in multichannel subscriber
parent
128f9344
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
0 deletions
+80
-0
test_subscriber.rb
test/test_subscriber.rb
+80
-0
No files found.
test/test_subscriber.rb
View file @
ac1a4e5a
...
...
@@ -394,6 +394,86 @@ class TestPublisher < Test::Unit::TestCase
}
end
def
config_test_retreive_new_messages_in_multichannel_subscribe
@header_template
=
nil
@message_template
=
'{\"channel\":\"~channel~\", \"id\":\"~id~\", \"message\":\"~text~\"}'
end
def
test_retreive_new_messages_in_multichannel_subscribe
headers
=
{
'accept'
=>
'application/json'
}
channel_1
=
'test_retreive_new_messages_in_multichannel_subscribe_1'
channel_2
=
'test_retreive_new_messages_in_multich_subscribe_2'
channel_3
=
'test_retreive_new_messages_in_multchannel_subscribe_3'
channel_4
=
'test_retreive_new_msgs_in_multichannel_subscribe_4'
channel_5
=
'test_retreive_new_messages_in_multichannel_subs_5'
channel_6
=
'test_retreive_new_msgs_in_multichannel_subs_6'
body
=
'body'
response
=
""
EventMachine
.
run
{
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel_1
.
to_s
+
'/'
+
channel_2
.
to_s
+
'/'
+
channel_3
.
to_s
+
'/'
+
channel_4
.
to_s
+
'/'
+
channel_5
.
to_s
+
'/'
+
channel_6
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
.
stream
{
|
chunk
|
response
+=
chunk
lines
=
response
.
split
(
"
\r\n
"
)
if
lines
.
length
>=
6
line
=
JSON
.
parse
(
lines
[
0
])
assert_equal
(
channel_1
.
to_s
,
line
[
'channel'
],
"Wrong channel"
)
assert_equal
(
'body'
+
channel_1
.
to_s
,
line
[
'message'
],
"Wrong message"
)
assert_equal
(
1
,
line
[
'id'
].
to_i
,
"Wrong message"
)
line
=
JSON
.
parse
(
lines
[
1
])
assert_equal
(
channel_2
.
to_s
,
line
[
'channel'
],
"Wrong channel"
)
assert_equal
(
'body'
+
channel_2
.
to_s
,
line
[
'message'
],
"Wrong message"
)
assert_equal
(
1
,
line
[
'id'
].
to_i
,
"Wrong message"
)
line
=
JSON
.
parse
(
lines
[
2
])
assert_equal
(
channel_3
.
to_s
,
line
[
'channel'
],
"Wrong channel"
)
assert_equal
(
'body'
+
channel_3
.
to_s
,
line
[
'message'
],
"Wrong message"
)
assert_equal
(
1
,
line
[
'id'
].
to_i
,
"Wrong message"
)
line
=
JSON
.
parse
(
lines
[
3
])
assert_equal
(
channel_4
.
to_s
,
line
[
'channel'
],
"Wrong channel"
)
assert_equal
(
'body'
+
channel_4
.
to_s
,
line
[
'message'
],
"Wrong message"
)
assert_equal
(
1
,
line
[
'id'
].
to_i
,
"Wrong message"
)
line
=
JSON
.
parse
(
lines
[
4
])
assert_equal
(
channel_5
.
to_s
,
line
[
'channel'
],
"Wrong channel"
)
assert_equal
(
'body'
+
channel_5
.
to_s
,
line
[
'message'
],
"Wrong message"
)
assert_equal
(
1
,
line
[
'id'
].
to_i
,
"Wrong message"
)
line
=
JSON
.
parse
(
lines
[
5
])
assert_equal
(
channel_6
.
to_s
,
line
[
'channel'
],
"Wrong channel"
)
assert_equal
(
'body'
+
channel_6
.
to_s
,
line
[
'message'
],
"Wrong message"
)
assert_equal
(
1
,
line
[
'id'
].
to_i
,
"Wrong message"
)
EventMachine
.
stop
end
}
fail_if_connecttion_error
(
sub_1
)
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel_1
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
+
channel_1
.
to_s
,
:timeout
=>
30
fail_if_connecttion_error
(
pub_1
)
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel_2
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
+
channel_2
.
to_s
,
:timeout
=>
30
fail_if_connecttion_error
(
pub_2
)
pub_3
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel_3
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
+
channel_3
.
to_s
,
:timeout
=>
30
fail_if_connecttion_error
(
pub_3
)
pub_4
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel_4
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
+
channel_4
.
to_s
,
:timeout
=>
30
fail_if_connecttion_error
(
pub_4
)
pub_5
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel_5
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
+
channel_5
.
to_s
,
:timeout
=>
30
fail_if_connecttion_error
(
pub_5
)
pub_6
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel_6
.
to_s
).
post
:head
=>
headers
,
:body
=>
body
+
channel_6
.
to_s
,
:timeout
=>
30
fail_if_connecttion_error
(
pub_6
)
}
end
def
config_test_max_number_of_channels
@max_number_of_channels
=
1
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment