jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Glenn Caccia <gacac...@yahoo.com>
Subject Groovy GString incompatibility?
Date Mon, 23 Dec 2013 02:58:58 GMT


I have a JMeter test (2.10) that uses a JSR223 script sampler.  The groovy script was working
fine.  I then learned about GStrings and decided to convert the script to use that.  After
making the change, the groovy script fails to compile in JMeter (compiles fine in groovy console).

Here's an example, this will fail in JMeter:

==============================================================

import groovy.sql.Sql

def projectName = vars.get("projectName")
def sql = Sql.newInstance("jdbc:sqlserver://SERVERNAME\\DBINSTANCE:PORT", "reporter", "reporter",
"com.microsoft.sqlserver.jdbc.SQLServerDriver")

//def row = sql.firstRow("select projectId from projects where projectName = '" + projectName
+ "'")
def row = sql.firstRow("select projectId from projects where projectName = '${projectName}'")
==============================================================

The JMeter log will report an unexpected character on the line for "def sql =" at character
"\" in "SERVERNAME\\DBINSTANCE:PORT".

If I uncomment the 2nd to last line and comment out the last line, then the script runs fine
in JMeter.  Am I missing something or is this a defect in JMeter?

The error dump looks like:

2013/12/22 18:40:41 ERROR - jmeter.protocol.java.sampler.JSR223Sampler: Problem in JSR223
script javax.script.ScriptException: org.codehaus.groovy.control.MultipleCompilationErrorsException:
startup failed:
Script9.groovy: 5: unexpected char: '\' @ line 5, column 60.


    at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:152)
    at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:216)
    at org.apache.jmeter.util.JSR223TestElement.processFileOrScript(JSR223TestElement.java:202)
    at org.apache.jmeter.protocol.java.sampler.JSR223Sampler.sample(JSR223Sampler.java:70)
    at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:429)
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:257)
    at java.lang.Thread.run(Thread.java:662)
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message