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