Search in sources :

Example 1 with TimeoutException

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);
}
Also used : RegisterRequest(org.eclipse.leshan.core.request.RegisterRequest) ReadResponse(org.eclipse.leshan.core.response.ReadResponse) ReadRequest(org.eclipse.leshan.core.request.ReadRequest) TimeoutException(org.eclipse.leshan.core.request.exception.TimeoutException) Test(org.junit.Test)

Example 2 with 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);
}
Also used : RegisterRequest(org.eclipse.leshan.core.request.RegisterRequest) ReadResponse(org.eclipse.leshan.core.response.ReadResponse) ReadRequest(org.eclipse.leshan.core.request.ReadRequest) TimeoutException(org.eclipse.leshan.core.request.exception.TimeoutException) Test(org.junit.Test)

Aggregations

ReadRequest (org.eclipse.leshan.core.request.ReadRequest)2 RegisterRequest (org.eclipse.leshan.core.request.RegisterRequest)2 TimeoutException (org.eclipse.leshan.core.request.exception.TimeoutException)2 ReadResponse (org.eclipse.leshan.core.response.ReadResponse)2 Test (org.junit.Test)2