cancel
Showing results for 
Search instead for 
Did you mean: 

Getting error for the Groovy Script

Occasional Contributor

Getting error for the Groovy Script

Groovy script i tried to run is

def values = context.getProperty( "values" )
def index = context.getProperty( "index" )

def str = values[index]
def ix = str.indexOf( "," )

def props = testRunner.testCase.getTestStepByName( "Properties" )
def resultCount = props.getPropertyValue( "ResultCount" )
def count = str.substring( ix+1 )
def year = props.getPropertyValue( "year" )

if( count > resultCount )
{
  throw new Exception( "not enough hits for year [" + year +
                        "], expected " + count + ", got " + resultCount )
}
else
{
  log.info( "got " + resultCount + " hits for [" + year + "], required " + count )
  if( ++index < values.size() )
  {
      context.setProperty( "index", index )
      testRunner.gotoStepByName( "Init Run" )
  }
  else
  {
      log.info ( "Finished TestCase, tested " + values.size() + " values" )
  }
}



and i am getting the following error




org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, Script6.groovy: 1: unexpected token: @ line 1, column 1.org.codehaus.groovy.syntax.SyntaxException: unexpected token: @ line 1, column 1. at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:83) at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:239) at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:143) at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:772) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:438) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:271) at groovy.lang.GroovyShell.parseClass(GroovyShell.java:488) at groovy.lang.GroovyShell.parse(GroovyShell.java:500) at groovy.lang.GroovyShell.parse(GroovyShell.java:480) at groovy.lang.GroovyShell.parse(GroovyShell.java:539) at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.compile(SoapUIGroovyScriptEngine.java:87) at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:58) at com.eviware.soapui.support.scripting.groovy.SoapUIProGroovyScriptEngineFactory$SoapUIProGroovyScriptEngine.run(SourceFile:51) at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:140) at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.run(WsdlTestCaseRunner.java:185) at com.eviware.soapui.impl.wsdl.loadtest.WsdlLoadTestRunner$TestCaseRunner.run(WsdlLoadTestRunner.java:401) at java.lang.Thread.run(Unknown Source) Caused by: Script6.groovy:1:1: unexpected token: at org.codehaus.groovy.antlr.parser.GroovyRecognizer.compilationUnit(GroovyRecognizer.java:484) at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:74) ... 16 more 1 error startup failed, Script6.groovy: 1: unexpected token: @ line 1, column 1.org.codehaus.groovy.syntax.SyntaxException: unexpected token: @ line 1, column 1. at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:83) at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:239) at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:143) at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:772) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:438) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:271) at groovy.lang.GroovyShell.parseClass(GroovyShell.java:488) at groovy.lang.GroovyShell.parse(GroovyShell.java:500) at groovy.lang.GroovyShell.parse(GroovyShell.java:480) at groovy.lang.GroovyShell.parse(GroovyShell.java:539) at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.compile(SoapUIGroovyScriptEngine.java:87) at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:58) at com.eviware.soapui.support.scripting.groovy.SoapUIProGroovyScriptEngineFactory$SoapUIProGroovyScriptEngine.run(SourceFile:51) at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:140) at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.run(WsdlTestCaseRunner.java:185) at com.eviware.soapui.impl.wsdl.loadtest.WsdlLoadTestRunner$TestCaseRunner.run(WsdlLoadTestRunner.java:401) at java.lang.Thread.run(Unknown Source) Caused by: Script6.groovy:1:1: unexpected token: at org.codehaus.groovy.antlr.parser.GroovyRecognizer.compilationUnit(GroovyRecognizer.java:484) at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:74) ... 16 more 1 error


and i am not seeing any logs in the groovy log.
Please, help me in this to resolve ASAP.


Thanks in advance for your response
4 REPLIES 4
Super Contributor

Re: Getting error for the Groovy Script

Hi,

hmm.. this compiles ok for me.. what is your system locale? If you copy-pasted this, try pasting to notepad first to get rid of any "unusual" characters!?

regards,

/Ole
eviware.com
Occasional Contributor

Re: Getting error for the Groovy Script

Hi Ole,

Thanks for your reply.

but still i am facing the same error.
I am attaching the script and the error screen shot .

And i am unable to see any logs in the groovy log.

Please , tell me where i am missing exactly.
Super Contributor

Re: Getting error for the Groovy Script

Hi,

can you double-click the error entry in the LoadTest log and post the detailed error information?

What happens if you run the TestCase from the TestCase editor.. same error?

regards,

/Ole
eviware.com
Occasional Contributor

Re: Getting error for the Groovy Script

I am getting the same error in the test case also.

Below is the test case log.

Test started at 2008-04-22 20:00:50.903
Step 1 [GetData] OK: took 7 ms
Step 2 [Properties] OK: took 0 ms
Step 3 [Init] OK: took 0 ms
Step 4 [Set Year Args] OK: took 16 ms
-> Performed transfer [year]
Step 5 [GetGoodFridayRequest] OK: took 620 ms
Step 6 [Get Result] OK: took 0 ms
-> Performed transfer [year]
Step 7 [Validate and Loop] FAILED: took 0 ms
-> startup failed, Script3.groovy: 1: unexpected token: < @ line 1, column 1.org.codehaus.groovy.syntax.SyntaxException: unexpected token: < @ line 1, column 1.
at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:83)
at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:239)
at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:143)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:772)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:438)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:271)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:488)
at groovy.lang.GroovyShell.parse(GroovyShell.java:500)
at groovy.lang.GroovyShell.parse(GroovyShell.java:480)
at groovy.lang.GroovyShell.parse(GroovyShell.java:539)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.compile(SoapUIGroovyScriptEngine.java:87)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:58)
at com.eviware.soapui.support.scripting.groovy.SoapUIProGroovyScriptEngineFactory$SoapUIProGroovyScriptEngine.run(SourceFile:51)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:140)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.run(WsdlTestCaseRunner.java:185)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: Script3.groovy:1:1: unexpected token: <
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.compilationUnit(GroovyRecognizer.java:484)
at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:74)
... 20 more

1 error

TestCase finished with status [FINISHED], time taken = 643


Please find the attachment for the error.
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors