1 2 package org.jbpm.bpel.wsdl.xml; 3 4 import java.io.CharArrayWriter ; 5 6 import javax.wsdl.Definition; 7 import javax.wsdl.factory.WSDLFactory; 8 import javax.xml.namespace.QName ; 9 10 import junit.framework.TestCase; 11 12 import org.jbpm.bpel.wsdl.def.Property; 13 import org.jbpm.bpel.wsdl.util.WsdlUtil; 14 import org.jbpm.bpel.xml.BpelConstants; 15 import org.jbpm.bpel.xml.util.NodeUtil; 16 17 21 public class PropertyTest extends TestCase { 22 23 private WSDLFactory factory; 24 private Definition definition; 25 26 private static final String FILE_NAME = "propertySample.wsdl"; 27 28 protected void setUp() throws Exception { 29 factory = WsdlUtil.getFactory(); 30 definition = factory.newWSDLReader().readWSDL(getClass().getResource(FILE_NAME).toString()); 31 } 32 33 public void testGetProperty() { 34 String tns = definition.getTargetNamespace(); 35 Property property = WsdlUtil.getProperty(definition, new QName (tns, "customerID")); 36 assertNotNull(property); 37 assertEquals(new QName (BpelConstants.NS_XML_SCHEMA, "string"), property.getType()); 38 39 property = WsdlUtil.getProperty(definition, new QName (tns, "invoiceNumber")); 40 assertNotNull(property); 41 assertEquals(new QName (BpelConstants.NS_XML_SCHEMA, "int"), property.getType()); 42 } 43 44 public void testUnmarshall() { 45 String tns = definition.getTargetNamespace(); 47 Property property = WsdlUtil.getProperty(definition, new QName (tns, "customerID")); 49 assertNotNull(property); 50 assertEquals(new QName (BpelConstants.NS_XML_SCHEMA, "string"), property.getType()); 51 property = WsdlUtil.getProperty(definition, new QName (tns, "orderNumber")); 53 assertNotNull(property); 54 assertEquals(new QName (BpelConstants.NS_XML_SCHEMA, "int"), property.getType()); 55 } 56 57 public void testMarshall() throws Exception { 58 CharArrayWriter output = new CharArrayWriter (); 60 factory.newWSDLWriter().writeWSDL(definition, output); 61 output.close(); 62 definition = factory.newWSDLReader().readWSDL( 64 definition.getDocumentBaseURI(), NodeUtil.parseElement(output.toString())); 65 testUnmarshall(); 67 } 68 } 69 | Popular Tags |