Forum Discussion

mtroost's avatar
mtroost
Occasional Contributor
10 years ago

After executing a systemcall , the waitFor() method hangs

This piece of groovy is used in an assertion on a teststep. It does make a systemcall to execute unzip. The cmd itself works fine. the call cmd.execute() works fine and the unzip command is properly executed by the OS.
The problem is the next statement "results.waitFor()" because SoapUI hangs. It doesnt do anything but you cant click on anything except drag the window of the assertion code editor. The canvas however is not painted anymore, all buttons dont work and killing the process is the only way to get rid of it. Commenting out the waitFor line resolves the problem but then you cant test the result of the systemcall.

 

def unzipPath = "C:\\zip\\unzip.exe"
def cmd = "$unzipPath \"$zipFileName\" -d \"${groovyUtils.projectPath}\""
log.info "cmd=$cmd"
def results = cmd.execute()
results.waitFor()
log.info "result is "+results.exitValue()
//assert results.exitValue() == 0
//results.destroy() 

How can I test the exitValue?

5 Replies

  • michel2016's avatar
    michel2016
    New Contributor

    I also got the same problem.

     

    Did you found any solution?

    The system hangs each time (Currently using 5.1.3)

     

    // Properties
    def testSuite = 'testsuite.html'
    
    //Code
    def projectPath = context.expand('${projectDir}')
    def seleniumTestSuite = new File(projectPath, testSuite).toString()
    seleniumTestSuite = "\"$seleniumTestSuite\""
    def reportPath = new File(projectPath, 'report').toString()
    reportPath = "\"$reportPath\""
    def baseUrl = context.expand('${#Project#home}')
    
    def process = "cmd /c java -jar ext\\selenese-runner.jar --baseurl \"$baseUrl\" --html-result $reportPath $seleniumTestSuite".execute()
    process.waitFor()
    
    def exitValue = process.exitValue()
    //System hangs
    log.info(exitValue )
    • nmrao's avatar
      nmrao
      Champion Level 3
      Just curious to know, when you can run the same command using a batch file / command-line directly, any reason for using from soapUI?
      • michel2016's avatar
        michel2016
        New Contributor

        Hi Rao,

         

        Of course it is possible to run the test from command line. But we want the UI testing be a part of our whole integration test performed by SOAPUI (Auto runned by Jenkins and Maven)

         

        So we also use SOAPUI to fill the DB (by Groovy). Run Rest and Soap calls and now even run UI testing (by Groovy).

         

        In the meantime we found the solution:

         

        def process = "java -jar ext\\selenese-runner.jar --baseurl \"$baseUrl\" --strict-exit-code --timeout 2500 --html-result $reportPath $seleniumTestSuite".execute()
        
        process.waitForProcessOutput()
        
        def exitValue = process.exitValue()
        
        assert (exitValue == 0), "Test failed see report dir for more info about the failed tests ($reportPath)"

        process.waitForProcessOutput()  did the trick!