Gatling: How should I transform a binary response to json and then check it? -
i have page returns pretty big response body binary, when decoded plain text response in json format.
i want transform response can traversed json , checked.
for example:
import org.asynchttpclient.util.base64 import io.gatling.http.response._ import java.nio.charset.standardcharsets.utf_8 // .... val read = exec(http("get results") .get("/foo?bar=baz") // response in binary .transformresponse { case response if response.isreceived => new responsewrapper(response) { override val body = new bytearrayresponsebody(base64.decode(response.body.string), utf_8) } } .check( jsonpath("$.alpha.beta").exists.saveas("gamma") ) )
but throws error:
12:54:39.387 [debug] i.g.h.a.asynchandler - request 'get results' failed user 1 java.lang.stringindexoutofboundsexception: string index out of range: 102327 @ java.lang.string.charat(string.java:658) @ org.asynchttpclient.util.base64.decode(base64.java:125) @ foo$$anonfun$1$$anon$1.<init>(foo.scala:41) @ foo$$anonfun$1.applyorelse(foo.scala:40) @ foo$$anonfun$1.applyorelse(foo.scala:39) @ io.gatling.http.response.responsebuilder.build(responsebuilder.scala:205) @ io.gatling.http.ahc.asynchandler.withresponse(asynchandler.scala:126) @ io.gatling.http.ahc.asynchandler.oncompleted(asynchandler.scala:134) @ io.gatling.http.ahc.asynchandler.oncompleted(asynchandler.scala:47) @ org.asynchttpclient.netty.nettyresponsefuture.getcontent(nettyresponsefuture.java:189) @ org.asynchttpclient.netty.nettyresponsefuture.done(nettyresponsefuture.java:223) @ org.asynchttpclient.netty.handler.httphandler.finishupdate(httphandler.java:58) @ org.asynchttpclient.netty.handler.httphandler.handlechunk(httphandler.java:159) @ org.asynchttpclient.netty.handler.httphandler.handleread(httphandler.java:187) @ org.asynchttpclient.netty.handler.asynchttpclienthandler.channelread(asynchttpclienthandler.java:76) @ io.netty.channel.abstractchannelhandlercontext.invokechannelread(abstractchannelhandlercontext.java:357) @ io.netty.channel.abstractchannelhandlercontext.invokechannelread(abstractchannelhandlercontext.java:343) @ io.netty.channel.abstractchannelhandlercontext.firechannelread(abstractchannelhandlercontext.java:336) @ io.netty.channel.channelinboundhandleradapter.channelread(channelinboundhandleradapter.java:86) @ io.netty.channel.abstractchannelhandlercontext.invokechannelread(abstractchannelhandlercontext.java:357) @ io.netty.channel.abstractchannelhandlercontext.invokechannelread(abstractchannelhandlercontext.java:343) @ io.netty.channel.abstractchannelhandlercontext.firechannelread(abstractchannelhandlercontext.java:336) @ io.netty.handler.codec.messagetomessagedecoder.channelread(messagetomessagedecoder.java:102) @ io.netty.channel.abstractchannelhandlercontext.invokechannelread(abstractchannelhandlercontext.java:357) @ io.netty.channel.abstractchannelhandlercontext.invokechannelread(abstractchannelhandlercontext.java:343) @ io.netty.channel.abstractchannelhandlercontext.firechannelread(abstractchannelhandlercontext.java:336) @ io.netty.channel.combinedchannelduplexhandler$delegatingchannelhandlercontext.firechannelread(combinedchannelduplexhandler.java:435) @ io.netty.handler.codec.bytetomessagedecoder.firechannelread(bytetomessagedecoder.java:293) @ io.netty.handler.codec.bytetomessagedecoder.channelread(bytetomessagedecoder.java:267) @ io.netty.channel.combinedchannelduplexhandler.channelread(combinedchannelduplexhandler.java:250) @ io.netty.channel.abstractchannelhandlercontext.invokechannelread(abstractchannelhandlercontext.java:357) @ io.netty.channel.abstractchannelhandlercontext.invokechannelread(abstractchannelhandlercontext.java:343) @ io.netty.channel.abstractchannelhandlercontext.firechannelread(abstractchannelhandlercontext.java:336) @ io.netty.channel.defaultchannelpipeline$headcontext.channelread(defaultchannelpipeline.java:1294) @ io.netty.channel.abstractchannelhandlercontext.invokechannelread(abstractchannelhandlercontext.java:357) @ io.netty.channel.abstractchannelhandlercontext.invokechannelread(abstractchannelhandlercontext.java:343) @ io.netty.channel.defaultchannelpipeline.firechannelread(defaultchannelpipeline.java:911) @ io.netty.channel.nio.abstractniobytechannel$niobyteunsafe.read(abstractniobytechannel.java:131) @ io.netty.channel.nio.nioeventloop.processselectedkey(nioeventloop.java:643) @ io.netty.channel.nio.nioeventloop.processselectedkeysoptimized(nioeventloop.java:566) @ io.netty.channel.nio.nioeventloop.processselectedkeys(nioeventloop.java:480) @ io.netty.channel.nio.nioeventloop.run(nioeventloop.java:442) @ io.netty.util.concurrent.singlethreadeventexecutor$2.run(singlethreadeventexecutor.java:131) @ io.netty.util.concurrent.defaultthreadfactory$defaultrunnabledecorator.run(defaultthreadfactory.java:144) @ java.lang.thread.run(thread.java:748) 12:54:39.389 [warn ] i.g.h.a.responseprocessor - request 'get results' failed: j.l.stringindexoutofboundsexception: string index out of range: 102327 12:54:39.399 [trace] i.g.h.a.responseprocessor - >>>>>>>>>>>>>>>>>>>>>>>>>>
is intended purpose transformresponse? doing incorrectly?
Comments
Post a Comment