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);}}