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

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

Introduction

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

Prototype

public void setJdbcCallOperationsCacheSize(int jdbcCallOperationsCacheSize) 

Source Link

Document

Defines the maximum number of SimpleJdbcCallOperations A value of zero will disable the cache.

Usage

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();// w w w .j av a  2  s  .  c  o m
    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());

}