Ask a Question

Global Groovy scripts usage question

alibaba82
Super Contributor

Global Groovy scripts usage question

Hello,
I am trying to understand how the global groovy feature works but am having some problem. I tried the example and it worked fine. I then modified your Greet.groovy to the following.

package soapui.demo
class Greet
{
  def salute()
  {
log.info("testing")
  }
}

I then create a groovy script containing
def greet = new soapui.demo.Greet( "Ole", log )
greet.salute()

and the response has
'Hello Ole'

Shouldnt response have 'testing'

Also if i define greet as
def greet = new soapui.demo.Greet( )
I get groovy.lang.GroovyRuntimeException: Could not find matching constructor for: soapui.demo.Greet()

Shouldn't this be ok (based on my java knowledge)

THanks

Ali
8 REPLIES 8
omatzura
Super Contributor

Hi,

hmm.. when you save the updated Greet.groovy file, do you get a message in the soapui log that it has found the updated file and reloaded it?

regards,

/Ole
eviware.com
omatzura
Super Contributor

Hi again,

you probably got an error when soapUI tries to reload the file, since the log variable has not been defined/initialized for the class.. right?

regards,

/Ole
eviware.com
alibaba82
Super Contributor

So I am editing Greet.groovy through notepad. I do notice that when I changed the file in notepad to
package soapui.demo
class Greet
{
  def salute()
  {
log.info("testing")
  }
}

and save the file, soapUI log shows 
"Wed Jul 11 13:07:39 PDT 2007:INFO:C:\Program Files\eviware\soapUI-Pro-1.7.5-beta2\bin\scripts\Greet.groovy is new or has changed, reloading...
"
This is the last entry in the soapUI log. Nothing about 'found the updated file and reloaded it"
omatzura
Super Contributor

ok.. you should at least have gotten an error message.. let me see if I can reproduce..

regards,

/Ole
eviware.com
alibaba82
Super Contributor

I changed the greet.groovy code to

package soapui.demo
class Greet
{
def log;
Greet(log)
{this.log = log;}

def salute()
{
log.info("testing")
}
}

and still same thing in soapUI log. There is nothing in the 'error log'
omatzura
Super Contributor

Hi,

ok.. please check that soapUI is loading scripts from the correct path in the soapUI Pro Preferences Tab (it could be pointing at the the beta1 installation scripts..)

regards,

/Ole
eviware.com
alibaba82
Super Contributor

I already checked that. It is
C:\Program Files\eviware\soapUI-Pro-1.7.5-beta2\bin\scripts
omatzura
Super Contributor

ok.. and you changed your groovy script that calls the Greet class to

def greet = new soapui.demo.Greet(  log )
greet.salute()

?

/Ole
eviware.com
cancel
Showing results for 
Search instead for 
Did you mean: