KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.jbpm.bpel.xml;
2
3 import java.io.StringReader JavaDoc;
4
5 import junit.framework.TestCase;
6
7 import org.xml.sax.InputSource JavaDoc;
8
9 import org.jbpm.bpel.bar.BarApplication;
10 import org.jbpm.bpel.bar.BarPartnerLink;
11 import org.jbpm.bpel.bar.BarScope;
12 import org.jbpm.bpel.xml.util.NodeUtil;
13
14 public class BarDescriptorReaderTest extends TestCase {
15
16   BarDescriptorReader reader = BarDescriptorReader.getInstance();
17   
18   public void testReadUri() {
19     ProblemCollector problems = new ProblemCollector();
20     reader.setProblemHandler(problems);
21     
22     BarApplication application = new BarApplication();
23     String JavaDoc locationUri = getClass().getResource("bpelApplicationSample.xml").toString();
24     reader.read(application, new InputSource JavaDoc(locationUri));
25     
26     assertFalse(problems.hasErrors());
27   }
28
29   public void testApplicationConnectionFactoryName() throws Exception JavaDoc {
30     String JavaDoc text =
31       "<bpelApplication xmlns='" + BpelConstants.NS_VENDOR + "'>" +
32       " <connectionFactory name='CF'/>" +
33       "</bpelApplication>";
34     BarApplication application = new BarApplication();
35     reader.read(application, new InputSource JavaDoc( new StringReader JavaDoc(text) ));
36     
37     assertEquals("CF", application.getConnectionFactoryName());
38   }
39   
40   public void testScopeName() throws Exception JavaDoc {
41     String JavaDoc text = "<scope name='rfpScope'/>";
42     BarScope scope = new BarScope();
43     reader.readScope(NodeUtil.parseElement(text), scope);
44     
45     assertEquals("rfpScope", scope.getName());
46   }
47   
48   public void testScopeDestination() throws Exception JavaDoc {
49     String JavaDoc text =
50       "<scope xmlns='" + BpelConstants.NS_VENDOR + "'>" +
51       " <destination name='queue/b'/>" +
52       "</scope>";
53     BarScope scope = new BarScope();
54     reader.readScope(NodeUtil.parseElement(text), scope);
55     
56     assertEquals("queue/b", scope.getDestinationName());
57   }
58   
59   public void testScopePartnerLinks() throws Exception JavaDoc {
60     String JavaDoc text =
61       "<scope xmlns='" + BpelConstants.NS_VENDOR + "'>" +
62       "<partnerLinks><partnerLink name='aName'/></partnerLinks>" +
63       "</scope>";
64     BarScope scope = new BarScope();
65     reader.readScope(NodeUtil.parseElement(text), scope);
66
67     assertEquals(1, scope.getPartnerLinks().size());
68   }
69   
70   public void testScopeScopes() throws Exception JavaDoc {
71     String JavaDoc text =
72       "<scope xmlns='" + BpelConstants.NS_VENDOR + "'>" +
73       "<scopes><scope name='aName'/></scopes>" +
74       "</scope>";
75     BarScope scope = new BarScope();
76     reader.readScope(NodeUtil.parseElement(text), scope);
77
78     assertEquals(1, scope.getScopes().size());
79   }
80   
81   public void testPartnerLinkName() throws Exception JavaDoc {
82     String JavaDoc text = "<partnerLink name='schedulerPL'/>";
83     BarPartnerLink plink = reader.readPartnerLink(NodeUtil.parseElement(text));
84     
85     assertEquals("schedulerPL", plink.getName());
86   }
87   
88   public void testPartnerLinkDestination() throws Exception JavaDoc {
89     String JavaDoc text =
90       "<partnerLink xmlns='" + BpelConstants.NS_VENDOR + "'>" +
91       " <destination name='queue/b'/>" +
92       "</partnerLink>";
93     BarPartnerLink plink = reader.readPartnerLink(NodeUtil.parseElement(text));
94     
95     assertEquals("queue/b", plink.getDestinationName());
96   }
97   
98   public void testPartnerLinkJndiName() throws Exception JavaDoc {
99     String JavaDoc text =
100       "<partnerLink xmlns='" + BpelConstants.NS_VENDOR + "'>" +
101       " <namingContext name='Scheduler'/>" +
102       "</partnerLink>";
103     BarPartnerLink plink = reader.readPartnerLink(NodeUtil.parseElement(text));
104     
105     assertEquals("Scheduler", plink.getNamingContextName());
106   }
107
108 }
109
Popular Tags