Example usage for org.springframework.integration.jdbc StoredProcExecutor getJdbcCallOperationsCacheStatistics

List of usage examples for org.springframework.integration.jdbc StoredProcExecutor getJdbcCallOperationsCacheStatistics

Introduction

In this page you can find the example usage for org.springframework.integration.jdbc StoredProcExecutor getJdbcCallOperationsCacheStatistics.

Prototype

@Deprecated
public Object getJdbcCallOperationsCacheStatistics() 

Source Link

Document

Allows for the retrieval of metrics.

Usage

From source file:org.springframework.integration.jdbc.StoredProcExecutorTests.java

@Test
public void testStoredProcExecutorJdbcCallOperationsCache() throws Exception {

    final DataSource datasource = mock(DataSource.class);

    final StoredProcExecutor storedProcExecutor = new StoredProcExecutor(datasource);

    final ExpressionFactoryBean efb = new ExpressionFactoryBean("headers['stored_procedure_name']");
    efb.afterPropertiesSet();//from   w  w  w. j ava 2s  .  c om
    final Expression expression = efb.getObject();

    storedProcExecutor.setStoredProcedureNameExpression(expression);
    storedProcExecutor.setBeanFactory(mock(BeanFactory.class));

    storedProcExecutor.afterPropertiesSet();

    this.mockTheOperationsCache(storedProcExecutor);

    for (int i = 1; i <= 3; i++) {
        storedProcExecutor.executeStoredProcedure(
                MessageBuilder.withPayload("test").setHeader("stored_procedure_name", "123").build());
    }

    final CacheStats stats = (CacheStats) storedProcExecutor.getJdbcCallOperationsCacheStatistics();
    LOGGER.info(stats);
    LOGGER.info(stats.totalLoadTime() / 1000 / 1000);

    assertEquals(stats.hitCount(), 2);
    assertEquals(stats.missCount(), 1);
    assertEquals(stats.loadCount(), 1);

}

From source file:org.springframework.integration.jdbc.StoredProcExecutorTests.java

@Test
public void testSetJdbcCallOperationsCacheSize() throws Exception {

    final DataSource datasource = mock(DataSource.class);

    final StoredProcExecutor storedProcExecutor = new StoredProcExecutor(datasource);

    storedProcExecutor.setJdbcCallOperationsCacheSize(0);

    final ExpressionFactoryBean efb = new ExpressionFactoryBean("headers['stored_procedure_name']");
    efb.afterPropertiesSet();//from  w  w w  . j  a va 2 s.com
    final Expression expression = efb.getObject();

    storedProcExecutor.setStoredProcedureNameExpression(expression);
    storedProcExecutor.setBeanFactory(mock(BeanFactory.class));

    storedProcExecutor.afterPropertiesSet();

    this.mockTheOperationsCache(storedProcExecutor);

    for (int i = 1; i <= 10; i++) {
        storedProcExecutor.executeStoredProcedure(
                MessageBuilder.withPayload("test").setHeader("stored_procedure_name", "123").build());
    }

    final CacheStats stats = (CacheStats) storedProcExecutor.getJdbcCallOperationsCacheStatistics();
    LOGGER.info(stats);
    assertEquals("Expected a cache misscount of 10", 10, stats.missCount());

}