1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | package com.test; import static org.junit.Assert.*; import java.util.HashMap; import java.util.Map; import javax.annotation.Resource; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.transaction.TransactionConfiguration; import org.springframework.transaction.annotation.Transactional; import com.test.service.UserService; import com.test.service.UserVO; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations={ "classpath:egovframework/spring/com/context-datasource.xml", "classpath:egovframework/spring/com/context-aspect.xml", "classpath:egovframework/spring/com/context-common.xml", "classpath:egovframework/spring/com/context-excel.xml", "classpath:egovframework/spring/com/context-idgen.xml", "classpath:egovframework/spring/com/context-mail.xml", "classpath:egovframework/spring/com/context-properties.xml", // "classpath:egovframework/spring/com/context-security.xml", "classpath:egovframework/spring/com/context-sqlMap.xml", "classpath:egovframework/spring/com/context-transaction.xml", "classpath:egovframework/spring/com/context-validator.xml" }) @Transactional @TransactionConfiguration(transactionManager="txManager" , defaultRollback=true) public class UserTest { @Resource(name="userService") private UserService userService; Log logger = LogFactory.getLog(this.getClass()); @Test public void 사용자입력테스트() throws Exception{ int count = userService.selectUserCnt("TEST_001"); logger.info("Count=" + count); UserVO userVO = new UserVO(); userVO.Name(“TEST_001”); userService.saveUser(userVO); count = userService. selectUserCnt ("TEST_001"); logger.info("Count=" + count); logger.info("입력="+ userService); assertEquals("입력 여부=" , count, 1); } } |
'Programming > Spring' 카테고리의 다른 글
web.xml url-pattern / 와 /* 의 차이점 (0) | 2015.06.11 |
---|---|
Spring 태그 <form:form> <form:select> (0) | 2015.06.10 |
[spring] @pathVariable 사용설정및 사용하기 (0) | 2015.06.10 |
[전자정부프레임워크] "알 수 없는 오류가 발생하였습니다." 라는 에러 메시지가 발생했을 때 대처법 (0) | 2015.06.04 |
[전자정부프레임워크] 공통서비스 - 게시판 익명처리 (0) | 2015.06.02 |