@ -20,6 +20,7 @@ import java.math.BigDecimal;
@@ -20,6 +20,7 @@ import java.math.BigDecimal;
import java.sql.Connection ;
import java.sql.ResultSet ;
import java.sql.ResultSetMetaData ;
import java.sql.SQLException ;
import java.sql.SQLFeatureNotSupportedException ;
import java.sql.Statement ;
import java.sql.Timestamp ;
@ -63,7 +64,7 @@ public abstract class AbstractRowMapperTests {
@@ -63,7 +64,7 @@ public abstract class AbstractRowMapperTests {
protected void verifyPerson ( ConcretePerson person ) {
assertThat ( person . getName ( ) ) . isEqualTo ( "Bubba" ) ;
assertThat ( person . getAge ( ) ) . isEqualTo ( 22L ) ;
assertThat ( person . getBirth_d ate ( ) ) . usingComparator ( Date : : compareTo ) . isEqualTo ( new java . util . Date ( 1221222L ) ) ;
assertThat ( person . getBirthD ate ( ) ) . usingComparator ( Date : : compareTo ) . isEqualTo ( new java . util . Date ( 1221222L ) ) ;
assertThat ( person . getBalance ( ) ) . isEqualTo ( new BigDecimal ( "1234.56" ) ) ;
verifyPersonViaBeanWrapper ( person ) ;
}
@ -94,7 +95,14 @@ public abstract class AbstractRowMapperTests {
@@ -94,7 +95,14 @@ public abstract class AbstractRowMapperTests {
BeanWrapper bw = PropertyAccessorFactory . forBeanPropertyAccess ( person ) ;
assertThat ( bw . getPropertyValue ( "name" ) ) . isEqualTo ( "Bubba" ) ;
assertThat ( bw . getPropertyValue ( "age" ) ) . isEqualTo ( 22L ) ;
assertThat ( ( Date ) bw . getPropertyValue ( "birth_date" ) ) . usingComparator ( Date : : compareTo ) . isEqualTo ( new java . util . Date ( 1221222L ) ) ;
Date birthDate ;
if ( bw . isReadableProperty ( "birth_date" ) ) {
birthDate = ( Date ) bw . getPropertyValue ( "birth_date" ) ;
}
else {
birthDate = ( Date ) bw . getPropertyValue ( "birthDate" ) ;
}
assertThat ( birthDate ) . usingComparator ( Date : : compareTo ) . isEqualTo ( new java . util . Date ( 1221222L ) ) ;
assertThat ( bw . getPropertyValue ( "balance" ) ) . isEqualTo ( new BigDecimal ( "1234.56" ) ) ;
}
@ -107,7 +115,7 @@ public abstract class AbstractRowMapperTests {
@@ -107,7 +115,7 @@ public abstract class AbstractRowMapperTests {
}
protected enum MockType { ONE , TWO , THREE }
protected enum MockType { ONE , TWO , THREE , FOUR }
protected static class Mock {
@ -152,13 +160,19 @@ public abstract class AbstractRowMapperTests {
@@ -152,13 +160,19 @@ public abstract class AbstractRowMapperTests {
given ( resultSetMetaData . getColumnLabel ( 1 ) ) . willReturn (
type = = MockType . THREE ? "Last Name" : "name" ) ;
given ( resultSetMetaData . getColumnLabel ( 2 ) ) . willReturn ( "age" ) ;
given ( resultSetMetaData . getColumnLabel ( 3 ) ) . willReturn ( "birth_date" ) ;
given ( resultSetMetaData . getColumnLabel ( 3 ) ) . willReturn ( type = = MockType . FOUR ? "birthdate" : "birth_date" ) ;
given ( resultSetMetaData . getColumnLabel ( 4 ) ) . willReturn ( "balance" ) ;
given ( resultSetMetaData . getColumnLabel ( 5 ) ) . willReturn ( "e_mail" ) ;
given ( resultSet . findColumn ( "name" ) ) . willReturn ( 1 ) ;
given ( resultSet . findColumn ( "age" ) ) . willReturn ( 2 ) ;
given ( resultSet . findColumn ( "birth_date" ) ) . willReturn ( 3 ) ;
if ( type = = MockType . FOUR ) {
given ( resultSet . findColumn ( "birthdate" ) ) . willReturn ( 3 ) ;
}
else {
given ( resultSet . findColumn ( "birthdate" ) ) . willThrow ( new SQLException ( ) ) ;
given ( resultSet . findColumn ( "birth_date" ) ) . willReturn ( 3 ) ;
}
given ( resultSet . findColumn ( "balance" ) ) . willReturn ( 4 ) ;
given ( resultSet . findColumn ( "e_mail" ) ) . willReturn ( 5 ) ;