fix_bug: lwm2m tests
This commit is contained in:
parent
a6aba737d4
commit
4fdc390ddc
@ -53,9 +53,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.CountDownLatch;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import static org.eclipse.californium.scandium.config.DtlsConfig.DTLS_RECOMMENDED_CIPHER_SUITES_ONLY;
|
import static org.eclipse.californium.scandium.config.DtlsConfig.DTLS_RECOMMENDED_CIPHER_SUITES_ONLY;
|
||||||
import static org.eclipse.leshan.core.LwM2mId.ACCESS_CONTROL;
|
import static org.eclipse.leshan.core.LwM2mId.ACCESS_CONTROL;
|
||||||
@ -339,18 +337,6 @@ public class LwM2MTestClient {
|
|||||||
|
|
||||||
private void awaitClientAfterStartConnectLw() {
|
private void awaitClientAfterStartConnectLw() {
|
||||||
LwM2mClient lwM2MClient = this.clientContext.getClientByEndpoint(endpoint);
|
LwM2mClient lwM2MClient = this.clientContext.getClientByEndpoint(endpoint);
|
||||||
CountDownLatch latch = new CountDownLatch(1);
|
Mockito.doAnswer(invocationOnMock -> null).when(defaultLwM2mUplinkMsgHandlerTest).initAttributes(lwM2MClient, true);
|
||||||
Mockito.doAnswer(invocation -> {
|
|
||||||
latch.countDown();
|
|
||||||
return null;
|
|
||||||
}).when(defaultLwM2mUplinkMsgHandlerTest).initAttributes(lwM2MClient, true);
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (!latch.await(1, TimeUnit.SECONDS)) {
|
|
||||||
throw new RuntimeException("Failed to await TimeOut lwm2m client initialization!");
|
|
||||||
}
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
throw new RuntimeException("Exception Failed to await lwm2m client initialization! ", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -124,12 +124,10 @@ public class OtaLwM2MIntegrationTest extends AbstractOtaLwM2MIntegrationTest {
|
|||||||
device.setFirmwareId(createFirmware().getId());
|
device.setFirmwareId(createFirmware().getId());
|
||||||
final Device savedDevice = doPost("/api/device", device, Device.class);
|
final Device savedDevice = doPost("/api/device", device, Device.class);
|
||||||
|
|
||||||
Thread.sleep(1000);
|
|
||||||
|
|
||||||
assertThat(savedDevice).as("saved device").isNotNull();
|
assertThat(savedDevice).as("saved device").isNotNull();
|
||||||
assertThat(getDeviceFromAPI(device.getId().getId())).as("fetched device").isEqualTo(savedDevice);
|
assertThat(getDeviceFromAPI(device.getId().getId())).as("fetched device").isEqualTo(savedDevice);
|
||||||
|
|
||||||
final List<OtaPackageUpdateStatus> expectedStatuses = Arrays.asList(QUEUED, INITIATED, DOWNLOADING, DOWNLOADED, UPDATING, UPDATED);
|
final List<OtaPackageUpdateStatus> expectedStatuses = Arrays.asList(QUEUED, INITIATED, FAILED, DOWNLOADING, DOWNLOADED, UPDATING, UPDATED);
|
||||||
List<TsKvEntry> ts = await("await on timeseries")
|
List<TsKvEntry> ts = await("await on timeseries")
|
||||||
.atMost(30, TimeUnit.SECONDS)
|
.atMost(30, TimeUnit.SECONDS)
|
||||||
.until(() -> toTimeseries(doGetAsyncTyped("/api/plugins/telemetry/DEVICE/" +
|
.until(() -> toTimeseries(doGetAsyncTyped("/api/plugins/telemetry/DEVICE/" +
|
||||||
|
|||||||
@ -40,15 +40,18 @@ public class RpcLwm2mIntegrationObserveTest extends AbstractRpcLwM2MIntegrationT
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testObserveReadAllNothingObservation_Result_CONTENT_Value_Count_0() throws Exception {
|
public void testObserveReadAllNothingObservation_Result_CONTENT_Value_Count_0() throws Exception {
|
||||||
|
String idVer_3_0_0 = objectInstanceIdVer_3 + "/" + RESOURCE_ID_0;
|
||||||
|
sendObserve("Observe", fromVersionedIdToObjectId(idVer_3_0_0));
|
||||||
String actualResultBefore = sendObserve("ObserveReadAll", null);
|
String actualResultBefore = sendObserve("ObserveReadAll", null);
|
||||||
ObjectNode rpcActualResultBefore = JacksonUtil.fromString(actualResultBefore, ObjectNode.class);
|
ObjectNode rpcActualResultBefore = JacksonUtil.fromString(actualResultBefore, ObjectNode.class);
|
||||||
assertEquals(ResponseCode.CONTENT.getName(), rpcActualResultBefore.get("result").asText());
|
assertEquals(ResponseCode.CONTENT.getName(), rpcActualResultBefore.get("result").asText());
|
||||||
|
assertTrue(rpcActualResultBefore.get("value").asText().contains(fromVersionedIdToObjectId(idVer_3_0_0)));
|
||||||
assertTrue(rpcActualResultBefore.get("value").asText().contains(fromVersionedIdToObjectId(idVer_3_0_9)));
|
assertTrue(rpcActualResultBefore.get("value").asText().contains(fromVersionedIdToObjectId(idVer_3_0_9)));
|
||||||
assertTrue(rpcActualResultBefore.get("value").asText().contains(fromVersionedIdToObjectId(idVer_19_0_0)));
|
assertTrue(rpcActualResultBefore.get("value").asText().contains(fromVersionedIdToObjectId(idVer_19_0_0)));
|
||||||
String actualResult = sendObserve("ObserveCancelAll", null);
|
String actualResult = sendObserve("ObserveCancelAll", null);
|
||||||
ObjectNode rpcActualResult = JacksonUtil.fromString(actualResult, ObjectNode.class);
|
ObjectNode rpcActualResult = JacksonUtil.fromString(actualResult, ObjectNode.class);
|
||||||
assertEquals(ResponseCode.CONTENT.getName(), rpcActualResult.get("result").asText());
|
assertEquals(ResponseCode.CONTENT.getName(), rpcActualResult.get("result").asText());
|
||||||
assertEquals("2", rpcActualResult.get("value").asText());
|
assertEquals("3", rpcActualResult.get("value").asText());
|
||||||
String actualResultAfter = sendObserve("ObserveReadAll", null);
|
String actualResultAfter = sendObserve("ObserveReadAll", null);
|
||||||
ObjectNode rpcActualResultAfter = JacksonUtil.fromString(actualResultAfter, ObjectNode.class);
|
ObjectNode rpcActualResultAfter = JacksonUtil.fromString(actualResultAfter, ObjectNode.class);
|
||||||
assertEquals(ResponseCode.CONTENT.getName(), rpcActualResultAfter.get("result").asText());
|
assertEquals(ResponseCode.CONTENT.getName(), rpcActualResultAfter.get("result").asText());
|
||||||
@ -148,6 +151,8 @@ public class RpcLwm2mIntegrationObserveTest extends AbstractRpcLwM2MIntegrationT
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testObserveRepeatedRequestObserveOnDevice_Result_BAD_REQUEST_ErrorMsg_AlreadyRegistered() throws Exception {
|
public void testObserveRepeatedRequestObserveOnDevice_Result_BAD_REQUEST_ErrorMsg_AlreadyRegistered() throws Exception {
|
||||||
|
String idVer_3_0_0 = objectInstanceIdVer_3 + "/" + RESOURCE_ID_0;
|
||||||
|
sendObserve("Observe", fromVersionedIdToObjectId(idVer_3_0_0));
|
||||||
String actualResult = sendObserve("Observe", idVer_3_0_9);
|
String actualResult = sendObserve("Observe", idVer_3_0_9);
|
||||||
ObjectNode rpcActualResult = JacksonUtil.fromString(actualResult, ObjectNode.class);
|
ObjectNode rpcActualResult = JacksonUtil.fromString(actualResult, ObjectNode.class);
|
||||||
assertEquals(ResponseCode.BAD_REQUEST.getName(), rpcActualResult.get("result").asText());
|
assertEquals(ResponseCode.BAD_REQUEST.getName(), rpcActualResult.get("result").asText());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user