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

📄 portfoliohandlertest.java.svn-base

📁 rmi server web service for a stock track systerm
💻 SVN-BASE
字号:
package ase.assignment.sts.test;

import java.rmi.RemoteException;

import junit.framework.TestCase;
import ase.assignment.sts.api.HandlerFactoryProxy;
import ase.assignment.sts.api.PortfolioHandler;
import ase.assignment.sts.beans.PortfolioEntity;

public class PortfolioHandlerTest extends TestCase {
	private static final int PORTFOLIO_TEST_ID = 88;

	private PortfolioHandler getHandler() throws RemoteException {
		return HandlerFactoryProxy.instance().getPortfolioHandler();
	}

	public void testCreate() throws RemoteException {
		assertNull(getHandler().findById(PORTFOLIO_TEST_ID));

		PortfolioEntity entity = new PortfolioEntity(PORTFOLIO_TEST_ID);
		entity.setName("testName");
		entity.setCustomerName("test");
		getHandler().create(entity);
		assertNotNull(getHandler().findById(PORTFOLIO_TEST_ID));
	}

	public void testDelete() throws RemoteException {
		assertNotNull(getHandler().findById(PORTFOLIO_TEST_ID));
		getHandler().delete(PORTFOLIO_TEST_ID);
		assertNull(getHandler().findById(PORTFOLIO_TEST_ID));
	}

	public void testUpdate() throws RemoteException {
		PortfolioEntity entity = getHandler().findById(1);
		assertNotNull(entity);
		assertEquals("Software", entity.getName());

		entity.setName("port2");
		getHandler().update(entity);
		entity = getHandler().findById(1);
		assertEquals("port2", entity.getName());

		// Rollback
		entity.setName("Software");
		getHandler().update(entity);
	}

	public void testFind() throws RemoteException {
		PortfolioEntity entity = getHandler().findById(1);
		assertNotNull(entity);
		assertEquals("Software", entity.getName());
		assertEquals("test", entity.getCustomerName());
	}

	public void testGetAllPortfolios() throws RemoteException {
		PortfolioEntity[] pors = getHandler().getAllPortfolios("test");
		assertNotNull(pors);
		assertEquals(2, pors.length);
		for (int i = 0; i < pors.length; i++) {
			assertEquals("test", pors[i].getCustomerName());
		}
	}
}

⌨️ 快捷键说明

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