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)