Showing posts with label Encode and Decode Images in SoapUI. Show all posts
Showing posts with label Encode and Decode Images in SoapUI. Show all posts

Saturday, April 11, 2015

How to Read and Encode an Image file using Groovy in SoapUI

Make sure all the Groovy GDK ars are present in SoapUI/Lib folder

def s = 'Any tag value which has Base64 encoded image'
String encoded = s.bytes.encodeBase64().toString()
assert 'QXJnaCwgR3Jvb3Z5IHlvdSBzYXksIG1hdGU/' == encoded
byte[] decoded = encoded.decodeBase64()
assert s == new String(decoded)