@@ -24,46 +24,46 @@ public class EngineTemperatureSensorLiveTest {
2424 @ Test
2525 public void whenSendSingleMessage_thenSuccess () throws Exception {
2626
27- String senderId = UUID .randomUUID ().toString ();
28- MqttClient sender = new MqttClient ("tcp://iot.eclipse.org:1883" ,senderId );
29-
30- String receiverId = UUID .randomUUID ().toString ();
31- MqttClient receiver = new MqttClient ("tcp://iot.eclipse.org:1883" ,receiverId );
27+ String publisherId = UUID .randomUUID ().toString ();
28+ MqttClient publisher = new MqttClient ("tcp://iot.eclipse.org:1883" ,publisherId );
3229
30+ String subscriberId = UUID .randomUUID ().toString ();
31+ MqttClient subscriber = new MqttClient ("tcp://iot.eclipse.org:1883" ,subscriberId );
3332
3433 MqttConnectOptions options = new MqttConnectOptions ();
3534 options .setAutomaticReconnect (true );
3635 options .setCleanSession (true );
3736 options .setConnectionTimeout (10 );
3837
3938
40- receiver .connect (options );
41- sender .connect (options );
39+ subscriber .connect (options );
40+ publisher .connect (options );
4241
4342 CountDownLatch receivedSignal = new CountDownLatch (1 );
4443
45- receiver .subscribe (EngineTemperatureSensor .TOPIC , (topic , msg ) -> {
46- log .info ("[I41] Message received: topic={}, payload={}" , topic , new String (msg .getPayload ()));
44+ subscriber .subscribe (EngineTemperatureSensor .TOPIC , (topic , msg ) -> {
45+ byte [] payload = msg .getPayload ();
46+ log .info ("[I46] Message received: topic={}, payload={}" , topic , new String (payload ));
4747 receivedSignal .countDown ();
4848 });
4949
5050
51- Callable <Void > target = new EngineTemperatureSensor (sender );
51+ Callable <Void > target = new EngineTemperatureSensor (publisher );
5252 target .call ();
5353
5454 receivedSignal .await (1 , TimeUnit .MINUTES );
5555
56- log .info ("[I51 ] Success !" );
56+ log .info ("[I56 ] Success !" );
5757 }
5858
5959 @ Test
6060 public void whenSendMultipleMessages_thenSuccess () throws Exception {
6161
62- String senderId = UUID .randomUUID ().toString ();
63- MqttClient sender = new MqttClient ("tcp://iot.eclipse.org:1883" ,senderId );
62+ String publisherId = UUID .randomUUID ().toString ();
63+ MqttClient publisher = new MqttClient ("tcp://iot.eclipse.org:1883" ,publisherId );
6464
65- String receiverId = UUID .randomUUID ().toString ();
66- MqttClient receiver = new MqttClient ("tcp://iot.eclipse.org:1883" ,receiverId );
65+ String subscriberId = UUID .randomUUID ().toString ();
66+ MqttClient subscriber = new MqttClient ("tcp://iot.eclipse.org:1883" ,subscriberId );
6767
6868
6969 MqttConnectOptions options = new MqttConnectOptions ();
@@ -72,18 +72,19 @@ public void whenSendMultipleMessages_thenSuccess() throws Exception {
7272 options .setConnectionTimeout (10 );
7373
7474
75- sender .connect (options );
76- receiver .connect (options );
75+ publisher .connect (options );
76+ subscriber .connect (options );
7777
7878 CountDownLatch receivedSignal = new CountDownLatch (10 );
7979
80- receiver .subscribe (EngineTemperatureSensor .TOPIC , (topic , msg ) -> {
81- log .info ("[I41] Message received: topic={}, payload={}" , topic , new String (msg .getPayload ()));
80+ subscriber .subscribe (EngineTemperatureSensor .TOPIC , (topic , msg ) -> {
81+ byte [] payload = msg .getPayload ();
82+ log .info ("[I82] Message received: topic={}, payload={}" , topic , new String (payload ));
8283 receivedSignal .countDown ();
8384 });
8485
8586
86- Callable <Void > target = new EngineTemperatureSensor (sender );
87+ Callable <Void > target = new EngineTemperatureSensor (publisher );
8788
8889 ScheduledExecutorService executor = Executors .newSingleThreadScheduledExecutor ();
8990 executor .scheduleAtFixedRate (() -> {
@@ -96,12 +97,12 @@ public void whenSendMultipleMessages_thenSuccess() throws Exception {
9697 }, 1 , 1 , TimeUnit .SECONDS );
9798
9899
99- receivedSignal .await (1 , TimeUnit .DAYS );
100+ receivedSignal .await (1 , TimeUnit .MINUTES );
100101 executor .shutdown ();
101102
102103 assertTrue (receivedSignal .getCount () == 0 , "Countdown should be zero" );
103104
104- log .info ("[I51 ] Success !" );
105+ log .info ("[I105 ] Success !" );
105106 }
106107
107108
0 commit comments