Changes between Version 2 and Version 3 of demo_04


Ignore:
Timestamp:
04/05/2012 02:27:08 PM (14 years ago)
Author:
chenyang
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • demo_04

    v2 v3  
    3434     } 
    3535}}} 
     36如何单元测试SqlHelper.buildInsert?[[BR]] 
     37测试SqlHelper.buildInsert(List<FieldDesc> fields, String tablename,String[] excludes);方法,需要准备fields,tablename,excludes这三个参数[[BR]] 
     38fields是数据库表的元信息,元信息依赖SimpleJdbcTemplate对象根据表名获取,我们让测试类SqlHelperTest继承之AbstractTransactionalJUnit4SpringContextTests[[BR]] 
     39以获得applicationContext对象的引用,然后注入SimpleJdbcTemplate对象. 
     40{{{ #!java 
     41@RunWith(SpringJUnit4ClassRunner.class) 
     42@ContextConfiguration(locations = { "classpath:applicationContext.xml" }) 
     43public class SqlHelperTest extends 
     44                AbstractTransactionalJUnit4SpringContextTests { 
     45 
     46        @Autowired 
     47        SimpleJdbcTemplate simpleJdbcTemplate; 
     48 
     49        ...... 
     50} 
     51}}}