1   /*
2    *  soapUI, copyright (C) 2004-2007 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of version 2.1 of the GNU Lesser General Public License as published by 
6    *  the Free Software Foundation.
7    *
8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
9    *  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  
14  package com.eviware.soapui.impl.wsdl.support;
15  
16  import javax.wsdl.BindingOperation;
17  import javax.wsdl.Definition;
18  
19  import com.eviware.soapui.impl.wsdl.WsdlInterface;
20  import com.eviware.soapui.impl.wsdl.WsdlOperation;
21  import com.eviware.soapui.impl.wsdl.WsdlProject;
22  import com.eviware.soapui.impl.wsdl.WsdlRequest;
23  import com.eviware.soapui.impl.wsdl.WsdlSubmitContext;
24  import com.eviware.soapui.impl.wsdl.support.wsdl.WsdlImporter;
25  import com.eviware.soapui.impl.wsdl.support.wsdl.WsdlUtils;
26  import com.eviware.soapui.model.iface.Submit;
27  import com.eviware.soapui.support.TestCaseWithJetty;
28  
29  public class WsdlImporterTestCase extends TestCaseWithJetty
30  {
31  	public void testOneWayOperationImport() throws Exception
32     {
33     	WsdlProject project = new WsdlProject();
34     	WsdlInterface[] wsdls = WsdlImporter.getInstance().importWsdl( 
35     			project, "http://localhost:8082/testonewayop/TestService.wsdl");
36     	
37     	assertEquals( 1, wsdls.length );
38     	
39     	WsdlInterface iface = wsdls[0];
40     	
41     	assertNotNull( iface );
42     	assertEquals( 2, iface.getOperationCount() );
43  
44     	WsdlOperation operation = (WsdlOperation) iface.getOperationAt( 0 );
45     	
46     	assertNotNull( operation );
47     	assertEquals( "GetDefaultPageData", operation.getName() );
48     	
49     	Definition definition = WsdlUtils.readDefinition( "http://localhost:8082/testonewayop/TestService.wsdl" );
50     	
51     	BindingOperation bindingOperation = operation.findBindingOperation( definition );
52     	assertNotNull( bindingOperation );
53     	assertEquals( bindingOperation.getName(), operation.getBindingOperationName() );
54     	
55     	assertNull( operation.getOutputName() );
56     	
57     	WsdlRequest request = operation.addNewRequest( "TestRequest" );
58     	assertNotNull( request );
59  
60     	String requestXml = operation.createRequest( true );
61     	assertNotNull( requestXml );
62     	
63     	request.setRequestContent( requestXml );
64     	
65     	Submit submit = request.submit( new WsdlSubmitContext( null ), false );
66     	
67     	assertTrue( submit.getResponse().getContentAsString().indexOf( "Error 404 NOT_FOUND" ) > 0 );
68     }
69  }