Forum Discussion

Erwan92's avatar
13 years ago

getMockResultAt() does not work for the first result

Hello,

Using:
SoapUI Pro 4.5.1
Build [internal]
Build Date 2012/09/27 14:05

Using groovy, I am trying to get the RequestContent of a mock runner using this statement:
testRunner.testCase.testSuite.project.mockServices[myMockService].getMockRunner().getMockResultAt(myIndex).getMockRequest().getRequestContent()


My scenario is the following
step1: start the mock service
step2: call the mock service
step3: get the request
step4: clear the mock runner result

The problem is that the statement above does not work, the getMockResultAt(int index) of WsdlMockRunner does not seem to work for the first result.
if myIndex = 0 I got the error:
java.lang.NullPointerException: Cannot invoke method getMockRequest() on null object java.lang.NullPointerException: Cannot invoke method getMockRequest() on null object error
if myIndex = 1 I got the error:
java.lang.IndexOutOfBoundsException: Invalid index:1, size=1

The problem seems to occur only for the first mock result. If my scenario is:
step1: start the mock service
step2: call the mock service
step3: call the mock service
step4: get the request
step5: clear the mock runner result

then
myIndex = 1
testRunner.testCase.testSuite.project.mockServices[myMockService].getMockRunner().getMockResultAt(myIndex).getMockRequest().getRequestContent()

will return the request sent at step 3.

Is that a known issue or am I doing something wrong here?

I have a workaround here, which is to introduce a dummy call (step 2 of the second scenario), so this is not critical.

Thank you.
No RepliesBe the first to reply