From: Juergen H. <jho...@us...> - 2006-04-20 09:50:25
|
Update of /cvsroot/springframework/spring/test/org/springframework/jdbc/core/namedparam In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17651/test/org/springframework/jdbc/core/namedparam Modified Files: NamedParameterUtilsTests.java Log Message: use char array instead of byte array, throw exception if SQL to parse is null Index: NamedParameterUtilsTests.java =================================================================== RCS file: /cvsroot/springframework/spring/test/org/springframework/jdbc/core/namedparam/NamedParameterUtilsTests.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** NamedParameterUtilsTests.java 18 Apr 2006 09:52:13 -0000 1.2 --- NamedParameterUtilsTests.java 20 Apr 2006 09:50:16 -0000 1.3 *************** *** 26,31 **** /** - * Unit tests for the {@link NamedParameterUtils} class. - * * @author Thomas Risberg * @author Juergen Hoeller --- 26,29 ---- *************** *** 110,151 **** } ! public void testBuildValueArrayWithMissingParameterValue() throws Exception { ! new AssertThrows(InvalidDataAccessApiUsageException.class) { ! public void test() throws Exception { ! String sql = "select count(0) from foo where id = :id"; ! NamedParameterUtils.buildValueArray(sql, new HashMap()); ! } ! }.runTest(); ! } ! ! public void testCountParameterPlaceholdersWithNullSqlString() throws Exception { ! assertEquals(0, NamedParameterUtils.countParameterPlaceholders(null)); ! } ! ! public void testParseSqlStatementWithNullSqlString() throws Exception { ! ParsedSql parsedSql = NamedParameterUtils.parseSqlStatement(null); ! assertNotNull(parsedSql); ! assertNull(parsedSql.getSql()); ! assertEquals("", parsedSql.getNewSql()); ! } ! public void testSubstituteNamedParametersWithNullString() throws Exception { ! String sql = NamedParameterUtils.substituteNamedParameters(null, new SimpleSqlParameterSource()); ! assertEquals("", sql); ! } ! public void testSubstituteNamedParametersWithStringContainingQuotes() throws Exception { ! String expectedSql = "select 'first name' from artists where id = ? and quote = 'exsqueeze me?'"; ! String sql = "select 'first name' from artists where id = :id and quote = 'exsqueeze me?'"; ! String newSql = NamedParameterUtils.substituteNamedParameters(sql, new SimpleSqlParameterSource()); ! assertEquals(expectedSql, newSql); ! } ! public void testParseSqlStatementWithStringContainingQuotes() throws Exception { ! String expectedSql = "select 'first name' from artists where id = ? and quote = 'exsqueeze me?'"; ! String sql = "select 'first name' from artists where id = :id and quote = 'exsqueeze me?'"; ! ParsedSql parsedSql = NamedParameterUtils.parseSqlStatement(sql); ! assertEquals(expectedSql, parsedSql.getNewSql()); ! } } --- 108,137 ---- } ! public void testBuildValueArrayWithMissingParameterValue() throws Exception { ! new AssertThrows(InvalidDataAccessApiUsageException.class) { ! public void test() throws Exception { ! String sql = "select count(0) from foo where id = :id"; ! NamedParameterUtils.buildValueArray(sql, new HashMap()); ! } ! }.runTest(); ! } ! public void testCountParameterPlaceholdersWithNullSqlString() throws Exception { ! assertEquals(0, NamedParameterUtils.countParameterPlaceholders(null)); ! } ! public void testSubstituteNamedParametersWithStringContainingQuotes() throws Exception { ! String expectedSql = "select 'first name' from artists where id = ? and quote = 'exsqueeze me?'"; ! String sql = "select 'first name' from artists where id = :id and quote = 'exsqueeze me?'"; ! String newSql = NamedParameterUtils.substituteNamedParameters(sql, new SimpleSqlParameterSource()); ! assertEquals(expectedSql, newSql); ! } ! public void testParseSqlStatementWithStringContainingQuotes() throws Exception { ! String expectedSql = "select 'first name' from artists where id = ? and quote = 'exsqueeze me?'"; ! String sql = "select 'first name' from artists where id = :id and quote = 'exsqueeze me?'"; ! ParsedSql parsedSql = NamedParameterUtils.parseSqlStatement(sql); ! assertEquals(expectedSql, parsedSql.getNewSql()); ! } } |