com.p6spy.engine.event.SimpleJdbcEventListener Java Examples

The following examples show how to use com.p6spy.engine.event.SimpleJdbcEventListener. 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
Source File: ContextJdbcEventListenerFactoryTest.java    From spring-boot-data-source-decorator with Apache License 2.0 5 votes vote down vote up
@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
Source File: ContextJdbcEventListenerFactoryTest.java    From spring-boot-data-source-decorator with Apache License 2.0 5 votes vote down vote up
@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);
}