📄 testpartservice.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.PartParams;import net.java.workeffort.service.domain.PageResult;import net.java.workeffort.service.domain.Part;import net.java.workeffort.service.domain.PartQuery;import net.java.workeffort.service.support.OptimisticLockingException;/** * Test for part service. * @author Antony Joseph */public class TestPartService extends BaseServiceTestCase { private IPartService service; private PartParams params; public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(TestPartService.class); List list = new ArrayList(); list.add(DataFileUtil.PART); return new ServiceTestSetup(suite, list); } protected void setUp() throws Exception { super.setUp(); service = (IPartService) ServiceTestSetup.getApplicationContext() .getBean("partService"); params = new PartParams(); } public void testGetPartPageResult() throws Exception { PartQuery query = params.testGetPageResultPart(); PageResult result = service.getPageResultPart(query); assertNotNull("Should not return null object", result.getRows()); assertEquals("Should return 1 row", 1, result.getRows().size()); } public void testGetPart() throws Exception { String pk = params.testGetPart(); Part result = service.getPart(pk); assertNotNull("Should not return null object", result); } public void testInsertPart() throws Exception { Part input = params.testInsertPart(); service.insertPart(input); assertEquals("version should be set to 1.", new Integer(1), input .getVersion()); } public void testUpdatePart() throws Exception { Part input = params.testUpdatePart(); service.updatePart(input); assertEquals("version should be incremented to 2.", new Integer(2), input.getVersion()); } public void testDeletePart() throws Exception { Part input = params.testDeletePart(); input.setVersion(new Integer(1)); service.deletePart(input); Part result = service.getPart(input.getPartCd()); assertNull("Should return null object", result); } public void testUpdatePartOptLck() throws Exception { Part input = params.testUpdatePartOptLck(); try { service.updatePart(input); fail("An OptimisticLockingException should be raised"); } catch (OptimisticLockingException expected) { assertTrue(true); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -