Forum Discussion

marco's avatar
marco
New Contributor
16 years ago

stateful mock service

Hello,

I would like to create a mock service which has states and depending on these states creates new requests by itself. Unfortunately i did not find forum topic about such a scenario.

Our web service is event based, which means on every request the WS answers with a ACK response. After this ACK it has to create a new request and sending back to where the first request came. This means, that the mock service is sometimes a client and sometimes a server (i know a bit a "strange" setup).

Is there a way to create such a scenario?

greetings & thanks
marco

2 Replies

  • marco's avatar
    marco
    New Contributor
    from the user guide:
    context - an instance of MockRunContext  that can hold dynamically user-defined properties. The context is service scoped, i.e. shared between all MockOperations/MockResponses for a MockService during its lifetime. Since this object implements the Map interface it can be accessed using Groovy's built-in collection support (see example screenshot above)


    So i think this one i could use to store the state of the service.

    So the last issue to solve is to have a mock service which sends WS request by its self without incoming requests
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi Marco,

    what you can do is create a TestCase containing the request(s) you want to send after receiving the request to your MockService, then in the MockResponse Script (tab at the bottom) for your response you can trigger this testcase (wrap it in a SwingUtilities.invokeLater call) which will send your requests as desired.

    Does that make sense?

    regards!

    /Ole
    eviware.com