Search in sources :

Example 1 with PrimeMapper

use of org.springframework.integration.jdbc.storedproc.PrimeMapper in project spring-integration by spring-projects.

the class StoredProcPollingChannelAdapterParserTests method testReturningResultSetRowMappersAreSet.

@SuppressWarnings("unchecked")
@Test
public void testReturningResultSetRowMappersAreSet() throws Exception {
    setUp("storedProcPollingChannelAdapterParserTest.xml", getClass());
    DirectFieldAccessor accessor = new DirectFieldAccessor(this.pollingAdapter);
    Object source = accessor.getPropertyValue("source");
    accessor = new DirectFieldAccessor(source);
    source = accessor.getPropertyValue("executor");
    accessor = new DirectFieldAccessor(source);
    Object returningResultSetRowMappers = accessor.getPropertyValue("returningResultSetRowMappers");
    assertNotNull(returningResultSetRowMappers);
    assertTrue(returningResultSetRowMappers instanceof Map);
    Map<String, RowMapper<?>> returningResultSetRowMappersAsMap = (Map<String, RowMapper<?>>) returningResultSetRowMappers;
    assertTrue("The rowmapper was not set. Expected returningResultSetRowMappersAsMap.size() == 2", returningResultSetRowMappersAsMap.size() == 2);
    Iterator<Entry<String, RowMapper<?>>> iterator = returningResultSetRowMappersAsMap.entrySet().iterator();
    Entry<String, ?> mapEntry = iterator.next();
    assertEquals("out", mapEntry.getKey());
    assertTrue(mapEntry.getValue() instanceof PrimeMapper);
    mapEntry = iterator.next();
    assertEquals("out2", mapEntry.getKey());
    assertTrue(mapEntry.getValue() instanceof SingleColumnRowMapper);
}
Also used : Entry(java.util.Map.Entry) PrimeMapper(org.springframework.integration.jdbc.storedproc.PrimeMapper) SingleColumnRowMapper(org.springframework.jdbc.core.SingleColumnRowMapper) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Map(java.util.Map) SingleColumnRowMapper(org.springframework.jdbc.core.SingleColumnRowMapper) RowMapper(org.springframework.jdbc.core.RowMapper) Test(org.junit.Test)

Example 2 with PrimeMapper

use of org.springframework.integration.jdbc.storedproc.PrimeMapper in project spring-integration by spring-projects.

the class StoredProcOutboundGatewayParserTests method testReturningResultSetRowMappersAreSet.

@SuppressWarnings("unchecked")
@Test
public void testReturningResultSetRowMappersAreSet() throws Exception {
    setUp("storedProcOutboundGatewayParserTest.xml", getClass());
    DirectFieldAccessor accessor = new DirectFieldAccessor(this.outboundGateway);
    Object source = accessor.getPropertyValue("handler");
    accessor = new DirectFieldAccessor(source);
    source = accessor.getPropertyValue("executor");
    accessor = new DirectFieldAccessor(source);
    Object returningResultSetRowMappers = accessor.getPropertyValue("returningResultSetRowMappers");
    assertNotNull(returningResultSetRowMappers);
    assertTrue(returningResultSetRowMappers instanceof Map);
    Map<String, RowMapper<?>> returningResultSetRowMappersAsMap = (Map<String, RowMapper<?>>) returningResultSetRowMappers;
    assertTrue("The rowmapper was not set. Expected returningResultSetRowMappersAsMap.size() == 1", returningResultSetRowMappersAsMap.size() == 1);
    Entry<String, ?> mapEntry1 = returningResultSetRowMappersAsMap.entrySet().iterator().next();
    assertEquals("out", mapEntry1.getKey());
    assertTrue(mapEntry1.getValue() instanceof PrimeMapper);
}
Also used : PrimeMapper(org.springframework.integration.jdbc.storedproc.PrimeMapper) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Map(java.util.Map) RowMapper(org.springframework.jdbc.core.RowMapper) Test(org.junit.Test)

Aggregations

Map (java.util.Map)2 Test (org.junit.Test)2 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)2 PrimeMapper (org.springframework.integration.jdbc.storedproc.PrimeMapper)2 RowMapper (org.springframework.jdbc.core.RowMapper)2 Entry (java.util.Map.Entry)1 SingleColumnRowMapper (org.springframework.jdbc.core.SingleColumnRowMapper)1