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.support;
14:
15: import javax.wsdl.BindingOperation;
16: import javax.wsdl.Definition;
17:
18: import com.eviware.soapui.impl.wsdl.WsdlInterface;
19: import com.eviware.soapui.impl.wsdl.WsdlOperation;
20: import com.eviware.soapui.impl.wsdl.WsdlProject;
21: import com.eviware.soapui.impl.wsdl.WsdlRequest;
22: import com.eviware.soapui.impl.wsdl.WsdlSubmitContext;
23: import com.eviware.soapui.impl.wsdl.support.wsdl.WsdlImporter;
24: import com.eviware.soapui.impl.wsdl.support.wsdl.WsdlUtils;
25: import com.eviware.soapui.model.iface.Submit;
26: import com.eviware.soapui.support.TestCaseWithJetty;
27:
28: public class WsdlImporterTestCase extends TestCaseWithJetty {
29: public void testOneWayOperationImport() throws Exception {
30: WsdlProject project = new WsdlProject();
31: WsdlInterface[] wsdls = WsdlImporter.getInstance().importWsdl(
32: project,
33: "http://localhost:8082/testonewayop/TestService.wsdl");
34:
35: assertEquals(1, wsdls.length);
36:
37: WsdlInterface iface = wsdls[0];
38:
39: assertNotNull(iface);
40: assertEquals(2, iface.getOperationCount());
41:
42: WsdlOperation operation = (WsdlOperation) iface
43: .getOperationAt(0);
44:
45: assertNotNull(operation);
46: assertEquals("GetDefaultPageData", operation.getName());
47:
48: Definition definition = WsdlUtils
49: .readDefinition("http://localhost:8082/testonewayop/TestService.wsdl");
50:
51: BindingOperation bindingOperation = operation
52: .findBindingOperation(definition);
53: assertNotNull(bindingOperation);
54: assertEquals(bindingOperation.getName(), operation
55: .getBindingOperationName());
56:
57: assertNull(operation.getOutputName());
58:
59: WsdlRequest request = operation.addNewRequest("TestRequest");
60: assertNotNull(request);
61:
62: String requestXml = operation.createRequest(true);
63: assertNotNull(requestXml);
64:
65: request.setRequestContent(requestXml);
66:
67: Submit submit = request.submit(new WsdlSubmitContext(null),
68: false);
69:
70: assertTrue(submit.getResponse().getContentAsString().indexOf(
71: "Error 404 NOT_FOUND") > 0);
72: }
73: }
|