How to read Session attributes outside of Gatling DSL

406 views
Skip to first unread message

Yves

unread,
Apr 9, 2015, 4:27:49 AM4/9/15
to gat...@googlegroups.com
Hi,

I would like to read the Session Map after a call to a feeder in a Scala function.

Assume here is my code :

class RechercheUSParCriteresIdsMonoValueEvol extends Simulation {

// some Stuff

object consultationService {
    
        def rechercheUS (pTypeUS: String, IdFoncUS: String = "IDENTIFIANT", nbIdFoncUS: Int = 0) : ChainBuilder = {
            
            return exec { session =>
                var pCriteres : String = ""
                if (nbIdFoncUS != 0){
                    pCriteres = pCriteres + generateBuilder(IdFoncUS, nbIdFoncUS)
                }
                val newsession = session.set("pCritere", pCriteres).set("pTypeUS", pTypeUS)
                newsession
            }
            .exec(
                soapPost("RECHERCHE_ID_FONC_US", urlService, "Request_rechercherUnitesStructurellesParCriteres.txt")
            )
            .pause(pacingTime)
        }
        
        def generateBuilder (tCritere : String, nbTCritere: Int) : String = {
            val session: Session = ???
            
            var valeursCriteres : List[String] = List()
            
            for ( x <- 0 to nbTCritere - 1) {
                feed(usiFeeder) -> must inject data in the session 
                valeursCriteres = session("idFonctionnelUs").as[String] :: valeursCriteres
            }
            return (new pCriteres(true, tCritere, valeursCriteres)).toString()
         }      
    }

// Some stuff

}

The compilation is OK, but at runtime I got this exception on the line where I declare ( val session: Session = ??? )

Exception in thread "main" scala.NotImplementedError: an implementation is missing
        at scala.Predef$.$qmark$qmark$qmark(Predef.scala:225)
        at consultationService .RechercheUS.<init>(RecordedSimulation.scala:54)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at java.lang.Class.newInstance(Unknown Source)
        at io.gatling.core.runner.Runner.run(Runner.scala:41)
        at io.gatling.app.Gatling$$anonfun$runSimulationIfNecessary$1.apply(Gatling.scala:126)
        at io.gatling.app.Gatling$$anonfun$runSimulationIfNecessary$1.apply(Gatling.scala:111)
        at scala.Option.getOrElse(Option.scala:121)
        at io.gatling.app.Gatling.runSimulationIfNecessary(Gatling.scala:111)
        at io.gatling.app.Gatling.start(Gatling.scala:67)
        at io.gatling.app.Gatling$.fromArgs(Gatling.scala:53)
        at io.gatling.app.Gatling$.main(Gatling.scala:44)
        at io.gatling.app.Gatling.main(Gatling.scala)

Any Idea on what happened ?

Thx

Stéphane LANDELLE

unread,
Apr 9, 2015, 7:10:35 AM4/9/15
to gat...@googlegroups.com
??? is exactly that: something that throws a NotImplementedError at runtime.

It's used as an intermediate step to write down all your logic while coding but you're not finished implementing yet.
You shouldn't be using it here and expect the Simulation to work.

Stéphane Landelle
Lead developer


--
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/d/optout.

Yves

unread,
Apr 9, 2015, 7:36:57 AM4/9/15
to gat...@googlegroups.com
Ok i was asking myself what was then meaning of ???.

So how could i fetch the Session and use them like : valeursCriteres = session("idFonctionnelUs").as[String] :: valeursCriteres   without need to do exec { session => ...

thx
Reply all
Reply to author
Forward
0 new messages