KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > wsdl > xml > PropertyTest


1
2 package org.jbpm.bpel.wsdl.xml;
3
4 import java.io.CharArrayWriter JavaDoc;
5
6 import javax.wsdl.Definition;
7 import javax.wsdl.factory.WSDLFactory;
8 import javax.xml.namespace.QName JavaDoc;
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 /**
18  * @author Alejandro Guízar
19  * @version $Revision: 1.4 $ $Date: 2005/06/23 02:17:27 $
20  */

21 public class PropertyTest extends TestCase {
22   
23   private WSDLFactory factory;
24   private Definition definition;
25   
26   private static final String JavaDoc FILE_NAME = "propertySample.wsdl";
27
28   protected void setUp() throws Exception JavaDoc {
29     factory = WsdlUtil.getFactory();
30     definition = factory.newWSDLReader().readWSDL(getClass().getResource(FILE_NAME).toString());
31   }
32   
33   public void testGetProperty() {
34     String JavaDoc tns = definition.getTargetNamespace();
35     Property property = WsdlUtil.getProperty(definition, new QName JavaDoc(tns, "customerID"));
36     assertNotNull(property);
37     assertEquals(new QName JavaDoc(BpelConstants.NS_XML_SCHEMA, "string"), property.getType());
38
39     property = WsdlUtil.getProperty(definition, new QName JavaDoc(tns, "invoiceNumber"));
40     assertNotNull(property);
41     assertEquals(new QName JavaDoc(BpelConstants.NS_XML_SCHEMA, "int"), property.getType());
42   }
43
44   public void testUnmarshall() {
45     // find properties within extensibility elements
46
String JavaDoc tns = definition.getTargetNamespace();
47     // First property
48
Property property = WsdlUtil.getProperty(definition, new QName JavaDoc(tns, "customerID"));
49     assertNotNull(property);
50     assertEquals(new QName JavaDoc(BpelConstants.NS_XML_SCHEMA, "string"), property.getType());
51     // Second property
52
property = WsdlUtil.getProperty(definition, new QName JavaDoc(tns, "orderNumber"));
53     assertNotNull(property);
54     assertEquals(new QName JavaDoc(BpelConstants.NS_XML_SCHEMA, "int"), property.getType());
55   }
56
57   public void testMarshall() throws Exception JavaDoc {
58     // write the definition to a stream
59
CharArrayWriter JavaDoc output = new CharArrayWriter JavaDoc();
60     factory.newWSDLWriter().writeWSDL(definition, output);
61     output.close();
62     // read the definition back from the stream
63
definition = factory.newWSDLReader().readWSDL(
64         definition.getDocumentBaseURI(), NodeUtil.parseElement(output.toString()));
65     // test the definition works the same
66
testUnmarshall();
67   }
68 }
69
Popular Tags