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