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;
14:
15: import java.io.File;
16:
17: import junit.framework.TestCase;
18:
19: public class AttachmentTestCase extends TestCase {
20: public void test() throws Exception {
21: String wsdlUrl = new File(
22: "src/test-resources/attachment-test.wsdl").toURL()
23: .toString();
24: WsdlProject project = new WsdlProject();
25: WsdlInterface iface = project.importWsdl(wsdlUrl, false)[0];
26:
27: WsdlOperation operation = (WsdlOperation) iface
28: .getOperationByName("SendClaim");
29: WsdlRequest request = operation.addNewRequest("Test");
30:
31: request.setRequestContent(operation.createRequest(true));
32:
33: System.out.println(request.getRequestContent());
34:
35: WsdlAttachmentPart[] definedAttachmentParts = request
36: .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: }
|