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

📄 testproductservice.java

📁 一个很好的开源项目管理系统源代码
💻 JAVA
字号:
package net.java.workeffort.service;import java.util.ArrayList;import java.util.List;import junit.framework.Test;import junit.framework.TestSuite;import net.java.workeffort.data.DataFileUtil;import net.java.workeffort.params.ProductParams;import net.java.workeffort.service.domain.PageResult;import net.java.workeffort.service.domain.Product;import net.java.workeffort.service.domain.ProductQuery;import net.java.workeffort.service.support.OptimisticLockingException;/** * Test for product service. * @author Antony Joseph */public class TestProductService extends BaseServiceTestCase {    private IProductService service;    private ProductParams params;    public static Test suite() {        TestSuite suite = new TestSuite();        suite.addTestSuite(TestProductService.class);        List list = new ArrayList();        list.add(DataFileUtil.PRODUCT);        return new ServiceTestSetup(suite, list);    }    protected void setUp() throws Exception {        super.setUp();        service = (IProductService) ServiceTestSetup.getApplicationContext()                .getBean("productService");        params = new ProductParams();    }    public void testGetProductPageResult() throws Exception {        ProductQuery query = params.testGetPageResultProduct();        PageResult result = service.getPageResultProduct(query);        assertNotNull("Should not return null object", result.getRows());        assertEquals("Should return 1 row", 1, result.getRows().size());    }    public void testGetProduct() throws Exception {        String pk = params.testGetProduct();        Product result = service.getProduct(pk);        assertNotNull("Should not return null object", result);    }    public void testInsertProduct() throws Exception {        Product input = params.testInsertProduct();       service.insertProduct(input);        assertEquals("version should be set to 1.", new Integer(1), input                .getVersion());    }    public void testUpdateProduct() throws Exception {        Product input = params.testUpdateProduct();        service.updateProduct(input);        assertEquals("version should be incremented to 2.", new Integer(2),                input.getVersion());    }    public void testDeleteProduct() throws Exception {        Product input = params.testDeleteProduct();        service.deleteProduct(input);        Product result = service.getProduct(input.getProductCd());        assertNull("Should return null object", result);    }    public void testUpdateProductOptLck() throws Exception {        Product input = params.testUpdateProductOptLck();        try {             service.updateProduct(input);            fail("An OptimisticLockingException should be raised");        }        catch (OptimisticLockingException expected) {            assertTrue(true);        }    }}

⌨️ 快捷键说明

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