KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > xml > ParDescriptorReaderTest


1 package org.jbpm.bpel.xml;
2
3 import java.io.StringReader JavaDoc;
4
5 import org.xml.sax.InputSource JavaDoc;
6
7 import junit.framework.TestCase;
8
9 import org.jbpm.bpel.def.Import;
10 import org.jbpm.bpel.par.ParDefinition;
11 import org.jbpm.bpel.xml.util.NodeUtil;
12
13 /**
14  * @author Alejandro Guízar
15  * @version $Revision: 1.4 $ $Date: 2005/06/23 20:45:04 $
16  */

17 public class ParDescriptorReaderTest extends TestCase {
18   
19   private ParDescriptorReader reader = ParDescriptorReader.getInstance();
20   
21   public void testReadUri() {
22     ProblemCollector problems = new ProblemCollector();
23     reader.setProblemHandler(problems);
24     
25     String JavaDoc locationUri = getClass().getResource("bpelDefinitionSample.xml").toString();
26     ParDefinition definition = new ParDefinition();
27     reader.read(definition, new InputSource JavaDoc(locationUri));
28     
29     assertFalse(problems.hasErrors());
30   }
31   
32   public void testDefinitionLocation() throws Exception JavaDoc {
33     // read descriptor
34
String JavaDoc text = "<bpelDefinition location='hello.bpel' xmlns='http://jbpm.org/bpel'/>";
35     ParDefinition definition = new ParDefinition();
36     reader.read(definition, new InputSource JavaDoc( new StringReader JavaDoc(text) ));
37     // assertions
38
assertEquals("hello.bpel", definition.getLocation());
39   }
40
41   public void testDefinitionImports() throws Exception JavaDoc {
42     // read descriptor
43
String JavaDoc text =
44       "<bpelDefinition xmlns='http://jbpm.org/bpel'>" +
45       " <imports>" +
46       " <wsdl />" +
47       " <schema />" +
48       " </imports>" +
49       "</bpelDefinition>";
50     ParDefinition definition = new ParDefinition();
51     reader.read(definition, new InputSource JavaDoc( new StringReader JavaDoc(text) ));
52     // assertions
53
assertEquals(2, definition.getImports().size());
54   }
55
56   public void testImportNamespace() throws Exception JavaDoc {
57     // read descriptor
58
String JavaDoc text = "<wsdl namespace='http://jbpm.org/bpel/examples'/>";
59     Import imp = reader.readImport(NodeUtil.parseElement(text));
60     // assertions
61
assertEquals(BpelConstants.NS_EXAMPLES, imp.getNamespace());
62   }
63
64   public void testImportLocation() throws Exception JavaDoc {
65     // read descriptor
66
String JavaDoc text = "<wsdl location='hello.wsdl'/>";
67     Import imp = reader.readImport(NodeUtil.parseElement(text));
68     // assertions
69
assertEquals("hello.wsdl", imp.getLocation());
70   }
71   
72   public void testImportTypeWsdl() throws Exception JavaDoc {
73     // read descriptor
74
String JavaDoc text = "<wsdl />";
75     Import imp = reader.readImport(NodeUtil.parseElement(text));
76     // assertions
77
assertEquals(Import.Type.WSDL, imp.getType());
78   }
79   
80   public void testImportTypeXmlSchema() throws Exception JavaDoc {
81     // read descriptor
82
String JavaDoc text = "<schema />";
83     Import imp = reader.readImport(NodeUtil.parseElement(text));
84     // assertions
85
assertEquals(Import.Type.XML_SCHEMA, imp.getType());
86   }
87 }
88
Popular Tags