Package org.mokai.persist.jdbc

Examples of org.mokai.persist.jdbc.JdbcMessageStore


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

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

    Collection<Message> messages = messageStore.list(new MessageCriteria());

    Assert.assertEquals(1, messages.size());
  }
View Full Code Here


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

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

    Collection<Message> messages = messageStore.list(null);

    Assert.assertEquals(1, messages.size());
  }
View Full Code Here

    when(handler.supportsDirection(any(Direction.class))).thenReturn(true);
    when(handler.listMessages(any(Connection.class), any(MessageCriteria.class)))
      .thenReturn(Collections.singleton(new Message()));

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

    MessageCriteria criteria = new MessageCriteria()
      .direction(Direction.TO_APPLICATIONS);
    Collection<Message> messages = messageStore.list(criteria);

    Assert.assertEquals(1, messages.size());
  }
View Full Code Here

    MessageHandler handler = mock(MessageHandler.class);
    when(handler.listMessages(any(Connection.class), any(MessageCriteria.class)))
      .thenReturn(null);

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

    Collection<Message> messages = messageStore.list(new MessageCriteria());

    Assert.assertNotNull(messages);
    Assert.assertEquals(0, messages.size());

    verify(handler).listMessages(any(Connection.class), any(MessageCriteria.class));
View Full Code Here

  public void testListWithNotSupportedDirectionCriteria() 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);
    Collection<Message> messages = messageStore.list(criteria);
    Assert.assertNotNull(messages);
    Assert.assertEquals(0, messages.size());

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

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

  @Test(expectedExceptions=IllegalStateException.class)
  public void shouldFailSaveOrUpdateWithNullDataSource() throws Exception {
    JdbcMessageStore messageStore = createMessageStoreNoDataSource();
    messageStore.saveOrUpdate(new Message());
  }
View Full Code Here

    messageStore.saveOrUpdate(new Message());
  }

  @Test(expectedExceptions=IllegalStateException.class)
  public void shouldFailUpdateStatusWithNullDataSource() throws Exception {
    JdbcMessageStore messageStore = createMessageStoreNoDataSource();
    messageStore.updateStatus(new MessageCriteria(), Message.STATUS_CREATED);
  }
View Full Code Here

    messageStore.updateStatus(new MessageCriteria(), Message.STATUS_CREATED);
  }

  @Test(expectedExceptions=IllegalStateException.class)
  public void shouldFailListWithNullDataSource() throws Exception {
    JdbcMessageStore messageStore = createMessageStoreNoDataSource();
    messageStore.list(new MessageCriteria());
  }
View Full Code Here

    return dataSource;
  }

  private JdbcMessageStore createMessageStore(DataSource dataSource, MessageHandler handler) {
    JdbcMessageStore messageStore = new JdbcMessageStore();
    messageStore.setDataSource(dataSource);
    messageStore.setMessageHandler(handler);

    return messageStore;
  }
View Full Code Here

    return messageStore;
  }

  private JdbcMessageStore createMessageStoreNoDataSource() {
    MessageHandler handler = mock(MessageHandler.class);
    JdbcMessageStore messageStore = new JdbcMessageStore();
    messageStore.setMessageHandler(handler);

    return messageStore;
  }
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.