@Test
public void testDeliveryListener_fail() throws CoapException {

    ObservationListener obsListener = mock(ObservationListener.class);
    doThrow(new ObservationTerminatedException(null, null)).when(obsListener).onObservation(any(CoapPacket.class));
    assertNotNull(client.resource("/obs").sync().observe(obsListener));
    NotificationDeliveryListener delivListener = mock(NotificationDeliveryListener.class);
    obsResource.setBody("A", delivListener);
    verify(delivListener, timeout(3000)).onFail(any(InetSocketAddress.class));
    assertNotNull(client.resource("/obs").sync().observe(obsListener));
    obsResource.setBody("B", delivListener);
    verify(delivListener, timeout(3000).times(2)).onFail(any(InetSocketAddress.class));
    verify(delivListener, never()).onSuccess(any(InetSocketAddress.class));
    verify(delivListener, never()).onNoObservers();
}