ahsu
17 years agoOccasional 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
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