There may be mistranslations because i'm using a translator.
i want to create response assertion in beanshell
script content is postrequest site and get responsedata
but this request usually fail so i want to check everytime with response assertion
i want to check make response assertion in jmeter beanshell
Whether the request is successful or not, I want to create a response assertion in beanshell.
can i help?
for(int i=0; i<10; i++){
HttpClient client = HttpClientBuilder.create().build();
HttpPost postRequest = new HttpPost(requestURL);
postRequest.setEntity(new StringEntity(jsonMessage));
HttpResponse response = client.execute(postRequest);
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String inputLine;
StringBuffer sbRes = new StringBuffer();
while((inputLine = reader.readLine()) != null) {
sbRes.append(inputLine);
}
reader.close();
String trans = sbRes.toString();
Boolean checkResult = trans.contains("result\":0");
if(checkResult==true){
//** i want create response assertion here **
}
else{
// **i want create response assertion here **
}
}