Skip to content

Commit

Permalink
fixes rabbitmq#9
Browse files Browse the repository at this point in the history
  • Loading branch information
videlalvaro committed May 11, 2015
1 parent a57f67e commit 8e78034
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/rabbit_exchange_type_delayed_message.erl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ route(X, Delivery) ->

validate(#exchange{arguments = Args} = X) ->
case table_lookup(Args, <<"x-delayed-type">>) of
{_ArgType, <<"x-delayed-message">>} ->
rabbit_misc:protocol_error(precondition_failed,
"Invalid argument, "
"'x-delayed-message' can't be used"
"for 'x-delayed-type'",
[]);
{_ArgType, Type} when is_binary(Type) ->
rabbit_exchange:check_type(Type),
?EXCHANGE(X):validate(X);
Expand Down
9 changes: 9 additions & 0 deletions test/src/rabbit_exchange_type_delayed_message_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ wrong_exchange_argument_type_test() ->
?assertExit(_, amqp_channel:call(Chan, make_exchange(Ex, Type))),
ok.

exchange_argument_type_not_self_test() ->
{ok, Conn} = amqp_connection:start(#amqp_params_network{}),
{ok, Chan} = amqp_connection:open_channel(Conn),
Ex = <<"fail">>,
Type = <<"x-delayed-message">>,
process_flag(trap_exit, true),
?assertExit(_, amqp_channel:call(Chan, make_exchange(Ex, Type))),
ok.

routing_topic_test() ->
BKs = [<<"a.b.c">>, <<"a.*.c">>, <<"a.#">>],
RKs = [<<"a.b.c">>, <<"a.z.c">>, <<"a.j.k">>, <<"b.b.c">>],
Expand Down

0 comments on commit 8e78034

Please sign in to comment.