SPRING/chapter04_MVC

BoardServiceTests.java

GAWON 2023. 7. 18. 09:41
package org.joonzis.service;

import java.util.List;

import org.joonzis.domain.BoardVO;
import org.joonzis.domain.Criteria;
import org.joonzis.mapper.BoardMapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import lombok.Setter;
import lombok.extern.log4j.Log4j;

@Log4j         // log사용
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("file:src/main/webapp/WEB-INF/spring/root-context.xml")
public class BoardServiceTests {

   @Autowired         
   BoardService service;
   
   
   // allList(페이징)
   @Test
   public void testGetList() {
   	  Criteria cri = new Criteria(1, 10);
      List<BoardVO> list = service.getList(cri);
      for(BoardVO vo : list) {
            log.info(vo);
         }
   }
   
   
   @Test
   public void register() {
      BoardVO vo = new BoardVO();
      vo.setTitle("테스트제목7");
      vo.setContent("테스트내용7");
      vo.setWriter("user07");
      service.register(vo);
      log.info(vo);
      
   }
   
   @Test
   public void get() {
      BoardVO vo = service.get(3);
      log.info(vo);
   }
   
   @Test
   public void remove() {
      log.info(service.remove(8));
   }
   
   @Test
   public void modify() {
      BoardVO vo = new BoardVO();
      vo.setTitle("테스트제목 7");
      vo.setContent("테스트내용 7");
      vo.setWriter("user07");
      vo.setBno(2);
      service.modify(vo);
      
      log.info(vo);
   }
   
   
}