Thanks for the reply,
Here is the sample code for the method:
object BasicLogin {
def login ( hostparam:String, controlparam:String, usernameparam:String, passwordparam:String) : (ChainBuilder, String) = {
val user = usernameparam
val password = passwordparam
val host = hostparam
val controlid = controlparam
val logintype = "user"
val jsonrequest = “”"{“logintype”:"""" + logintype + “”"",
"controlid":"""" + controlid + “”"",
"user":"""" + user + “”"",
"password":"""" + password + “”"",
"host":"""" + host + “”""
}"""
val loginChain = exec(http(“Login”)
.post(“sample.url.com”)
.body(StringBody(jsonrequest))
.asJSON
.check(jsonPath("$…result").is(“true”))
.check(jsonPath("$…session")
.find
.saveAs(“currentSession”)))
val accessToken: String = exec(session => {
val sessionid = session(“currentSession”).as[String]
println("token: " + sessionid)
session })
.toString
return (loginChain, accessToken)
}
}
Here is my code calling the method for login:
val host = "IPaddress"
val controlid = "IDcontroller"
val username = "JDoe"
val password = "TerriblePassword"
val result = BasicLogin.login(host, controlid, username, password)
val basiclogin:ChainBuilder = result._1
val currentSession:String = result._2
println("Session: " + currentSession)
println("Login: " + basiclogin)
And here is what I get in response:
Session: ChainBuilder(List(io.gatling.core.action.builder.SessionHookBuilder@6f70f32f))
Login: ChainBuilder(List(io.gatling.http.action.sync.HttpRequestActionBuilder@3dd69f5a))
I do want to note that the println("token " + sessionID) does not get returned to the screen. Any idea what it is I am missing here?
Thanks for the help,
Rob