Browse Source

Improved tests

pull/5436/head
Andrii Shvaika 5 years ago
parent
commit
b2a93e834b
  1. 3
      application/src/test/java/org/thingsboard/server/transport/lwm2m/AbstractLwM2MIntegrationTest.java
  2. 13
      application/src/test/java/org/thingsboard/server/transport/lwm2m/rpc/AbstractRpcLwM2MIntegrationTest.java
  3. 2
      application/src/test/java/org/thingsboard/server/transport/lwm2m/rpc/sql/RpcLwm2mIntegrationWriteTest.java

3
application/src/test/java/org/thingsboard/server/transport/lwm2m/AbstractLwM2MIntegrationTest.java

@ -123,7 +123,7 @@ public abstract class AbstractLwM2MIntegrationTest extends AbstractWebsocketTest
protected LwM2MTestClient client;
private final LwM2MBootstrapCredentials defaultBootstrapCredentials;
private String[] resources;
private String endpoint;
protected String endpoint;
public AbstractLwM2MIntegrationTest() {
this.defaultBootstrapCredentials = new LwM2MBootstrapCredentials();
@ -238,7 +238,6 @@ public abstract class AbstractLwM2MIntegrationTest extends AbstractWebsocketTest
deviceCredentials.setCredentialsValue(JacksonUtil.toString(credentials));
doPost("/api/device/credentials", deviceCredentials).andExpect(status().isOk());
Thread.sleep(1000);
return device;
}

13
application/src/test/java/org/thingsboard/server/transport/lwm2m/rpc/AbstractRpcLwM2MIntegrationTest.java

@ -24,6 +24,7 @@ import org.thingsboard.server.transport.lwm2m.AbstractLwM2MIntegrationTest;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Predicate;
import static org.eclipse.leshan.core.LwM2mId.ACCESS_CONTROL;
@ -52,7 +53,6 @@ public abstract class AbstractRpcLwM2MIntegrationTest extends AbstractLwM2MInteg
protected String RPC_TRANSPORT_CONFIGURATION;
protected static final String ENDPOINT_RPC = "deviceEndpointRpc";
protected ScheduledExecutorService executor;
protected TbTestWebSocketClient wsClient;
protected String deviceId;
@ -72,19 +72,18 @@ public abstract class AbstractRpcLwM2MIntegrationTest extends AbstractLwM2MInteg
protected String objectIdVer_19;
protected String objectIdVer_50 = "/50";
protected String objectIdVer_3303;
protected static AtomicInteger endpointSequence = new AtomicInteger();
public AbstractRpcLwM2MIntegrationTest(){
setResources(resources);
setEndpoint(ENDPOINT_RPC);
}
@Before
public void beforeTest() throws Exception {
setEndpoint("deviceEndpointRpc" + endpointSequence.incrementAndGet());
init();
createNewClient (SECURITY, COAP_CONFIG, true);
Thread.sleep(1000);
expectedObjects = ConcurrentHashMap.newKeySet();
expectedObjectIdVers = ConcurrentHashMap.newKeySet();
expectedInstances = ConcurrentHashMap.newKeySet();
@ -179,14 +178,10 @@ public abstract class AbstractRpcLwM2MIntegrationTest extends AbstractLwM2MInteg
"}";
createDeviceProfile(RPC_TRANSPORT_CONFIGURATION);
Thread.sleep(1000);
NoSecClientCredentials credentials = createNoSecClientCredentials(ENDPOINT_RPC);
NoSecClientCredentials credentials = createNoSecClientCredentials(endpoint);
final Device device = createDevice(credentials);
deviceId = device.getId().getId().toString();
Thread.sleep(1000);
client.start();
}

2
application/src/test/java/org/thingsboard/server/transport/lwm2m/rpc/sql/RpcLwm2mIntegrationWriteTest.java

@ -121,7 +121,7 @@ public class RpcLwm2mIntegrationWriteTest extends AbstractRpcLwM2MIntegrationTes
ObjectNode rpcActualResult = JacksonUtil.fromString(actualResult, ObjectNode.class);
assertEquals(ResponseCode.BAD_REQUEST.getName(), rpcActualResult.get("result").asText());
String actualValues = rpcActualResult.get("error").asText();
String expected = "Format value is bad. Value for this Multi-Instance Resource must be in Json format!";
String expected = "Value of Multi-Instance Resource must be in Json format!";
assertTrue(actualValues.contains(expected));
}

Loading…
Cancel
Save