use of org.eclipse.leshan.core.response.ReadResponse in project leshan by eclipse.
the class QueueModeTest method sleeping_if_timeout.
@Test
public void sleeping_if_timeout() throws InterruptedException {
// Check client is not registered
queueModeHelper.assertClientNotRegisterered();
// Start it and wait for registration
queueModeHelper.client.start();
queueModeHelper.waitForRegistration(1);
// Check client is well registered and awake
queueModeHelper.assertClientRegisterered();
queueModeHelper.ensureClientAwake();
// Stop the client to ensure that TimeOut exception is thrown
queueModeHelper.client.stop(false);
// Send a response with very short timeout
ReadResponse response = queueModeHelper.server.send(queueModeHelper.getCurrentRegistration(), new ReadRequest(3, 0, 1), 1);
// Check that a timeout occurs
queueModeHelper.ensureTimeoutException(response);
// Check that the client is sleeping
queueModeHelper.ensureClientSleeping();
}
use of org.eclipse.leshan.core.response.ReadResponse in project leshan by eclipse.
the class ReadTest method can_read_object.
@Test
public void can_read_object() throws InterruptedException {
// read device object
ReadResponse response = helper.server.send(helper.getCurrentRegistration(), new ReadRequest(3));
// verify result
assertEquals(CONTENT, response.getCode());
assertNotNull(response.getCoapResponse());
assertThat(response.getCoapResponse(), is(instanceOf(Response.class)));
LwM2mObject object = (LwM2mObject) response.getContent();
assertEquals(3, object.getId());
LwM2mObjectInstance instance = object.getInstance(0);
assertEquals(0, instance.getId());
}
use of org.eclipse.leshan.core.response.ReadResponse in project leshan by eclipse.
the class ReadTest method cannot_read_non_existent_object.
@Test
public void cannot_read_non_existent_object() throws InterruptedException {
// read object "50"
ReadResponse response = helper.server.send(helper.getCurrentRegistration(), new ReadRequest(50));
// verify result
assertEquals(NOT_FOUND, response.getCode());
assertNotNull(response.getCoapResponse());
assertThat(response.getCoapResponse(), is(instanceOf(Response.class)));
}
use of org.eclipse.leshan.core.response.ReadResponse in project leshan by eclipse.
the class ReadTest method cannot_read_non_existent_resource.
@Test
public void cannot_read_non_existent_resource() throws InterruptedException {
// read device 50 resource
ReadResponse response = helper.server.send(helper.getCurrentRegistration(), new ReadRequest(3, 0, 50));
// verify result
assertEquals(NOT_FOUND, response.getCode());
assertNotNull(response.getCoapResponse());
assertThat(response.getCoapResponse(), is(instanceOf(Response.class)));
}
use of org.eclipse.leshan.core.response.ReadResponse in project leshan by eclipse.
the class ReadTest method can_read_empty_object.
@Test
public void can_read_empty_object() throws InterruptedException {
// read ACL object
ReadResponse response = helper.server.send(helper.getCurrentRegistration(), new ReadRequest(2));
// verify result
assertEquals(CONTENT, response.getCode());
assertNotNull(response.getCoapResponse());
assertThat(response.getCoapResponse(), is(instanceOf(Response.class)));
LwM2mObject object = (LwM2mObject) response.getContent();
assertEquals(2, object.getId());
assertTrue(object.getInstances().isEmpty());
}
Aggregations