Multiple saveAs

Hello,
I try to save in session some id from a http response and it seems that only the last one is currently saved (richtexti18nUuid in the exemple)
Here my code :

.exec(http(“publish2”)
.post("/gwt/contentManager.gwt?lang=${LANG}&site=${siteUuid}&workspace=default")
.headers(headers_gwt)
.fileBody(“getPublicationInfo”, map)
.check(regex("""(^//OK)"""))
.check(regex("""“uuid”,"([0-9 a-z]+-[0-9 a-z]+-[0-9 a-z]+-[0-9 a-z]+-[0-9 a-z]+)",“title”,""").saveAs(“uuid”))
.check(regex("""“i18nUuid”,"([0-9 a-z]+-[0-9 a-z]+-[0-9 a-z]+-[0-9 a-z]+-[0-9 a-z]+)",""").saveAs(“i18nUuid”))
.check(regex(""""([0-9 a-z]+-[0-9 a-z]+-[0-9 a-z]+-[0-9 a-z]+-[0-9 a-z]+)",“maincontent”,""").saveAs(“mainContentUuid”))
.check(regex(""""([0-9 a-z]+-[0-9 a-z]+-[0-9 a-z]+-[0-9 a-z]+-[0-9 a-z]+)",“rich-text”,""").saveAs(“richtextUuid”))
.check(regex("""“Rich text”,"([0-9 a-z]+-[0-9 a-z]+-[0-9 a-z]+-[0-9 a-z]+-[0-9 a-z]+)""").saveAs(“richtexti18nUuid”))
)
.exec((session: Session) => {
println("richtexti18nUuid : " + session.getAttribute(“richtexti18nUuid”))
println("richtextUuid : " + session.getAttribute(“richtextUuid”))
println("uuid : " + session.getAttribute(“uuid”))
println("i18nUuid : " + session.getAttribute(“i18nUuid”))
println("mainContentUuid : " + session.getAttribute(“mainContentUuid”))
session
}
)

Is it possible to have more than one saveAs ? and if yes how to achieve this ?

Hi Stéphane,

See doc here:
https://github.com/excilys/gatling/wiki/Checks#wiki-checks

As all the DSL elements are immutable so that they can be composed and reused, the consequence of what you wrote is that you overrode the checks previously defined.

What you have to write is check(check1, check2, check3, …)

Cheers,

Steph

2012/8/13 Stéphane Journiac <sjourniac@jahia.com>

Thank you Stephane I’ll try that.

Cheers

You’re welcome.
This is a common mistake, so I added a word of notice to the doc.

Cheers,

Steph

2012/8/13 Stéphane Journiac <sjourniac@jahia.com>

Trying this, like described in the documentation, I get a compilation error (using 1.3.x).

.check(
status.is(201)),
regex(“Location:./(.)”).saveAs(“test”)
)

type mismatch;
found : com.excilys.ebi.gatling.http.request.builder.PostHttpRequestBuilder
required: com.excilys.ebi.gatling.core.structure.ChainBuilder
10:43:25.301 [ERROR] c.e.e.g.a.ZincCompiler$ - .check(
10:43:25.301 [ERROR] c.e.e.g.a.ZincCompiler$ - ^
10:43:25.319 [ERROR] c.e.e.g.a.ZincCompiler$ - one error found
Exception in thread “main” Compilation failed

Regards Danny

You have a parenthesis that should be here: you close the check method call after status:

.check(
status.is(201), // ← removed parenthesis
regex(“Location:./(.)”).saveAs(“test”)
)

Ah sorry, my bad.