Package org.mokai.persist.jdbc

Examples of org.mokai.persist.jdbc.MessageHandler


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

  @Test
  public void testUpdateStatusUnknownDirection() 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().direction(Direction.UNKNOWN),
        Message.STATUS_RETRYING);

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


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

  @Test
  public void testListAllMessages() throws Exception {
    MessageHandler inHandler = mock(MessageHandler.class);
    when(inHandler.listMessages(any(Connection.class), any(MessageCriteria.class)))
      .thenReturn(Collections.singleton(new Message()));
    MessageHandler outHandler = mock(MessageHandler.class);
    when(outHandler.listMessages(any(Connection.class), any(MessageCriteria.class)))
      .thenReturn(Collections.singleton(new Message()));

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

    Collection<Message> message = handler.listMessages(conn, new MessageCriteria());
    Assert.assertEquals(2, message.size());
  }
View Full Code Here

    Assert.assertEquals(2, message.size());
  }

  @Test
  public void testListOutboundMessages() throws Exception {
    MessageHandler outHandler = mock(MessageHandler.class);
    when(outHandler.listMessages(any(Connection.class), any(MessageCriteria.class)))
      .thenReturn(Collections.singleton(new Message()));
    MessageHandler inHandler = mock(MessageHandler.class);

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

    Collection<Message> message = handler.listMessages(conn,
        new MessageCriteria().direction(Direction.TO_CONNECTIONS));
    Assert.assertEquals(1, message.size());

    verify(inHandler, never()).listMessages(any(Connection.class), any(MessageCriteria.class));
  }
View Full Code Here

    verify(inHandler, never()).listMessages(any(Connection.class), any(MessageCriteria.class));
  }

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

    MessageHandler inHandler = mock(MessageHandler.class);
    when(inHandler.listMessages(any(Connection.class), any(MessageCriteria.class)))
      .thenReturn(Collections.singleton(new Message()));

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

    Collection<Message> message = handler.listMessages(conn,
        new MessageCriteria().direction(Direction.TO_APPLICATIONS));
    Assert.assertEquals(1, message.size());

    verify(outHandler, never()).listMessages(any(Connection.class), any(MessageCriteria.class));
  }
View Full Code Here

    verify(outHandler, never()).listMessages(any(Connection.class), any(MessageCriteria.class));
  }

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

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

    Collection<Message> message = handler.listMessages(conn, new MessageCriteria());
    Assert.assertEquals(0, message.size());

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

    verify(inHandler).listMessages(any(Connection.class), any(MessageCriteria.class));
  }

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

    MessageHandler handler = createMessageHandler(outHandler, inHandler);

    Assert.assertTrue(handler.supportsDirection(Direction.TO_CONNECTIONS));
    Assert.assertTrue(handler.supportsDirection(Direction.TO_APPLICATIONS));
    Assert.assertFalse(handler.supportsDirection(Direction.UNKNOWN));
    Assert.assertFalse(handler.supportsDirection(null));
  }
View Full Code Here

*/
public class JdbcMessageStoreTest {

  @Test
  public void testSaveMessage() throws Exception {
    MessageHandler handler = mock(MessageHandler.class);
    when(handler.supportsDirection(any(Direction.class))).thenReturn(true);
    when(handler.insertMessage(any(Connection.class), any(Message.class)))
      .thenReturn(10L);

    DataSource dataSource = mockDataSource();
    JdbcMessageStore messageStore = createMessageStore(dataSource, handler);

View Full Code Here

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

  @Test(expectedExceptions=RejectedException.class)
  public void shouldFailSaveIfNotSupported() throws Exception {
    MessageHandler handler = mock(MessageHandler.class);

    DataSource dataSource = mockDataSource();
    JdbcMessageStore messageStore = createMessageStore(dataSource, handler);

    Message message = new Message();
View Full Code Here

    messageStore.saveOrUpdate(message);
  }

  @Test
  public void testUpdateMessage() throws Exception {
    MessageHandler handler = mock(MessageHandler.class);
    when(handler.supportsDirection(any(Direction.class))).thenReturn(true);
    when(handler.updateMessage(any(Connection.class), any(Message.class)))
      .thenReturn(true);

    DataSource dataSource = mockDataSource();
    JdbcMessageStore messageStore = createMessageStore(dataSource, handler);
View Full Code Here

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

  @Test(expectedExceptions=ObjectNotFoundException.class)
  public void shouldFailToUpdateNonExistentId() throws Exception {
    MessageHandler handler = mock(MessageHandler.class);
    when(handler.supportsDirection(any(Direction.class))).thenReturn(true);
    when(handler.updateMessage(any(Connection.class), any(Message.class)))
      .thenReturn(false);

    DataSource dataSource = mockDataSource();
    JdbcMessageStore messageStore = createMessageStore(dataSource, handler);
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.