首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 互联网 >

Test种@Before方法

2013-08-04 
Test类@Before方法cache的定义要在before外面,以供所有的test公用/** **/package com.taobao.cmp.jury.tai

Test类@Before方法
cache的定义要在before外面,以供所有的test公用

/** *  */package com.taobao.cmp.jury.tair.cache;import java.util.Map;import org.junit.After;import org.junit.Before;import org.junit.Test;import org.springframework.context.support.ClassPathXmlApplicationContext;import com.taobao.cmp.jury.tair.JuryTairClientGroup;/** * @author qianyi.zby *  */@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration(locations={"classpath:/spring-test.xml"})public class UserTaskOverTimeCacheTest {UserTaskOverTimeCache cache;/** * @throws java.lang.Exception */@Beforepublic void setUp() throws Exception {      ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(                  "spring.xml");           cache = (UserTaskOverTimeCache)           context.getBean("userTaskOverTimeCache"); }/** * @throws java.lang.Exception */@Afterpublic void tearDown() throws Exception {System.out.println("@After");}@Testpublic void testRead() {//final UserTaskOverTimeCache cache = new UserTaskOverTimeCache(556,//tairGroup);Map<Long, Long> map = cache.get(2053128170l);System.out.println(map);}@Testpublic void testWrite() {//final UserTaskOverTimeCache cache = new UserTaskOverTimeCache(556,//tairGroup);int map = cache.add(2053128170l, 123l, 3);System.out.println(map);}@Testpublic void testClear() {//final UserTaskOverTimeCache cache = new UserTaskOverTimeCache(556,//tairGroup);boolean map = cache.delete(2053128170l);System.out.println(map);}}


公共部分写在Before标签里面

热点排行