### Question:
FIXOutgoingMessageHandler { public synchronized void sendMessage(Message message, SessionID targetSession, String sourceSession, int counter, MessageContext msgCtx, String targetEPR) throws SessionNotFound { boolean ignoreOrder = "true".equals(msgCtx.getProperty(FIXConstants.FIX_IGNORE_ORDER)); if (sourceSession != null && counter != -1 && !ignoreOrder) { int expectedValue; if (countersMap.containsKey(sourceSession)) { expectedValue = countersMap.get(sourceSession); } else { countersMap.put(sourceSession, 1); messagesMap.put(sourceSession, new ConcurrentHashMap<Integer,Object[]>()); expectedValue = 1; } if (expectedValue == counter) { sendToTarget(msgCtx, targetEPR, message, targetSession); if (FIXConstants.DEFAULT_COUNTER_UPPER_LIMIT == expectedValue) { if (log.isDebugEnabled()) { log.debug("Outgoing request counter rolled over for the session: " + sourceSession + " (from " + expectedValue + ")"); } expectedValue = 1; } countersMap.put(sourceSession, ++expectedValue); sendQueuedMessages(expectedValue, sourceSession); } else { if (log.isDebugEnabled()) { log.debug("Source session: " + sourceSession + " - Expected sequence number (" + expectedValue + ") does not match with the actual sequence number (" + counter + "). Holding the message back for later delivery."); } Map<Integer,Object[]> messages = messagesMap.get(sourceSession); Object[] obj = new Object[] { message, targetSession, msgCtx, targetEPR } ; messages.put(counter, obj); } } else { sendToTarget(msgCtx, targetEPR, message, targetSession); } } FIXOutgoingMessageHandler(); void setSessionFactory(FIXSessionFactory sessionFactory); synchronized void sendMessage(Message message, SessionID targetSession, String sourceSession,
                            int counter, MessageContext msgCtx, String targetEPR); void cleanUpMessages(String session);  }### Answer:
@Test public void testSendMessage() throws Exception { int SEQ_NUM = 1; String SESSION_ID = "FIX.4.1:BANZAI->SYNAPSE"; Message message = new NewOrderSingle(); MessageContext msgCtx = new MessageContext(); PowerMockito.when(sessionFactory.getApplication(anyString())).thenReturn(app); PowerMockito.mockStatic(Session.class); PowerMockito.when(Session.sendToTarget(any(Message.class), any(SessionID.class))).thenReturn(true); SessionID id = new SessionID(new BeginString("FIX.4.1"), new SenderCompID("SYNAPSE"), new TargetCompID("BANZAI"), "FIX.4.1:SYNAPSE->BANZAI"); spy.sendMessage(message, id, SESSION_ID, SEQ_NUM, msgCtx, "fix: PowerMockito.verifyStatic(times(1)); }