您的位置:軟件測(cè)試 > 開源軟件測(cè)試 > 開源性能測(cè)試工具 > Jmeter
接口性能測(cè)試--JMeter
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時(shí)間:[ 2013/11/6 15:37:25 ] 推薦標(biāo)簽:

  3)GetPersonTest為某一類具有相似業(yè)務(wù)場(chǎng)景的測(cè)試類
  其中 getDefaultParameters方法設(shè)置默認(rèn)參數(shù):test傳入具體要執(zhí)行的測(cè)試方法;info傳入日志級(jí)別,利用main方法進(jìn)行調(diào)試時(shí)設(shè)置為true,真正進(jìn)行性能測(cè)試的時(shí)候設(shè)置為false
package  com . xxx . yyy . perf;
import  org.apache.jmeter.config.Argument;
import  org.apache.jmeter.config.Arguments;
import  org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
import  org.apache.jmeter.samplers.SampleResult;
import  org.springframework.context.ApplicationContext;
import  org.springframework.context.support.ClassPathXmlApplicationContext;
import  com.xxx.udb.client.PersonService;
import  com.xxx.udb.client.result.MultiPersonResult;
import  com.xxx.udb.client.result.PersonResult;
import  com.xxx.udb.perf.base.AbstractServiceClient;
/**
* Test get person
* @author flynewton
*/
public  class  GetPersonTest  extends  AbstractServiceClient  {
private  static  final  ApplicationContext  ctx  =  new ClassPathXmlApplicationContext(
"spring-udb.xml");
private  static  PersonService  personService  =  null;
private  static  String  loginIdCache  =  "00000sb";
private  static  String  loginIdWithoutCache  =  "01haytham";
private  static  String  siteIdCache  =  "CN";
private  static  String  siteIdWithoutCache  =  "IN";
private  static  String  alimailCn  =  "gchg2008@zzgcchen.cn";
private  static  String  alimailUdb  =  "000001@lvcuinm.com.cn";
private  static  String  uidCache  =  "300113578";
private  static  String  uidWithoutCache  =  "in5002997";
private  static  String  emailCache  =  "00000sb@alibaba-test.com";
private  static  String  emailWithoutCache  =  "5002997@alibaba-inc.com";
@Override
public  void  setupTest( JavaSamplerContext  context)  {
super . setupTest( context);
personService  = ( PersonService)  ctx . getBean( "personServiceClient");
}
public  Arguments  getDefaultParameters()  {
Arguments  params  =  new  Arguments();
params . addArgument( "test" ,  "testMethod");
params . addArgument( "info" ,  "false");
return  params;
}
@Override
public  void  teardownTest( JavaSamplerContext  context)  {
super . teardownTest( context);
}
public  Object  testGetPersonByLongIdViaCache( JavaSamplerContext  arg0 ,
SampleResult  sample)  {
PersonResult  personResult  =  null;
try  {
sample . sampleStart();
personResult  =  personService . getPersonByLongId( siteIdCache , loginIdCache);
sample . sampleEnd();
}  catch ( Throwable  t)  {
this . getLogger (). error( "Exception:"  +  t);
return  null;
}
return  personResult;
}
public  Object  testGetPersonByLongIdWithoutCache( JavaSamplerContext  arg0 ,
SampleResult  sample)  {
PersonResult  personResult  =  null;
try  {
sample . sampleStart();
personResult  =  personService . getPersonByLongId( siteIdWithoutCache , loginIdWithoutCache);
sample . sampleEnd();
}  catch ( Throwable  t)  {
this . getLogger (). error( "Exception:"  +  t);
return  null;
}
return  personResult;
}
public  Object  testGetPersonByAlimailCN( JavaSamplerContext  arg0 ,
SampleResult  sample)  {
PersonResult  personResult  =  null;
try  {
sample . sampleStart();

上一頁123下一頁
軟件測(cè)試工具 | 聯(lián)系我們 | 投訴建議 | 誠(chéng)聘英才 | 申請(qǐng)使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd