Forum Discussion

dgiger's avatar
dgiger
New Contributor
12 years ago

catch timeout of Mock Response TestStep

Dear SoapUI community,

I would like to test an async callback is NOT triggered within the timeout that was specified in the Mock Response TestStep.
The testcase contains 2 TestSteps:
1 - Test Request TestStep: synchronous invocation of a service that will trigger an asynchronous callback based on some conditions.
2 - Mock Response TestStep: Callback handler

The problem is that the timeout of the Mock Response is stopping the TestCase.
The goal would be to assert that there was no message received by the Mock Response TestStep.

I did try to do this in GroovyScript using the MockTestRunner, but it is blocking the TestCase.
Any idea on how to achieve this?
Maybe with 2 GroovyScripts, one starting the MockTestRunner in a seperate thread and the other to check the status of the MockTest and terminate the thread?

I'm using SoapUI 4.5.2 on Windows XP.
  • dgiger's avatar
    dgiger
    New Contributor
    Hi Rao,

    Thank you for the link. I am totally aware of the functionality of the Mock TestStep. The problem is that SoapUI does not support this kind of negative test scenario out of the box.
    From the description it's clear that the timeout is stopping the execution of the TestSteps:

    Timeout - Fails the MockResponse Step if no request has been received within the specified number of milliseconds. Specifying 0 will wait indefinitely.

    I also have no chance to handle it in a script of the MockResponse - as this is only triggered once there is a request.

    What I want to achieve is to wait for ~1000ms (timeout) and if nothing was received during that time - the TestStep shall be threated as successfull.

    Maybe I have to set the timeout to 0 (while setting the StartStep to the TestStep that could trigger the unwanted request) and stop the MockResponse TestStep in another groovy TestStep after a short sleep (timeout). I'll give it a try and report back my findings.
  • Hi,

    The idea of having two Groovy test steps, as you suggested in your first post in this thread, is definitely worth trying.

    Kind regards,
    Manne Fagerlind
    SmartBear Stockholm
  • dgiger's avatar
    dgiger
    New Contributor
    Hi,

    I did manage to get it working with 2 groovy scripts and I would like to share it. Maybe someone find it useful or even has a better idea on how to make it working.

    I needed 2 groovy scripts, as I wanted the MockService to start listening before the actual TestStep (the one that should NOT invoke a webservice call) is executing.

    Start Groovy Script TestCase:
    def runner = testRunner.testCase.testSuite.project.mockServices["TEST MockService"].start()
    runner.clearResults()
    log.info "mock service started"


    Stop Groovy Script TestCase:
    def runner = testRunner.testCase.testSuite.project.mockServices["TEST MockService"].getMockRunner()
    assert runner.isRunning() == true

    sleep(1000)
    def resultCount = runner.getMockResultCount()
    log.info "result count : " + resultCount

    runner.stop()
    log.info "mock service stopped"
    assert resultCount == 0


    Between the 2 Groovy Scripts the actual TestStep is executed.

    Best Regards,
    -dg-
  • Hi ,

    I very new to SoapUI, when i trying to send request, i'm getting below error, Could you please help me out of this.

    Thu Oct 24 20:52:04 BST 2013:DEBUG:HttpConnectionManager.getConnection: config = HostConfiguration[host=https://bt-dev.onbmc.com], timeout = 0
    Thu Oct 24 20:52:04 BST 2013:DEBUG:Getting free connection, hostConfig=HostConfiguration[host=https://bt-dev.onbmc.com]
    Thu Oct 24 20:52:08 BST 2013:DEBUG:Freeing connection, hostConfig=HostConfiguration[host=https://bt-dev.onbmc.com]
    Thu Oct 24 20:52:08 BST 2013:DEBUG:Notifying no-one, there are no waiting threads
    Thu Oct 24 20:52:08 BST 2013:ERROR:Exception in request: java.lang.Exception: java.net.ConnectException: Connection refused: connect
    Thu Oct 24 20:52:08 BST 2013:ERROR:An error occured [java.net.ConnectException: Connection refused: connect], see error log for details
    Thu Oct 24 20:52:08 BST 2013:INFO:Error getting response for [PortSoapBinding.Create:Request 1]; java.lang.Exception: java.net.ConnectException: Connection refused: connect


    Thanks in advance
  • Does your request validate against the WSDL?

    Also does it have the right Soap Action?

    Thanks,
    Michael Giller
    SmartBear Software