Java Code Examples for com.p6spy.engine.event.SimpleJdbcEventListener

The following examples show how to use com.p6spy.engine.event.SimpleJdbcEventListener. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Test
void shouldUseDelegateToCreateListener() {
    SimpleJdbcEventListener listener1 = new SimpleJdbcEventListener() {};
    SimpleJdbcEventListener listener2 = new SimpleJdbcEventListener() {};
    Mockito.when(delegate.createJdbcEventListener()).thenReturn(listener1);
    ContextJdbcEventListenerFactory contextJdbcEventListenerFactory = new ContextJdbcEventListenerFactory(delegate, Collections.singletonList(listener2));

    CompoundJdbcEventListener jdbcEventListener = (CompoundJdbcEventListener) contextJdbcEventListenerFactory.createJdbcEventListener();
    assertThat(jdbcEventListener.getEventListeners()).hasSize(2);
    assertThat(jdbcEventListener.getEventListeners()).contains(listener1, listener2);
}
 
Example 2
@Test
void shouldReuseCompoundListenerFromFactory() {
    SimpleJdbcEventListener listener1 = new SimpleJdbcEventListener() {};
    Mockito.when(delegate.createJdbcEventListener()).thenReturn(new CompoundJdbcEventListener());
    ContextJdbcEventListenerFactory contextJdbcEventListenerFactory = new ContextJdbcEventListenerFactory(delegate, Collections.singletonList(listener1));

    CompoundJdbcEventListener jdbcEventListener = (CompoundJdbcEventListener) contextJdbcEventListenerFactory.createJdbcEventListener();
    assertThat(jdbcEventListener.getEventListeners()).hasSize(1);
    assertThat(jdbcEventListener.getEventListeners()).contains(listener1);
}