Cherry
Cherry

Reputation: 33618

How test soap based application with mock?

I have 2 web applications which have web services. Suppose application One have 3 web methods and application Second app have only 1 web method which can return different results. Also all webmethods from app One call web method in app Second.

The goal is creation integration test for application One.

I can create soapui tests for each webmethod in app One and also add mock of Second app. But when tests for each method executes in parallel I must "tell" to mock "now you return that data, but now thow an Exception". I need that mock be able to recognize when it receive request for Second app from 1,2 or 3 web method in app One. When I create request for app One I cannot control it sub-request to app Second. So to distinguish them I must (somehow) mark entire requst chain:

Request1 -> App One (WebMethod1) -> SubRequest1 -> Mock

For example if I can add Http header in Request1 which also can be retranslated to SubRequest1 the Mock will analyze this header and return/throw what I want. But actually HttpHeader do not retranslated. I can add java code for this, but code only for test is not very good.

Is there any approach or way to do that testing? This is simplified example, in real situation there are more that 2 communicated applications and more web methods.

IMPORTANT

This question is not about Unit tests or EasyMock, PowerMock and Mockito. These frameworks related to unit tests, but I want integration testing.

Upvotes: 1

Views: 1654

Answers (1)

Pantelis Natsiavas
Pantelis Natsiavas

Reputation: 5369

This tutorial could give you a lead on how to mock up a service using JUnit and Mockito.

Hope I helped!

Upvotes: 1

Related Questions