1 16 17 package org.springframework.jdbc.support; 18 19 import java.sql.Types ; 20 21 import junit.framework.TestCase; 22 23 30 public class JdbcUtilsTests extends TestCase { 31 32 public void testCountParameterPlaceholders() { 33 assertTrue(JdbcUtils.countParameterPlaceholders(null, '?', '\'') == 0); 34 35 assertTrue(JdbcUtils.countParameterPlaceholders("", '?', '\'') == 0); 36 37 assertTrue(JdbcUtils.countParameterPlaceholders("?", '?', '\'') == 1); 38 39 assertTrue(JdbcUtils.countParameterPlaceholders("The big ? 'bad wolf'", '?', '\'') == 1); 40 41 assertTrue(JdbcUtils.countParameterPlaceholders("The big ?? bad wolf", '?', '\'') == 2); 42 43 assertTrue(JdbcUtils.countParameterPlaceholders("The big 'ba''ad?' ? wolf", '?', '\'') == 1); 44 45 assertTrue(JdbcUtils.countParameterPlaceholders(null, '?', "\"'") == 0); 46 47 assertTrue(JdbcUtils.countParameterPlaceholders("", '?', "\"'") == 0); 48 49 assertTrue(JdbcUtils.countParameterPlaceholders("?", '?', "\"'") == 1); 50 51 assertTrue(JdbcUtils.countParameterPlaceholders("The \"big\" ? 'bad wolf'", '?', "\"'") == 1); 52 53 assertTrue(JdbcUtils.countParameterPlaceholders("The big ?? bad wolf", '?', "\"'") == 2); 54 55 assertTrue(JdbcUtils.countParameterPlaceholders("The \"big?\" 'ba''ad?' ? wolf", '?', "\"'") == 1); 56 } 57 58 public void testIsNumeric() { 59 assertTrue(JdbcUtils.isNumeric(Types.BIGINT)); 60 assertTrue(JdbcUtils.isNumeric(Types.NUMERIC)); 61 assertTrue(JdbcUtils.isNumeric(Types.INTEGER)); 62 assertTrue(JdbcUtils.isNumeric(Types.FLOAT)); 63 assertTrue(!JdbcUtils.isNumeric(Types.VARCHAR)); 64 } 65 66 public void testTranslateType() { 67 assertTrue(JdbcUtils.translateType(Types.VARCHAR) == Types.VARCHAR); 68 assertTrue(JdbcUtils.translateType(Types.CHAR) == Types.VARCHAR); 69 } 70 71 } 72 | Popular Tags |