@Test public void testExchangeCompletionHandlerIsNotRegisteredOnUnsentRequests() { Request request = Request.newGet(); request.setDestinationContext(new AddressEndpointContext(dest)); Exchange exchange = new Exchange(request, Origin.LOCAL, MatcherTestUtils.TEST_EXCHANGE_EXECUTOR); MessageExchangeStore exchangeStore = mock(MessageExchangeStore.class); when(exchangeStore.registerOutboundRequest(exchange)).thenReturn(false); verify(endpointContextMatcher, never()).isResponseRelatedToRequest(null, null); UdpMatcher matcher = newUdpMatcher(exchangeStore); matcher.sendRequest(exchange); assertThat(request.getToken(), is(nullValue())); assertFalse(request.hasMID()); assertFalse(exchange.hasRemoveHandler()); }
@Override public void sendRequest(final Exchange exchange) { Request request = exchange.getCurrentRequest(); if (request.isObserve() && 0 == exchange.getFailedTransmissionCount()) { if (exchangeStore.assignMessageId(request) != Message.NONE) { registerObserve(request); } else { LOGGER.warn("message IDs exhausted, could not register outbound observe request for tracking"); request.setSendError(new IllegalStateException("automatic message IDs exhausted")); return; } } try { if (exchangeStore.registerOutboundRequest(exchange)) { exchange.setRemoveHandler(exchangeRemoveHandler); LOGGER.debug("tracking open request [{}, {}]", exchange.getKeyMID(), exchange.getKeyToken()); } else { LOGGER.warn("message IDs exhausted, could not register outbound request for tracking"); request.setSendError(new IllegalStateException("automatic message IDs exhausted")); } } catch (IllegalArgumentException ex) { request.setSendError(ex); } }
UdpMatcher extends BaseMatcher { @Override public void sendRequest(final Exchange exchange) { Request request = exchange.getCurrentRequest(); if (request.isObserve() && 0 == exchange.getFailedTransmissionCount()) { if (exchangeStore.assignMessageId(request) != Message.NONE) { registerObserve(request); } else { LOGGER.warn("message IDs exhausted, could not register outbound observe request for tracking"); request.setSendError(new IllegalStateException("automatic message IDs exhausted")); return; } } try { if (exchangeStore.registerOutboundRequest(exchange)) { exchange.setRemoveHandler(exchangeRemoveHandler); LOGGER.debug("tracking open request [{}, {}]", exchange.getKeyMID(), exchange.getKeyToken()); } else { LOGGER.warn("message IDs exhausted, could not register outbound request for tracking"); request.setSendError(new IllegalStateException("automatic message IDs exhausted")); } } catch (IllegalArgumentException ex) { request.setSendError(ex); } } }
UdpMatcher extends BaseMatcher { @Override public void sendRequest(final Exchange exchange) { Request request = exchange.getCurrentRequest(); if (request.isObserve() && 0 == exchange.getFailedTransmissionCount()) { if (exchangeStore.assignMessageId(request) != Message.NONE) { registerObserve(request); } else { LOGGER.warn("message IDs exhausted, could not register outbound observe request for tracking"); request.setSendError(new IllegalStateException("automatic message IDs exhausted")); return; } } try { if (exchangeStore.registerOutboundRequest(exchange)) { exchange.setRemoveHandler(exchangeRemoveHandler); LOGGER.debug("tracking open request [{}, {}]", exchange.getKeyMID(), exchange.getKeyToken()); } else { LOGGER.warn("message IDs exhausted, could not register outbound request for tracking"); request.setSendError(new IllegalStateException("automatic message IDs exhausted")); } } catch (IllegalArgumentException ex) { request.setSendError(ex); } } UdpMatcher(NetworkConfig config, NotificationListener notificationListener, TokenGenerator tokenGenerator,
			ObservationStore observationStore, MessageExchangeStore exchangeStore, Executor executor,
			EndpointContextMatcher matchingStrategy); }
UdpMatcher extends BaseMatcher { @Override public void sendRequest(final Exchange exchange) { Request request = exchange.getCurrentRequest(); if (request.isObserve() && 0 == exchange.getFailedTransmissionCount()) { if (exchangeStore.assignMessageId(request) != Message.NONE) { registerObserve(request); } else { LOGGER.warn("message IDs exhausted, could not register outbound observe request for tracking"); request.setSendError(new IllegalStateException("automatic message IDs exhausted")); return; } } try { if (exchangeStore.registerOutboundRequest(exchange)) { exchange.setRemoveHandler(exchangeRemoveHandler); LOGGER.debug("tracking open request [{}, {}]", exchange.getKeyMID(), exchange.getKeyToken()); } else { LOGGER.warn("message IDs exhausted, could not register outbound request for tracking"); request.setSendError(new IllegalStateException("automatic message IDs exhausted")); } } catch (IllegalArgumentException ex) { request.setSendError(ex); } } UdpMatcher(NetworkConfig config, NotificationListener notificationListener, TokenGenerator tokenGenerator,
			ObservationStore observationStore, MessageExchangeStore exchangeStore, Executor executor,
			EndpointContextMatcher matchingStrategy); @Override void sendRequest(final Exchange exchange); @Override void sendResponse(final Exchange exchange); @Override void sendEmptyMessage(final Exchange exchange, final EmptyMessage message); @Override void receiveRequest(final Request request, final EndpointReceiver receiver); @Override void receiveResponse(final Response response, final EndpointReceiver receiver); @Override void receiveEmptyMessage(final EmptyMessage message, final EndpointReceiver receiver); }
UdpMatcher extends BaseMatcher { @Override public void sendRequest(final Exchange exchange) { Request request = exchange.getCurrentRequest(); if (request.isObserve() && 0 == exchange.getFailedTransmissionCount()) { if (exchangeStore.assignMessageId(request) != Message.NONE) { registerObserve(request); } else { LOGGER.warn("message IDs exhausted, could not register outbound observe request for tracking"); request.setSendError(new IllegalStateException("automatic message IDs exhausted")); return; } } try { if (exchangeStore.registerOutboundRequest(exchange)) { exchange.setRemoveHandler(exchangeRemoveHandler); LOGGER.debug("tracking open request [{}, {}]", exchange.getKeyMID(), exchange.getKeyToken()); } else { LOGGER.warn("message IDs exhausted, could not register outbound request for tracking"); request.setSendError(new IllegalStateException("automatic message IDs exhausted")); } } catch (IllegalArgumentException ex) { request.setSendError(ex); } } UdpMatcher(NetworkConfig config, NotificationListener notificationListener, TokenGenerator tokenGenerator,
			ObservationStore observationStore, MessageExchangeStore exchangeStore, Executor executor,
			EndpointContextMatcher matchingStrategy); @Override void sendRequest(final Exchange exchange); @Override void sendResponse(final Exchange exchange); @Override void sendEmptyMessage(final Exchange exchange, final EmptyMessage message); @Override void receiveRequest(final Request request, final EndpointReceiver receiver); @Override void receiveResponse(final Response response, final EndpointReceiver receiver); @Override void receiveEmptyMessage(final EmptyMessage message, final EndpointReceiver receiver);  }