Forum Discussion

clarksj71's avatar
clarksj71
Occasional Contributor
13 years ago

New to Groovy Scripting

I'm trying to get the Hello World sample script to work in SoapUI. I was trying to get it to output to the log output, but the value returning is null. Here the script. Any ideas?

class Greet {
def name
Greet(who) { name = who[0].toUpperCase() +
who[1..-1] }
def salute() { println "Hello $name!" }
}

g = new Greet('world') // create object
g.salute() // output "Hello World!"
log.info g.salute()


Here the log output:

Thu Dec 06 10:01:31 CST 2012:INFO:null

any ideas?

2 Replies

  • MartinS's avatar
    MartinS
    Occasional Contributor
    Hi,

    i dont know if its exactly what u need but this works:

    class Greet {
    def name;
    def log
    Greet(who,log){
    this.name = who[0].toUpperCase() + who[1..-1] ;
    this.log = log;
    }
    def salute(){
    log.info "Hello "+ name+"!";
    }
    }

    g = new Greet('world', log);
    g.salute();


    MartinS
  • clarksj71's avatar
    clarksj71
    Occasional Contributor
    I was just trying to get the code to output to the soap ui "Log Output" in the gui. You code works, so now I'll go figure out exactly what was messed up. Thank you so much.