Package org.mokai.persist.jdbc

Examples of org.mokai.persist.jdbc.MessageHandler


*/
public class OutboundInboundHandlerTest {

  @Test
  public void testSaveOutboundMessage() throws Exception {
    MessageHandler outHandler = mockHandlerForSaveMessage();
    MessageHandler inHandler = mock(MessageHandler.class);

    Connection conn = mock(Connection.class);
    MessageHandler handler = createMessageHandler(outHandler, inHandler);

    Message message = new Message();
    message.setDirection(Direction.TO_CONNECTIONS);

    handler.insertMessage(conn, message);

    verify(outHandler).insertMessage(any(Connection.class), any(Message.class));
    verify(inHandler, never()).insertMessage(any(Connection.class), any(Message.class));
  }
View Full Code Here


    verify(inHandler, never()).insertMessage(any(Connection.class), any(Message.class));
  }

  @Test
  public void testSaveInboundMessage() throws Exception {
    MessageHandler inHandler = mockHandlerForSaveMessage();
    MessageHandler outHandler = mock(MessageHandler.class);

    Connection conn = mock(Connection.class);
    MessageHandler handler = createMessageHandler(outHandler, inHandler);

    Message message = new Message();
    message.setDirection(Direction.TO_APPLICATIONS);

    handler.insertMessage(conn, message);

    verify(inHandler).insertMessage(any(Connection.class), any(Message.class));
    verify(outHandler, never()).insertMessage(any(Connection.class), any(Message.class));
  }
View Full Code Here

    verify(inHandler).insertMessage(any(Connection.class), any(Message.class));
    verify(outHandler, never()).insertMessage(any(Connection.class), any(Message.class));
  }

  private MessageHandler mockHandlerForSaveMessage() throws Exception {
    MessageHandler handler = mock(MessageHandler.class);
    when(handler.insertMessage(any(Connection.class), any(Message.class)))
      .thenReturn(10L);

    return handler;
  }
View Full Code Here

    return handler;
  }

  @Test(expectedExceptions=RejectedException.class)
  public void testSaveWithUnknownDirection() throws Exception {
    MessageHandler outHandler = mock(MessageHandler.class);
    MessageHandler inHandler = mock(MessageHandler.class);

    Connection conn = mock(Connection.class);
    MessageHandler handler = createMessageHandler(outHandler, inHandler);

    Message message = new Message();
    message.setDirection(Direction.UNKNOWN);

    handler.insertMessage(conn, message);
  }
View Full Code Here

    handler.insertMessage(conn, message);
  }

  @Test
  public void testUpdateOutboundMessage() throws Exception {
    MessageHandler outHandler = mock(MessageHandler.class);
    when(outHandler.updateMessage(any(Connection.class), any(Message.class)))
      .thenReturn(true);

    MessageHandler inHandler = mock(MessageHandler.class);

    Connection conn = mock(Connection.class);
    MessageHandler handler = createMessageHandler(outHandler, inHandler);

    Message message = new Message();
    message.setId(10);
    message.setDirection(Direction.TO_CONNECTIONS);

    handler.updateMessage(conn, message);

    verify(outHandler).updateMessage(any(Connection.class), any(Message.class));
    verify(inHandler, never()).updateMessage(any(Connection.class), any(Message.class));
  }
View Full Code Here

    verify(inHandler, never()).updateMessage(any(Connection.class), any(Message.class));
  }

  @Test
  public void testUpdateInboundMessage() throws Exception {
    MessageHandler inHandler = mock(MessageHandler.class);
    when(inHandler.updateMessage(any(Connection.class), any(Message.class)))
      .thenReturn(true);

    MessageHandler outHandler = mock(MessageHandler.class);

    Connection conn = mock(Connection.class);
    MessageHandler handler = createMessageHandler(outHandler, inHandler);

    Message message = new Message();
    message.setId(10);
    message.setDirection(Direction.TO_APPLICATIONS);

    handler.updateMessage(conn, message);

    verify(inHandler).updateMessage(any(Connection.class), any(Message.class));
    verify(outHandler, never()).updateMessage(any(Connection.class), any(Message.class));
  }
View Full Code Here

    verify(outHandler, never()).updateMessage(any(Connection.class), any(Message.class));
  }

  @Test(expectedExceptions=RejectedException.class)
  public void testUpdateWithUnknownDirection() throws Exception {
    MessageHandler outHandler = mock(MessageHandler.class);
    MessageHandler inHandler = mock(MessageHandler.class);

    Connection conn = mock(Connection.class);
    MessageHandler handler = createMessageHandler(outHandler, inHandler);

    Message message = new Message();
    message.setDirection(Direction.UNKNOWN);

    handler.updateMessage(conn, message);
  }
View Full Code Here

    handler.updateMessage(conn, message);
  }

  @Test
  public void testUpdateStatusOfOutboundMessages() throws Exception {
    MessageHandler outHandler = mock(MessageHandler.class);
    MessageHandler inHandler = mock(MessageHandler.class);

    Connection conn = mock(Connection.class);
    MessageHandler handler = createMessageHandler(outHandler, inHandler);

    MessageCriteria criteria = new MessageCriteria()
      .direction(Direction.TO_CONNECTIONS);
    handler.updateMessagesStatus(conn, criteria, Message.STATUS_RETRYING);

    verify(outHandler).updateMessagesStatus(any(Connection.class),
        any(MessageCriteria.class), anyByte());
    verify(inHandler, never()).updateMessagesStatus(any(Connection.class),
        any(MessageCriteria.class), anyByte());
View Full Code Here

        any(MessageCriteria.class), anyByte());
  }

  @Test
  public void testUpdateStatusOfInboundMessages() throws Exception {
    MessageHandler inHandler = mock(MessageHandler.class);
    MessageHandler outHandler = mock(MessageHandler.class);

    Connection conn = mock(Connection.class);
    MessageHandler handler = createMessageHandler(outHandler, inHandler);

    MessageCriteria criteria = new MessageCriteria()
      .direction(Direction.TO_APPLICATIONS);
    handler.updateMessagesStatus(conn, criteria, Message.STATUS_RETRYING);

    verify(inHandler).updateMessagesStatus(any(Connection.class),
        any(MessageCriteria.class), anyByte());
    verify(outHandler, never()).updateMessagesStatus(any(Connection.class),
        any(MessageCriteria.class), anyByte());
View Full Code Here

        any(MessageCriteria.class), anyByte());
  }

  @Test
  public void testUpdateStatusOfAllMessages() throws Exception {
    MessageHandler inHandler = mock(MessageHandler.class);
    MessageHandler outHandler = mock(MessageHandler.class);

    Connection conn = mock(Connection.class);
    MessageHandler handler = createMessageHandler(outHandler, inHandler);

    handler.updateMessagesStatus(conn, new MessageCriteria(), Message.STATUS_RETRYING);

    verify(inHandler).updateMessagesStatus(any(Connection.class),
        any(MessageCriteria.class), anyByte());
    verify(outHandler).updateMessagesStatus(any(Connection.class),
        any(MessageCriteria.class), anyByte());
View Full Code Here

TOP

Related Classes of org.mokai.persist.jdbc.MessageHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.