use of org.eclipse.leshan.core.request.exception.TimeoutException in project leshan by eclipse.
the class FailingTest method async_send_with_acknowleged_request_without_response.
@Test
public void async_send_with_acknowleged_request_without_response() throws Exception {
// register client
LockStepLwM2mClient client = new LockStepLwM2mClient(helper.server.getUnsecuredAddress());
client.sendLwM2mRequest(new RegisterRequest(helper.getCurrentEndpoint(), 60l, null, BindingMode.U, null, Link.parse("</1>,</2>,</3>".getBytes()), null));
client.expectResponse().go();
helper.waitForRegistration(1);
// send read
Callback<ReadResponse> callback = new Callback<ReadResponse>();
helper.server.send(helper.getCurrentRegistration(), new ReadRequest(3), 3000l, callback, callback);
// Acknowledge the response
client.expectRequest().storeMID("R").go();
client.sendEmpty(Type.ACK).loadMID("R").go();
// Request should timedout in ~3s as we send a ack
Thread.sleep(1500);
Assert.assertTrue("we should still wait for response", callback.getException() == null);
callback.waitForResponse(2000);
Assert.assertTrue("we should timeout", callback.getException() instanceof TimeoutException);
}
use of org.eclipse.leshan.core.request.exception.TimeoutException in project leshan by eclipse.
the class FailingTest method async_send_without_acknowleged.
@Test
public void async_send_without_acknowleged() throws Exception {
// register client
LockStepLwM2mClient client = new LockStepLwM2mClient(helper.server.getUnsecuredAddress());
client.sendLwM2mRequest(new RegisterRequest(helper.getCurrentEndpoint(), 60l, null, BindingMode.U, null, Link.parse("</1>,</2>,</3>".getBytes()), null));
client.expectResponse().go();
helper.waitForRegistration(1);
// send read
Callback<ReadResponse> callback = new Callback<ReadResponse>();
helper.server.send(helper.getCurrentRegistration(), new ReadRequest(3), 3000l, callback, callback);
// Request should timedout in ~1s we don't send ACK
callback.waitForResponse(1500);
Assert.assertTrue("we should timeout", callback.getException() instanceof TimeoutException);
}
Aggregations