anchor.diff:      Unsubscribe = packet:gen_unsubscribe(593, "retain/clear/test"),
       Unsuback = packet:gen_unsuback(593),
       {ok, Socket} = packet:do_client_connect(Connect, Connack, []),
  -    enable_on_publish(),
  -    enable_on_subscribe(),
       %% Send retained message
       ok = gen_tcp:send(Socket, Publish),
       %% Subscribe to topic, we should get the retained message back.
  
positive.code:     ok = gen_tcp:send(Socket, Subscribe),
      ok = packet:expect_packet(Socket, "suback", Suback),
      ok = packet:expect_packet(Socket, "publish", Publish),
      disable_on_publish(),
      disable_on_subscribe(),
      ok = gen_tcp:close(Socket).
  
  retain_qos0_fresh_test(_) ->
      Connect = packet:gen_connect("retain-qos0-fresh-test", [{keepalive,60}]),
      Connack = packet:gen_connack(0),
      Publish = packet:gen_publish("retain/qos0/test", 0, <<"retained message">>, [{retain, true}]),
      PublishFresh = packet:gen_publish("retain/qos0/test", 0, <<"retained message">>, []),
      Subscribe = packet:gen_subscribe(16, "retain/qos0/test", 0),
      Suback = packet:gen_suback(16, 0),
      {ok, Socket} = packet:do_client_connect(Connect, Connack, []),
      enable_on_publish(),
      enable_on_subscribe(),
      %% Send retained message
      ok = gen_tcp:send(Socket, Subscribe),
      ok = packet:expect_packet(Socket, "suback", Suback),
      ok = gen_tcp:send(Socket, Publish),
      ok = packet:expect_packet(Socket, "publish", PublishFresh),
      disable_on_publish(),
      disable_on_subscribe(),
      ok = gen_tcp:close(Socket).
  
  retain_qos0_clear_test(_) ->
  
negative.code:     %% Receive the empty payload msg as normal publish.
      ok = packet:expect_packet(Socket, "publish", RetainClearSub),
      {error, timeout} = gen_tcp:recv(Socket, 256, 1000),
      ok = gen_tcp:close(Socket).
  
  retain_wildcard_test(_) ->
      Connect = packet:gen_connect("retain-wildcard-test", [{keepalive,60}]),
      Connack = packet:gen_connack(0),
      Publish = packet:gen_publish("retainwildcard/wildcard/test", 0, <<"retained message">>, [{retain, true}]),
      Subscribe = packet:gen_subscribe(16, "retainwildcard/+/#", 0),
      Suback = packet:gen_suback(16, 0),
      {ok, Socket} = packet:do_client_connect(Connect, Connack, []),
      %% Send retained message
      ok = gen_tcp:send(Socket, Publish),
      ok = gen_tcp:send(Socket, Subscribe),
      ok = packet:expect_packet(Socket, "suback", Suback),
      ok = packet:expect_packet(Socket, "publish", Publish),
      ok = gen_tcp:close(Socket).
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %%% Hooks
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  hook_auth_on_subscribe(_,_,_) -> ok.
  
  hook_auth_on_publish(_, _, _, _, _, _) -> ok.
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %%% Helper
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  