?? testgoodscactus1.java
字號:
package cactustest;
import org.apache.cactus.*;
import javax.naming.*;
import java.util.Collection;
import java.rmi.RemoteException;
import stockmanagementpro.*;
public class TestGoodsCactus1 extends ServletTestCase {
private static final String ERROR_NULL_REMOTE = "接口未定義.";
private static final int MAX_OUTPUT_LINE_LENGTH = 100;
private boolean logging = false;
private GoodsHome goodsHome = null;
private Goods goods = null;
public TestGoodsCactus1(String name) {
super(name);
}
public void initializeLocalHome() throws Exception {
Context context = new InitialContext();
goodsHome = (GoodsHome) context.lookup("Goods");
}
public void setUp() throws Exception {
super.setUp();
initializeLocalHome();
}
public void tearDown() throws Exception {
goodsHome = null;
goods = null;
super.tearDown();
}
//測試商品創建方法
public void testGoodsCreate() throws Exception {
/*String goodsBarCode = "10000001";
int categoryId = 1;
String goodsName = "類別1的商品1";
String goodsNickName = "別名1";
String goodsAssistantName = "助記碼1";
String goodsPYName = "LBDSP1";
String unit = "件";
String specification = "每箱10件";
String producer = "生產廠商1";
int upperLimit = 0;
int lowerLimit = 0;
double salePrice = 15;
double discount = 1;
//創建商品
goodsHome.create(goodsBarCode, categoryId, goodsName, goodsNickName,
goodsAssistantName, goodsPYName, unit,
specification, producer, upperLimit, lowerLimit,
salePrice, discount);
goodsBarCode = "10000002";
categoryId = 1;
goodsName = "類別1的商品2";
goodsNickName = "別名2";
goodsAssistantName = "助記碼2";
goodsPYName = "LBDSP2";
unit = "件";
specification = "每箱10件";
producer = "生產廠商2";
upperLimit = 0;
lowerLimit = 0;
salePrice = 20;
discount = 1;
//創建商品
goodsHome.create(goodsBarCode, categoryId, goodsName, goodsNickName,
goodsAssistantName, goodsPYName, unit,
specification, producer, upperLimit, lowerLimit,
salePrice, discount);*/
}
//測試根據類別取得商品的方法
public void testFindByGoodsCategory() throws Exception {
java.util.Collection col = goodsHome.findByGoodsCategory(1);
this.assertEquals("return value", 2, col.size());
}
//測試根據條形碼取得商品的方法
public void testFindByGoodsBarCode() throws Exception {
java.util.Collection col = goodsHome.findByGoodsBarCode("%1%");
this.assertEquals("return value", 2, col.size());
}
//測試根據商品名字取得商品的方法
public void testFindByGoodsName() throws Exception {
java.util.Collection col = goodsHome.findByGoodsName("%商品%");
this.assertEquals("return value", 2, col.size());
}
//測試根據生產廠商取得商品的方法
public void testFindByProducer() throws Exception {
java.util.Collection col = goodsHome.findByProducer("%生產廠商%");
this.assertEquals("return value", 2, col.size());
}
//測試取得打折商品的方法
public void testFindDiscountGoods() throws Exception {
java.util.Collection col = goodsHome.findDiscountGoods();
this.assertEquals("return value", 2, col.size());
}
//測試商品刪除方法
public void testGoodsDelete() throws Exception {
/*String goodsBarCode = "10000001";
goods = goodsHome.findByPrimaryKey(goodsBarCode);
//刪除商品
goods.remove();
goodsBarCode = "10000002";
goods = goodsHome.findByPrimaryKey(goodsBarCode);
//刪除商品
goods.remove();*/
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -