Forum Discussion

tomaszarmata's avatar
tomaszarmata
Contributor
10 years ago

Script library. Problem with following guide

Hello,

Im using Ready! API 1.4.1, SoapUI NG PRO.

Im trying to build my script library using guide - http://www.soapui.org/scripting---properties/scripting-and-the-script-library.html. But i have some problem.

 

Path to library script folder in preferences: D:\SOAPUI\scripts

Path to file: D:\SOAPUI\scripts\soapui\demo\Callee.groovy

File content:

package soapui.demo

//Callee.groovy
class Callee {
  String hello() {
     return "hello, world"
  }
  
  def static salute( who, log ) { log.info "Hello again $who!" }
}

Groovy script step content:

//Caller.groovy
c = new Callee()
log.info c.hello("Mike")

When Im trying to run this step i got error:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script3.groovy: 2: unable to resolve class Callee @ line 2, column 5. c = new Callee() ^ org.codehaus.groovy.syntax.SyntaxException: unable to resolve class Callee @ line 2, column 5. at org.codehaus.groovy.ast.ClassCodeVisitorSupport.addError(ClassCodeVisitorSupport.java:146) at org.codehaus.groovy.control.ResolveVisitor.resolveOrFail(ResolveVisitor.java:261) at org.codehaus.groovy.control.ResolveVisitor.resolveOrFail(ResolveVisitor.java:271) at org.codehaus.groovy.control.ResolveVisitor.transformConstructorCallExpression(ResolveVisitor.java:1046) at org.codehaus.groovy.control.ResolveVisitor.transform(ResolveVisitor.java:705) at org.codehaus.groovy.control.ResolveVisitor.transformBinaryExpression(ResolveVisitor.java:1014) at org.codehaus.groovy.control.ResolveVisitor.transform(ResolveVisitor.java:699) at org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitExpressionStatement(ClassCodeExpressionTransformer.java:139) at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40) at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:35) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:163) at org.codehaus.groovy.control.ResolveVisitor.visitBlockStatement(ResolveVisitor.java:1317) at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:101) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:112) at org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitConstructorOrMethod(ClassCodeExpressionTransformer.java:50) at org.codehaus.groovy.control.ResolveVisitor.visitConstructorOrMethod(ResolveVisitor.java:200) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:123) at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1083) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:50) at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1260) at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:175) at org.codehaus.groovy.control.CompilationUnit$11.call(CompilationUnit.java:648) at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:928) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:590) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:539) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:297) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:267) at groovy.lang.GroovyShell.parseClass(GroovyShell.java:692) at groovy.lang.GroovyShell.parse(GroovyShell.java:704) at groovy.lang.GroovyShell.parse(GroovyShell.java:740) at groovy.lang.GroovyShell.parse(GroovyShell.java:731) at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.compile(SoapUIGroovyScriptEngine.java:138) at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:89) at com.eviware.soapui.support.scripting.groovy.SoapUIProGroovyScriptEngineFactory$SoapUIProGroovyScriptEngine.run(SoapUIProGroovyScriptEngineFactory.java:76) at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:155) at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:263) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) 1 error

What am I doing wrong?

  • You see that because of incorrect signature and with added complexity as package being used. 

     

    There is hello() method without any parameters, and you are using with arguments.

     

    Right way to call is

    import soapui.demo.Callee
    def say = new Callee() log.info say.hello()

    If you want to salute

    import static soapui.demo.Callee.salute
    salute("John", log)

     

  • nmrao's avatar
    nmrao
    Champion Level 3

    You see that because of incorrect signature and with added complexity as package being used. 

     

    There is hello() method without any parameters, and you are using with arguments.

     

    Right way to call is

    import soapui.demo.Callee
    def say = new Callee() log.info say.hello()

    If you want to salute

    import static soapui.demo.Callee.salute
    salute("John", log)