|
LZ好意,但好象少了一个例子。。我发下我以前项目中的测试脚本,是一个springupload的例子:(java vuser的缺点在于需要负载机性能强大内存大,而且主要是针对服务端的压力测试)
/*
* LoadRunner Java script. (Build: 759)
*
* Script Description:
*
*/
import java.math.BigDecimal;
import java.util.Date;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.ce.dpos.sale.payment.model.PaymentMannerDO;
import com.ce.dpos.sale.payment.model.PaymentTypeDO;
import com.ce.dpos.sale.remoteservice.IRemoteUploadService;
import com.ce.dpos.sale.trade.model.PaymentItemDO;
import com.ce.dpos.sale.trade.model.SaleDO;
import com.ce.dpos.sale.trade.model.SaleItemDO;
import com.ce.component.log4ce.core.BizLogInfo;
import com.ce.component.log4ce.core.BizOperationResult;
import com.ce.component.log4ce.core.BizOperationType;
import lrapi.lr;
public class Actions {
public SaleDO saleDO;
public BizLogInfo bizLogInfo;
public IRemoteUploadService remoteUploadService;
public int init() {
ApplicationContext ctx = new ClassPathXmlApplicationContext(
"/invoker-client.xml");
remoteUploadService = (IRemoteUploadService) ctx
.getBean("remoteUploadServiceProxy");
saleDO = new SaleDO();
// saleDO.setChangeItems(arg0);
saleDO.setEdit();
// saleDO.setFavourableAuthUser(1, 1, 2);
// saleDO.setIdNull();
saleDO.setIsUpdateStock(false);
saleDO.setIsUpload(true);
saleDO.setSaleCode("lijian123");
saleDO.setSaleCreateTime(new Date());
saleDO.setSaleId(1);
saleDO.setSalePayTime(new Date());
saleDO.setTerCode("001");
// saleDO.setTradeSettings(arg0);
saleDO.setUserId(2);
saleDO.setWarehouseId(1);
SaleItemDO saleItemDO = new SaleItemDO();
saleItemDO.setAuthUserId(2);
saleItemDO.setEdit();
saleItemDO.setMerBarCode("barCode400101865");
saleItemDO.setMerchandiseId(1);
saleItemDO.setMerCode("00101");
saleItemDO.setMerName("可乐-1287854501");
saleItemDO.setSaleId(1);
// saleItemDO.setSdAppStrategyState(arg0);
saleItemDO.setSdCreateTime(new Date());
// saleItemDO.setSdId(arg0);
saleItemDO.setSdIdNull();
saleItemDO.setSdMyid(1);
saleItemDO.setSdOriginalPrice(BigDecimal.valueOf(4.29));
// saleItemDO.setStrategyApplyId(arg0);
// saleItemDO.setStrategyId(arg0);
saleItemDO.setWrhId(1);
saleItemDO.modifyAmount(BigDecimal.valueOf(1));
saleItemDO.modifyPrice(BigDecimal.valueOf(4.29));
PaymentItemDO paymentItemDO = new PaymentItemDO();
paymentItemDO.setEdit();
// paymentItemDO.setPiAdditionalInfo(arg0);
paymentItemDO.setPiCreateTime(new Date());
paymentItemDO.setPiExchangeRate(BigDecimal.valueOf(1));
paymentItemDO.setPiExchangeSum(BigDecimal.valueOf(4.29));
// paymentItemDO.setPiId(arg0);
paymentItemDO.setPiPaySum(BigDecimal.valueOf(4.29));
paymentItemDO.setPiPaytype(1);
paymentItemDO.setPiState(Byte.valueOf("2"));
paymentItemDO.setPiTicketAmount(0);
// paymentItemDO.setPiWarrant(0);
paymentItemDO.setSaleId(1);
PaymentMannerDO paymentMannerDO = new PaymentMannerDO();
paymentMannerDO.setCanChange(true);
paymentMannerDO.setEdit();
paymentMannerDO.setExchangeRate(BigDecimal.valueOf(1));
paymentMannerDO.setIsBasicCurrency(true);
paymentMannerDO.setPmCode("RMB");
paymentMannerDO.setPmDeleted(false);
paymentMannerDO.setPmDisabled(false);
paymentMannerDO.setPmId(1);
paymentMannerDO.setPmName("人民币");
paymentMannerDO.setPmPlugin("Plugin001");
paymentMannerDO.setPtId(1);
paymentMannerDO.setShareProfitCalc(true);
// paymentMannerDO.setValidEndDatetime(arg0);
paymentMannerDO.setValidForever(true);
// paymentMannerDO.setValidStartDatetime(arg0);
PaymentTypeDO paymentTypeDO = new PaymentTypeDO();
paymentTypeDO.setPtId(1);
paymentTypeDO.setPtName("现金");
paymentMannerDO.setTypeDO(paymentTypeDO);
paymentItemDO.setPaymentMannerDO(paymentMannerDO);
saleDO.addItem(saleItemDO);
bizLogInfo = new BizLogInfo();
bizLogInfo.setBizDescription("Unspecified biz description.");
bizLogInfo.setBizOperationResult(BizOperationResult.SUCCESS);
bizLogInfo.setBizOperationType(BizOperationType.UNKNOWN);
bizLogInfo.setBizType("Unspecified");
bizLogInfo.setClientAddress("192.168.102.9");
// bizLogInfo.setExceptionMessage(arg0);
bizLogInfo.setId(Long.parseLong("1"));
bizLogInfo.setOperatingTime(new Date());
bizLogInfo.setOperation("测试");
bizLogInfo.setOperationMessage("测试");
bizLogInfo.setOperator("lijian");
bizLogInfo.setSystemAddress("1");
bizLogInfo.setSystemName("88888888");
bizLogInfo.setThreadId(Long.parseLong("100"));
return 0;
}// end of init
public int action() {
lr.start_transaction("uploadSale");
try {
remoteUploadService.uploadSale(saleDO);
} catch (Exception e) {
// TODO: handle exception
lr.end_transaction("uploadSale", lr.FAIL);
}
lr.end_transaction("uploadSale", lr.AUTO);
lr.start_transaction("uploadLog");
try {
remoteUploadService.uploadLog(bizLogInfo);
} catch (Exception e) {
lr.end_transaction("uploadLog", lr.FAIL);
}
lr.end_transaction("uploadLog", lr.AUTO);
return 0;
}// end of action
public int end() {
return 0;
}// end of end
}
以上只是脚本部分,如果不知道怎么设置,可以去查看相关资料(其实只用把所依赖的包放到classpath下就行了) |
|