读书人

基于spring3 单元测试例证

发布时间: 2012-11-09 10:18:48 作者: rapoo

基于spring3 单元测试例子

package com.smartlife.test;import org.junit.Before;import org.junit.Test;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.test.annotation.Rollback;import org.springframework.test.context.ContextConfiguration;import org.springside.modules.test.spring.SpringTxTestCase;import com.smartlife.service.BrandService;@ContextConfiguration(locations = { "/applicationContext.xml" })public class TestSpringjunit extends SpringTxTestCase {  @Autowired  private BrandService brandService;  @Beforepublic void reloadSampleData() throws Exception {//Fixtures.reloadAllTable(dataSource, "/data/sample-data.xml");}@Test//如果你需要真正插入数据库,将Rollback设为false@Rollback(false) public void crudEntity() {System.out.println(brandService);}}

读书人网 >编程

热点推荐