Commit 31f0689f63e55abe2af8db7a26af7bea76a1b832

Authored by Igor Kulikov
1 parent 0894b23b

Websocket Api tests improvements

@@ -445,6 +445,7 @@ public class BaseWebsocketApiTest extends AbstractWebsocketTest { @@ -445,6 +445,7 @@ public class BaseWebsocketApiTest extends AbstractWebsocketTest {
445 445
446 wsClient.send(mapper.writeValueAsString(wrapper)); 446 wsClient.send(mapper.writeValueAsString(wrapper));
447 String msg = wsClient.waitForReply(); 447 String msg = wsClient.waitForReply();
  448 + Assert.assertNotNull(msg);
448 EntityDataUpdate update = mapper.readValue(msg, EntityDataUpdate.class); 449 EntityDataUpdate update = mapper.readValue(msg, EntityDataUpdate.class);
449 Assert.assertEquals(1, update.getCmdId()); 450 Assert.assertEquals(1, update.getCmdId());
450 PageData<EntityData> pageData = update.getData(); 451 PageData<EntityData> pageData = update.getData();
@@ -457,13 +458,14 @@ public class BaseWebsocketApiTest extends AbstractWebsocketTest { @@ -457,13 +458,14 @@ public class BaseWebsocketApiTest extends AbstractWebsocketTest {
457 458
458 459
459 wsClient.registerWaitForUpdate(); 460 wsClient.registerWaitForUpdate();
460 - Thread.sleep(100); 461 + Thread.sleep(500);
461 462
462 AttributeKvEntry dataPoint1 = new BaseAttributeKvEntry(now - TimeUnit.MINUTES.toMillis(1), new LongDataEntry("serverAttributeKey", 42L)); 463 AttributeKvEntry dataPoint1 = new BaseAttributeKvEntry(now - TimeUnit.MINUTES.toMillis(1), new LongDataEntry("serverAttributeKey", 42L));
463 List<AttributeKvEntry> tsData = Arrays.asList(dataPoint1); 464 List<AttributeKvEntry> tsData = Arrays.asList(dataPoint1);
464 sendAttributes(device, TbAttributeSubscriptionScope.SERVER_SCOPE, tsData); 465 sendAttributes(device, TbAttributeSubscriptionScope.SERVER_SCOPE, tsData);
465 466
466 msg = wsClient.waitForUpdate(); 467 msg = wsClient.waitForUpdate();
  468 + Assert.assertNotNull(msg);
467 update = mapper.readValue(msg, EntityDataUpdate.class); 469 update = mapper.readValue(msg, EntityDataUpdate.class);
468 470
469 Assert.assertEquals(1, update.getCmdId()); 471 Assert.assertEquals(1, update.getCmdId());
@@ -479,9 +481,10 @@ public class BaseWebsocketApiTest extends AbstractWebsocketTest { @@ -479,9 +481,10 @@ public class BaseWebsocketApiTest extends AbstractWebsocketTest {
479 AttributeKvEntry dataPoint2 = new BaseAttributeKvEntry(now, new LongDataEntry("serverAttributeKey", 52L)); 481 AttributeKvEntry dataPoint2 = new BaseAttributeKvEntry(now, new LongDataEntry("serverAttributeKey", 52L));
480 482
481 wsClient.registerWaitForUpdate(); 483 wsClient.registerWaitForUpdate();
482 - Thread.sleep(100); 484 + Thread.sleep(500);
483 sendAttributes(device, TbAttributeSubscriptionScope.SERVER_SCOPE, Arrays.asList(dataPoint2)); 485 sendAttributes(device, TbAttributeSubscriptionScope.SERVER_SCOPE, Arrays.asList(dataPoint2));
484 msg = wsClient.waitForUpdate(); 486 msg = wsClient.waitForUpdate();
  487 + Assert.assertNotNull(msg);
485 488
486 update = mapper.readValue(msg, EntityDataUpdate.class); 489 update = mapper.readValue(msg, EntityDataUpdate.class);
487 Assert.assertEquals(1, update.getCmdId()); 490 Assert.assertEquals(1, update.getCmdId());
@@ -495,14 +498,14 @@ public class BaseWebsocketApiTest extends AbstractWebsocketTest { @@ -495,14 +498,14 @@ public class BaseWebsocketApiTest extends AbstractWebsocketTest {
495 498
496 //Sending update from the past, while latest value has new timestamp; 499 //Sending update from the past, while latest value has new timestamp;
497 wsClient.registerWaitForUpdate(); 500 wsClient.registerWaitForUpdate();
498 - Thread.sleep(100); 501 + Thread.sleep(500);
499 sendAttributes(device, TbAttributeSubscriptionScope.SERVER_SCOPE, Arrays.asList(dataPoint1)); 502 sendAttributes(device, TbAttributeSubscriptionScope.SERVER_SCOPE, Arrays.asList(dataPoint1));
500 msg = wsClient.waitForUpdate(TimeUnit.SECONDS.toMillis(1)); 503 msg = wsClient.waitForUpdate(TimeUnit.SECONDS.toMillis(1));
501 Assert.assertNull(msg); 504 Assert.assertNull(msg);
502 505
503 //Sending duplicate update again 506 //Sending duplicate update again
504 wsClient.registerWaitForUpdate(); 507 wsClient.registerWaitForUpdate();
505 - Thread.sleep(100); 508 + Thread.sleep(500);
506 sendAttributes(device, TbAttributeSubscriptionScope.SERVER_SCOPE, Arrays.asList(dataPoint2)); 509 sendAttributes(device, TbAttributeSubscriptionScope.SERVER_SCOPE, Arrays.asList(dataPoint2));
507 msg = wsClient.waitForUpdate(TimeUnit.SECONDS.toMillis(1)); 510 msg = wsClient.waitForUpdate(TimeUnit.SECONDS.toMillis(1));
508 Assert.assertNull(msg); 511 Assert.assertNull(msg);