formUpload with ssp template (or ElFileBody...)?

74 views
Skip to first unread message

Nol de Wit

unread,
Aug 24, 2016, 9:35:27 AM8/24/16
to Gatling User Group
Hi,

For a formUpload() I'm currently using specific file content per user. With the increase of the number of (specific, authenticated) users this becomes undoable.

I'm looking at the filebody/spp functionality, but from what I read here it is depricated? (Also I couldn't find if it is usable with formUpload(). I failed to figure out a way to use the apperent alternative, ElFileBody.

Could anybody give me a couple of pointers that could help me change the code below such that it uses a template file in the formUpload()? 

  def importXML(size: String, merge: Boolean) = exec(http("Import merge" + merge.toString + ": /rapportage/DNB-M.2016-02.{userId}.e.xml?merge=" + merge.toString + " " + size)
    .post("/ebridge/api/rapportage/DNB-M.2016-02.${userId}.e.xml?merge=" + merge.toString)
    .headers(headers_import)
    .formUpload("file", "rap-DNB-M-2016-2.${userId}." + size + ".xml")
  ).pause(Durations.lowPause, Durations.highPause)


Thanks,
Nol

Stéphane LANDELLE

unread,
Aug 24, 2016, 11:16:39 AM8/24/16
to gat...@googlegroups.com
formUpload is just an alias for bodyPart(RawFileBody), see http://gatling.io/docs/2.2.2/http/http_request.html#multipart-request

Stéphane Landelle
GatlingCorp CEO


--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nol de Wit

unread,
Aug 25, 2016, 7:46:13 AM8/25/16
to Gatling User Group
Thanks Stepan, that got me in the right direction. 
That is to say, I can use a 'template' now, and values inside the tempate are replaced, but I get some errors. I think these are not related to the EL syntax, but apperently to the file content (in relation to the bodyPart/RawFileBodyPart I use). This file however is used before by the previous implementation (formUpload) without errors.

Is my combination of bodyPart - RawFileBodyPart - ElFileBody correct?

The new version of my code:
  def importXML(size: String, merge: Boolean) = exec(http("Import merge" + merge.toString + ": /rapportage/ABC-M.2016-02.{userId}.e.xml?merge=" + merge.toString + " " + size)
    .post("/ebridge/api/rapportage/ABC-M.2016-02.${userId}.e.xml?merge=" + merge.toString)
    .headers(headers_import)
    .bodyPart(RawFileBodyPart("file", ElFileBody("rap-ABC-M-2016-2.10k.xml")))
      //.formUpload("file", "rap-ABC-M-2016-2.${userId}." + size + ".xml")
  ).pause(Durations.lowPause, Durations.highPause)


The (first line) of my template (rap-ABC-M-2016-2.10k.xml):
<?xml version="1.0" encoding="ISO-8859-1"?><?bestandsnaam ABC-M.2016-02.${userId}.e.xml?><?eerstemaandrapportageperiode 2016-02?> etc. etc.


The error I got:
---- Errors --------------------------------------------------------------------
> Failed to build request Import mergefalse: /rapportage/ABC-M.2      2 (Infinity%)
016-02.{userId}.e.xml?merge=false 10k: Failed to build request...
================================================================================

12:07:44.295 [ERROR] i.g.h.a.s.HttpRequestAction - 'httpRequest-11' failed to execute: Failed to build request: Illegal char <<> at index 0: <?xml version="1.0" encoding="ISO-8859-1"?><?bestandsnaam ABC-M.2016-02.12000001.e.xml?><?eerstemaandrapportageperiode 2016-02?><?first false?><?laatstemaandrapportageperiode 2016-02?><?nihil false?><?rapportageperiode 2016-02?><?registratienummer 12000001?><?status e?><?versienr 1?>
<ABC-M xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="bb.abc.nl" xsi:schemaLocation="bb.abc.nlABC-M.xsd$2016-02.xsd">

etc. etc.

Any ideas what could cause this?


Op woensdag 24 augustus 2016 17:16:39 UTC+2 schreef Stéphane Landelle:
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages