--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
http("request").post("uri").objectBody(newObject(foo)).asJSON
Thanks for the quick answer. I agree that using byteArrayBody isn't a good fit for a plain text format.
Sure, I can give some background. I've got a Java API exposed using Spring MVC, so my requests and responses are all defined as Java objects. In order to test this API with as little effort as possible, I'd like to use these Java clases from Scala, call their setters, and specify the object itself as the thing to marshall and send. For example, imagine some syntax like
http("request").post("uri").objectBody(newObject(foo)).asJSON
where newObject builds the object to send, objectBody specifies the Scala/Java object, and asJSON does the serialization.
The two alternatives right now that I can see are to1. Manually pass all my objects through Jackson to get their JSON equivalent, and copy the produced JSON to request body files. The problem here, besides the manual labour, is that those request body files would need to be maintained should the objects change. Using objects I could find usages when I modify the object and updated my Scala test code accordingly.
2. Use the standard body() call and replace newObject() with newObjectAsString(), which would somehow call Jackson to give me back a String representation of the passed object (not something I'm comfortable with just yet given how completely new I am to both Gatling and Scala)
--
http("String body").post("my.post.uri") .body(${line}).asJSON