Isheet
Isheet

Reputation: 31

How to assert nonprintable control characters using JMeter?

How can I assert nonprintable control characters format using JMeter? My data which I want to assert is in this small square box, but I am not sure what settings I can do in JMeter to assert it.

enter image description here

I am trying to use BeanShellPostProcesser but I am not sure how to use it, this is my first time trying to use BeanShellPostProcesser.

Upvotes: 1

Views: 35

Answers (1)

Ivan G
Ivan G

Reputation: 2872

According to Java documentation

char: The char data type is a single 16-bit Unicode character. It has a minimum value of '\u0000' (or 0) and a maximum value of '\uffff' (or 65,535 inclusive).

so you can check the presence of the character code you're looking for in the response.

prev shorthand provides you access to the previous SampleResult, you can get response data in form of byte array using prev.getResponseData() function or in form of string using prev.getResponseDataAsString() function. Then check presence of the character(s) you expect to be there and if it's not present in the response use prev.setSuccessful() function to conditionally mark the parent Sampler as failed.

Also regarding Beanshell, since JMeter 3.1 you should be using JSR223 Test Elements and Groovy language for scripting so it worth looking into that direction. More information: Apache Groovy: What Is Groovy Used For?

Upvotes: 0

Related Questions