JUnit 테스트 코드
package test.kr.co.cop.alert.service;
import javax.annotation.Resource;
import kr.co.cop.alert.service.PortalAlertProgramService;
import kr.co.cop.alert.vo.PortalAlert;
import kr.co.cop.cmm.crud.service.ParameterContext;
import kr.co.cop.cmm.crud.vo.CacheVO;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.ui.ModelMap;
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration(locations = {
"classpath*:egovframework/spring/com/*.xml",
})
public class PortalAlertProgramServiceTest {
@Resource(name="portalAlertProgramService")
PortalAlertProgramService service;
ParameterContext<PortalAlert> paramCtx = new ParameterContext<PortalAlert>();
@Before
public void setUp() throws Exception{
ModelMap model = new ModelMap();
PortalAlert param = new PortalAlert();
param.setProgramId("portalAlert");
paramCtx.setModel(model);
paramCtx.setParam(param);
paramCtx.setRequest(new MockHttpServletRequest());
paramCtx.setResponse(new MockHttpServletResponse());
CacheVO cvo = new CacheVO();
cvo.setCacheName(PortalAlertProgramService.PORTAL_ALERT_CACHE_NAME);
paramCtx.setCacheVO(cvo);
}
@Test
public void testCache() throws Exception{
service.list(paramCtx);
service.delete(paramCtx);
service.list(paramCtx);
}
}
'JAVA' 카테고리의 다른 글
Listener :: ServletContextListener (0) | 2019.02.15 |
---|---|
List 정렬 (0) | 2019.02.15 |
[JAVA]jsp 파일 읽어 저장 (0) | 2017.11.30 |
[JAVA] jndi2 (0) | 2017.11.28 |
[JAVA] javaee 오류 (0) | 2017.11.27 |