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

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

Introduction

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

Prototype

public StoredProcExecutor(DataSource dataSource) 

Source Link

Document

Constructor taking DataSource from which the DB Connection can be obtained.

Usage

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

@Test
public void testStoredProcExecutorWithNullDataSource() {

    try {/*from w ww.j av a 2s. c om*/
        new StoredProcExecutor(null);
    } catch (IllegalArgumentException e) {
        assertEquals("dataSource must not be null.", e.getMessage());
        return;
    }

    fail("Exception expected.");
}

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

@Test
public void testStoredProcExecutorWithNullProcedureName() {

    DataSource datasource = mock(DataSource.class);

    try {//from   w  w  w .  j a  v a 2s.c o m
        StoredProcExecutor storedProcExecutor = new StoredProcExecutor(datasource);
        storedProcExecutor.setBeanFactory(mock(BeanFactory.class));
        storedProcExecutor.afterPropertiesSet();
    } catch (IllegalArgumentException e) {
        assertEquals(
                "You must either provide a " + "Stored Procedure Name or a Stored Procedure Name Expression.",
                e.getMessage());
        return;
    }

    fail("Exception expected.");
}

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

@Test
public void testStoredProcExecutorWithEmptyProcedureName() {

    DataSource datasource = mock(DataSource.class);
    StoredProcExecutor storedProcExecutor = new StoredProcExecutor(datasource);

    try {//  w  w  w .j  a  v  a2  s.  c om
        storedProcExecutor.setStoredProcedureName("      ");
    } catch (IllegalArgumentException e) {
        assertEquals("storedProcedureName must not be null and cannot be empty.", e.getMessage());
        return;
    }

    fail("Exception expected.");
}

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

@Test
public void testGetStoredProcedureNameExpressionAsString() throws Exception {

    DataSource datasource = mock(DataSource.class);
    StoredProcExecutor storedProcExecutor = new StoredProcExecutor(datasource);

    final ExpressionFactoryBean efb = new ExpressionFactoryBean("headers['stored_procedure_name']");
    efb.afterPropertiesSet();//from   ww w  . ja  v  a  2s .c o m
    final Expression expression = efb.getObject();

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

    assertEquals("headers['stored_procedure_name']",
            storedProcExecutor.getStoredProcedureNameExpressionAsString());
}

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

@Test
public void testGetStoredProcedureNameExpressionAsString2() throws Exception {

    DataSource datasource = mock(DataSource.class);
    StoredProcExecutor storedProcExecutor = new StoredProcExecutor(datasource);

    storedProcExecutor.setStoredProcedureName("123");
    storedProcExecutor.setBeanFactory(mock(BeanFactory.class));
    storedProcExecutor.afterPropertiesSet();

    assertEquals("123", storedProcExecutor.getStoredProcedureName());
    assertEquals("123", storedProcExecutor.getStoredProcedureNameExpressionAsString());
}

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

@Test
public void testSetReturningResultSetRowMappersWithNullMap() {

    DataSource datasource = mock(DataSource.class);
    StoredProcExecutor storedProcExecutor = new StoredProcExecutor(datasource);

    try {/*from  w  w w.  ja  v a2s  .com*/
        storedProcExecutor.setReturningResultSetRowMappers(null);
    } catch (IllegalArgumentException e) {
        assertEquals("returningResultSetRowMappers must not be null.", e.getMessage());
        return;
    }

    fail("Exception expected.");

}

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

@Test
public void testSetReturningResultSetRowMappersWithMapContainingNullValues() {

    DataSource datasource = mock(DataSource.class);
    StoredProcExecutor storedProcExecutor = new StoredProcExecutor(datasource);

    Map<String, RowMapper<?>> rowmappers = new HashMap<String, RowMapper<?>>();
    rowmappers.put("results", null);

    try {//from www  .ja  v a 2 s.com
        storedProcExecutor.setReturningResultSetRowMappers(rowmappers);
    } catch (IllegalArgumentException e) {
        assertEquals("The provided map cannot contain null values.", e.getMessage());
        return;
    }

    fail("Exception expected.");

}

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

@Test
public void testSetReturningResultSetRowMappersWithEmptyMap() {

    DataSource datasource = mock(DataSource.class);
    StoredProcExecutor storedProcExecutor = new StoredProcExecutor(datasource);

    Map<String, RowMapper<?>> rowmappers = new HashMap<String, RowMapper<?>>();

    storedProcExecutor.setReturningResultSetRowMappers(rowmappers);

    //Should Successfully finish

}

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

@Test
public void testSetSqlParameterSourceFactoryWithNullParameter() {
    DataSource datasource = mock(DataSource.class);
    StoredProcExecutor storedProcExecutor = new StoredProcExecutor(datasource);

    try {/*from ww  w  . ja v  a2s .c o  m*/
        storedProcExecutor.setSqlParameterSourceFactory(null);
    } catch (IllegalArgumentException e) {
        assertEquals("sqlParameterSourceFactory must not be null.", e.getMessage());
        return;
    }

    fail("Exception expected.");

}

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

@Test
public void testSetSqlParametersWithNullValueInList() {

    DataSource datasource = mock(DataSource.class);
    StoredProcExecutor storedProcExecutor = new StoredProcExecutor(datasource);

    List<SqlParameter> sqlParameters = new ArrayList<SqlParameter>();
    sqlParameters.add(null);// www .ja v a2 s .  c  o  m

    try {
        storedProcExecutor.setSqlParameters(sqlParameters);
    } catch (IllegalArgumentException e) {
        assertEquals("The provided list (sqlParameters) cannot contain null values.", e.getMessage());
        return;
    }

    fail("Exception expected.");

}