📄 testcustomercactus1.java~9~
字号:
package baseinforinterface;import org.apache.cactus.*;import stockmanagementpro.*;import javax.naming.*;import java.util.Collection;import java.rmi.RemoteException;public class TestCustomerCactus1 extends ServletTestCase { private static final String ERROR_NULL_REMOTE = "接口未定义."; private static final int MAX_OUTPUT_LINE_LENGTH = 100; private boolean logging = false; private CustomerHome customerHome = null; private Customer customer = null; public TestCustomerCactus1(String name) { super(name); } public void initializeLocalHome() throws Exception { Context context = new InitialContext(); customerHome = (CustomerHome) context.lookup("Customer"); } public void setUp() throws Exception { super.setUp(); initializeLocalHome(); } public void tearDown() throws Exception { customerHome = null; customer = null; super.tearDown(); } //测试客户创建方法 public void testSupplierCreate() throws Exception{ //创建客户数组 String[] supplier = new String[]{"测试客户1", "南部", "拼音码1", "简称1", "021-556892", "张凡", "1350058956", "021-896523", "021-963258", "地址1", "511896", "中行", "银行帐号", "jack@hotmail.com", "www.jack.com", "备注1"}; //创建客户 supplierHome.create(supplier[0], supplier[1], supplier[2], supplier[3], supplier[4], supplier[5], supplier[6], supplier[7], supplier[8], supplier[9], supplier[10], supplier[11], supplier[12], supplier[13], supplier[14], supplier[15]); supplier = new String[]{"测试客户2", "北部", "拼音码2", "简称2", "021-556892", "张凡", "1350058956", "021-896523", "021-963258", "地址2", "511896", "中行", "银行帐号", "jack@hotmail.com", "www.jack.com", "备注2"}; //创建客户 supplierHome.create(supplier[0], supplier[1], supplier[2], supplier[3], supplier[4], supplier[5], supplier[6], supplier[7], supplier[8], supplier[9], supplier[10], supplier[11], supplier[12], supplier[13], supplier[14], supplier[15]); supplier = new String[]{"测试客户3", "南部", "拼音码3", "简称3", "021-556892", "张凡", "1350058956", "021-896523", "021-963258", "地址3", "511896", "中行", "银行帐号", "jack@hotmail.com", "www.jack.com", "备注3"}; //创建客户 supplierHome.create(supplier[0], supplier[1], supplier[2], supplier[3], supplier[4], supplier[5], supplier[6], supplier[7], supplier[8], supplier[9], supplier[10], supplier[11], supplier[12], supplier[13], supplier[14], supplier[15]); } //测试客户更新方法 public void testSupplierUpdate() throws Exception{ String[] supplier = new String[]{"测试客户1", "北部", "拼音码1", "简称1", "021-556892", "张凡", "1350058956", "021-896523", "021-963258", "地址1", "511896", "中行", "银行帐号", "jack@hotmail.com", "www.jack.com", "备注1"}; this.supplier = supplierHome.findByPrimaryKey(supplier[0]); //更新客户的值 this.supplier.setSupplierZone(supplier[1]); } //测试根据客户名字取得记录的方法 public void testFindBySupplierName() throws Exception { Collection col = supplierHome.findBySupplierName("%客户%"); this.assertEquals("", 3, col.size()); } //测试根据地区取得记录的方法 public void testFindBySupplierZone() throws Exception { Collection col = supplierHome.findBySupplierZone("%北部%"); this.assertEquals("", 2, col.size()); } //测试客户删除方法 public void testSupplierDelete() throws Exception{ String[] suppliers = new String[]{"测试客户1", "测试客户2", "测试客户3"}; supplier = supplierHome.findByPrimaryKey(suppliers[0]); //删除客户 supplier.remove(); supplier = supplierHome.findByPrimaryKey(suppliers[1]); //删除客户 supplier.remove(); supplier = supplierHome.findByPrimaryKey(suppliers[2]); //删除客户 supplier.remove(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -