본문 바로가기

개발/스프링

JUnit Test

■ JUnit Test

package dic.dao;

import static org.junit.Assert.*;

import java.util.Calendar; import java.util.List;

import org.junit.Before;

import org.junit.Test;

import org.springframework.context.support.FileSystemXmlApplicationContext;

import dic.model.Accounting;

public class AccountingDaoTest {  

private AccountingDao ad = null;  

@Before  public void setUp() throws Exception {  

String[] paths = {    "D:\\cranix\\workspace\\DICProject\\WebContent\\WEB-INF\\applicationContext.xml",    

"D:\\cranix\\workspace\\DICProject\\WebContent\\WEB-INF\\applicationContext-jdbc.xml"   };  

 

FileSystemXmlApplicationContext ctx = new FileSystemXmlApplicationContext(paths);  

ad = (AccountingDao)ctx.getBean("accountingDao");  

}

 @Test  public void testGetAccountingList() {  

List<Accounting> ll = ad.getAccountingList();   assertTrue(true);  

}

 @Test  public void testInsertAccounting() {  

Accounting ac = new Accounting();   ac.setInPrice(10);   ac.setRegDate(Calendar.getInstance().getTime());   assertEquals(ad.insertAccounting(ac),1);  

}

}