0

I am wanting to create an automated test case within Ready API that creates 2D data matrices from input strings that come back in the response to a REST web service request. I would like for the script to save these 2D data matrices as GIF or JPEG images to a folder on my machine.

I have a script (below) that extracts the indiciaStream from the response and decodes it to create a string. The last step in this step just assigns the decoded string to a testCase property which I then write to a data source. But I'd like to be able to create the 2D data matrices from the script and store on my machine.

Any help would be much appreciated.

def response = context.expand( '${createRequest#Response}' );
def slurper = new XmlSlurper().parseText(response)

String indiciaStream =     slurper.Body.createResponse.CreateResponse.IndiciaStream

byte[] decodedIS = indiciaStream.decodeBase64();

String decodedIndiciaStream = new String(decodedIS);
testRunner.getTestCase().setPropertyValue('decodedIndiciaStream',decodedIndiciaStream)

The inidicia stream looks like ...

SkdCIDgyMTUxQTA2MDAwMDAwNTZGMDAwMDIwMDEwMDQ0MDI1MDkxNTAwNyAgS0IwNjAwMDAyODVHQjIxICBNMTU0UFMgICBHQiBDTTE2NkxMUyAg

And decoded it looks like ...

JGB 82151A0600000056F0000200100440250915007  KB060000285GB21  M154PS   GB CM166LLS  
chucknor
  • 837
  • 2
  • 18
  • 33
  • How do you intend to convert `JGB 82151A0600000056F0000200100440250915007 KB060000285GB21 M154PS GB CM166LLS ` to a JPG? Not sure I follow... – tim_yates Sep 25 '15 at 13:03
  • Hi. There are sites e.g. http://barcode.tec-it.com/en# that you can use to convert a string into a 2D data matrix and then download it as a gif file. I would like to know if it's at all possible to do this within SoapUI using groovy. I don't mind what the format is i.e. image or pdf as long as I can scan the 2D barcode. – chucknor Sep 25 '15 at 13:06
  • You can just hit their server it looks like: http://barcode.tec-it.com/barcode.ashx?code=DataMatrix&data=Hello%20tam – tim_yates Sep 25 '15 at 13:17
  • Oh I see. Thanks. I just need to figure out how to send this request from within SoapUI and save the result with a unique name. Could I add an http request in the SoapUI test case? I will look into it. – chucknor Sep 25 '15 at 13:35

0 Answers0