anchor.diff:      Suback = packet:gen_suback(18, 0),
       Publish0 = packet:gen_publish("retain/qos1/test", 0, <<"retained message">>, [{retain, true}]),
       {ok, Socket} = packet:do_client_connect(Connect, Connack, []),
  -    enable_on_publish(),
  -    enable_on_subscribe(),
       %% Send retained message
       ok = gen_tcp:send(Socket, Publish),
       ok = packet:expect_packet(Socket, "puback", Puback),
       ok = gen_tcp:send(Socket, Subscribe),
       ok = packet:expect_packet(Socket, "suback", Suback),
       ok = packet:expect_packet(Socket, "publish0", Publish0),
  -    disable_on_publish(),
  -    disable_on_subscribe(),
       ok = gen_tcp:close(Socket).
   
   publish_empty_retained_msg_test(_) ->
  -    Connect = packet:gen_connect("retain-clear-test", [{keepalive,60}]),
  -    Connack = packet:gen_connack(0),
  -    Publish = packet:gen_publish("retain/clear/test", 0, <<"retained message">>, [{retain, true}]),
  -    RetainClearPub = packet:gen_publish("retain/clear/test", 0, <<>>, [{retain, true}]),
  -    RetainClearSub = packet:gen_publish("retain/clear/test", 0, <<>>, [{retain, false}]),
  -    Subscribe = packet:gen_subscribe(592, "retain/clear/test", 0),
  +    Connect = packet:gen_connect("retain-clear-empty-test", [{keepalive,60}]),
  +    Connack = packet:gen_connack(0),
  +    Publish = packet:gen_publish("retain/clear/emptytest", 0, <<"retained message">>, [{retain, true}]),
  +    RetainClearPub = packet:gen_publish("retain/clear/emptytest", 0, <<>>, [{retain, true}]),
  +    RetainClearSub = packet:gen_publish("retain/clear/emptytest", 0, <<>>, [{retain, false}]),
  +    Subscribe = packet:gen_subscribe(592, "retain/clear/emptytest", 0),
       Suback = packet:gen_suback(592, 0),
       {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: -module(vmq_retain_SUITE).
  
  -compile(export_all).
  -compile(nowarn_export_all).
  
  %% ===================================================================
  %% common_test callbacks
  %% ===================================================================
  init_per_suite(_Config) ->
      vmq_test_utils:setup(),
      vmq_server_cmd:set_config(allow_anonymous, true),
      vmq_server_cmd:set_config(retry_interval, 10),
      vmq_server_cmd:listener_start(1888, []),
      cover:start(),
      enable_on_publish(),
      enable_on_subscribe(),
      _Config.
  
  end_per_suite(_Config) ->
      disable_on_publish(),
      disable_on_subscribe(),
      vmq_test_utils:teardown(),
      _Config.
  
  init_per_testcase(_Case, Config) ->
      Config.
  
  end_per_testcase(_, Config) ->
      Config.
  
  all() ->
      [
       {group, mqtt}
      ].
  
  groups() ->
      Tests =
          [retain_qos0_test,
           retain_qos0_repeated_test,
           retain_qos0_fresh_test,
           retain_qos0_clear_test,
           retain_qos1_qos0_test,
           retain_wildcard_test,
           publish_empty_retained_msg_test],
      [
       {mqtt, [shuffle, parallel], Tests}
      ].
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %%% Actual Tests
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  
  retain_qos0_test(_) ->
      Connect = packet:gen_connect("retain-qos0-test", [{keepalive,60}]),
      Connack = packet:gen_connack(0),
  