spring多个xml配置文件测试方式1

/**
* 2010-7-6 上午11:47:21
*/
package com.wichina.test;

import java.util.Date;
import java.util.List;

import junit.framework.TestCase;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.wichina.dao.BookDAO;
import com.wichina.model.Book;

/**
* @author wuquanyou
*
*/
public class BookDAOTest extends TestCase {
private ApplicationContext context = null;

@Override
protected void setUp() throws Exception {

//context = new FileSystemXmlApplicationContext("WebRoot/WEB-INF/classes/applicationContext.xml");
[color=red]context = new ClassPathXmlApplicationContext(new String[]{"application_dao.xml","application_data.xml","application_action.xml","application_service.xml","application_sso.xml"});[/color]
}
@Override
protected void tearDown() throws Exception {

super.tearDown();
}


public void getCount(){
BookDAO bookDAO = (BookDAO)context.getBean("bookDAO");
int i =bookDAO.countBookStateByUser("jade", (short)1);
System.out.println(i);
}

public void save(){
BookDAO bookDAO = (BookDAO)context.getBean("bookDAO");
Book book = null;
for(int i=1;i<6;i++){
book = new Book();
book.setAppNo("12323ad"+i);
book.setAuthorName("dfdfd"+i);
book.setCreateDate(new Date());
book.setCreateUser("jade");
book.setIntro("fdfdfd");
book.setModifyDate(new Date());
book.setName("火影");
book.setPropery((short)1);
book.setState((short)i);
book.setStyle((short)2);
book.setTotalEpisode(4);
book.setType((short)1);
bookDAO.save(book);
}
}

public void delete(){
BookDAO bookDAO = (BookDAO)context.getBean("bookDAO");
if(bookDAO.delete(2)){
System.out.println("successful");
}
}

public void getMaxId(){
BookDAO bookDAO = (BookDAO)context.getBean("bookDAO");
System.out.println(bookDAO.getMaxId());
}

public void findByPropery(){
BookDAO bookDAO = (BookDAO)context.getBean("bookDAO");
List<Book> bookl = bookDAO.findByProperty("appNo", "abc65");
for(Book b : bookl){
System.out.println(b.getName());
}
}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值