Package org.mokai.persist.jdbc

Examples of org.mokai.persist.jdbc.JdbcMessageStore


    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);

    Message message = new Message();
    messageStore.saveOrUpdate(message);

    Assert.assertEquals(10L, ((Long) message.getId()).longValue());

    verify(handler).insertMessage(any(Connection.class), any(Message.class));
    verify(handler, never()).updateMessage(any(Connection.class), any(Message.class));
View Full Code Here


  @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();
    messageStore.saveOrUpdate(message);
  }
View Full Code Here

    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);

    Message message = new Message();
    message.setId(10);
    messageStore.saveOrUpdate(message);

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

    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);

    Message message = new Message();
    message.setId(10);
    messageStore.saveOrUpdate(message);
  }
View Full Code Here

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

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

    Message message = new Message();
    message.setId(10);
    messageStore.saveOrUpdate(message);
  }
View Full Code Here

  @Test(expectedExceptions=IllegalArgumentException.class)
  public void shouldFailToSaveOrUpdateWithNullMessage() throws Exception {
    MessageHandler handler = mock(MessageHandler.class);
    DataSource dataSource = mockDataSource();
    JdbcMessageStore messageStore = createMessageStore(dataSource, handler);

    messageStore.saveOrUpdate(null);
  }
View Full Code Here

  @Test
  public void testUpdateStatusWithEmptyCriteria() throws Exception {
    MessageHandler handler = mock(MessageHandler.class);
    DataSource dataSource = mockDataSource();
    JdbcMessageStore messageStore = createMessageStore(dataSource, handler);

    messageStore.updateStatus(new MessageCriteria(), Message.STATUS_RETRYING);

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

  @Test
  public void testUpdateStatusWithNullMessageCriteria() throws Exception {
    MessageHandler handler = mock(MessageHandler.class);
    DataSource dataSource = mockDataSource();
    JdbcMessageStore messageStore = createMessageStore(dataSource, handler);

    messageStore.updateStatus(null, Message.STATUS_RETRYING);

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

  public void testUpdateStatusWithTypeAndDirectionCriteria() throws Exception {
    MessageHandler handler = mock(MessageHandler.class);
    when(handler.supportsDirection(any(Direction.class))).thenReturn(true);

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

    MessageCriteria criteria = new MessageCriteria()
      .direction(Direction.TO_APPLICATIONS);
    messageStore.updateStatus(criteria, Message.STATUS_RETRYING);

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

  public void testUpdateStatusWithNotSupportedDirectionCriteria() throws Exception {
    MessageHandler handler = mock(MessageHandler.class);
    when(handler.supportsDirection(any(Direction.class))).thenReturn(false);

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

    MessageCriteria criteria = new MessageCriteria()
      .direction(Direction.TO_APPLICATIONS);
    messageStore.updateStatus(criteria, Message.STATUS_RETRYING);

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

TOP

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

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.