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

📄 billserviceimpltest.java

📁 自己做的关于spring框架的使用
💻 JAVA
字号:
/**
 * 
 */
package test.myspring.v3.ts;

import org.springframework.dao.DataIntegrityViolationException;

import myspring.v3.ts.BillServiceImpl;
import junit.framework.TestCase;

/**
 * @author maboli
 * @date Oct 24, 2008
 *
 */
public class BillServiceImplTest extends TestCase {

	/* (non-Javadoc)
	 * @see junit.framework.TestCase#setUp()
	 */
	protected void setUp() throws Exception {
		super.setUp();
	}

	/* (non-Javadoc)
	 * @see junit.framework.TestCase#tearDown()
	 */
	protected void tearDown() throws Exception {
		super.tearDown();
	}

	/**
	 * Test method for {@link myspring.v3.ts.BillServiceImpl#buy(int, int, float)}.
	 */
	public void testBuy() {
		BillServiceImpl service = new BillServiceImpl();
		
		service.setAccountDao(new AccountDaoMock());
		service.setBillDao(new BillDaoMock());
		
		assertTrue(service.buy(1, 1, new Float(20.5)));
		assertFalse(service.buy(23, 343, new Float(20.5)));
		assertFalse(service.buy(0, 0, new Float(20.5)));
		
		assertFalse(service.buy(1, 1, new Float(-20.5)));
		
		try {
			service.buy(0, 1, new Float(20.5));
			fail("未抛出预料的异常!");
		} catch (DataIntegrityViolationException e){
			assertFalse(false);
		}
		
		
	}

}

⌨️ 快捷键说明

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