import org.junit.After;
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.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import com.oyp.TestServiceInterface;
/**
* Spring test 示例
* @author pouyang 2010-6-15 14:03:27
*/
@ContextConfiguration(locations={"/applicationContext.xml"})
public class SpringTest extends AbstractTransactionalJUnit4SpringContextTests {
protected static final String TIME = "2010-6-15";
@Autowired
private TestServiceInterface testService;
/**
* 测试每个方法之前执行的方法(初始化)
* @throws Exception
*/
@Before
public void setUp() throws Exception {
deleteFromTables("TB_TEST");
executeSqlScript("/prepareTestData-test.sql", false);
}
/**
* 测试每个方法之后执行的方法(销毁)
* @throws Exception
*/
@After
public void tearDown() throws Exception {
}
/**
* 测试方法
*/
@Test
public void testInsertMethod() {
}
/**
* 有的时候由于事务的限制,导致对数据库的操作产生不了影响
* 可以使用注解@Rollback(false):事务自动提交(脱离spring配置文件的束缚)
*/
@Rollback(false)
public void testUpdateMehthodDAO () {
}
// 更多注解参考spring doc
public void moreTest() {
}
}
分享到:
相关推荐
Spring test
spring框架集的简单小应用,实现了一些基本的功能
spring test学习spring test学习spring test学习spring test学习spring test学习
spring+redis作为缓存,带springTest配置,导入resource下的数据库文件,配置数据库地址和redis地址,点击test文件夹下的测试方法即可运行,也可完善页面运行。
SpringTest代码 package lib; //JavaBean public class HelloWorld { private String helloWorld; public String getHelloWorld() { return helloWorld; } public void setHelloWorld(String helloWorld) {...
spring test
SpringTest cookie
a java spring test in invertion of control a java spring test in invertion of control
提供一个很好的测试spring的样例,包括如何配置,详细的测试方案,还有相关代码展示
spring的练习,最简单的,用spring框架开发系统的基础东西
JAVA SpringMVC框架模板,内含pom,MVCxml,Webxml.适合新手直接下载来练手。
mybatis+spring+springtest 求ActionBean的ut测试
spring+springmvc+mybatis+log4j+springtest的demo,并且配置了多环境的配置文件,xml文件在源码中,配置了service层的事务处理,
Spring Test与开发者测试(10)
Spring整合Junit测试时所需要的jar包。 spring-test-3.2.3.RELEASE.jar
springTest新闻发布 这个是用spring 的dao模板 数据源是用 spring 提供的数据源配合的 用到了事务 功能有 游客的浏览新闻 会员的发布新闻 删除新闻等
SpringTest(3).zip
Spring Test 整合 JUnit 4 使用总结.rar