categorydbtest.java

来自「ibatisDemom Persistance software」· Java 代码 · 共 82 行

JAVA
82
字号
/*
 * 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 + =
减小字号Ctrl + -
显示快捷键?