在要测试的层,新建一个JUnit的test类,如下实例,然后运行即可。
package jp.co.nec.necst.ebiz.dao.dmr.user;
import java.util.List;
import junit.framework.TestCase;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
public class TestDmrDao extends TestCase {
public void testDao() {
ApplicationContext context = new FileSystemXmlApplicationContext("WEB-INF/applicationContext.xml");
DmrListDao dao = (DmrListDao) context.getBean("dmrListDao");
String studentNo = "A";
StringBuffer buffer = new StringBuffer();
buffer.append("A1001,");
buffer.append("A1002");
List<Object[]> list = dao.getDmList(studentNo,buffer);
System.out.println(list.size());
for (Object[] objects : list) {
Object obj1 = objects[0];
Object obj2 = objects[1];
Object obj3 = objects[2];
Object obj4 = objects[3];
System.out.println(obj1.toString());
System.out.println(obj2.toString());
System.out.println(obj3.toString());
System.out.println(obj4.toString());
}
}
}