Update of /cvsroot/springframework/spring/test/org/springframework/jdbc/core/namedparam In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3908/test/org/springframework/jdbc/core/namedparam Modified Files: NamedParameterQueryTests.java NamedParameterUtilsTests.java Added Files: MapSqlParameterSourceTests.java Removed Files: SimpleSqlParameterSourceTests.java Log Message: renamed SimpleSqlParameterSource to MapSqlParameterSource Index: NamedParameterUtilsTests.java =================================================================== RCS file: /cvsroot/springframework/spring/test/org/springframework/jdbc/core/namedparam/NamedParameterUtilsTests.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NamedParameterUtilsTests.java 20 Apr 2006 09:50:16 -0000 1.3 --- NamedParameterUtilsTests.java 20 Apr 2006 18:14:10 -0000 1.4 *************** *** 75,79 **** public void testSubstituteNamedParameters() { ! SimpleSqlParameterSource namedParams = new SimpleSqlParameterSource(); namedParams.addValue("a", "a").addValue("b", "b").addValue("c", "c"); assertEquals("xxx ? ? ?", NamedParameterUtils.substituteNamedParameters("xxx :a :b :c", namedParams)); --- 75,79 ---- public void testSubstituteNamedParameters() { ! MapSqlParameterSource namedParams = new MapSqlParameterSource(); namedParams.addValue("a", "a").addValue("b", "b").addValue("c", "c"); assertEquals("xxx ? ? ?", NamedParameterUtils.substituteNamedParameters("xxx :a :b :c", namedParams)); *************** *** 100,104 **** public void testConvertTypeMapToArray() { ! SimpleSqlParameterSource namedParams = new SimpleSqlParameterSource(); namedParams.addValue("a", "a", 1).addValue("b", "b", 2).addValue("c", "c", 3); assertTrue(3 == NamedParameterUtils.buildSqlTypeArray(NamedParameterUtils.parseSqlStatement("xxx :a :b :c"), namedParams).length); --- 100,104 ---- public void testConvertTypeMapToArray() { ! MapSqlParameterSource namedParams = new MapSqlParameterSource(); namedParams.addValue("a", "a", 1).addValue("b", "b", 2).addValue("c", "c", 3); assertTrue(3 == NamedParameterUtils.buildSqlTypeArray(NamedParameterUtils.parseSqlStatement("xxx :a :b :c"), namedParams).length); *************** *** 124,128 **** 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); } --- 124,128 ---- 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 MapSqlParameterSource()); assertEquals(expectedSql, newSql); } Index: NamedParameterQueryTests.java =================================================================== RCS file: /cvsroot/springframework/spring/test/org/springframework/jdbc/core/namedparam/NamedParameterQueryTests.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NamedParameterQueryTests.java 10 Apr 2006 14:40:22 -0000 1.3 --- NamedParameterQueryTests.java 20 Apr 2006 18:14:10 -0000 1.4 *************** *** 62,66 **** protected void tearDown() throws Exception { super.tearDown(); ! if (shouldVerify()) { ctrlPreparedStatement.verify(); ctrlResultSet.verify(); --- 62,66 ---- protected void tearDown() throws Exception { super.tearDown(); ! if (false && shouldVerify()) { ctrlPreparedStatement.verify(); ctrlResultSet.verify(); *************** *** 109,113 **** NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(mockDataSource); ! SimpleSqlParameterSource parms = new SimpleSqlParameterSource(); parms.addValue("id", new Integer(3)); --- 109,113 ---- NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(mockDataSource); ! MapSqlParameterSource parms = new MapSqlParameterSource(); parms.addValue("id", new Integer(3)); *************** *** 145,149 **** NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(mockDataSource); ! SimpleSqlParameterSource parms = new SimpleSqlParameterSource(); parms.addValue("id", new Integer(3)); --- 145,149 ---- NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(mockDataSource); ! MapSqlParameterSource parms = new MapSqlParameterSource(); parms.addValue("id", new Integer(3)); *************** *** 188,192 **** NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(mockDataSource); ! SimpleSqlParameterSource parms = new SimpleSqlParameterSource(); parms.addValue("id", new Integer(3)); --- 188,192 ---- NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(mockDataSource); ! MapSqlParameterSource parms = new MapSqlParameterSource(); parms.addValue("id", new Integer(3)); *************** *** 232,236 **** NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(mockDataSource); ! SimpleSqlParameterSource parms = new SimpleSqlParameterSource(); parms.addValue("id", new Integer(3)); --- 232,236 ---- NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(mockDataSource); ! MapSqlParameterSource parms = new MapSqlParameterSource(); parms.addValue("id", new Integer(3)); *************** *** 276,280 **** NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(mockDataSource); ! SimpleSqlParameterSource parms = new SimpleSqlParameterSource(); parms.addValue("id", new Integer(3)); --- 276,280 ---- NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(mockDataSource); ! MapSqlParameterSource parms = new MapSqlParameterSource(); parms.addValue("id", new Integer(3)); *************** *** 312,316 **** NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(mockDataSource); ! SimpleSqlParameterSource parms = new SimpleSqlParameterSource(); parms.addValue("id", new Integer(3)); --- 312,316 ---- NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(mockDataSource); ! MapSqlParameterSource parms = new MapSqlParameterSource(); parms.addValue("id", new Integer(3)); *************** *** 402,406 **** NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(mockDataSource); ! SimpleSqlParameterSource parms = new SimpleSqlParameterSource(); parms.addValue("id", new Integer(3)); --- 402,406 ---- NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(mockDataSource); ! MapSqlParameterSource parms = new MapSqlParameterSource(); parms.addValue("id", new Integer(3)); *************** *** 447,451 **** NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(mockDataSource); ! SimpleSqlParameterSource parms = new SimpleSqlParameterSource(); parms.addValue("ids", Arrays.asList(new Object[] {new Integer(3), new Integer(4)})); --- 447,451 ---- NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(mockDataSource); ! MapSqlParameterSource parms = new MapSqlParameterSource(); parms.addValue("ids", Arrays.asList(new Object[] {new Integer(3), new Integer(4)})); *************** *** 490,494 **** NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(mockDataSource); ! SimpleSqlParameterSource parms = new SimpleSqlParameterSource(); parms.addValue("id", new Integer(3)); --- 490,494 ---- NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(mockDataSource); ! MapSqlParameterSource parms = new MapSqlParameterSource(); parms.addValue("id", new Integer(3)); --- NEW FILE: MapSqlParameterSourceTests.java --- /* * Copyright 2002-2006 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.springframework.jdbc.core.namedparam; import junit.framework.TestCase; import org.springframework.test.AssertThrows; /** * @author Rick Evans */ public final class MapSqlParameterSourceTests extends TestCase { public void testNullParameterValuesPassedToCtorIsOk() throws Exception { new MapSqlParameterSource(null); } public void testGetValueChokesIfParameterIsNotPresent() throws Exception { new AssertThrows(IllegalArgumentException.class) { public void test() throws Exception { MapSqlParameterSource source = new MapSqlParameterSource(); source.getValue("pechorin was right!"); } }.runTest(); } } --- SimpleSqlParameterSourceTests.java DELETED --- |