### Question:
MessageDispatchSender implements Sender, MessageDispatchRegistry { public void send(final Message message) throws CommunicationException { if (message instanceof MessageRequiringResponse) { final MessageRequiringResponse messageRequringResponse = (MessageRequiringResponse)message; final Message requestMessage = messageRequringResponse.getMessage(); final BlockingHandler<Message> responder = m_responders.get(requestMessage.getClass()); if (responder != null) { messageRequringResponse.sendResponse( responder.blockingSend(requestMessage)); return; } } else { final Handler<Message> handler = m_handlers.get(message.getClass()); if (handler != null) { handler.handle(message); return; } } final CommunicationException[] exception = new CommunicationException[1]; m_fallbackHandlers.apply(new ListenerSupport.Informer<Handler<Message>>() { public void inform(Handler<Message> handler) { try { handler.handle(message); } catch (CommunicationException e) { exception[0] = e; } } }); if (message instanceof MessageRequiringResponse) { final MessageRequiringResponse messageRequringResponse = (MessageRequiringResponse)message; if (!messageRequringResponse.isResponseSent()) { messageRequringResponse.sendResponse(new NoResponseMessage()); } } if (exception[0] != null) { throw exception[0]; } }  @SuppressWarnings("unchecked") @Override Handler<T> set(Class<S> messageType, Handler<T> messageHandler); @SuppressWarnings("unchecked") @Override BlockingHandler<T> set(Class<S> messageType, BlockingHandler<T> responder); void addFallback(Handler<Message> messageHandler); void send(final Message message); void shutdown();  }### Answer:
@Test public void testSend() throws Exception { final MessageDispatchSender messageDispatchSender = new MessageDispatchSender(); messageDispatchSender.send(new SimpleMessage()); messageDispatchSender.addFallback(m_fallBackHandler); final Message m1 = new SimpleMessage(); final Message m2 = new SimpleMessage(); messageDispatchSender.send(m1); messageDispatchSender.send(m2); verify(m_fallBackHandler).handle(m1); verify(m_fallBackHandler).handle(m2); final Handler<Message> previousHandler = messageDispatchSender.set(SimpleMessage.class, m_handler); assertNull(previousHandler); final Handler<Message> previousHandler2 = messageDispatchSender.set(OtherMessage.class, m_handler2); assertNull(previousHandler2); messageDispatchSender.send(m1); messageDispatchSender.send(m2); verify(m_handler).handle(m1); verify(m_handler).handle(m2); final OtherMessage m3 = new OtherMessage(); messageDispatchSender.send(m3); verify(m_handler2).handle(m3); final CommunicationException e = new CommunicationException(""); doThrow(e).when(m_handler).handle(m1); try { messageDispatchSender.send(m1); fail("Expected CommunicationException"); } catch (CommunicationException e2) { assertSame(e, e2); } verify(m_handler, times(2)).handle(m1); verifyNoMoreInteractions(m_handler, m_handler2, m_fallBackHandler); }