Forum Discussion

John_Overbaugh's avatar
John_Overbaugh
Occasional Contributor
17 years ago

Coding shared soapUI groovy scripts in Eclipse

Hopefully the last low-level question... I'm moving most of my Groovy scripts into a shared Groovy script. In the process, I decided to add another layer of complexity, and code these scripts in Eclipse. So I've installed Eclipse, added the Groovy plug in, and created a new Java project with Groovy scripts.

I was able to muddle through referencing the groovy.sql.Sql. I've also seen that, in order to log, I need to pass a reference to the log:
soapUI.lds.org.qa.tools.PersonInfoSharedScripts.CleanUpPerson('AccountID0002', log)

My script is erroring, though, when I try to call it with (text, log). The error is :
java.lang.VerifyError: (class: soapUI/lds/org/qa/tools/PersonInfoSharedScripts, method: CleanUpPerson signature: (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;) Incompatible type for getting or setting field

I've attached the .groovy file I'm using. What am I doing wrong, that I cannot reference it?

One general question: is there any easy way to debug shared scripts? I'm guessing which line is erroring, and why... I'm debugging blind. It'd be great to be able to debug and step through the code, or at least see what's happening and where the error is occuring.

Thinking forward, are there any other libraries/jars I should reference proactively (for things like accessing XML results, throwing exceptions on error, etc.)?

JTO

4 Replies

  • omatzura's avatar
    omatzura
    Super Contributor
    Hi John,

    I think you need to wrap your method in a class instead, something like

    package john.overbaugh.utils

    public class DBUtils
    {
        def static CleanUpPerson( AccountID, log )
        {
            ...
        }
    }

    which you can then call with

    john.overbaugh.utils.DBUtils.CleanUpPerson( "123", log )

    Hope this helps!

    regards,

    /Ole
    eviware.com
  • John_Overbaugh's avatar
    John_Overbaugh
    Occasional Contributor
    Hey Ole... Yeah, I actually have it wrapped up in a class (I neglected to copy/past that info my attachment) so that can't be the problem. Is there any way to 'debug' a script once it's been moved to a central location?

    Here's my class:
    class PersonInfoSharedScripts
    {
    def log
    def AccountID

      def static CleanUpPerson(AccountID, log)
      {
      def db = Sql.newInstance('jdbc:oracle:thin:@server:1234:db', 'username', 'password', 'oracle.jdbc.OracleDriver')

    // If the AccountID exists, we need to delete it for cleanliness
    // conditional if - on whether there's anything in the first cell of the first row'
      def myString
    this.AccountID = AccountID

    // if (db.eachRow("SELECT AccountUserName FROM TABLE WHERE accountid = 'AccountID0002'"){ row -> log.info(row[0])}) {
      db.eachRow("SELECT AccountUserName FROM TABLE WHERE accountid = 'AccountID0002'")
      { row -> (myString = row[0])}
     
      if (myString)
      {
      // IF WE GOT HERE, WE FOUND AT LEAST ONE INSTANCE OF AccountID0002
      log.info("AccountID found - will delete it now")

      // first, delete all entries in sperson_sideaccountusername related to accoutID0002
      // this is a complex query - nestling a query to get the fsperson.id value within the delete state
      log.info("  deleting sidetable entries")
      db.execute("DELETE FROM fsperson_sidetable WHERE sperson_id = (select id from sperson where AccountID = 'AccountID0002')")

      // next, delete the row from auth_table where accountid = 'AccountID0002'
      log.info("  deleting entries in auth_table")
      db.execute("DELETE FROM auth_table where username = (select accountusername from person where accountid = 'AccountID0002')")

      // next, delete the entire row in the SPERSON table
      log.info("  deleting entries from person")
      db.execute("DELETE FROM person WHERE accountid = 'AccountID0002'")
      }

      else
      {
      log.info("AccountID not found - proceed to next step")
      }
      }
    }
  • John_Overbaugh's avatar
    John_Overbaugh
    Occasional Contributor
    OK, after beating my head against a wall on this for four hours, I rewrote the method with a different name. It works now. ?? I don't get it, but I'm moving ahead.
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi John,

    sorry for not replying earlier, please let us know if you bump into this again!

    regards,

    /Ole
    eviware.com