Forum Discussion

StevenC's avatar
StevenC
Contributor
11 years ago

Setting up reusable libraries is not working

I went down to copying the demo you have here ...

http://www.soapui.org/Scripting-Properties/scripting-and-the-script-library.html


and it is still not working.

I have my script path set to ...
C:\clu-QAAutomation\scripts


I can see that SOAP UI Pro is picking up the scripts in the log...

Fri Apr 11 14:19:37 EDT 2014:INFO:C:\clu-QAAutomation\scripts\soapui\demo\Callee.groovy is new or has changed, reloading...
Fri Apr 11 14:19:37 EDT 2014:INFO:Resetting groovy class cache due to 1 modified file
Fri Apr 11 14:19:37 EDT 2014:INFO:C:\clu-QAAutomation\scripts\soapui\demo\Callee.groovy is new or has changed, reloading...
Fri Apr 11 14:19:37 EDT 2014:INFO:Resetting groovy class cache due to 1 modified file


As the demo states the contents of Callee.groovy is ...

package soapui.demo



//Callee.groovy why doesn't this work?

class Callee {

String hello() {

return "hello, world"

}

def static salute( who, log ) { log.info "Hello again $who!" }

}


Again as with the Demo I have a groovy test step setup with the following code...

c = new Callee()

log.info c.hello("Mike")



When I run it I get the following error...

Fri Apr 11 14:19:42 EDT 2014:ERROR:An error occurred [No match found], see error log for details
Fri Apr 11 14:19:42 EDT 2014:ERROR:An error occurred [startup failed:
Script3.groovy: 1: unable to resolve class Callee
@ line 1, column 5.
c = new Callee()
^
org.codehaus.groovy.syntax.SyntaxException: unable to resolve class Callee
@ line 1, column 5.
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.addError(ClassCodeVisitorSupport.java:146)
at org.codehaus.groovy.control.ResolveVisitor.resolveOrFail(ResolveVisitor.java:222)
at org.codehaus.groovy.control.ResolveVisitor.resolveOrFail(ResolveVisitor.java:232)
at org.codehaus.groovy.control.ResolveVisitor.transformConstructorCallExpression(ResolveVisitor.java:969)
at org.codehaus.groovy.control.ResolveVisitor.transform(ResolveVisitor.java:646)
at org.codehaus.groovy.control.ResolveVisitor.transformBinaryExpression(ResolveVisitor.java:937)
at org.codehaus.groovy.control.ResolveVisitor.transform(ResolveVisitor.java:640)
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:1240)
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:166)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:123)
at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1055)
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:50)
at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1183)
at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:141)
at org.codehaus.groovy.control.CompilationUnit$10.call(CompilationUnit.java:632)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:912)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:574)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:523)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:279)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:258)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:613)
at groovy.lang.GroovyShell.parse(GroovyShell.java:625)
at groovy.lang.GroovyShell.parse(GroovyShell.java:652)
at groovy.lang.GroovyShell.parse(GroovyShell.java:643)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.compile(SoapUIGroovyScriptEngine.java:148)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:93)
at com.eviware.soapui.support.scripting.groovy.SoapUIProGroovyScriptEngineFactory$SoapUIProGroovyScriptEngine.run(SourceFile:89)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:149)
at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:274)
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
], see error log for details


As near as I can tell from the Demo this is set up correctly so what am I doing wrong?

This is happening with SoapUI Pro 4.6.2

2 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    Did you import the Callee class in your groovy code that uses the Callee class?

    import soapui.demo.Callee;




    Regards,
    Marcus
    SmartBear Support
  • Nope, being relatively new to soapui I assumed based on the text of your help page that importing those objects was implicitly handled. You really should update your help page to make it clear that the classes need to be imported.

    Specifically this page

    http://www.soapui.org/Scripting-Propert ... brary.html

    The text here...

    Now let's setup SoapUI Pro to load up your Groovy library. Set File > Preferences > SoapUI Pro tab > Script Library. So I would set that to "C:\GroovyLib" in my example. Then restart SoapUI Pro to pick up the library script.
    Now if we create a Groovy Script Step in a TestCase, we can use the above class with the following:
    1.
    //Caller.groovy
    2.
    c = new Callee()
    3.
    log.info c.hello("Mike")
    Running this from within the Groovy Editor will show the following in the Groovy Editors log:
    Tue Dec 31 10:49:05 EST 2013:INFO:hello, Mike
    We can also call the static salute method:


    The bolded section combined with not including the import statement in the code block implies that the import is handled internally