⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 categorydbtest.java

📁 ibatisDemom Persistance software
💻 JAVA
字号:
/*
 * Created on 2003-10-11
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package com.ewuxi.champion.persistence.dao;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.ewuxi.champion.Service;
import com.ewuxi.champion.persistence.vo.Category;

import junit.framework.TestCase;

/**
 * @author champion
 *
 * To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
public class CategoryDbTest extends TestCase {
	private Category ct = new Category();
	private CategoryDb cd = new CategoryDb();
	private Log log = LogFactory.getLog(this.getClass());
	/*
	 * @see TestCase#setUp()
	 */
	protected void setUp() throws Exception {
		Service.initSet();
		ct.setCategoryId("test");
		ct.setDescription("testdesc");
		ct.setName("testname");
		super.setUp();
	}

	/*
	 * @see TestCase#tearDown()
	 */
	protected void tearDown() throws Exception {
		super.tearDown();
	}

	public void testInsert() throws Exception {
		assertEquals(ct, ct);
		DaoCommon.startTransaction();
		//		清除这个对象
		cd.delete(ct);
		//加入一个对象
		cd.insert(ct);
		//比较当前的对象和查找出来的对象是否相同
		assertEquals(ct, cd.findByPk(ct));
		log.info(ct);
		log.info(cd.findByPk(ct));
		//清除这个对象
		cd.delete(ct);
		DaoCommon.commit();

	}

	public void testUpdate() throws Exception {
		DaoCommon.startTransaction();
		//		清除这个对象
		cd.delete(ct);
		//		加入一个对象
		cd.insert(ct);
		ct.setDescription("for Update");
		//修改这个对象
		cd.update(ct);
		//比较当前的对象和查找出来的对象是否相同
		assertEquals(ct, cd.findByPk(ct));
		log.info(ct);
		log.info(cd.findByPk(ct));
		//		清除这个对象
		cd.delete(ct);
		DaoCommon.commit();

	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -