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(); |