Hi,
I’m a new Gatling user, and trying to test a web application where all the request parameters need to be sent using custom encoding to the server. We have a java class that performs this custom encoding in our main application. I’m trying to include that same Java class into the Gatling project, so that I can just call the same encode method before sending the Gatling requests. I know that in theory this should work, because Scala classes should be able to call Java methods. I have another Scala project where this works fine already, and I don’t want to convert the whole encoder class to Scala.
So in my Gatling project the file structure is:
user-files/simulations/example/ExampleSimulation.scala
user-files/simulations/example/CustomParamEncoder.java
Inside of CustomParamEncoder.java:
package example;
public class CustomParamEncoder {
public static String encode(String paramsToEncode) {
// Do some encoding and return a new string
}
}
Inside of ExampleSimulation.scala:
package example
class ExampleSimulation extends Simulation {
// Setup code
val encodedParams = CustomParamEncoder.encode(“blah blah blah”)
// Finish setting up simulation
}
However, when I try to run this using gatling.sh I get the following error:
GATLING_HOME is set to /Users/zgarbowitz/dev/gatling
11:05:04.209 [ERROR] i.g.a.ZincCompiler$ - /Users/zgarbowitz/dev/gatling/user-files/simulations/example/ExampleSimulation.scala:9: not found: value CustomParamEncoder
11:05:04.211 [ERROR] i.g.a.ZincCompiler$ - CustomParamEncoder.encode(paramString)
11:05:04.212 [ERROR] i.g.a.ZincCompiler$ - ^
11:05:04.414 [ERROR] i.g.a.ZincCompiler$ - one error found
Compilation failed
Both files are in the same package. I’m doing my text editing in IntelliJ, and the IntelliJ auto-complete recognizes the class as being present just fine. But when I actually run it through gatling.sh it doesn’t recognize the symbol.
Has anyone else done something similar to this, or have any ideas for how to get the gatling compiler to recognize the java file? Is it possible it’s set to only consider scala files it finds in user-files, but not java files? Any help would be much appreciated.
Thanks,
Zack