1   package com.eviware.soapui.impl.wsdl;
2   
3   import java.io.File;
4   
5   import junit.framework.TestCase;
6   
7   import com.eviware.soapui.impl.wsdl.WsdlAttachmentPart;
8   import com.eviware.soapui.impl.wsdl.WsdlInterface;
9   import com.eviware.soapui.impl.wsdl.WsdlOperation;
10  import com.eviware.soapui.impl.wsdl.WsdlProject;
11  import com.eviware.soapui.impl.wsdl.WsdlRequest;
12  
13  public class AttachmentTestCase extends TestCase
14  {
15     public void test() throws Exception
16     {
17     	String wsdlUrl = new File( "src/test-resources/attachment-test.wsdl" ).toURL().toString();
18     	WsdlProject project = new WsdlProject();
19     	WsdlInterface iface = project.importWsdl( wsdlUrl, false )[0];
20  
21     	WsdlOperation operation = (WsdlOperation) iface.getOperationByName( "SendClaim" );
22     	WsdlRequest request = operation.addNewRequest( "Test" );
23     	
24     	request.setRequestContent( operation.createRequest( true ));
25     	
26     	System.out.println( request.getRequestContent() );
27     	
28     	WsdlAttachmentPart[] definedAttachmentParts = request.getDefinedAttachmentParts();
29     	
30     	assertEquals( definedAttachmentParts.length, 4 );
31     	assertEquals( definedAttachmentParts[0].getName(), "ClaimPhoto" );
32     	
33     	/*
34  		XmlCursor cursor = xmlObject.newCursor(); //xmlObject.changeType( docType ).newCursor();
35  		while( !cursor.isEnddoc() )
36  		{
37  			if( cursor.isContainer() )
38  			{
39  				String attributeText = cursor.getAttributeText( new QName( "http://www.w3.org/2004/11/xmlmime", "contentType"));
40  				if( attributeText != null )
41  					System.out.println( "contentType: " + attributeText);
42  				
43  				SchemaType schemaType = cursor.getObject().schemaType();
44  				if( schemaType != null && schemaType.getName().equals( new QName("http://ws-i.org/profiles/basic/1.1/xsd","swaRef")) )
45  				{
46  					System.out.println( cursor.getTextValue() );
47  				}
48  			}
49  			
50  			cursor.toNextToken();
51  			
52  		}*/
53     }
54  }