收到一只叮咚
public class AutoNumberRmiTest extends AbstractJavaSamplerClient
{
private AutoNumberSeqService autoNumberSeqService;
private TenantParam tenantParam;
@Override
public Arguments getDefaultParameters() {
Arguments args = new Arguments();
args.addArgument("label","用户接口测试");
args.addArgument("hostAddress","");
args.addArgument("tenantId","");
args.addArgument("itemId","");
return args;
}
@Override
public void setupTest(JavaSamplerContext context) {
try {
autoNumberSeqService = (AutoNumberSeqService) Naming.lookup("//"+context.getParameter("hostAddress")+":9238/AutoNumberSeqRMIService");
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
} catch (NotBoundException e) {
e.printStackTrace();
}
tenantParam = new TenantParam(context.getLongParameter("tenantId"));
super.setupTest(context);
}
public SampleResult runTest(JavaSamplerContext javaSamplerContext) {
long itemId = javaSamplerContext.getLongParameter("itemId");
SampleResult sampleResult = new SampleResult();
sampleResult.setSampleLabel(javaSamplerContext.getParameter("label"));
sampleResult.setSuccessful(false);
try {
sampleResult.sampleStart();
String autoNuberCode = autoNumberSeqService.buildCodeByItem(itemId, tenantParam);
if (autoNuberCode != null) {
sampleResult.setSuccessful(true);
sampleResult.setResponseData(autoNuberCode);
sampleResult.setDataType(SampleResult.TEXT);
}
} catch (CustomizeException e) {
e.printStackTrace();
sampleResult.setSuccessful(false);
} finally{
sampleResult.sampleEnd();
}
return sampleResult;
}
}