01: /*
02: * soapUI, copyright (C) 2004-2007 eviware.com
03: *
04: * soapUI is free software; you can redistribute it and/or modify it under the
05: * terms of version 2.1 of the GNU Lesser General Public License as published by
06: * the Free Software Foundation.
07: *
08: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
09: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: * See the GNU Lesser General Public License for more details at gnu.org.
11: */
12:
13: package com.eviware.soapui.impl.wsdl.mocksuite;
14:
15: import com.eviware.soapui.impl.wsdl.WsdlInterface;
16: import com.eviware.soapui.impl.wsdl.WsdlOperation;
17: import com.eviware.soapui.impl.wsdl.WsdlProject;
18: import com.eviware.soapui.impl.wsdl.WsdlRequest;
19: import com.eviware.soapui.impl.wsdl.WsdlSubmitContext;
20: import com.eviware.soapui.impl.wsdl.mock.WsdlMockOperation;
21: import com.eviware.soapui.impl.wsdl.mock.WsdlMockResponse;
22: import com.eviware.soapui.impl.wsdl.mock.WsdlMockService;
23: import com.eviware.soapui.model.iface.Response;
24: import com.eviware.soapui.support.TestCaseWithJetty;
25:
26: public class MockServiceTestCase extends TestCaseWithJetty {
27: public void testMockOperation() throws Exception {
28: WsdlProject project = new WsdlProject();
29: WsdlInterface iface = project.importWsdl(
30: "http://localhost:8082/test8/TestService.wsdl", true)[0];
31:
32: WsdlMockService mockService = (WsdlMockService) project
33: .addNewMockService("MockService 1");
34:
35: mockService.setPort(9081);
36: mockService.setPath("/testmock");
37:
38: WsdlOperation operation = (WsdlOperation) iface
39: .getOperationAt(0);
40: WsdlMockOperation mockOperation = (WsdlMockOperation) mockService
41: .addNewMockOperation(operation);
42: WsdlMockResponse mockResponse = mockOperation
43: .addNewMockResponse("Test Response", true);
44: mockResponse.setResponseContent("Tjohoo!");
45:
46: mockService.start();
47:
48: iface.addEndpoint("/testmock");
49: WsdlRequest request = (WsdlRequest) operation.getRequestAt(0);
50:
51: request.setEndpoint("http://localhost:9081/testmock");
52: Response response = request.submit(new WsdlSubmitContext(null),
53: false).getResponse();
54:
55: assertEquals(response.getContentAsString(), mockResponse
56: .getResponseContent());
57: }
58: }
|